:root {
  --bg: #0e1812;
  --panel: #15231b;
  --panel-2: #1c2f24;
  --text: #eef5ef;
  --muted: #9db3a4;
  --accent: #7ee081;
  --accent-ink: #0b2410;
  --warn: #f3c86b;
  --line: rgba(255, 255, 255, 0.1);
  --hud-bg: rgba(10, 22, 15, 0.62);
  --figure: #eef5ef;
  --figure-back: #6d8a78;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Outfit", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }

.screen { display: none; position: fixed; inset: 0; overflow: auto; }
.screen.active { display: flex; }

#cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn.big { padding: 16px 30px; font-size: 20px; width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 6px;
  font-weight: 600;
}
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Setup ---------- */
#setup {
  flex-direction: column;
  align-items: center;
  padding: 40px 16px 56px;
  gap: 28px;
  background: radial-gradient(1200px 600px at 50% -10%, #1f3d2a 0%, var(--bg) 60%);
}
.brand { text-align: center; }
.brand h1 { font-size: clamp(40px, 8vw, 72px); margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.brand h1 span { color: var(--accent); }
.brand p { color: var(--muted); margin: 6px 0 0; font-size: 18px; }

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 28px;
  width: min(1180px, 100%);
  align-items: start;
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.setup-panel h3, .lineup-title { margin: 0 0 12px; font-size: 16px; color: var(--muted); font-weight: 600; }
.setup-panel h3:not(:first-child) { margin-top: 24px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px;
  padding: 12px 6px; font-weight: 800; font-size: 20px; cursor: pointer;
}
.days { display: grid; grid-template-columns: 1fr; gap: 6px; }
.days button {
  display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 8px; text-align: left;
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 9px 12px; cursor: pointer;
}
.days b { font-size: 14px; }
.days span { color: var(--muted); font-size: 14px; }
.days em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; }
.days button[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.days button[aria-checked="true"] span { color: var(--text); }
.seg button small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.seg button[aria-checked="true"] small { color: var(--accent-ink); }

.modes { display: grid; gap: 8px; }
.mode {
  text-align: left; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 14px; padding: 14px 16px; cursor: pointer; display: grid; gap: 2px;
}
.mode b { font-size: 17px; }
.mode span { color: var(--muted); font-size: 14px; }
.mode[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mode[disabled] { opacity: 0.45; cursor: default; }
.note { color: var(--warn); font-size: 14px; margin: 10px 0 0; }
.summary { color: var(--muted); margin: 22px 0 14px; line-height: 1.5; }

.lineup { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.lineup-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px 16px; border-top: 4px solid var(--move);
}
.lineup-card canvas { width: 100%; height: 150px; display: block; margin-bottom: 8px; }
.lineup-card small { color: var(--move); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.lineup-card h4 { margin: 2px 0 6px; font-size: 18px; }
.lineup-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.lineup-card p b { color: var(--text); font-weight: 600; }

/* ---------- Position check ---------- */
#position { align-items: center; justify-content: center; padding: 24px 16px; }
.position-layout {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px;
  align-items: center; width: min(1100px, 100%);
}
.position-stage {
  position: relative; background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 4 / 3; border: 1px solid var(--line);
}
#pos-canvas { width: 100%; height: 100%; display: block; }
.pos-count {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: Anton, Impact, sans-serif; font-size: 140px; color: #fff;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5); pointer-events: none;
}
.position-info h2 { font-size: 34px; margin: 0 0 18px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.checks li {
  padding: 12px 14px 12px 44px; border-radius: 12px; border: 1px solid var(--line);
  position: relative; color: var(--muted);
}
.checks li::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 18px; height: 18px;
  border-radius: 50%; transform: translateY(-50%); border: 2px solid var(--muted);
}
.checks li.ok { color: var(--text); border-color: var(--accent); }
.checks li.ok::before { background: var(--accent); border-color: var(--accent); }
.status { font-size: 15px; margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.status.ok { color: var(--accent); }
.status.warn { color: var(--warn); }

/* ---------- Workout ---------- */
#workout { overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.wipe { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: var(--move, #000); }
.wipe.go { animation: wipe 0.7s ease-out; }
@keyframes wipe { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }

.coach-panel, .topbar > *, .scene-hud, .next-banner, .cam-card {
  background: var(--hud-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
}

.coach-panel {
  position: absolute; left: 16px; top: 16px; bottom: 16px;
  width: clamp(200px, 24vw, 340px);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  display: flex; flex-direction: column;
  border-top: 5px solid var(--move, var(--accent));
}
.coach-world { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--move, var(--accent)); font-weight: 600; }
.coach-move { margin: 2px 0 0; font-size: clamp(22px, 2.4vw, 32px); line-height: 1.1; }
#coach-canvas { flex: 1; min-height: 0; width: 100%; display: block; }
.coach-cue {
  margin: 0 0 12px; text-align: center; font-family: Anton, Impact, sans-serif;
  font-size: clamp(28px, 3.4vw, 48px); letter-spacing: 0.04em; color: #fff; min-height: 1.1em;
}
.block-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#block-fill { height: 100%; width: 0; background: var(--move, var(--accent)); }
.block-left { margin: 8px 0 0; font-size: 14px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

.topbar {
  position: absolute; top: 16px; right: 16px;
  left: calc(clamp(200px, 24vw, 340px) + 32px);
  display: flex; gap: 12px; align-items: stretch;
}
.topbar > * { border-radius: 14px; }
.plan-bar { flex: 1; display: flex; gap: 3px; padding: 10px; position: relative; align-items: stretch; min-width: 120px; }
.plan-seg { border-radius: 4px; background: var(--seg); opacity: 0.35; min-width: 3px; }
.plan-seg.past { opacity: 0.9; }
.plan-seg.now { opacity: 1; box-shadow: 0 0 0 2px #fff; }
.plan-head { position: absolute; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: #fff; left: 10px; }
.top-right { display: flex; gap: 14px; align-items: center; padding: 6px 10px 6px 16px; }
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.scene-hud {
  position: absolute; bottom: 16px;
  left: calc(clamp(200px, 24vw, 340px) + 32px);
  padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 16px;
}
.scene-hud:empty { display: none; }

.next-banner {
  position: absolute; top: 84px; right: 16px;
  display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 8px; border-radius: 16px;
  border-left: 5px solid var(--move, var(--accent));
  animation: slidein 0.35s ease-out;
}
.next-banner[hidden] { display: none; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
#next-canvas { width: 64px; height: 64px; display: block; }
.next-banner small { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.next-banner b { font-size: 20px; }
.next-count { font-family: Anton, Impact, sans-serif; font-size: 40px; min-width: 1.2em; text-align: center; }

.center-msg {
  position: absolute; top: 45%; transform: translate(-50%, -50%);
  left: calc((clamp(200px, 24vw, 340px) + 32px + 100vw) / 2);
  font-family: Anton, Impact, sans-serif; font-size: clamp(80px, 14vw, 180px);
  color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.45);
  pointer-events: none; text-align: center; line-height: 1;
}
.center-msg small { display: block; font-size: 0.3em; letter-spacing: 0.04em; }

.cam-card { position: absolute; right: 16px; bottom: 16px; border-radius: 14px; overflow: hidden; width: 220px; aspect-ratio: 4 / 3; }
.cam-card[hidden] { display: none; }
#cam-canvas { width: 100%; height: 100%; display: block; }
.cam-hint {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 12px; font-size: 14px; font-weight: 600; background: rgba(120, 20, 20, 0.6);
}
.cam-hint[hidden] { display: none; }
.cam-card.hit { animation: hit 0.35s ease-out; }
@keyframes hit { 0% { box-shadow: 0 0 0 4px var(--move, var(--accent)); } 100% { box-shadow: 0 0 0 0 transparent; } }
.cam-debug { position: absolute; left: 6px; right: 6px; bottom: 4px; font: 11px/1.3 ui-monospace, monospace; color: #fff; text-shadow: 0 1px 2px #000; }
.cam-debug:empty { display: none; }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(5, 12, 8, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; text-align: center; width: min(420px, calc(100% - 32px));
}
.overlay-card h2 { margin: 0 0 6px; font-size: 32px; }
.overlay-card p { color: var(--muted); margin: 0 0 20px; }
.overlay-card .actions { justify-content: center; }

/* ---------- Done ---------- */
#done { align-items: center; justify-content: center; padding: 24px 16px; }
.done-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: min(620px, 100%); text-align: center;
}
.done-card h2 { font-size: 32px; margin: 0 0 24px; }
.done-card .actions { justify-content: center; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stats div { background: var(--panel-2); border-radius: 12px; padding: 14px 6px; display: flex; flex-direction: column; gap: 4px; }
.stats b { font-size: 30px; }
.stats span { font-size: 12px; color: var(--muted); }
.breakdown { list-style: none; padding: 0; margin: 0 0 24px; text-align: left; display: grid; gap: 6px; }
.breakdown li {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px;
  border-radius: 10px; background: var(--panel-2); border-left: 4px solid var(--move);
}
.breakdown li span { color: var(--muted); text-align: right; }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .setup-grid, .position-layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .coach-panel { bottom: auto; width: 150px; height: 230px; padding: 10px; }
  .coach-move { font-size: 16px; }
  .coach-cue { font-size: 24px; margin-bottom: 6px; }
  .block-left { display: none; }
  .topbar { left: 182px; flex-direction: column; }
  .top-right { flex-wrap: wrap; gap: 8px; padding: 6px 10px; }
  .plan-bar { min-height: 26px; }
  .scene-hud { left: 16px; right: 16px; font-size: 14px; }
  .cam-card { width: 120px; bottom: 70px; }
  .next-banner { top: auto; bottom: 70px; right: auto; left: 16px; }
  .center-msg { left: 50%; }
  .stats b { font-size: 24px; }
  .position-info h2 { font-size: 26px; }
}
