/* Arena: full-screen 3D view with the HUD on top. Self-contained: app.css is not loaded here because its
   rhythm-game rules (#callout, .hud, .stat, .status, .meter) would clash. Tokens and controls copied from app.css. */

/* ---- shared with app.css ---- */
:root {
  --bg: #0b0d17;
  --panel: #141829;
  --panel-2: #1c2138;
  --line: #2a3050;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --lime: #c6f432;
  --left: #3fd6ff;
  --right: #ff6b6b;
  --gold: #ffcf4a;
  --p1: #c6f432;
  --p2: #b18cff;
  --p3: #ffa24a;
  --p4: #ff7ad9;
  --radius: 16px;
  color-scheme: dark;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
a { color: inherit; }
.chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; white-space: nowrap; }
.chip:hover { border-color: var(--muted); }

.btn { border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; font-size: 15px; background: var(--panel-2); border: 1px solid var(--line); }
.btn.primary { background: var(--lime); color: #111; border-color: var(--lime); }
.btn:hover { filter: brightness(1.1); }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.seg { display: inline-flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg-label { font-size: 12px; color: var(--muted); padding: 0 8px 0 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 7px 14px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--lime); }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin: 8px 0 12px; }
.back:hover { color: var(--text); }

/* ---- arena ---- */

html, body { height: 100%; overflow: hidden; }
body { background: #05060d; }
#arena { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }

/* Camera panel: the live picture with the tracked body drawn on it. A corner window while playing, big while
   setting up. The video is mirrored; the tracked points are already mirrored, so the overlay is not. */
.cam-panel { position: fixed; right: 16px; bottom: 16px; width: min(300px, 38vw); aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden;
  border: 2px solid var(--line); background: #000; z-index: 3; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.cam-panel video, .cam-panel canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-panel video { transform: scaleX(-1); }
.cam-panel.big { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(720px, 92vw); border-color: var(--lime); }
.cam-label { position: absolute; left: 8px; top: 8px; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  background: rgba(11, 13, 23, 0.7); border-radius: 999px; padding: 3px 10px 3px 8px; }
.cam-label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.cam-label .dot.ok { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.cam-label .dot.warn { background: var(--gold); }
.cam-label .dot.off { background: var(--right); }

/* Menu */
.menu { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow: auto; z-index: 4;
  background: linear-gradient(90deg, rgba(5, 6, 13, 0.92) 0%, rgba(5, 6, 13, 0.7) 55%, rgba(5, 6, 13, 0.25) 100%); }
.menu-card { width: min(640px, 100%); background: rgba(20, 24, 41, 0.86); border: 1px solid var(--line); border-radius: 22px; padding: 26px 26px 20px; backdrop-filter: blur(8px); }
.menu-card h1 { font-size: clamp(30px, 6vw, 46px); margin: 4px 0 8px; line-height: 1.05; }
.menu-card .lead { color: var(--muted); margin: 0 0 16px; }
.menu-card .back { color: var(--muted); text-decoration: none; font-size: 14px; }
.menu-card .seg { margin: 10px 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; color: var(--lime); margin: 10px 0 0; font-weight: 700; }
.new { background: var(--gold); color: #111; border-radius: 999px; padding: 1px 8px; font-size: 11px; letter-spacing: 0.04em; margin-left: 6px; }
.how { padding-left: 20px; color: var(--muted); margin: 10px 0 16px; }
.how li { margin: 4px 0; }
.how b { color: var(--text); }
.menu-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn.big { font-size: 18px; padding: 14px 26px; }
.soon { color: var(--muted); font-size: 13px; margin: 16px 0 0; }

/* HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.hud button, .hud .panel { pointer-events: auto; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; flex-wrap: wrap; }
.hud-score { background: rgba(11, 13, 23, 0.72); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; display: grid; grid-template-columns: auto auto; column-gap: 12px; align-items: baseline; }
.hud-score #shot-no { color: var(--muted); font-size: 13px; }
.hud-score b { font-size: 30px; line-height: 1; color: var(--lime); grid-row: span 2; text-align: right; }
.hud-score small { color: var(--muted); font-size: 12px; }
.dots { list-style: none; display: flex; gap: 5px; margin: 8px 0 0; padding: 0; grid-column: 1 / -1; }
.dots li { width: 12px; height: 12px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); }
.dots li.g { background: var(--lime); border-color: var(--lime); }
.dots li.m { background: var(--right); border-color: var(--right); }
.dots li.now { border-color: var(--text); box-shadow: 0 0 0 2px rgba(238, 241, 255, 0.3); }
.dots.big { justify-content: center; margin: 14px 0 18px; }
.dots.big li { width: auto; height: auto; background: none; border: 0; font-size: 22px; }
.dots.big li.m { color: var(--right); }
.hud-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 760px; }
.views { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.on, .chip[aria-pressed="true"].on { background: var(--lime); color: #111; border-color: var(--lime); }
.chip { background: rgba(28, 33, 56, 0.85); }
#pip[aria-pressed="false"], #replay-toggle[aria-pressed="false"] { opacity: 0.65; }

/* Shot card: what the movement decided */
.card { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 32px); background: rgba(11, 13, 23, 0.78); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.stat { display: grid; min-width: 64px; padding: 2px 8px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { font-size: 20px; line-height: 1.1; }
.stat.big b { font-size: 30px; color: var(--lime); }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.card .tag { align-self: center; font-size: 11px; color: #111; background: var(--gold); border-radius: 999px; padding: 2px 8px; }

/* Live foot speed */
.meter { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); width: 16px; height: 34vh; border-radius: 10px; background: rgba(11, 13, 23, 0.7); border: 1px solid var(--line); overflow: hidden; }
.meter i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, var(--left), var(--lime) 60%, var(--gold)); transition: height 60ms linear; }
.meter em { position: absolute; left: 0; right: 0; background: rgba(198, 244, 50, 0.3); border-top: 2px solid var(--lime); border-bottom: 2px solid var(--lime); }
.meter span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; font-size: 10px; color: var(--muted); white-space: nowrap; }

/* Centre popup: see-through glass so the goal stays visible behind it; goals pop with confetti */
.callout { position: absolute; left: 50%; top: 46%; z-index: 5; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none;
  text-align: center; min-width: min(360px, 84vw); max-width: 92vw; padding: 18px 26px 16px; border-radius: 26px; overflow: hidden;
  background: rgba(11, 13, 23, 0.38); border: 1px solid rgba(238, 241, 255, 0.22); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); text-shadow: 0 3px 16px rgba(0, 0, 0, 0.55); transition: opacity 0.2s, transform 0.2s; }
.callout.show { opacity: 1; transform: translate(-50%, -50%) scale(1); animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(0.4); } 100% { transform: translate(-50%, -50%) scale(1); } }
.callout i { display: block; font-style: normal; font-size: clamp(34px, 7vw, 56px); line-height: 1; margin-bottom: 4px; }
.callout b { display: block; font-size: clamp(38px, 9vw, 84px); line-height: 1; font-weight: 900; letter-spacing: 0.02em; }
.callout span { display: block; font-size: clamp(14px, 2.4vw, 19px); color: var(--text); margin-top: 8px; font-weight: 600; }
.callout.good { border-color: rgba(198, 244, 50, 0.55); box-shadow: 0 0 40px rgba(198, 244, 50, 0.28), 0 18px 50px rgba(0, 0, 0, 0.35); }
.callout.good b { color: var(--lime); }
.callout.bad { border-color: rgba(255, 107, 107, 0.45); }
.callout.bad b { color: var(--right); }
.confetti { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; opacity: 0.9; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(260px) rotate(540deg); opacity: 0; } }
.status { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(11, 13, 23, 0.8); border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; font-weight: 600; text-align: center; max-width: calc(100% - 32px); }
.replay-badge { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 4; color: #fff; font-weight: 800; letter-spacing: 0.18em;
  background: rgba(255, 107, 107, 0.35); border: 1px solid rgba(255, 107, 107, 0.7); backdrop-filter: blur(4px); border-radius: 999px; padding: 6px 16px; white-space: nowrap; animation: blink 1.2s infinite; }
.replay-badge small { letter-spacing: 0.05em; font-weight: 600; opacity: 0.85; }
@keyframes blink { 50% { opacity: 0.35; } }
.skip { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 4; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 6, 13, 0.6); padding: 16px; pointer-events: auto; }
.overlay .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 24px; text-align: center; width: min(480px, 100%); }
.done h2 { font-size: 40px; margin: 4px 0; color: var(--lime); }
.final b { font-size: 56px; display: block; line-height: 1; }
.final span { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin-top: 16px; }
.stats div { background: var(--panel-2); border-radius: 12px; padding: 8px 4px; display: grid; }
.stats b { font-size: 22px; }
.stats span { font-size: 11px; color: var(--muted); }
.done .menu-actions { justify-content: center; }

/* Hub: every game, same card */
html:has(.hub-page), .hub-page { height: auto; overflow: auto; }
.hub-page { min-height: 100vh; background: radial-gradient(1200px 600px at 30% -10%, #1c2552, #05060d 70%); }
.hub { width: min(1080px, 100%); margin: 0 auto; padding: 16px 16px 40px; }
.hub h1 { font-size: clamp(30px, 6vw, 46px); margin: 4px 0 8px; line-height: 1.05; }
.hub .lead { color: var(--muted); margin: 0 0 20px; max-width: 680px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.hub-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: var(--radius); background: rgba(20, 24, 41, 0.86); border: 1px solid var(--line); text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
.hub-card:hover, .hub-card:focus-visible { transform: translateY(-3px); border-color: var(--lime); outline: none; }
.hub-card .ico { font-size: 38px; line-height: 1; }
.hub-card h2 { font-size: 20px; margin: 4px 0 0; }
.hub-card small { color: var(--lime); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
.hub-card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.hub-card .best { color: var(--gold); font-size: 13px; font-weight: 700; min-height: 1.5em; }

@media (max-width: 760px) {
  .views .lbl { display: none; }
  .hud-top { padding: 10px 12px; }
  .stat { min-width: 52px; }
  .stat b { font-size: 16px; }
  .stat.big b { font-size: 22px; }
  .meter { height: 24vh; right: 10px; }
  .cam-panel { width: 40vw; right: 10px; bottom: 10px; }
  .cam-panel.big { width: 92vw; }
}
@media (prefers-reduced-motion: reduce) {
  .replay-badge, .callout.show, .confetti { animation: none; }
}
