/* MoveTV — playful game-console look: deep navy, illustrated tiles, fat rounded titles. */
:root {
  --bg: #0f1630;
  --surface: #1c2754;
  --surface-2: #26336a;
  --text: #ffffff;
  --muted: #a9b4e0;
  --accent: #c6ff3d;
  --accent-ink: #11140a;
  --play: #ff3b4f;
  --danger: #ff3b30;
  --gold: #ffcf3d;
  --ink: #141033;
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --round: "Arial Rounded MT Bold", "Arial Rounded MT", "Nunito", "Varela Round", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: var(--round);
  background: radial-gradient(120% 80% at 50% -10%, #23307a 0%, var(--bg) 60%) fixed;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* fat cartoon titles */
.chunky {
  font-family: var(--round); font-weight: 900; letter-spacing: .5px; text-transform: uppercase;
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
}

.screen {
  display: none; min-height: 100dvh; padding: calc(16px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  max-width: 980px; margin: 0 auto; flex-direction: column; gap: 16px;
}
.screen.active { display: flex; }

/* header */
.brand { display: flex; gap: 14px; align-items: center; margin: 6px 0 4px; }
.logo { width: 56px; height: 56px; border-radius: 18px; background: linear-gradient(135deg, #c6ff3d, #3dd6ff); color: var(--ink); display: grid; place-items: center; font-size: 34px; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
.brand h1 { font-size: 34px; -webkit-text-stroke-width: 4px; }
.tag { color: var(--muted); font-size: 16px; font-weight: 700; margin-top: 2px; }
.top-nav { margin-left: auto; display: flex; gap: 8px; }
.top-nav button, .round-btn { width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 24px; backdrop-filter: blur(6px); }
.round-btn { flex: none; }

/* game tiles */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { position: relative; aspect-ratio: 16 / 9.5; border-radius: 20px; overflow: hidden; box-shadow: 0 8px 0 rgba(0,0,0,.28), 0 14px 30px rgba(0,0,0,.25); transition: transform .14s ease; text-align: left; }
.tile:active { transform: scale(.97) translateY(2px); }
.tile .art, .tile .art svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tile .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(10,8,40,.55) 100%); }
.tile .title { position: absolute; left: 14px; right: 14px; bottom: 30px; font-size: clamp(26px, 7.2vw, 38px); line-height: .95; }
.tile .sub { position: absolute; left: 16px; bottom: 10px; font-size: 13px; font-weight: 800; color: #fff; opacity: .92; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.tile .best { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.45); border-radius: 999px; padding: 4px 10px; font-weight: 800; font-size: 14px; color: var(--gold); display: flex; gap: 5px; align-items: center; }
.tile .badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 70%; }
.tile .badges span { background: rgba(0,0,0,.45); border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 800; }

/* splash */
.screen.splash { max-width: none; padding: 0; position: relative; overflow: hidden; }
.screen.splash.active { display: block; }
.splash-art, .splash-art svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.splash::after { content: ''; position: absolute; inset: 0; background: radial-gradient(70% 60% at 50% 55%, rgba(0,0,0,0) 0%, rgba(10,8,40,.35) 100%); pointer-events: none; }
.back-btn { position: absolute; top: calc(14px + var(--safe-t)); left: 14px; z-index: 2; background: rgba(10,8,40,.45); }
.help-btn { position: absolute; bottom: calc(14px + var(--safe-b)); right: 14px; z-index: 2; background: rgba(10,8,40,.45); }
.splash-body { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 1; text-align: center; padding: 16px; }
.huge-title { font-size: clamp(46px, 13vmin, 120px); line-height: .92; -webkit-text-stroke-width: 8px; text-shadow: 0 8px 0 var(--ink); max-width: 12ch; }
.splash-tag { font-size: clamp(16px, 3.2vmin, 24px); font-weight: 800; background: rgba(10,8,40,.45); padding: 6px 14px; border-radius: 999px; }

.play-pill { background: var(--play); color: #fff; border-radius: 999px; min-height: 58px; padding: 0 30px; font-weight: 900; font-size: 22px; letter-spacing: 1px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 6px 0 #a3122a, 0 12px 24px rgba(0,0,0,.25); transition: transform .1s; }
.play-pill:active { transform: translateY(3px); box-shadow: 0 3px 0 #a3122a; }
.play-pill:disabled { opacity: .4; }
.play-pill.wide { width: 100%; min-height: 66px; font-size: 24px; }
.ghost { background: rgba(255,255,255,.1); border-radius: 18px; min-height: 54px; font-size: 17px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; }
.ghost.small { min-height: 46px; font-size: 15px; }

/* step screens */
.step-top { display: flex; align-items: center; gap: 14px; }
.step-top h2 { font-size: clamp(26px, 6vw, 34px); -webkit-text-stroke-width: 4px; }
.step-num { color: var(--muted); font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.choice-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.choice { display: flex; align-items: center; gap: 16px; padding: 16px; min-height: 96px; border-radius: var(--r); text-align: left; color: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.28); transition: transform .12s; position: relative; overflow: hidden; }
.choice::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.2), rgba(255,255,255,0) 60%); pointer-events: none; }
.choice:active, .time-btn:active { transform: scale(.97); }
.choice .name { font-size: 24px; font-weight: 900; text-transform: uppercase; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.choice .sub { font-size: 15px; font-weight: 800; margin-top: 2px; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.choice-icon { width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; font-size: 32px; color: var(--ink); flex: none; position: relative; }
.choice.last { outline: 4px solid #fff; }
.time-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.time-btn { background: linear-gradient(160deg, var(--surface-2), var(--surface)); border-radius: var(--r); min-height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 6px 0 rgba(0,0,0,.28); }
.time-btn .num { font-size: 46px; font-weight: 900; line-height: 1; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.time-btn .unit { color: var(--muted); font-size: 15px; font-weight: 800; margin-top: 4px; }
.time-btn.last { outline: 4px solid var(--accent); }

/* prep */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { --c: var(--accent); display: inline-flex; gap: 6px; align-items: center; background: rgba(255,255,255,.1); border-radius: 999px; padding: 6px 12px; font-size: 15px; font-weight: 800; }
.chip i { color: var(--c); font-size: 20px; }
.card { background: rgba(255,255,255,.07); border-radius: var(--r); padding: 16px; border: 1px solid rgba(255,255,255,.08); }
.card h3 { font-size: 18px; display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.plan { display: grid; gap: 10px; }
.timeline { display: flex; gap: 2px; height: 24px; border-radius: 10px; overflow: hidden; }
.timeline div { min-width: 2px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 16px; font-weight: 700; }
.steps li::before { content: '•'; color: var(--accent); margin-right: 8px; }
.note { color: var(--muted); font-size: 14px; }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.howto div { background: rgba(255,255,255,.08); border-radius: 18px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 15px; font-weight: 800; text-align: center; }
.howto i { font-size: 38px; color: var(--accent); }
.check { display: flex; align-items: center; gap: 12px; min-height: 50px; font-size: 17px; font-weight: 700; cursor: pointer; }
.check input { width: 28px; height: 28px; accent-color: var(--accent); flex: none; }
.check i { font-size: 24px; color: var(--muted); }
.place { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 15px; font-weight: 700; }
.place > i { font-size: 30px; color: var(--accent); }
.place span { flex: 1; min-width: 160px; }
.link { color: var(--accent); font-weight: 800; display: inline-flex; gap: 6px; align-items: center; min-height: 44px; }
.bottom-actions { margin-top: auto; display: grid; gap: 10px; }

/* play */
#play.screen { max-width: none; padding: 0; position: fixed; inset: 0; background: #000; }
#play.screen.active { display: block; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#stage canvas { width: 100%; height: 100%; display: block; }
.pip { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; width: 20vmin; aspect-ratio: 4/3; border-radius: 14px; overflow: hidden; border: 3px solid rgba(255,255,255,.7); background: #111; z-index: 3; }
.pip.hidden-pip { opacity: 0; pointer-events: none; }
.mirror { position: absolute; inset: 0; transform: scaleX(-1); }
.mirror video, .mirror canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#play.calibrating .pip.hidden-pip { opacity: 1; }
#play.calibrating .pip { top: 0; left: 0; width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; border: 0; }
.hud { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(50vw - min(23vw, 190px) - 16px); z-index: 4; }
.pill { background: rgba(10,8,40,.6); backdrop-filter: blur(6px); border-radius: 999px; padding: 8px 14px; display: flex; gap: 6px; align-items: center; font-weight: 900; font-size: clamp(16px, 2.6vmin, 26px); }
.pill .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s infinite; }
.pill.cam.off .dot { background: var(--muted); animation: none; }
.pill.fps { position: absolute; bottom: calc(10px + var(--safe-b)); right: 10px; z-index: 4; font-size: 13px; font-weight: 700; color: var(--muted); }
.pill .ph-star { color: var(--gold); }
.lives:empty { display: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(255,59,48,0); } 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); } }
.stop { position: absolute; bottom: calc(16px + var(--safe-b)); left: 16px; width: 80px; height: 80px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 38px; display: grid; place-items: center; z-index: 6; box-shadow: 0 6px 0 #9c1b14; }

/* workout banner */
.phase { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 4; min-width: min(46vw, 380px); background: rgba(10,8,40,.62); backdrop-filter: blur(6px); border-radius: 22px; padding: 8px 18px 10px; text-align: center; pointer-events: none; color: var(--accent); }
.phase-label { font-size: clamp(20px, 4.6vmin, 44px); font-weight: 900; line-height: 1.05; text-transform: uppercase; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.phase-sec { font-size: clamp(26px, 6.5vmin, 64px); font-weight: 900; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.phase-next { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: clamp(12px, 2.3vmin, 19px); font-weight: 700; margin-top: 2px; }
.phase-next .total { display: inline-flex; gap: 4px; align-items: center; font-variant-numeric: tabular-nums; }
.phase-bar { height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.phase-bar div { height: 100%; background: currentColor; width: 0; }
.phase[data-kind="work"], .phase[data-kind="surge"] { color: var(--gold); }
.phase[data-kind="rest"], .phase[data-kind="water"], .phase[data-kind="cooldown"], .phase[data-kind="warmup"] { color: #7df9ff; }
.phase.pop { animation: pop .45s ease; }
@keyframes pop { 30% { transform: translateX(-50%) scale(1.12); } }
/* pace meter: how fast you're going vs the target (white line = target) */
.pace { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); z-index: 4; width: min(50vw, 420px); background: rgba(10,8,40,.62); backdrop-filter: blur(6px); border-radius: 18px; padding: 8px 14px; pointer-events: none; }
.pace-bar { position: relative; height: 14px; border-radius: 7px; background: rgba(255,255,255,.15); overflow: hidden; }
.pace-bar #paceFill { height: 100%; width: 0; background: linear-gradient(90deg, #ff3b4f, #ffcf3d 60%, #c6ff3d); border-radius: 7px; transition: width .3s; }
.pace-target { position: absolute; top: 0; bottom: 0; left: 80%; width: 3px; background: #fff; }
.pace-text { text-align: center; font-weight: 900; font-size: clamp(13px, 2.4vmin, 20px); margin-top: 4px; }
.workout-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(255,255,255,.12); z-index: 4; }
.workout-bar div { height: 100%; background: var(--accent); width: 0; }

.overlay { position: absolute; inset: 0; z-index: 5; }
.overlay.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; }
.overlay.dim { background: rgba(10,8,40,.65); }
.big-icon { font-size: 80px; color: var(--accent); }
.big-icon.gold { color: var(--gold); }
.big-text { font-size: clamp(24px, 5vmin, 48px); font-weight: 900; }
.count { font-size: 30vmin; color: var(--accent); -webkit-text-stroke-width: 10px; text-shadow: 0 12px 0 var(--ink); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* calibration */
.calib { pointer-events: none; }
.calib .guide { position: absolute; inset: 0; display: grid; place-items: center; }
.calib .frame { height: 78%; aspect-ratio: 1 / 1.6; border: 4px dashed rgba(255,255,255,.7); border-radius: 40px; display: grid; place-items: center; transition: border-color .2s; }
.calib .frame i { font-size: 40vmin; color: rgba(255,255,255,.18); }
.calib .frame.ok { border-color: var(--accent); border-style: solid; }
.calib .frame.wide { aspect-ratio: 1.3 / 1; height: 60%; }
.calib-msg { position: absolute; bottom: calc(18px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; background: rgba(10,8,40,.75); padding: 14px 24px 14px 14px; border-radius: 999px; }
.calib-msg i { font-size: 34px; color: var(--accent); }
.calib-msg p { font-size: clamp(20px, 4vmin, 36px); font-weight: 900; white-space: nowrap; }
.calib-msg > div { display: flex; align-items: center; gap: 10px; }
.ring { width: 64px; height: 64px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: rgba(255,255,255,.15); }
.ring .fg { stroke: var(--accent); stroke-dasharray: 276.5; stroke-dashoffset: 276.5; stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
#useSaved { position: absolute; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); pointer-events: auto; }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(5,4,25,.7); display: grid; place-items: center; z-index: 20; padding: 16px; }
.sheet { width: 100%; max-width: 480px; max-height: calc(100dvh - 32px); overflow-y: auto; background: linear-gradient(170deg, #2a3880, #1c2754); border-radius: 28px; padding: 22px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center; box-shadow: 0 10px 0 rgba(0,0,0,.3); }
.sheet .big-icon { align-self: center; }
.sheet h2 { font-size: 28px; }
.sheet p { color: var(--muted); font-size: 17px; }
.done-title { color: #fff !important; font-weight: 900; font-size: 19px !important; text-transform: uppercase; }
.final { font-size: 72px; color: var(--accent); -webkit-text-stroke-width: 7px; }
.stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.stats div { background: rgba(255,255,255,.1); border-radius: 16px; padding: 8px 12px; display: flex; flex-direction: column; align-items: center; min-width: 76px; }
.stats i { color: var(--accent); font-size: 22px; }
.stats b { font-size: 24px; }
.stats span { color: var(--muted); font-size: 12px; font-weight: 700; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-preview { width: 100%; border-radius: 18px; background: #000; aspect-ratio: 16/9; }

/* tv / privacy / settings */
.tv-card ol { margin: 0; padding-left: 22px; font-size: 17px; line-height: 1.8; font-weight: 700; }
.tv-card .note { margin-top: 6px; }
.warn { display: flex; gap: 10px; align-items: center; font-size: 15px; font-weight: 700; }
.warn i { font-size: 26px; color: var(--gold); }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.facts li { background: rgba(255,255,255,.07); border-radius: 18px; padding: 14px; display: flex; gap: 12px; align-items: flex-start; font-size: 16px; line-height: 1.45; font-weight: 600; }
.facts i { font-size: 28px; color: var(--accent); flex: none; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 17px; font-weight: 800; }
.setting > span { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; background: rgba(0,0,0,.25); border-radius: 14px; padding: 4px; }
.seg button { min-height: 42px; padding: 0 14px; border-radius: 10px; font-size: 15px; color: var(--muted); font-weight: 800; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.toggle input { width: 30px; height: 30px; accent-color: var(--accent); }

/* 3D game overlays */
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fx-text { position: absolute; left: 50%; top: 38%; transform: translate(-50%, 0); font-size: clamp(30px, 9vmin, 90px); font-weight: 900; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); animation: fxUp .9s ease-out forwards; white-space: nowrap; }
.fx-flash { position: absolute; inset: 0; background: rgba(255,60,40,.45); animation: fxFade .4s ease-out forwards; }
.fx-hint { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); font-size: clamp(30px, 10vmin, 96px); font-weight: 900; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); animation: hintPulse .8s ease-in-out infinite alternate; white-space: nowrap; }
@keyframes fxUp { from { opacity: 1; transform: translate(-50%, 10px) scale(.8); } 30% { transform: translate(-50%, -10px) scale(1.1); } to { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
@keyframes fxFade { to { opacity: 0; } }
@keyframes hintPulse { from { transform: translate(-50%, -50%) scale(.94); } to { transform: translate(-50%, -50%) scale(1.06); } }

@media (orientation: landscape) and (max-height: 500px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
  .tile .title { font-size: 24px; }
  .time-grid { grid-template-columns: repeat(6, 1fr); }
  .phase { top: 6px; padding: 4px 14px 6px; }
  .modal { padding: 8px; }
  .sheet { padding: 14px 16px; gap: 8px; max-width: 640px; }
  .sheet .big-icon { display: none; }
  .final { font-size: 44px; }
  .stats div { padding: 4px 8px; min-width: 64px; }
  .stats b { font-size: 18px; }
  .share-preview { max-height: 38dvh; width: auto; align-self: center; }
  .play-pill.wide { min-height: 54px; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
