/* ==========================================================================
   Slice Storm: Fate's Edge — shell styling
   Storm-dark panels, gold hairlines, serif display type. All chrome lives in
   the DOM so the canvas stays purely gameplay.
   ========================================================================== */
:root {
  --ink: #f3efe4;
  --dim: #a9a68f;
  --gold: #e8c47a;
  --gold-2: #fff0c2;
  --storm: #080a14;
  --slate: #12162b;
  --panel: rgba(11, 13, 26, 0.90);
  --line: rgba(232, 196, 122, 0.30);
  --bad: #ff6b81;
  --ok: #7fe3a5;
  --violet: #9d8cff;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background:
    radial-gradient(1100px 620px at 50% -8%, #232a56 0%, rgba(9, 11, 22, 0) 62%),
    radial-gradient(900px 700px at 12% 108%, #2b2148 0%, rgba(9, 11, 22, 0) 60%),
    linear-gradient(180deg, #05060d 0%, #0a0d1c 46%, #06070f 100%);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 16px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 24, 46, 0.85), rgba(9, 11, 22, 0.9));
  box-shadow: var(--shadow);
}
.brand {
  font: 700 21px/1 Georgia, "Times New Roman", serif;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--gold-2);
  text-shadow: 0 0 18px rgba(232, 196, 122, 0.45);
}
.brand span {
  display: block;
  font: 400 10px/1.6 ui-monospace, Menlo, monospace;
  letter-spacing: 0.32em;
  color: var(--dim);
}
.hud { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.hearts { display: flex; gap: 5px; }
.heart {
  width: 15px; height: 15px; display: block;
  background: rgba(255, 255, 255, 0.13);
  clip-path: polygon(50% 100%, 0 45%, 12% 8%, 50% 26%, 88% 8%, 100% 45%);
}
.heart.on { background: linear-gradient(180deg, #ff9db0, #d33a55); box-shadow: 0 0 12px rgba(255, 90, 120, 0.6); }
.metric { display: flex; align-items: baseline; gap: 7px; }
.metric b { font: 700 22px/1 Georgia, serif; color: var(--gold-2); }
.metric span { font: 400 10px/1 ui-monospace, Menlo, monospace; letter-spacing: 0.2em; color: var(--dim); text-transform: uppercase; }
.metric.small b { font-size: 15px; }
.icobtn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--gold-2); font-size: 15px; cursor: pointer;
}
.icobtn:hover { background: rgba(232, 196, 122, 0.14); }

/* ------------------------------------------------------------------- stage */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: min(74vh, 860px);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #05060e;
  box-shadow: var(--shadow);
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.stagehud {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  pointer-events: none;
  z-index: 3;
}
.chapterlabel {
  font: 600 12px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold-2);
  background: rgba(6, 8, 16, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  white-space: nowrap;
}
.timerwrap { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.timer {
  font: 700 13px/1 ui-monospace, Menlo, monospace;
  color: var(--ink); background: rgba(6, 8, 16, 0.72);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px;
}
.timerbarwrap { width: 108px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.13); overflow: hidden; }
.timerbar { height: 100%; width: 100%; background: linear-gradient(90deg, #ffe6a8, #e0a94f); }
.stagebot {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px;
  background: linear-gradient(0deg, rgba(4, 6, 14, 0.86), rgba(4, 6, 14, 0));
  pointer-events: none;
  z-index: 3;
}
.chip {
  font: 600 11px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--dim);
  background: rgba(8, 10, 20, 0.7);
}
.chip.done { color: #17220f; background: linear-gradient(180deg, #d8f7c4, #9ede84); border-color: #b7e79a; }

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  z-index: 4; pointer-events: none; width: max-content; max-width: 92%;
}
.toast {
  font: 600 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1a1408;
  background: linear-gradient(180deg, #ffe9b6, #e3bd72);
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  transition: opacity 0.4s, transform 0.4s;
  text-align: center;
}
.toast.warn { background: linear-gradient(180deg, #d9d2ff, #a99bf0); color: #171233; }
.toast.bad { background: linear-gradient(180deg, #ffb4c1, #e0566f); color: #2b0511; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------------------------------------------------------------- overlays */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: radial-gradient(700px 520px at 50% 30%, rgba(30, 34, 68, 0.72), rgba(3, 4, 10, 0.94));
  backdrop-filter: blur(3px);
  z-index: 6;
  overflow: auto;
}
.panel {
  width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  max-height: calc(100% - 8px);
  overflow: auto;
}
.panel.wide { width: min(880px, 100%); }
.panel h1, .panel h2 { font-family: Georgia, "Times New Roman", serif; margin: 0 0 6px; letter-spacing: 0.02em; }
.panel h1 { font-size: 30px; color: var(--gold-2); }
.panel h2 { font-size: 21px; color: var(--gold-2); }
.panel .eyebrow {
  font: 600 11px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.32em; text-transform: uppercase; color: var(--dim);
  margin-bottom: 10px; display: block;
}
.panel p { margin: 8px 0; color: #ded9c9; }
.panel .lede { color: var(--dim); font-size: 14.5px; }
.panel .btncol { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.row { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; }
.btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 12px;
  font: 600 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  transition: transform 0.12s, background 0.16s, box-shadow 0.16s;
  flex: 1 1 auto;
  text-align: center;
}
.btn:hover { transform: translateY(-1px); background: rgba(232, 196, 122, 0.15); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, #ffe9b6, #dfae57);
  color: #1c1405;
  box-shadow: 0 12px 30px rgba(224, 174, 87, 0.28);
  font-weight: 700;
}
.btn.ghost { background: transparent; }
.btn.small { flex: 0 1 auto; padding: 10px 13px; font-size: 13px; }
.mt8 { margin-top: 8px; }

/* chapter select */
#levelGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 9px; margin-top: 14px; }
.actrow { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 9px; margin: 14px 0 2px; flex-wrap: wrap; }
.actrow .actn { font: 700 11px/1 ui-monospace, monospace; letter-spacing: 0.26em; color: var(--gold); text-transform: uppercase; }
.actrow b { font: 700 17px/1 Georgia, serif; color: var(--gold-2); }
.actrow i { color: var(--dim); font-style: italic; font-size: 13px; }
.lvcard {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 11px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink); text-align: left;
}
.lvcard:hover { background: rgba(232, 196, 122, 0.14); transform: translateY(-1px); }
.lvcard b { font: 700 12px/1 ui-monospace, monospace; color: var(--gold); letter-spacing: 0.1em; }
.lvcard span { font-size: 13.5px; font-weight: 600; }
.lvcard .stars { font-style: normal; font-size: 13px; color: var(--gold-2); letter-spacing: 0.1em; }
.lvcard .stars u { text-decoration: none; color: rgba(255, 255, 255, 0.22); }
.lvcard em { font-style: normal; font-size: 11px; color: var(--dim); font-family: ui-monospace, monospace; }
.lvcard.locked { opacity: 0.42; cursor: not-allowed; }

/* brief + result */
.briefhead { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.pill {
  font: 600 11px/1 ui-monospace, monospace; letter-spacing: 0.16em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; color: var(--gold-2);
  background: rgba(6, 8, 16, 0.6);
}
.goals { margin: 12px 0 0; padding-left: 18px; color: #e7e2d2; }
.goals li { margin: 4px 0; }
.goals li.ok { color: var(--ok); }
.goals li.no { color: var(--bad); }
.statline { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; color: var(--dim); font-size: 13px; }
.statline b { color: var(--gold-2); font-family: ui-monospace, monospace; }
.starrow { font-size: 34px; letter-spacing: 0.14em; color: var(--gold-2); text-shadow: 0 0 22px rgba(232, 196, 122, 0.5); min-height: 42px; }
.starrow u { text-decoration: none; color: rgba(255, 255, 255, 0.2); }
.scorebig { font: 700 34px/1.1 Georgia, serif; color: #fff; margin: 4px 0 2px; }
.howto { display: grid; gap: 9px; margin-top: 12px; }
.howto div { border-left: 2px solid var(--line); padding-left: 11px; color: #ded9c9; font-size: 14px; }
.howto b { color: var(--gold-2); }
.note { font-size: 12.5px; color: var(--dim); margin-top: 12px; }

/* article below the fold */
.article { max-width: 1180px; margin: 22px auto 0; padding: 0 4px 40px; }
.article h2 { font-family: Georgia, serif; color: var(--gold-2); font-size: 22px; margin: 26px 0 8px; }
.article h3 { font-family: Georgia, serif; color: var(--ink); font-size: 17px; margin: 18px 0 6px; }
.article p, .article li { color: #d5d0c2; font-size: 15px; }
.article table { width: 100%; border-collapse: collapse; margin: 12px 0 6px; font-size: 14px; }
.article th, .article td { border: 1px solid rgba(232, 196, 122, 0.22); padding: 8px 10px; text-align: left; vertical-align: top; }
.article th { background: rgba(232, 196, 122, 0.10); color: var(--gold-2); font-weight: 700; }
.article code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 5px; }
.faq details { border: 1px solid rgba(232, 196, 122, 0.22); border-radius: 11px; padding: 11px 13px; margin: 8px 0; background: rgba(255, 255, 255, 0.03); }
.faq summary { cursor: pointer; font-weight: 600; color: var(--gold-2); }
.faq p { margin: 8px 0 0; }
.crumb { color: var(--dim); font-size: 13px; margin: 0 0 10px; }
.crumb a { color: var(--gold); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.foot { max-width: 1180px; margin: 10px auto 40px; padding: 0 4px; color: var(--dim); font-size: 13px; }
.foot strong { color: var(--gold-2); }

@media (max-width: 720px) {
  .shell { padding: 10px 10px 24px; }
  .stage { height: min(62vh, 560px); }
  .brand { font-size: 17px; }
  .metric b { font-size: 18px; }
  .panel { padding: 17px 15px; }
  .panel h1 { font-size: 24px; }
  .timerbarwrap { display: none; }
  #levelGrid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
}
