/* Cue Hunter: 0300 rounds. Dark ward, phosphor monitor, paper note, grease pencil. */
:root {
  --glass: #0E1B1F;
  --ward: #0A1518;
  --phosphor: #9EF0C8;
  --phosphor-dim: #4E8A72;
  --amber: #FFB454;
  --grease: #FF5A4E;
  --paper: #E8E2D0;
  --ink: #2A2622;
  --lift: 0;                 /* raised one notch per level cleared */
  --font: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: color-mix(in srgb, var(--ward) calc(100% - var(--lift) * 6%), #2a3b40);
  color: var(--phosphor);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  transition: background 600ms ease;
}
.noscript { padding: 24px; color: var(--paper); }
button { font: inherit; color: inherit; }
button:focus-visible, .chunk:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.stage { max-width: 720px; margin: 0 auto; padding: 16px; min-height: 100dvh; display: flex; flex-direction: column; }
.stage.narrow { max-width: 360px; --stage-w: 360px; }
.screen[hidden], [hidden] { display: none !important; }
.screen { flex: 1; display: flex; flex-direction: column; animation: fadein 250ms ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.btn {
  min-height: 44px; padding: 10px 18px; border-radius: 6px;
  border: 1px solid var(--phosphor-dim); background: transparent; color: var(--phosphor);
  font-weight: 600; cursor: pointer; transition: border-color 80ms ease-out, transform 120ms ease-out;
}
.btn:hover { border-color: var(--amber); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--phosphor); color: var(--glass); border-color: var(--phosphor); font-weight: 800; }
.btn.primary:hover { background: var(--amber); border-color: var(--amber); }

/* ---------- title ---------- */
.title { justify-content: center; align-items: center; text-align: center; gap: 12px; }
.hero-tile {
  position: relative; display: grid; grid-template-columns: auto auto; column-gap: 10px; align-items: baseline;
  background: var(--glass); border: 1px solid #1e3238; border-radius: 8px; padding: 14px 22px 12px;
  box-shadow: 0 0 40px rgba(158, 240, 200, 0.12), inset 0 0 30px rgba(158, 240, 200, 0.04);
  margin-bottom: 20px;
}
.hero-tile .k { grid-column: 1 / 3; font-size: 13px; font-weight: 600; color: var(--phosphor-dim); text-align: left; }
.hero-tile .v { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--grease); }
.hero-tile .u { font-size: 14px; color: var(--phosphor-dim); }
.hero-tile .pencil { position: absolute; left: -5px; top: -4px; }
.title h1 { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; color: var(--paper); }
.title .sub { margin: 0 0 18px; color: var(--phosphor-dim); font-size: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.best-line { color: var(--amber); font-weight: 600; margin: 6px 0 0; }
.credits { max-width: 46ch; color: var(--phosphor-dim); font-size: 14px; }

/* ---------- play ---------- */
.topbar { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; margin-bottom: 8px; }
.who { min-width: 0; line-height: 1.2; }
.who strong { display: block; font-size: 18px; font-weight: 800; color: var(--paper); }
.who span { display: block; font-size: 13px; color: var(--phosphor-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.streak {
  font-weight: 800; font-size: 15px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--phosphor-dim);
  font-variant-numeric: tabular-nums; transition: transform 120ms ease-out, color 120ms, border-color 120ms;
}
.streak.hot { color: var(--amber); border-color: var(--amber); }
.streak.pulse { animation: chip 300ms ease-out; }
.streak.squash { animation: squash 120ms ease-out; }
@keyframes chip { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes squash { 0% { transform: scale(1.1, 0.8); } 100% { transform: scale(1); } }
.timer { position: relative; width: 52px; height: 52px; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 0; width: 52px; height: 52px; transform: rotate(-90deg); }
.timer .track { fill: none; stroke: #1e3238; stroke-width: 3; }
.timer .ring { fill: none; stroke: var(--phosphor); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 132; stroke-dashoffset: 0; transition: stroke 200ms; }
.timer.warn .ring { stroke: var(--amber); }
.timer.danger .ring { stroke: var(--grease); }
.timer.flash .ring { animation: ringflash 300ms ease-out; }
@keyframes ringflash { 0%, 100% { stroke: var(--grease); } 50% { stroke: #fff; stroke-width: 5; } }
#time { font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.timer.danger #time { color: var(--grease); animation: ticksize 1s ease-out infinite; }
@keyframes ticksize { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
.penalty { position: absolute; top: -8px; right: -6px; font-size: 12px; font-weight: 800; color: var(--grease); opacity: 0; }
.penalty.show { animation: rise 1400ms ease-out; }
@keyframes rise { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-18px); } }

.status { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 28px; margin-bottom: 8px; }
.hint { color: var(--amber); font-size: 14px; font-weight: 600; }
.cues { display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--phosphor-dim); white-space: nowrap; }
.cues i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--phosphor-dim); display: inline-block; transition: background 150ms; }
.cues i.on { background: var(--grease); border-color: var(--grease); }
.cues i.miss { border-color: var(--amber); border-style: dashed; }

.scene { display: flex; flex-direction: column; gap: 12px; transition: opacity 400ms ease, filter 400ms ease; }
.scene.dim { opacity: 0.4; pointer-events: none; }
.scene.sheen { animation: sheen 350ms ease-out; }
@keyframes sheen { 0% { filter: brightness(1); } 30% { filter: brightness(1.35); } 100% { filter: brightness(1); } }

/* monitor */
.monitor {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: var(--glass); border: 1px solid #1e3238; border-radius: 10px; padding: 10px;
  box-shadow: inset 0 0 40px rgba(158, 240, 200, 0.05);
}
.tile {
  position: relative; display: grid; grid-template-rows: auto 1fr auto; text-align: left;
  min-height: 84px; padding: 8px 10px; border-radius: 6px; background: transparent; border: 1px solid transparent;
  cursor: crosshair; transition: border-color 80ms ease-out, transform 180ms cubic-bezier(.34,1.56,.64,1);
}
.tile:hover, .tile:focus-visible { border-color: var(--amber); }
.tile .k { font-size: 12px; font-weight: 600; color: var(--phosphor-dim); }
.tile .k small, .lab .k small { font-weight: 400; font-size: 11px; opacity: 0.8; }
.tile .v { font-size: 34px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile .u { font-size: 11px; color: var(--phosphor-dim); }
.tile.prior { opacity: 0.85; }
.tile.prior .v { font-size: 26px; }
.tile.hit { transform: scale(1.0); animation: popscale 180ms cubic-bezier(.34,1.56,.64,1); }
.tile.hit .v, .lab.hit .v { color: var(--grease); }
.chunk.hit { color: var(--grease); }
@keyframes popscale { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
.tile.guided { animation: guide 1.1s ease-in-out infinite; border-color: var(--amber); }
@keyframes guide { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 180, 84, 0); } 50% { box-shadow: 0 0 0 5px rgba(255, 180, 84, 0.35); } }

/* pencil circle */
.pencil { position: absolute; left: -5px; top: -4px; overflow: visible; pointer-events: none; }
.pencil path { fill: none; stroke: var(--grease); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke-dashoffset 220ms ease-out; opacity: 0.95; }
.pencil.dashed path { stroke: var(--amber); }
.glow .pencil path { filter: drop-shadow(0 0 4px var(--grease)); }

/* wrong */
.shake { animation: shake 240ms ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 17% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 83% { transform: translateX(-4px); } }
.wrong::after { content: ''; position: absolute; right: 8px; top: 8px; width: 14px; height: 3px; background: var(--grease); border-radius: 2px; transform: rotate(-20deg); }
.chunk.wrong::after { display: none; }
.chunk.wrong { text-decoration: line-through var(--grease) 2px; }

/* number pop */
.pop { position: absolute; top: 0; font-weight: 800; font-size: 16px; color: var(--amber); pointer-events: none; animation: rise 800ms ease-out forwards; }

/* lab strip */
.labwrap { overflow-x: auto; scrollbar-width: thin; padding: 2px 0 6px; -webkit-overflow-scrolling: touch; }
.strip { display: flex; gap: 6px; min-width: max-content; }
.lab {
  position: relative; display: grid; grid-template-rows: auto auto auto; gap: 1px; text-align: left; min-width: 92px; min-height: 64px;
  padding: 7px 9px; background: var(--paper); color: var(--ink); border: 1px solid #cdc6b2; border-top: 3px dashed #cdc6b2; border-radius: 3px;
  cursor: crosshair; transition: outline-color 80ms, transform 180ms cubic-bezier(.34,1.56,.64,1);
}
.lab:hover, .lab:focus-visible { outline: 2px solid var(--amber); outline-offset: -1px; }
.lab .k { font-size: 12px; font-weight: 600; color: #6c6558; }
.lab .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.lab .r { font-size: 11px; color: #6c6558; white-space: nowrap; }
.lab.hit { animation: popscale 180ms cubic-bezier(.34,1.56,.64,1); }
.lab.prior { background: #d9d3c0; }
.lab .pencil { left: -5px; top: -4px; }

/* note */
.note { background: var(--paper); color: var(--ink); border-radius: 3px; padding: 12px 14px; box-shadow: 0 2px 0 #cdc6b2; position: relative; }
.note::before { content: ''; position: absolute; left: 50%; top: -6px; width: 44px; height: 10px; margin-left: -22px; background: #6c6558; border-radius: 3px; }
.note-head { font-size: 12px; font-weight: 600; color: #6c6558; display: flex; justify-content: space-between; border-bottom: 1px solid #cdc6b2; padding-bottom: 6px; margin-bottom: 8px; }
.note-body { margin: 0; font-size: 17px; line-height: 1.7; }
.chunk {
  position: relative; display: inline; background: transparent; border: 0; padding: 2px 3px; border-radius: 3px; text-align: left;
  cursor: crosshair; color: var(--ink); font-weight: 400; line-height: inherit; transition: background 80ms;
  -webkit-box-decoration-break: clone; box-decoration-break: clone; min-height: 44px;
}
.chunk:hover, .chunk:focus-visible, .chunk.drag { background: rgba(255, 180, 84, 0.35); outline: none; }
.chunk.hit { background: rgba(255, 90, 78, 0.18); font-weight: 600; }
.chunk .pencil { display: none; }
.chunk .pop { color: var(--grease); }

.score-line { text-align: right; font-weight: 800; font-size: 15px; color: var(--phosphor-dim); margin-top: 8px; font-variant-numeric: tabular-nums; }
.score-line.count { color: var(--amber); }

/* debrief */
.debrief {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(var(--stage-w, 720px), 100%);
  max-height: 78dvh; overflow-y: auto; background: var(--paper); color: var(--ink);
  border-radius: 12px 12px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  animation: slideup 260ms cubic-bezier(.2,.8,.3,1);
}
@keyframes slideup { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.debrief h2 { margin: 0 0 10px; font-size: 22px; font-weight: 800; }
.debrief ul { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.debrief li { font-size: 15px; line-height: 1.4; padding-left: 12px; border-left: 3px solid var(--grease); }
.debrief li b { display: block; font-weight: 800; }
.debrief li.missed { border-left-color: var(--amber); }
.debrief li.missed b::after { content: ' · missed'; font-weight: 600; color: #a0661a; }
.debrief .theme { font-size: 15px; font-weight: 600; margin: 0 0 14px; padding-top: 10px; border-top: 1px solid #cdc6b2; }
.debrief .btn.primary { width: 100%; background: var(--ink); color: var(--paper); border-color: var(--ink); }
.debrief .btn.primary:hover { background: #4a4238; }

/* ---------- result ---------- */
.result, .end { justify-content: center; text-align: center; gap: 10px; }
.eyebrow { margin: 0; color: var(--phosphor-dim); font-weight: 600; }
.result h2, .end h2 { margin: 0; font-size: 36px; font-weight: 800; color: var(--paper); }
.result h2.fail { color: var(--amber); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.stats div { background: var(--glass); border: 1px solid #1e3238; border-radius: 8px; padding: 12px 8px; }
.stats dt { font-size: 12px; color: var(--phosphor-dim); font-weight: 600; }
.stats dd { margin: 4px 0 0; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rule { margin: 4px auto 14px; max-width: 48ch; background: var(--paper); color: var(--ink); padding: 12px 14px; border-radius: 3px; text-align: left; }
.rule span { display: block; font-size: 12px; font-weight: 600; color: #6c6558; margin-bottom: 4px; }
.rule em { font-style: normal; font-weight: 600; }
.best-badge { display: inline-block; margin: 0 auto; color: var(--amber); border: 2px solid var(--amber); border-radius: 6px; padding: 4px 10px; font-weight: 800; animation: stamp 320ms cubic-bezier(.34,1.56,.64,1); }
@keyframes stamp { 0% { transform: scale(1.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- end ---------- */
.total { margin: 6px 0; display: grid; }
.total span { font-size: 64px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--paper); }
.total small { color: var(--phosphor-dim); font-weight: 600; }
.bars { list-style: none; padding: 0; margin: 12px auto 18px; width: min(100%, 420px); display: grid; gap: 8px; text-align: left; }
.bars li { display: grid; grid-template-columns: 110px 1fr 56px; align-items: center; gap: 10px; font-size: 14px; }
.bars .bar { height: 10px; background: var(--glass); border-radius: 999px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--grease); border-radius: 999px; transition: width 600ms ease-out; }
.bars span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--phosphor-dim); }

/* grease-mark confetti */
.fx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.mark { position: absolute; width: 18px; height: 4px; background: var(--grease); border-radius: 2px; animation: fling 500ms ease-out forwards; }
@keyframes fling { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

/* ---------- phone ---------- */
@media (max-width: 420px) {
  .stage { padding: 12px; }
  .title h1 { font-size: 36px; }
  .monitor { gap: 6px; padding: 8px; }
  .tile { padding: 6px 8px; min-height: 76px; }
  .tile .v { font-size: 28px; }
  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .stats dd { font-size: 20px; }
}
.stage.narrow .title h1 { font-size: 36px; }
.stage.narrow .tile .v { font-size: 28px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .shake, .tile.hit, .lab.hit, .streak.pulse, .streak.squash, .timer.danger #time, .tile.guided, .scene.sheen, .best-badge { animation: none; }
  .pencil path { transition: none; }
  .debrief { animation: fadein 200ms ease-out; }
  .mark { display: none; }
  body { transition: none; }
}
