/* Behind the Cursor — one dark world: words made of light on blue-black. */
@font-face { font-family: "Rec Sans"; src: url("../assets/fonts/rec-sans.woff2") format("woff2"); font-weight: 300 1000; font-display: block; }
@font-face { font-family: "Rec Mono"; src: url("../assets/fonts/rec-mono.woff2") format("woff2"); font-weight: 300 1000; font-display: block; }
@font-face { font-family: "Rec VF"; src: url("../assets/fonts/rec-vf.woff2") format("woff2"); font-weight: 300 1000; font-display: swap; }

:root {
  /* layout: one full-bleed stage; UI floats over it, phone-first */
  --ink: #05060a;
  --ink-2: #0b0e17;
  --star: #eef2ff;
  --dim: #8f98b8;
  --faint: #2a3150;
  --glass: rgba(150, 175, 255, 0.08);
  --glass-line: rgba(200, 214, 255, 0.28);
  --ember: #ffb23e;           /* only ever means "chosen" */
  --cold: #9cc8ff;
  --sans: "Rec VF", "Rec Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "Rec Mono", ui-monospace, Menlo, Consolas, monospace;
  --pad: max(16px, env(safe-area-inset-left, 0px));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--star); }
body { font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
body[data-view="play"] { overflow: auto; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- theater ---------- */
.theater { position: fixed; inset: 0; background: var(--ink); }
body[data-view="play"] .theater { display: none; }
.stage { position: absolute; inset: 0; }
.stage-box { position: absolute; }
.stage-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.film-mode, body.film-mode * { cursor: none !important; }

.landing { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto; padding: max(20px, env(safe-area-inset-top)) var(--pad) max(28px, env(safe-area-inset-bottom)); pointer-events: none; }
.brand { margin: 0; font: 600 13px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--dim); }
.landing-actions { align-self: end; justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 14px; pointer-events: auto; margin-bottom: clamp(24px, 9vh, 120px); }
.loading { justify-self: center; margin: 0; font: 500 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); min-height: 1em; }

.btn { display: inline-flex; align-items: center; gap: 12px; border: 0; cursor: pointer; border-radius: 999px; transition: transform .2s cubic-bezier(.3,1.5,.5,1), background-color .2s, opacity .2s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.96); }
.btn:focus-visible, .icon-btn:focus-visible, .mute:focus-visible { outline: 2px solid var(--cold); outline-offset: 3px; }
.btn-primary { background: var(--star); color: var(--ink); padding: 16px 28px 16px 22px; font-weight: 650; font-size: 18px; box-shadow: 0 0 0 1px rgba(255,255,255,.3), 0 0 40px rgba(160,190,255,.25); }
.btn-primary svg { width: 22px; height: 22px; fill: currentColor; }
.btn-primary small { font: 500 12px/1 var(--mono); letter-spacing: .06em; opacity: .55; }
.btn-primary:disabled { opacity: .35; cursor: default; }
.btn-ghost { background: none; color: var(--dim); padding: 10px 16px; font-size: 15px; }
.btn-ghost:hover { color: var(--star); }

.film-ui { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 var(--pad) max(14px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 16px; }
.icon-btn { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 999px; padding: 8px 14px; font: 500 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); cursor: pointer; }
.icon-btn:hover { color: var(--star); }
.progress { flex: 1; height: 2px; background: var(--faint); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--dim); }

.end-cta { position: absolute; left: 0; right: 0; bottom: max(28px, env(safe-area-inset-bottom)); display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; padding: 0 var(--pad); }
.film-hint { position: absolute; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center; font: 500 12px/1.4 var(--mono); letter-spacing: .08em; color: var(--faint); }

.mute { position: fixed; z-index: 20; top: max(14px, env(safe-area-inset-top)); right: var(--pad); width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--glass-line); background: rgba(5,6,10,.55); color: var(--star); display: grid; place-items: center; cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.mute svg { width: 22px; height: 22px; fill: currentColor; }
.mute .off { display: none; }
.mute[aria-pressed="true"] .on { display: none; }
.mute[aria-pressed="true"] .off { display: block; }
body.film-mode .mute { display: none; }

@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* ---------- playground: phone-first, one column ---------- */
.play { min-height: 100%; max-width: 720px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) var(--pad) max(40px, env(safe-area-inset-bottom)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.play-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 56px 10px 0; background: linear-gradient(var(--ink) 75%, transparent); }
.back { background: none; border: 0; color: var(--dim); font: 500 14px/1 var(--sans); padding: 10px 6px; cursor: pointer; }
.back:hover { color: var(--star); }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); }
.tabs button { border: 0; background: none; border-radius: 999px; padding: 9px 16px; font: 600 14px/1 var(--sans); color: var(--dim); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--star); color: var(--ink); }
.tabs button:focus-visible, .chip-btn:focus-visible, .guess-opt:focus-visible, .btn-small:focus-visible, .back:focus-visible { outline: 2px solid var(--cold); outline-offset: 2px; }
.panel-title { margin: 14px 0 12px; font: 650 clamp(24px, 6vw, 38px)/1.1 var(--sans); letter-spacing: -0.01em; text-wrap: balance; }
.play-foot { margin-top: 48px; color: var(--dim); font: 500 12px/1.6 var(--mono); }
.play-foot p { margin: 0 0 6px; }

.btn-small { padding: 10px 16px; font-weight: 600; font-size: 14px; background: var(--star); color: var(--ink); }
.btn-small:disabled { opacity: .5; }
.btn-quiet { background: var(--glass); border: 1px solid var(--glass-line); color: var(--star); padding: 12px 18px; font-size: 15px; font-weight: 600; text-decoration: none; }
.btn-quiet:disabled { opacity: .35; cursor: default; }

/* model status */
.model-bar { display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-line); }
.model-copy { display: grid; gap: 3px; min-width: 0; font-size: 14px; }
.model-copy strong { font-weight: 650; font-size: 15px; }
.model-copy span { color: var(--dim); font: 500 12.5px/1.4 var(--mono); }
.model-bar.ready { grid-template-columns: 1fr; padding: 10px 14px; }
.model-bar.ready .model-copy { grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; }
.model-bar.ready strong { font-size: 13px; white-space: nowrap; }
.model-bar.ready strong::before { content: "● "; color: #6ee7a8; }
.bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--faint); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--star); transition: width .2s; }

/* starters */
.starters { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 6px; margin: 0 calc(-1 * var(--pad)); padding-left: var(--pad); padding-right: var(--pad); scrollbar-width: none; scroll-snap-type: x proximity; }
.starters::-webkit-scrollbar { display: none; }
.chip-btn { flex: none; scroll-snap-align: start; border-radius: 999px; padding: 10px 14px; background: none; border: 1px solid var(--glass-line); color: var(--dim); font: 500 14px/1.2 var(--sans); cursor: pointer; white-space: nowrap; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; }
.chip-btn[aria-pressed="true"] { color: var(--star); border-color: var(--star); background: var(--glass); }
.chip-own { border-style: dashed; }
.custom { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-top: 8px; }
.custom textarea, .tok-input { width: 100%; resize: vertical; background: var(--ink-2); color: var(--star); border: 1px solid var(--glass-line); border-radius: 14px; padding: 12px 14px; font: 500 16px/1.45 var(--sans); }
.custom textarea:focus, .tok-input:focus { outline: 2px solid var(--cold); outline-offset: 1px; }

/* the sentence */
.sentence { margin: 14px 0 6px; scroll-margin-top: 76px; min-height: 2.6em; font: 520 clamp(24px, 6.2vw, 34px)/1.35 var(--sans); overflow-wrap: anywhere; }
.sentence .prompt { color: var(--star); }
.sentence .gen { color: var(--ember); font-weight: 620; text-shadow: 0 0 18px rgba(255,178,62,.35); }
.sentence .gen.fresh { display: inline-block; animation: land .45s cubic-bezier(.3,1.6,.5,1); }
.sentence .cursor { display: inline-block; width: .08em; height: 1em; margin-left: .06em; vertical-align: -0.12em; background: var(--star); animation: blink 1.06s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes land { from { transform: translateY(-10px) scale(.9); opacity: .2; } }

/* wheel */
.wheel-wrap { position: relative; display: grid; justify-items: center; margin: 4px 0; }
.wheel-wrap canvas { max-width: 100%; touch-action: manipulation; }
.tail-note { position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%); margin: 0; padding: 10px 16px; border-radius: 14px; background: rgba(5,6,10,.85); border: 1px solid rgba(255,178,62,.45); text-align: center; display: grid; gap: 2px; animation: land .4s cubic-bezier(.3,1.6,.5,1); }
.tail-note b { color: var(--ember); font: 650 22px/1.2 var(--sans); }
.tail-note span { color: var(--dim); font: 500 12px/1.3 var(--mono); }

/* temperature */
.temp { margin: 8px 0 4px; }
.temp-row { display: flex; justify-content: space-between; align-items: baseline; }
.temp-label { font: 600 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.temp output { font: 650 22px/1 var(--mono); font-variant-numeric: tabular-nums; }
.temp input[type=range] { width: 100%; margin: 12px 0 6px; accent-color: var(--star); height: 28px; }
.temp input:disabled { opacity: .4; }
.temp-ends { display: flex; justify-content: space-between; color: var(--dim); font: 500 12px/1 var(--mono); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.actions .spin-btn { flex: 1 1 100%; justify-content: center; font-size: 20px; padding: 18px; }
.actions .spin-btn:disabled { opacity: .35; }
.actions .btn-quiet { flex: 1 1 0; justify-content: center; }

/* tokens */
.tok-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; color: var(--dim); font: 500 13px/1.3 var(--mono); }
.switch { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.switch input { accent-color: var(--star); width: 18px; height: 18px; }
.tok-view { font: 500 18px/2.2 var(--mono); overflow-wrap: anywhere; }
.tk { display: inline-flex; align-items: baseline; margin: 0 3px 6px 0; padding: 2px 6px; border-radius: 7px; border: 1px solid var(--glass-line); line-height: 1.5; vertical-align: top; }
.tk.a { background: rgba(150,175,255,.13); }
.tk.b { background: rgba(150,175,255,.05); }
.tk .sp { font-style: normal; color: var(--dim); margin-right: 1px; }
.tk small { margin-left: 6px; font-size: 10.5px; line-height: 1.2; color: var(--dim); }
.tk.bytes { color: var(--cold); border-style: dashed; font-size: 13px; }
.tk.special { color: var(--ember); }

/* guess */
.guess-score { margin: 0; color: var(--dim); font: 500 13px/1.4 var(--mono); }
.guess-opts { display: grid; gap: 10px; margin-top: 18px; }
.guess-opt { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; gap: 12px; align-items: center; text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--glass); border: 1px solid var(--glass-line); color: var(--star); font: 600 18px/1.2 var(--sans); cursor: pointer; }
.guess-opt .w, .guess-opt .bar, .guess-opt .pc { display: block; }
.guess-opt .bar { height: 8px; border-radius: 8px; background: transparent; overflow: hidden; }
.guess-opt .bar i { display: block; height: 100%; width: 0; background: var(--star); border-radius: 8px; transition: width .7s cubic-bezier(.2,1,.3,1); }
.guess-opt .pc { color: var(--dim); font: 500 14px/1 var(--mono); min-width: 4.5em; text-align: right; }
.guess-opt.shown { cursor: default; }
.guess-opt.mine { border-color: var(--star); }
.guess-opt.top .w { color: var(--ember); }
.guess-opt.top .bar i { background: var(--ember); }
.guess-verdict { min-height: 1.4em; margin: 16px 0 10px; font-weight: 600; }

/* share sheet */
.share-sheet { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px var(--pad); background: rgba(5,6,10,.86); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.share-box { width: min(100%, 460px); display: grid; gap: 14px; }
.share-box img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 18px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-actions .btn { flex: 1 1 auto; justify-content: center; }
.share-note { margin: 0; min-height: 1.2em; color: var(--dim); font: 500 13px/1.3 var(--mono); text-align: center; }

@media (min-width: 900px) {
  .play { max-width: 760px; }
  .actions .spin-btn { flex: 2 1 0; }
}
