/* Stick the Landing — design system */
:root {
  --bg: #f5f1e8;
  --bg-2: #ebe4d4;
  --surface: #fffdf8;
  --surface-2: #f9f4ea;
  --text: #16182a;
  --muted: #555a72;
  --line: #d9d0bd;
  --flame: #e5531a;
  --flame-2: #ff8a3d;
  --sky: #0a7bb5;
  --good: #1f8a4c;
  --warn: #b7791f;
  --bad: #c2362b;
  --gold: #c99a1b;
  --shadow: 0 2px 0 rgba(22, 24, 42, .08), 0 10px 30px -12px rgba(22, 24, 42, .25);
  --radius: 16px;
  --font-head: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b0f1e;
  --bg-2: #121833;
  --surface: #151c38;
  --surface-2: #1b2346;
  --text: #eef0fa;
  --muted: #a3aac8;
  --line: #2a3460;
  --flame: #ff6a2b;
  --flame-2: #ffa24a;
  --sky: #4fd1ff;
  --good: #45d483;
  --warn: #f2c14e;
  --bad: #ff6b5e;
  --gold: #f5c542;
  --shadow: 0 2px 0 rgba(0, 0, 0, .3), 0 14px 34px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--sky); text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.6rem); }
h2 { font-size: clamp(1.45rem, 4vw, 2.1rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--flame); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: .95rem; }
.nav a:hover { background: var(--bg-2); }
.nav a[aria-current="page"] { background: var(--text); color: var(--bg); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--text); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
}

/* Buttons */
.btn {
  --b: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem/1 var(--font-head); padding: 13px 20px; border-radius: 999px;
  border: 2px solid var(--b); background: transparent; color: var(--text);
  cursor: pointer; text-decoration: none; transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  min-height: 46px;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--flame); border-color: var(--flame); color: #fff; box-shadow: 0 6px 18px -6px var(--flame); }
.btn.primary:hover { background: var(--flame-2); border-color: var(--flame-2); color: #1a0d05; }
.btn.small { padding: 9px 14px; min-height: 38px; font-size: .9rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 600 .78rem/1 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; padding: 6px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); }
.pill.hot { background: color-mix(in srgb, var(--flame) 18%, transparent); color: var(--flame); }

section { padding: 44px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head p { margin: 0; color: var(--muted); }

/* Hero */
.hero { position: relative; padding: 36px 0 20px; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; }
.hero h1 span { color: var(--flame); }
.hero .lede { font-size: 1.15rem; color: var(--muted); max-width: 36ch; }
.hero-canvas-wrap { position: relative; aspect-ratio: 4 / 5; border-radius: 24px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: #0b0f1e; }
.hero-canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.hero-badge { position: absolute; left: 12px; top: 12px; }
@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-canvas-wrap { aspect-ratio: 16 / 12; max-height: 360px; }
}
.countdown { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.countdown div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; text-align: center; min-width: 64px; }
.countdown b { display: block; font: 700 1.4rem/1.1 var(--font-mono); }
.countdown small { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

.mode-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text); transition: transform .2s ease, border-color .2s ease; }
.mode-card:hover { transform: translateY(-3px); border-color: var(--flame); }
.mode-card .emoji { font-size: 2rem; }
.mode-card p { color: var(--muted); margin: 0; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat b { display: block; font: 700 1.6rem/1.1 var(--font-mono); }
.stat span { color: var(--muted); font-size: .85rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .92rem; margin-top: 30px; }
.site-footer .wrap { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 200; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Play page ---------- */
.tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 999px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--text); font: 700 .95rem/1 var(--font-head); padding: 10px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow); }
.panel[hidden] { display: none; }

.world-group { margin-top: 22px; }
.world-group h3 { display: flex; align-items: center; gap: 8px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.level-btn {
  text-align: left; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 14px; padding: 12px; cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 4px; min-height: 96px;
  transition: transform .15s ease, border-color .15s ease;
}
.level-btn:hover:not([disabled]) { transform: translateY(-2px); border-color: var(--flame); }
.level-btn .num { font: 700 .75rem/1 var(--font-mono); color: var(--muted); }
.level-btn .name { font: 700 1rem/1.2 var(--font-head); }
.level-btn .stars { margin-top: auto; letter-spacing: 2px; color: var(--gold); font-size: .95rem; }
.level-btn .stars .off { color: var(--line); }
.level-btn[disabled] { opacity: .5; cursor: not-allowed; }
.level-btn .site { font-size: .78rem; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
select, input[type="text"], input[type="number"] {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); min-height: 44px;
}
input[type="range"] { width: 100%; accent-color: var(--flame); min-height: 32px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 9px 14px; font: 600 .88rem/1 var(--font-body); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.game-shell { position: fixed; inset: 0; z-index: 80; background: #05070f; display: none; touch-action: none; user-select: none; -webkit-user-select: none; }
.game-shell.active { display: block; }
body.playing { overflow: hidden; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; top: 0; left: 0; right: 0; padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; pointer-events: none; color: #eef0fa; font-family: var(--font-mono); font-size: .8rem; }
.hud-block { background: rgba(8, 11, 24, .62); border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px; padding: 8px 10px; backdrop-filter: blur(6px); min-width: 0; }
.hud-block .row { display: flex; justify-content: space-between; gap: 10px; white-space: nowrap; }
.hud-block .row b { font-weight: 700; }
.hud .ok { color: #57e69a; }
.hud .meh { color: #f5c542; }
.hud .no { color: #ff7a6b; }
.hud-left { width: 150px; }
.hud-right { width: 150px; }
.hud-center { text-align: center; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-title { font-family: var(--font-head); font-weight: 700; font-size: .95rem; background: rgba(8,11,24,.62); padding: 6px 12px; border-radius: 999px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fuel-bar { height: 8px; background: rgba(255,255,255,.15); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.fuel-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff6a2b, #ffc24a); width: 100%; transition: width .1s linear; }
.hud-btns { position: absolute; top: 10px; right: 12px; display: none; }
.game-top-btns { position: absolute; right: 12px; top: 124px; display: flex; flex-direction: column; gap: 8px; z-index: 3; }
@media (max-width: 420px) { .game-top-btns { top: 108px; right: 8px; } }
.game-top-btns button { background: rgba(8, 11, 24, .7); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 12px; width: 44px; height: 44px; font-size: 1.05rem; cursor: pointer; }
.touch-ctrls { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 12px max(14px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.touch-ctrls .pair { display: flex; gap: 10px; pointer-events: auto; }
.tbtn {
  width: 74px; height: 74px; border-radius: 22px; border: 2px solid rgba(255,255,255,.3); background: rgba(8, 11, 24, .55); color: #fff;
  font-size: 1.6rem; display: grid; place-items: center; pointer-events: auto; touch-action: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tbtn.thrust { width: 110px; height: 110px; border-radius: 50%; border-color: rgba(255, 106, 43, .8); background: rgba(255, 106, 43, .25); font-size: 1rem; font-weight: 800; font-family: var(--font-head); }
.tbtn.on { background: rgba(255, 138, 61, .7); transform: scale(.96); }
.touch-ctrls .spacer { width: 1px; }
@media (hover: hover) and (pointer: fine) {
  .touch-ctrls { opacity: .55; }
}
.touch-ctrls.hidden { display: none; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(5, 7, 15, .55); z-index: 5; overflow-y: auto; }
.overlay[hidden] { display: none; }
.dialog { width: min(460px, 100%); background: var(--surface); color: var(--text); border-radius: 22px; padding: 22px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); border: 1px solid var(--line); max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog h2 { margin-bottom: 6px; }
.dialog .fact { background: var(--bg-2); border-radius: 12px; padding: 12px 14px; font-size: .92rem; margin: 12px 0; }
.dialog .fact b { color: var(--flame); }
.brief-stats { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.result-title { font-size: 1.7rem; }
.result-title.win { color: var(--good); }
.result-title.lose { color: var(--bad); }
.result-stars { font-size: 2.2rem; letter-spacing: 6px; color: var(--gold); margin: 4px 0; }
.result-stars .off { color: var(--line); }
.result-stars span { display: inline-block; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.result-stars span:nth-child(2) { animation-delay: .15s; }
.result-stars span:nth-child(3) { animation-delay: .3s; }
@keyframes pop { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: .92rem; }
.result-table td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.result-table td:last-child { text-align: right; font-family: var(--font-mono); font-weight: 700; }
.score-big { font: 800 2.2rem/1 var(--font-mono); }
.ghost-banner { background: color-mix(in srgb, var(--sky) 15%, transparent); border: 1px solid var(--sky); border-radius: 12px; padding: 10px 12px; font-size: .9rem; margin: 10px 0; }
.controls-help { font-size: .85rem; color: var(--muted); }
kbd { font-family: var(--font-mono); font-size: .8em; background: var(--bg-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }

.daily-card { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: linear-gradient(135deg, color-mix(in srgb, var(--flame) 16%, var(--surface)), var(--surface)); }
@media (max-width: 560px) { .daily-card { grid-template-columns: 1fr; } }

/* Learn page */
.timeline { position: relative; margin: 20px 0; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 3px; background: linear-gradient(var(--flame), var(--sky)); border-radius: 3px; }
.tl-item { position: relative; margin-bottom: 14px; }
.tl-item::before { content: ""; position: absolute; left: -24px; top: 18px; width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 3px solid var(--flame); }
.tl-item.fail::before { border-color: var(--bad); }
.tl-item.future::before { border-style: dashed; border-color: var(--sky); }
.tl-item .card { padding: 14px 16px; }
.tl-date { font: 700 .8rem/1 var(--font-mono); color: var(--muted); }
.tl-item h3 { margin: 6px 0 6px; }
.tl-item p { margin: 0; font-size: .95rem; }
.tl-item .tl-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; font-size: .82rem; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-row button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 14px; font: 600 .88rem/1 var(--font-body); cursor: pointer; }
.filter-row button[aria-pressed="true"] { background: var(--flame); border-color: var(--flame); color: #fff; }

.lab { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
@media (max-width: 820px) { .lab { grid-template-columns: 1fr; } }
.lab canvas { width: 100%; height: 300px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); }
.lab-out { font-family: var(--font-mono); font-size: 1rem; margin-top: 10px; }
.lab-out b { color: var(--flame); font-size: 1.3rem; }
.range-row { display: flex; justify-content: space-between; font-size: .9rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { font-family: var(--font-head); font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.table-scroll { overflow-x: auto; }

/* Hangar */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.ach { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.ach .ico { font-size: 1.7rem; filter: grayscale(1); opacity: .4; }
.ach.got .ico { filter: none; opacity: 1; }
.ach.got { border-color: var(--gold); }
.ach h4 { margin: 0 0 2px; font-size: .98rem; }
.ach p { margin: 0; font-size: .84rem; color: var(--muted); }
.livery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.livery { border: 2px solid var(--line); background: var(--surface); border-radius: 16px; padding: 12px; cursor: pointer; text-align: center; color: var(--text); font: inherit; }
.livery canvas { width: 60px; height: 150px; display: block; margin: 0 auto 8px; }
.livery[aria-pressed="true"] { border-color: var(--flame); box-shadow: 0 0 0 3px color-mix(in srgb, var(--flame) 30%, transparent); }
.livery[disabled] { opacity: .5; cursor: not-allowed; }
.livery small { display: block; color: var(--muted); }

.prose { max-width: 70ch; }
.prose h2 { margin-top: 1.4em; }
.prose li { margin-bottom: .4em; }

.reveal { animation: rise .6s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 420px) {
  .hud { font-size: .7rem; padding: 8px; gap: 6px; }
  .hud-left, .hud-right { width: 118px; }
  .hud-block { padding: 6px 8px; }
  .tbtn { width: 64px; height: 64px; }
  .tbtn.thrust { width: 96px; height: 96px; }
}
