/* The game. Shares the palette in lib/game_palette.dart with the landing page
   and nothing else: assets/site.css never loads here. */

:root {
  --ink: #05070C;
  --accent: #34E7F3;
  --left-fist: #FFC43D;
  --target: #FF3B47;
  --obstacle: #3D7BFF;
  --success: #32E67F;
  --danger: #FF3B47;
  --ember: #FF8A3D;
  --glow: #7C5CFF;
  --surface: #0E1523;
  --outline: rgba(255, 255, 255, .12);
  --outline-strong: rgba(255, 255, 255, .24);
  --text: #F2F6FF;
  --text-2: rgba(242, 246, 255, .70);
  --text-3: rgba(242, 246, 255, .42);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* -------------------------------------------------------- the portrait frame */

#stage {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh;
  display: grid; place-items: center;
  background: radial-gradient(120% 80% at 50% 0%, #0B1220 0%, var(--ink) 70%);
}

#frame {
  position: relative;
  width: 100%; height: 100%;
  /* 9:16, the shape the game is tuned for. A portrait phone is narrower than
     this and simply fills the screen. */
  max-width: min(100%, calc(100dvh * 0.5625));
  overflow: hidden;
  background: #05070C;
}

/* On anything roomier than a phone the frame reads as a handset. */
@media (min-width: 520px) and (min-height: 620px) {
  #frame {
    height: min(calc(100dvh - 48px), 900px);
    border-radius: 26px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .08);
  }
}

/* The video is letterboxed rather than cropped: a slip that goes off the side
   of a cover-cropped frame is a slip the game cannot see. */
#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  background: transparent;
}
#video.mirrored { transform: scaleX(-1); }

/* Sized and positioned in JS to sit exactly over the video's drawn rect, so
   canvas coordinates and pose coordinates are the same space. */
#scene { position: absolute; left: 0; top: 0; pointer-events: none; }

/* --------------------------------------------------------------------- HUD */

#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }

.top-scrim {
  position: absolute; left: 0; right: 0; top: 0; height: 30%;
  background: linear-gradient(to bottom, rgba(5,7,12,.88), rgba(5,7,12,0));
}

.hud-top {
  position: absolute;
  top: calc(var(--safe-t) + 14px);
  left: 16px; right: 116px;
}

.hud-buttons {
  position: absolute;
  top: calc(var(--safe-t) + 12px); right: 12px;
  display: flex; gap: 6px;
}

.progress { display: flex; gap: 6px; padding-top: 12px; }
.progress span {
  flex: 1; height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.18);
  transition: background .25s ease, box-shadow .25s ease;
}
.progress span.current { background: var(--accent); box-shadow: 0 0 10px rgba(52,231,243,.7); }
.progress span.done { background: var(--success); }

.score { display: flex; flex-direction: column; align-items: flex-start; }
.score-label { font-size: 10px; font-weight: 800; letter-spacing: 2.6px; color: rgba(255,255,255,.54); }
.score strong {
  font-size: 34px; font-weight: 900; line-height: 1.05; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0,0,0,.55);
}
.streak {
  margin-top: 4px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid rgba(52,231,243,.7);
  background: rgba(52,231,243,.18);
  color: var(--accent);
  font-size: 11px; font-weight: 800; letter-spacing: .8px;
  white-space: nowrap;
}

.icon-btn {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--outline);
  background: rgba(5,7,12,.55);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 15px; line-height: 1;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }

.instruction {
  position: absolute;
  left: 14px; right: 14px;
  bottom: calc(var(--safe-b) + 16px);
  display: flex; justify-content: center;
}
.instruction-card {
  width: 100%;
  padding: 14px 18px 16px;
  border-radius: 20px;
  border: 1px solid var(--outline);
  background: rgba(5,7,12,.72);
  backdrop-filter: blur(14px);
}
.instruction.done .instruction-card { border-color: rgba(50,230,127,.55); }
.instruction-step { font-size: 10px; font-weight: 900; letter-spacing: 2.6px; color: var(--accent); margin-bottom: 6px; }
.instruction-card h2 { font-size: 22px; font-weight: 900; letter-spacing: -.5px; }
.instruction-card p { font-size: 14px; line-height: 1.45; color: var(--text-2); margin-top: 5px; }
.nudge {
  margin-top: 9px !important; padding-top: 9px;
  border-top: 1px solid var(--outline);
  color: var(--accent) !important; font-size: 13px !important;
}

.cue {
  position: absolute; left: 0; right: 0; top: 32%;
  text-align: center;
  font-size: clamp(34px, 13vw, 64px); font-weight: 900; letter-spacing: -1.5px;
  text-shadow: 0 6px 30px rgba(0,0,0,.85);
}

.countdown {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-weight: 900;
  text-shadow: 0 6px 34px rgba(0,0,0,.9);
}

.pill {
  position: absolute; left: 50%; top: 74%;
  transform: translateX(-50%);
  padding: 9px 16px; border-radius: 99px;
  border: 1px solid var(--outline);
  background: rgba(5,7,12,.7);
  font-size: 13px; font-weight: 700;
}

/* The red wash on the frame that ended the round. */
.flash { position: absolute; inset: 0; background: var(--danger); }

/* ------------------------------------------------------------------ sheets */

.sheet {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(5,7,12,.95), rgba(11,18,32,.90), rgba(5,7,12,.97));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet.centred { display: flex; align-items: center; justify-content: center; padding: 20px; }

.sheet-inner {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 20px) 24px calc(var(--safe-b) + 20px);
}
.grow { flex: 1 1 auto; min-height: 12px; }

.home {
  align-self: flex-start;
  padding: 8px 14px 8px 12px;
  border: 1px solid var(--outline); border-radius: 99px;
  color: var(--text-2); text-decoration: none;
  font-size: 13px; font-weight: 700;
}
.home:hover { color: var(--text); border-color: var(--outline-strong); }

.eyebrow { font-size: 11px; font-weight: 900; letter-spacing: 3px; color: var(--accent); }
h1 { font-size: clamp(28px, 8.5vw, 38px); font-weight: 900; letter-spacing: -1.1px; line-height: 1.08; margin-top: 12px; }
.lede { font-size: 15px; line-height: 1.5; color: var(--text-2); margin-top: 14px; }

.moves { list-style: none; margin-top: 24px; }
.moves li { display: flex; gap: 14px; align-items: center; margin-bottom: 13px; }
.move-icon {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  border: 1px solid var(--outline);
  background: rgba(52,231,243,.09);
  font-size: 18px;
}
.moves b { display: block; font-size: 12px; font-weight: 900; letter-spacing: 2.4px; }
.moves i { display: block; font-style: normal; font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ----------------------------------------------------------------- buttons */

.primary, .secondary, .quiet {
  width: 100%;
  border-radius: 15px;
  font-family: inherit; font-weight: 800; cursor: pointer;
  display: block; text-align: center; text-decoration: none;
}
.primary {
  padding: 17px 20px; border: none;
  background: var(--accent); color: var(--ink);
  font-size: 17px; letter-spacing: .4px;
}
.secondary {
  margin-top: 10px; padding: 15px 20px;
  border: 1px solid var(--outline-strong); background: none; color: var(--text);
  font-size: 15px;
}
.quiet {
  margin-top: 12px; padding: 12px 20px;
  border: 1px solid var(--outline); background: none; color: var(--text-2);
  font-size: 14px; font-weight: 700;
}
.primary:active, .secondary:active, .quiet:active { transform: scale(.985); }
.primary:disabled { opacity: .45; }
.quiet.wide { width: 100%; }

.footnote { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 12px; }
.legal-links { margin-top: 4px; }
/* Small text, but a thumb-sized target. */
.legal-links a { display: inline-block; padding: 6px 8px; color: var(--text-3); text-decoration: none; }
.legal-links a:hover { color: var(--text-2); text-decoration: underline; }

/* ------------------------------------------------------------------- cards */

.card {
  width: 100%; max-width: 400px;
  text-align: center;
  padding: 28px 24px;
  border-radius: 26px;
  border: 1px solid var(--outline);
  background: rgba(14,21,35,.94);
  backdrop-filter: blur(14px);
  max-height: 100%;
  overflow-y: auto;
}
.card h2 { font-size: 23px; font-weight: 900; letter-spacing: -.4px; }
.card > p { font-size: 14px; line-height: 1.5; color: var(--text-2); margin-top: 10px; }
.card .eyebrow { display: block; margin-bottom: 10px; }

.ring { position: relative; width: 92px; height: 92px; margin: 0 auto 18px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-track { stroke: rgba(255,255,255,.13); }
.ring-fill {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 276.5; stroke-dashoffset: 276.5;
  transition: stroke-dashoffset .12s linear;
}
.ring-glyph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; }

.tick {
  width: 58px; height: 58px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 28px;
  color: var(--success);
  background: rgba(50,230,127,.16);
  border: 2px solid rgba(50,230,127,.7);
}
.tick.warn { color: var(--danger); background: rgba(255,59,71,.16); border-color: rgba(255,59,71,.7); }

/* ------------------------------------------------------------ round setup */

.choices { display: grid; gap: 8px; margin: 20px 0 18px; }
.choices button {
  padding: 12px 16px; border-radius: 14px;
  border: 1px solid var(--outline); background: none;
  color: var(--text); font-family: inherit; text-align: left; cursor: pointer;
}
.choices button b { display: block; font-size: 15px; font-weight: 800; }
.choices button span { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.choices button[aria-checked="true"] {
  border-color: var(--accent);
  background: rgba(52,231,243,.10);
  box-shadow: 0 0 0 1px rgba(52,231,243,.4) inset;
}

/* ---------------------------------------------------------------- summary */

.summary-card { text-align: center; }
.placement {
  display: inline-block; margin-bottom: 12px;
  padding: 5px 13px; border-radius: 99px;
  background: rgba(255,138,61,.16); border: 1px solid rgba(255,138,61,.6);
  color: var(--ember);
  font-size: 11px; font-weight: 900; letter-spacing: 1.6px;
}
.final { margin: 20px 0 4px; }
.final strong {
  display: block;
  font-size: 54px; font-weight: 900; letter-spacing: -2.5px; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.final span {
  display: inline-block; margin-top: 8px;
  font-size: 12px; font-weight: 900; letter-spacing: 3px; text-transform: uppercase;
  color: var(--text-2);
}

.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; margin: 22px 0 20px;
  background: var(--outline);
  border: 1px solid var(--outline); border-radius: 16px; overflow: hidden;
}
.stat-grid div { background: rgba(5,7,12,.72); padding: 12px 10px; }
.stat-grid dt { font-size: 9.5px; font-weight: 900; letter-spacing: 1.8px; color: var(--text-3); }
.stat-grid dd { font-size: 18px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }

.summary-links { display: flex; gap: 10px; }
.summary-links .quiet { flex: 1; }

/* The app, after a round. Under the actions and quieter than them. */
.promo { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--outline); }
.promo .eyebrow { margin-bottom: 8px; }
.promo h3 { font-size: 17px; font-weight: 900; letter-spacing: -.2px; }
.promo p { font-size: 13px; line-height: 1.5; color: var(--text-2); margin-top: 6px; }
.promo-stores { display: flex; gap: 10px; margin-top: 16px; }
.store {
  position: relative; flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 13px;
  border: 1px solid var(--outline-strong); background: rgba(5,7,12,.6);
  color: var(--text); text-decoration: none; text-align: left;
}
.store:hover { border-color: var(--accent); }
.store-glyph { width: 22px; height: 22px; flex: none; }
.store span { display: flex; flex-direction: column; font-size: 14px; font-weight: 800; line-height: 1.2; }
.store small { font-size: 9px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }
.soon {
  position: absolute; top: -8px; right: 8px;
  padding: 2px 7px; border-radius: 99px;
  background: var(--ember); color: var(--ink);
  font-size: 9px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; font-style: normal;
}

.score-list { list-style: none; counter-reset: rank; margin: 18px 0 4px; text-align: left; }
.score-list li {
  counter-increment: rank;
  display: flex; align-items: baseline; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--outline);
  font-size: 15px;
}
.score-list li::before {
  content: counter(rank);
  width: 22px; flex: none;
  color: var(--text-3); font-weight: 900; font-size: 13px;
}
.score-list b { font-variant-numeric: tabular-nums; font-weight: 800; }
.score-list span { margin-left: auto; font-size: 12.5px; color: var(--text-3); }
.score-list .empty { color: var(--text-3); font-size: 14px; border: none; }

/* Blocked camera: the fix is per browser, so it gets real steps. */
.steps { text-align: left; margin: 16px 0 4px; padding-left: 20px; }
.steps li { font-size: 13.5px; line-height: 1.5; color: var(--text-2); margin-bottom: 7px; }
/* The browser's own words, for a bug report. */
.detail { margin: 4px 0 14px; font-family: ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ orientation */

.rotate {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 24px; text-align: center;
  background: var(--ink);
}
.rotate h2 { font-size: 22px; font-weight: 900; margin-top: 16px; }
.rotate p { font-size: 14px; color: var(--text-2); margin-top: 10px; max-width: 34ch; }
.rotate-glyph { font-size: 44px; display: block; animation: tip 1.8s ease-in-out infinite; }
@keyframes tip { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }

/* ------------------------------------------------------------ animations */

.fade { opacity: 0; animation: fade-up .5s ease forwards; animation-delay: var(--d, 0s); }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .fade { animation-duration: .01s; }
  .rotate-glyph { animation: none; }
}

/* Short frames: the instruction card must not eat the whole preview. */
@media (max-height: 620px) {
  .instruction-card { padding: 10px 14px 12px; }
  .instruction-card h2 { font-size: 18px; }
  .instruction-card p { font-size: 12.5px; }
  .card { padding: 22px 20px; }
  .final strong { font-size: 44px; }
}
