/* Split the Vortex — shared styles */
:root {
  --bg: #070c22;
  --bg2: #0d1536;
  --panel: #111b44;
  --panel2: #18245a;
  --line: #2a3a7a;
  --ink: #eaf1ff;
  --ink2: #aebbe6;
  --muted: #7f8cc0;
  --ice: #7fe3ff;
  --ice2: #3fb7f0;
  --violet: #9b8cff;
  --ember: #ff7a45;
  --ember2: #ffb347;
  --good: #57e3a0;
  --bad: #ff5d73;
  --ocean: #0a1640;
  --land: #1f2d63;
  --landline: #3b4f99;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --radius: 18px;
  --font-head: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef4fc;
  --bg2: #e2ebf8;
  --panel: #ffffff;
  --panel2: #f2f6fd;
  --line: #c6d3ec;
  --ink: #0b1638;
  --ink2: #34426e;
  --muted: #5d6a94;
  --ice: #0b78b8;
  --ice2: #0a91d6;
  --violet: #5a45d6;
  --ember: #d64b12;
  --ember2: #b86a00;
  --good: #0d8a55;
  --bad: #c62842;
  --ocean: #cfe0f5;
  --land: #f7f9fd;
  --landline: #9db0d6;
  --shadow: 0 10px 30px rgba(20, 40, 90, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(155, 140, 255, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(127, 227, 255, .12), transparent 60%),
    var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--ice); }
a:hover { color: var(--ink); }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.6rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 750; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ice); color: #000; padding: .5em 1em; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--ember2); outline-offset: 2px; border-radius: 6px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-family: var(--font-head); font-weight: 800; font-size: 1.12rem; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.nav-links { display: flex; gap: .15rem; margin-left: auto; list-style: none; padding: 0; margin-top: 0; margin-bottom: 0; }
.nav-links a { display: block; text-decoration: none; color: var(--ink2); padding: .45rem .7rem; border-radius: 10px; font-weight: 500; font-size: .95rem; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); background: var(--panel2); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; width: 40px; height: 40px; display: inline-grid; place-items: center; cursor: pointer; font-size: 1.1rem; flex: none; }
.icon-btn:hover { background: var(--panel2); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--bg2); border-bottom: 1px solid var(--line); padding: .5rem; }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .8rem 1rem; }
}

main { max-width: 1180px; margin: 0 auto; padding: 1rem; }
section { margin: 2.5rem 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: 600 1rem var(--font-body);
  padding: .75em 1.25em; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  text-decoration: none; transition: transform .15s, background .15s, box-shadow .15s;
  min-height: 44px;
}
.btn:hover { background: var(--panel2); transform: translateY(-1px); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--ice), var(--violet)); color: #061033; border: none; box-shadow: 0 6px 24px rgba(127, 227, 255, .25); }
.btn.primary:hover { color: #061033; filter: brightness(1.08); }
.btn.hot { background: linear-gradient(135deg, var(--ember2), var(--ember)); color: #2a0b00; border: none; }
.btn.small { padding: .45em .9em; font-size: .9rem; min-height: 36px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tag { display: inline-block; font: 600 .72rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; padding: .2em .6em; border-radius: 999px; background: var(--panel2); color: var(--ink2); border: 1px solid var(--line); }
.tag.ice { color: var(--ice); }
.tag.ember { color: var(--ember); }
.tag.violet { color: var(--violet); }
.kicker { font: 600 .8rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ice); margin-bottom: .6rem; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2rem; align-items: center; margin-top: 1.5rem; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--ice), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lede { font-size: 1.15rem; color: var(--ink2); max-width: 36em; }
.hero-art { position: relative; aspect-ratio: 1; max-width: 420px; justify-self: center; width: 100%; }
.hero-art canvas { width: 100%; height: 100%; display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1.3rem 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .75rem .85rem; }
.stat b { display: block; font: 700 1.35rem var(--font-head); color: var(--ink); }
.stat span { font-size: .8rem; color: var(--muted); line-height: 1.3; display: block; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { max-width: 300px; order: -1; }
}
@media (max-width: 480px) { .stats { grid-template-columns: 1fr 1fr; } .stats .stat:last-child { grid-column: 1 / -1; } }

/* Missions */
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.mission {
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1rem;
  display: flex; flex-direction: column; gap: .3rem; transition: transform .15s, border-color .15s;
  position: relative; overflow: hidden;
}
.mission:hover { transform: translateY(-2px); border-color: var(--ice); }
.mission .yr { font: 700 1.6rem var(--font-head); color: var(--ice); }
.mission.special .yr { color: var(--ember2); }
.mission .ttl { font-weight: 700; }
.mission .sub { font-size: .85rem; color: var(--muted); }
.mission .stars { font-size: 1rem; letter-spacing: .1em; color: var(--muted); margin-top: auto; }
.mission .stars .on { color: var(--ember2); }
.mission.hl { border-color: var(--ember); background: linear-gradient(160deg, color-mix(in srgb, var(--ember) 16%, var(--panel)), var(--panel)); }

/* Game */
.game-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.stage { position: relative; background: var(--ocean); border-radius: 22px; border: 1px solid var(--line); overflow: hidden; aspect-ratio: 1; width: 100%; max-width: 680px; margin: 0 auto; touch-action: manipulation; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage .toast { position: absolute; left: 50%; top: 10%; transform: translateX(-50%); background: rgba(5, 10, 30, .82); color: #fff; padding: .45em .9em; border-radius: 999px; font-weight: 600; font-size: .9rem; pointer-events: none; opacity: 0; transition: opacity .25s; max-width: 92%; width: max-content; text-align: center; line-height: 1.3; }
.stage .toast.show { opacity: 1; }
.stage .paused { position: absolute; inset: 0; display: none; place-items: center; background: rgba(5, 10, 30, .55); color: #fff; font: 800 2rem var(--font-head); }
.stage.is-paused .paused { display: grid; }
.hud { display: flex; flex-direction: column; gap: .8rem; }
.hud .card { padding: .9rem 1rem; box-shadow: none; }
.hud-date { font: 700 1.4rem var(--font-head); }
.hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.meter { height: 12px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; position: relative; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--ice2), var(--ice)); border-radius: 999px; transition: width .1s linear; }
.meter.ember > i { background: linear-gradient(90deg, var(--ember2), var(--ember)); }
.meter.violet > i { background: linear-gradient(90deg, var(--violet), var(--ice)); }
.wind-big { font: 700 2.2rem var(--font-mono); line-height: 1; }
.wind-big.neg { color: var(--ember); }
.wind-gauge { position: relative; height: 18px; border-radius: 999px; background: linear-gradient(90deg, var(--ember) 0%, var(--ember) 14%, var(--panel2) 14%, var(--panel2) 100%); border: 1px solid var(--line); margin-top: .4rem; }
.wind-gauge .zero { position: absolute; left: 14%; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.wind-gauge .needle { position: absolute; top: -5px; width: 6px; height: 26px; margin-left: -3px; border-radius: 3px; background: var(--ice); box-shadow: 0 0 10px var(--ice); transition: left .1s linear; }
.wind-gauge .clim { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--muted); }
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; margin-top: .8rem; max-width: 680px; margin-left: auto; margin-right: auto; }
.src-btn {
  position: relative; overflow: hidden; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; min-height: 56px;
}
.src-btn .k { font: 600 .7rem var(--font-mono); color: var(--muted); }
.src-btn .n { font-weight: 700; font-size: .92rem; display: block; line-height: 1.2; }
.src-btn .cd { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--ice); width: 0; }
.src-btn.k2 .cd { background: var(--violet); }
.src-btn.aligned { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.src-btn.opposed { border-color: color-mix(in srgb, var(--bad) 60%, var(--line)); }
.src-btn[disabled] { opacity: .5; cursor: not-allowed; }
.src-btn .key { position: absolute; right: .5rem; top: .4rem; font: 600 .72rem var(--font-mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 .3em; }
.game-bar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; max-width: 680px; margin: 0 auto .7rem; }
.objectives { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; font-size: .9rem; }
.objectives li { display: flex; gap: .5rem; align-items: flex-start; }
.objectives li::before { content: "☆"; color: var(--muted); flex: none; }
.objectives li.done::before { content: "★"; color: var(--ember2); }
.objectives li.fail { color: var(--muted); text-decoration: line-through; }
@media (max-width: 900px) {
  .game-wrap { grid-template-columns: 1fr; }
  .hud { display: grid; grid-template-columns: 1fr 1fr; }
  .hud .card.wide { grid-column: 1 / -1; }
}
@media (max-width: 420px) { .hud { grid-template-columns: 1fr; } .sources { grid-template-columns: 1fr 1fr; } }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(3, 6, 20, .72); backdrop-filter: blur(4px); }
.modal.open { display: flex; }
.modal-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; width: min(640px, 100%); max-height: calc(100vh - 2rem); overflow: auto; padding: 1.4rem; box-shadow: var(--shadow); position: relative; }
.modal-box .close { position: absolute; right: .8rem; top: .8rem; }
.modal-box h2 { padding-right: 2.5rem; }
.brief-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.fact { border-left: 3px solid var(--ice); padding: .5rem .8rem; background: var(--panel); border-radius: 0 12px 12px 0; margin: .8rem 0; font-size: .95rem; }
.fact.ember { border-color: var(--ember); }

/* Results */
.result-head { text-align: center; }
.result-stars { font-size: 2.2rem; letter-spacing: .15em; color: var(--muted); }
.result-stars .on { color: var(--ember2); text-shadow: 0 0 18px rgba(255, 179, 71, .5); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0; }
.result-grid .stat b { font-size: 1.15rem; }
.drip { width: 100%; aspect-ratio: 2.2; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); display: block; }
.shared-banner { display: none; }
.shared-banner.show { display: block; }

/* Lab */
.lab-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.lab-stage { position: relative; aspect-ratio: 1; background: var(--ocean); border-radius: 22px; border: 1px solid var(--line); overflow: hidden; }
.lab-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ctrl { display: grid; gap: .25rem; margin-bottom: .9rem; }
.ctrl label { display: flex; justify-content: space-between; font-weight: 600; font-size: .92rem; }
.ctrl output { font-family: var(--font-mono); color: var(--ice); }
input[type="range"] { width: 100%; accent-color: var(--ice); min-height: 30px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { font: 600 .88rem var(--font-body); background: var(--panel); color: var(--ink2); border: none; padding: .5em 1em; cursor: pointer; min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--ice); color: #061033; }
.lab-readout { font-family: var(--font-mono); font-size: .9rem; background: var(--panel2); border-radius: 12px; padding: .7rem .8rem; border: 1px solid var(--line); }
.layers svg { width: 100%; height: auto; display: block; }
.explain { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.explain .card h3 { display: flex; gap: .5rem; align-items: center; }
.explain .emoji { font-size: 1.4rem; }
@media (max-width: 900px) { .lab-wrap { grid-template-columns: 1fr; } }

/* History */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 1.4rem 44px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: .35rem; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); border: 3px solid var(--ice); }
.timeline li.k-sh::before { border-color: var(--violet); }
.timeline li.k-cold::before { border-color: var(--ice2); background: var(--ice2); }
.timeline li.k-now::before { border-color: var(--ember); background: var(--ember); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ember) 25%, transparent); }
.timeline li.k-science::before { border-color: var(--muted); }
.timeline .when { font: 600 .82rem var(--font-mono); color: var(--muted); }
.timeline h3 { margin: .1rem 0 .3rem; }
.timeline p { margin: 0 0 .4rem; color: var(--ink2); }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip { font: 600 .85rem var(--font-body); border: 1px solid var(--line); background: var(--panel); color: var(--ink2); border-radius: 999px; padding: .4em .9em; cursor: pointer; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chart-card svg { width: 100%; height: auto; display: block; min-width: 580px; }
#chart { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-card .pt:focus { outline: none; }
.chart-card .pt:focus rect { stroke: var(--ember2); stroke-width: 2; }
.chart-card table th, .chart-card table td { padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
.chart-card .tt { position: absolute; pointer-events: none; background: var(--bg2); border: 1px solid var(--line); padding: .4rem .6rem; border-radius: 8px; font-size: .85rem; box-shadow: var(--shadow); opacity: 0; transition: opacity .12s; max-width: 240px; }

/* Quiz */
.quiz-box { max-width: 720px; margin: 0 auto; }
.q-statement { font: 700 clamp(1.3rem, 3.6vw, 1.8rem) var(--font-head); line-height: 1.25; margin: .6rem 0 1.2rem; min-height: 3.5em; }
.q-answers { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.q-answers .btn { font-size: 1.15rem; padding: 1em; border-radius: 16px; }
.q-answers .btn.right { background: var(--good); color: #02160c; border-color: var(--good); }
.q-answers .btn.wrong { background: var(--bad); color: #fff; border-color: var(--bad); }
.q-explain { margin-top: 1rem; display: none; }
.q-explain.show { display: block; animation: rise .3s ease; }
.q-progress { display: flex; gap: 4px; margin-bottom: .6rem; }
.q-progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--panel2); }
.q-progress i.r { background: var(--good); }
.q-progress i.w { background: var(--bad); }
.q-progress i.cur { background: var(--ice); }
.big-score { font: 800 4rem var(--font-head); text-align: center; line-height: 1; margin: .3em 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 1rem 2.5rem; color: var(--muted); font-size: .9rem; }
.site-footer .inner { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }
.site-footer a { color: var(--ink2); }

.prose { max-width: 760px; }
.prose li { margin-bottom: .4rem; }
.src-list { font-size: .92rem; word-break: break-word; }
.copy-note { font-size: .85rem; color: var(--good); min-height: 1.3em; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: rise .45s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
