/* SKY DRAGONS. One small system: dark glass panels, one cyan accent, one amber for results.
   Three text roles (label, body, display), one corner radius, big touch targets. */
:root {
  --ink: #e9f6fa;
  --dim: #9fb6bf;
  --cyan: #46e3ff;
  --amber: #ffb040;
  --glass: rgba(6, 14, 18, 0.62);
  --line: rgba(120, 220, 255, 0.28);
  --r: 14px;
  --label: 12px;
  --body: clamp(15px, 1.2vw + 10px, 18px);
  --pad: clamp(14px, 2.2vw, 28px);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #05090c; color: var(--ink); font-family: var(--font); overflow: hidden; overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* On the Light setting the film pass is off, so the dark edges are drawn here instead. */
#lens { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 46%, transparent 52%, rgba(0, 0, 0, 0.5) 100%); display: none; }
body.light #lens { display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* ── screens ── */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: max(var(--pad), env(safe-area-inset-top)) max(var(--pad), env(safe-area-inset-right)) max(var(--pad), env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left)); background: linear-gradient(90deg, rgba(3, 8, 11, 0.86) 0%, rgba(3, 8, 11, 0.5) 46%, rgba(3, 8, 11, 0) 78%); justify-items: start; overflow-y: auto; touch-action: pan-y; }
#loading { background: #05090c; justify-items: center; }
#pause, #finish { background: rgba(3, 8, 11, 0.6); justify-items: center; }
.card { width: min(100%, 520px); display: grid; gap: clamp(12px, 1.8vh, 20px); padding: clamp(18px, 3vw, 34px); background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.card.bare { background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; text-align: center; width: min(100%, 420px); }
h1, h2 { margin: 0; font-weight: 600; text-transform: uppercase; letter-spacing: 0.2em; line-height: 1.02; color: #fff; }
h1 { font-size: clamp(38px, 6.4vw, 76px); }
h2 { font-size: clamp(26px, 3.4vw, 40px); }
.lede { margin: 0; font-size: var(--body); line-height: 1.45; color: var(--ink); max-width: 34ch; }
.help { margin: 0; font-size: var(--label); line-height: 1.5; letter-spacing: 0.04em; color: var(--dim); }
.choose { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick { display: grid; gap: 6px; align-content: start; text-align: left; padding: 14px 14px 16px; min-height: 112px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(10, 24, 30, 0.5); transition: border-color 0.2s, background 0.2s; }
.pick b { font-size: clamp(20px, 2vw, 26px); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.pick span { font-size: var(--label); line-height: 1.45; letter-spacing: 0.02em; color: var(--dim); }
.pick[aria-checked="true"] { border-color: var(--cyan); background: rgba(20, 70, 86, 0.55); box-shadow: 0 0 0 1px var(--cyan) inset, 0 0 26px rgba(70, 227, 255, 0.22); }
.pick[aria-checked="true"] span { color: var(--ink); }
.go { min-height: 60px; border-radius: var(--r); background: var(--cyan); color: #021217; font-size: clamp(20px, 2vw, 24px); font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; box-shadow: 0 0 34px rgba(70, 227, 255, 0.35); transition: transform 0.12s; }
.go:active { transform: scale(0.98); }
.plain { min-height: 48px; border-radius: var(--r); border: 1px solid var(--line); font-size: var(--body); letter-spacing: 0.08em; text-transform: uppercase; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.loadbar { height: 3px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 4%; background: var(--cyan); transition: width 0.3s; }
.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.results div { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); }
.results span, .chip span, #boost span { font-size: var(--label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.results b { font-size: clamp(22px, 2.6vw, 32px); font-weight: 600; color: var(--amber); font-variant-numeric: tabular-nums; }

/* ── in flight ── */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-top { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); display: flex; gap: 8px; }
.chip { display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: baseline; padding: 8px 12px; min-width: 92px; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); }
.chip span { grid-column: 1 / -1; }
.chip b { font-size: clamp(20px, 2vw, 26px); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip i { font-style: normal; font-size: var(--label); color: var(--dim); }
.hud-side { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.tool { display: grid; justify-items: center; gap: 2px; width: 64px; min-height: 56px; padding: 8px 4px 6px; background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); }
.tool svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
#boost { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(40vw, 320px); display: grid; gap: 5px; justify-items: center; }
#boost .bar { width: 100%; height: 6px; background: rgba(255, 255, 255, 0.14); border-radius: 6px; overflow: hidden; }
#boost i { display: block; height: 100%; width: 60%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
#banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-size: clamp(34px, 7vw, 96px); font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: #fff; text-shadow: 0 0 30px rgba(70, 227, 255, 0.8); opacity: 0; transition: opacity 0.25s; }
#banner.show { opacity: 1; }
#banner.small { font-size: clamp(20px, 3vw, 34px); top: 30%; }
#coach { position: absolute; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 44px); transform: translateX(-50%); padding: 10px 16px; max-width: min(88vw, 560px); text-align: center; font-size: var(--body); background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); opacity: 0; transition: opacity 0.4s; }
#coach.show { opacity: 1; }
#coach kbd { display: inline-block; min-width: 1.9em; padding: 2px 7px; margin: 0 2px; border: 1px solid var(--cyan); border-radius: 7px; font: inherit; font-weight: 600; color: var(--cyan); }

/* ── touch ── */
#stick { position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px; border: 2px solid var(--line); border-radius: 50%; background: rgba(6, 14, 18, 0.3); opacity: 0; transition: opacity 0.15s; left: 110px; top: calc(100% - 120px); }
#stick.on { opacity: 1; }
#nub { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; background: rgba(70, 227, 255, 0.55); box-shadow: 0 0 18px rgba(70, 227, 255, 0.5); transform: translate(-50%, -50%); }
.pad { position: absolute; display: none; place-items: center; border-radius: 50%; border: 2px solid var(--line); background: var(--glass); font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; touch-action: none; }
.pad.down { border-color: var(--cyan); background: rgba(20, 70, 86, 0.75); }
body.touch .pad { display: grid; }
body.touch #stick { opacity: 0.35; }
body.touch #stick.on { opacity: 1; }
#btn-fire { right: max(20px, env(safe-area-inset-right)); bottom: max(26px, env(safe-area-inset-bottom)); width: 96px; height: 96px; }
#btn-boost { right: calc(max(20px, env(safe-area-inset-right)) + 108px); bottom: max(20px, env(safe-area-inset-bottom)); width: 78px; height: 78px; }
body.touch #boost { bottom: auto; top: calc(max(12px, env(safe-area-inset-top)) + 70px); left: max(12px, env(safe-area-inset-left)); transform: none; width: 180px; justify-items: start; }
body.touch #coach { bottom: auto; top: calc(max(12px, env(safe-area-inset-top)) + 116px); }

@media (max-width: 640px) {
  .screen { justify-items: center; background: rgba(3, 8, 11, 0.62); align-items: start; }
  .choose { grid-template-columns: 1fr; }
  .pick { min-height: 0; }
  .chip { min-width: 0; padding: 6px 9px; }
  .hud-top { gap: 5px; }
  .tool { width: 54px; }
  .tool span { display: none; }
  .tool { min-height: 48px; align-content: center; }
}
@media (max-height: 460px) {
  .card { gap: 8px; padding: 14px 18px; width: min(100%, 640px); }
  h1 { font-size: 30px; } h1 br { display: none; }
  .choose { grid-template-columns: 1fr 1fr; }
  .pick { min-height: 0; padding: 10px 12px; }
  .go { min-height: 50px; }
  #keys-help { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
