:root {
  --bg: #06080f; --bg2: #0a0e1b; --panel: #0e1424; --panel2: #151d35; --line: rgba(255, 255, 255, .09);
  --text: #eaeefe; --mute: #93a0c4; --cyan: #35e0ff; --violet: #8b5cf6; --green: #22c55e; --amber: #ffb020; --red: #ff5470;
  --r: 16px; --bar: 78px; --gut: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { background: radial-gradient(1200px 600px at 80% -10%, rgba(139, 92, 246, .16), transparent 60%), radial-gradient(900px 500px at -10% 10%, rgba(53, 224, 255, .10), transparent 60%), var(--bg); background-attachment: fixed; }
#app { min-height: 100%; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 12px var(--gut); border-bottom: 1px solid var(--line); background: rgba(6, 8, 15, .8); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { padding: 8px 14px; border-radius: 999px; color: var(--mute); font-weight: 600; font-size: 14px; }
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.nav a.on { color: #04121a; background: var(--cyan); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chip-btn, .icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; }
.icon-btn { padding: 9px; }
.chip-btn:hover, .icon-btn:hover { border-color: rgba(53, 224, 255, .5); }
body.playing .topbar { display: none; }

#view { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 22px var(--gut) 60px; }
body.playing #view { max-width: none; padding: 10px var(--gut) 12px; }

/* generic */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; background: var(--panel2); border: 1px solid var(--line); }
.btn:hover { border-color: rgba(255, 255, 255, .3); }
.btn.primary { background: linear-gradient(135deg, var(--cyan), #5b8cff); color: #031018; border: 0; box-shadow: 0 6px 24px rgba(53, 224, 255, .3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.violet { background: var(--violet); border: 0; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.panel { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.muted { color: var(--mute); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, .07); color: var(--mute); text-transform: uppercase; letter-spacing: .04em; }
.tag.weights { color: #c7b5ff; background: rgba(139, 92, 246, .18); }
.tag.bands { color: #ffd488; background: rgba(255, 176, 32, .15); }
.tag.bodyweight { color: #8df0ff; background: rgba(53, 224, 255, .13); }
.tag.hold { color: #8dffb6; background: rgba(34, 197, 94, .15); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
.stack { display: grid; gap: 12px; }

/* hero */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 30px; border: 1px solid var(--line); background: radial-gradient(600px 300px at 90% 0%, rgba(139, 92, 246, .35), transparent 70%), linear-gradient(180deg, #0d1226, #080b17); display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: center; }
.hero h1 { font-size: clamp(28px, 4vw, 46px); line-height: 1.05; font-weight: 800; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--mute); max-width: 52ch; line-height: 1.5; }
.hero canvas { width: 100%; max-width: 260px; height: auto; justify-self: center; }
.section-h { display: flex; align-items: baseline; gap: 12px; margin: 28px 0 12px; }
.section-h h2 { font-size: 20px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--mute); }
.chip.on { background: var(--cyan); color: #04121a; border-color: transparent; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { text-align: left; display: grid; gap: 8px; padding: 16px; border-radius: var(--r); border: 1px solid var(--line); background: linear-gradient(180deg, var(--panel), var(--bg2)); transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-2px); border-color: rgba(53, 224, 255, .45); }
.card h3 { font-size: 17px; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--mute); }
.best { color: var(--amber); font-weight: 700; }

/* lists */
.ex-list { display: grid; gap: 10px; }
.ex { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 10px 14px 10px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.ex canvas { width: 64px; height: 96px; background: #090d1a; border-radius: 10px; }
.ex h3 { font-size: 16px; }
.ex .cue { color: var(--mute); font-size: 13.5px; margin: 3px 0 6px; }
.ex .acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ex details { margin-top: 6px; font-size: 13px; color: var(--mute); }
.ex details ol { margin: 6px 0 0; padding-left: 18px; line-height: 1.45; }
.searchbar { width: 100%; max-width: 420px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
input[type=number], input[type=text], select { background: #090d1a; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; }
input[type=number] { width: 70px; }
.filters { display: grid; gap: 10px; margin-bottom: 16px; }
.filters .row > b { font-size: 12px; color: var(--mute); width: 78px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- play screen ---------- */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; height: calc(100vh - 24px); min-height: 520px; }
.play-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; align-items: center; }
.hud { display: flex; align-items: center; gap: 12px; width: 100%; padding: 2px 0 8px; position: relative; z-index: 6; }
.hud h2 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud .count { color: var(--mute); font-weight: 600; font-size: 14px; white-space: nowrap; }
.hud .btn { padding: 9px 14px; background: var(--panel2); }
@media (max-width: 860px) { .hud .btn { padding: 7px 10px; font-size: 13px; } .hud h2 { font-size: 15px; } }
.grid-stage { display: grid; grid-template-columns: var(--bar) auto var(--bar); gap: 10px; justify-content: center; align-items: stretch; width: 100%; flex: 1; min-height: 0; grid-template-rows: auto auto; align-content: start; }
.segs { grid-column: 2; display: flex; gap: 5px; height: 12px; margin-bottom: 4px; }
.seg { flex: 1; min-width: 4px; border-radius: 99px; background: rgba(53, 224, 255, .5); opacity: .5; overflow: hidden; position: relative; }
.seg.done { opacity: 1; background: var(--cyan); }
.seg.cur { opacity: 1; background: rgba(53, 224, 255, .5); }
.seg.cur > i { position: absolute; inset: 0 auto 0 0; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); border-radius: 99px; width: 0; }
.bar { position: relative; border-radius: 16px; overflow: hidden; background: #0a0f1d; border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: flex-end; grid-row: 2; }
.bar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; transition: height .08s linear; }
.bar.power .fill { background: linear-gradient(0deg, #ff5470, #ffb020 45%, #34f08a 90%); }
.bar.reps .fill { background: linear-gradient(0deg, #5b8cff, var(--violet)); }
.bar .lab { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 12px 0; z-index: 2; pointer-events: none; text-shadow: 0 1px 6px rgba(0, 0, 0, .8); }
.bar .lab b { font-size: 24px; font-weight: 800; }
.bar .lab span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 13px; letter-spacing: .3em; font-weight: 800; opacity: .9; }
.bar .lab small { font-size: 12px; font-weight: 700; opacity: .85; }
.bar .ticks { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 calc(10% - 1px), rgba(255, 255, 255, .12) calc(10% - 1px) 10%); z-index: 1; pointer-events: none; }
.stage { position: relative; grid-column: 2; grid-row: 2; background: #02030a; border-radius: 18px; overflow: hidden; border: 1px solid rgba(53, 224, 255, .25); box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 0 50px rgba(53, 224, 255, .12), inset 0 0 80px rgba(0, 0, 0, .6); }
.stage video, .stage canvas.ov { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); }
.stage video { object-fit: fill; opacity: .92; }
.stage.sim { background: radial-gradient(600px 360px at 50% 70%, #0d1530, #02030a); }
.stage.sim::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 94%, rgba(53, 224, 255, .2) 94% 95%, transparent 95%); pointer-events: none; }
.stage .floor { position: absolute; left: 0; right: 0; bottom: 6%; height: 1px; background: linear-gradient(90deg, transparent, rgba(53, 224, 255, .4), transparent); }
.msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; pointer-events: none; z-index: 3; padding: 0 12px; }
.msg .big { font-size: clamp(64px, 14vw, 150px); font-weight: 900; line-height: 1; text-shadow: 0 0 40px rgba(53, 224, 255, .7); }
.msg .title { font-size: clamp(20px, 3vw, 32px); font-weight: 800; text-shadow: 0 2px 14px #000; }
.msg .sub { font-size: clamp(13px, 1.6vw, 18px); color: #cfe; text-shadow: 0 2px 10px #000; max-width: 34ch; }
.msg.warn .title { color: var(--amber); }
.banner { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 4; background: rgba(255, 176, 32, .15); border: 1px solid rgba(255, 176, 32, .5); color: #ffe2a8; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.stage-btns { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 8; }
.stage-btns .btn { background: rgba(8, 12, 24, .75); backdrop-filter: blur(6px); padding: 8px 12px; font-size: 13px; }
.burst { position: absolute; inset: 0; z-index: 5; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.burst .pop { display: flex; flex-direction: column; align-items: center; gap: 4px; animation: pop .95s cubic-bezier(.2, .8, .2, 1) forwards; }
.burst .stars { font-size: clamp(34px, 7vw, 70px); letter-spacing: .06em; color: #ffd24a; text-shadow: 0 0 24px rgba(255, 210, 74, .85); }
.burst .stars i { font-style: normal; color: rgba(255, 255, 255, .22); text-shadow: none; }
.burst .word { font-size: clamp(18px, 3vw, 30px); font-weight: 800; text-shadow: 0 2px 12px #000; }
.burst .sp-p { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #ffd24a; box-shadow: 0 0 10px #ffd24a; animation: fly .9s ease-out forwards; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 18% { transform: scale(1.12); opacity: 1; } 70% { opacity: 1; } 100% { transform: scale(1) translateY(-20px); opacity: 0; } }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

.coach { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.coach .panel { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.coach .figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.coach figure { margin: 0; display: grid; gap: 4px; min-width: 0; }
.coach figcaption { text-align: center; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); font-weight: 700; }
.coach canvas { width: 100%; aspect-ratio: 3 / 4; background: radial-gradient(240px 240px at 50% 80%, rgba(139, 92, 246, .22), transparent 70%), #080b16; border-radius: 14px; }
.coach h3 { font-size: 20px; }
.coach .cue { font-size: 16px; line-height: 1.35; }
.coach .next { font-size: 13px; color: var(--mute); }

/* summary */
.summary { display: grid; justify-items: center; gap: 22px; padding: 20px 0; text-align: center; }
.summary h1 { font-size: clamp(26px, 4vw, 40px); }
.sum-row { display: grid; grid-template-columns: auto minmax(0, 520px) auto; gap: clamp(14px, 3vw, 36px); align-items: center; justify-content: center; width: 100%; }
.sq { width: clamp(104px, 18vw, 190px); aspect-ratio: 1; border: 0; border-radius: 26px; display: grid; place-items: center; align-content: center; gap: 8px; font-weight: 800; font-size: clamp(16px, 2.2vw, 24px); color: #fff; transition: transform .12s, filter .12s; }
.sq svg { width: 46%; height: 46%; }
.sq:hover { transform: translateY(-3px) scale(1.02); filter: brightness(1.1); }
.sq.home { background: linear-gradient(145deg, #9b6cff, #6b3ee0); box-shadow: 0 14px 40px rgba(139, 92, 246, .45); }
.sq.again { background: linear-gradient(145deg, #2fd673, #12a150); box-shadow: 0 14px 40px rgba(34, 197, 94, .4); }
.score-box .stars { font-size: clamp(40px, 8vw, 84px); color: #ffd24a; letter-spacing: .05em; text-shadow: 0 0 28px rgba(255, 210, 74, .6); line-height: 1; }
.score-box .stars i { font-style: normal; color: rgba(255, 255, 255, .16); text-shadow: none; }
.score-box .score { font-size: clamp(44px, 9vw, 96px); font-weight: 900; line-height: 1; margin-top: 8px; background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-box .score small { font-size: .35em; opacity: .8; }
.stats { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; color: var(--mute); }
.stats b { display: block; color: var(--text); font-size: 20px; }
.res-list { width: 100%; max-width: 760px; display: grid; gap: 6px; text-align: left; }
.res { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.res .st { margin-left: auto; color: #ffd24a; white-space: nowrap; }
.res.skip { opacity: .55; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 4, 10, .7); backdrop-filter: blur(5px); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: grid; gap: 14px; }
.modal h2 { font-size: 20px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.prof { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.prof.cur { border-color: var(--cyan); }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(30px); background: #121a31; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 80; pointer-events: none; font-weight: 600; }
#toast.on { opacity: 1; transform: translateX(-50%); }
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.draft { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.draft .nm { font-weight: 700; }
.note { font-size: 13px; color: var(--mute); line-height: 1.45; }
.limits { margin-top: 30px; }
.limits ul { margin: 8px 0 0; padding-left: 20px; color: var(--mute); line-height: 1.6; font-size: 14px; }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  :root { --bar: 46px; --gut: 12px; }
  .nav { display: none; }
  .top-actions .chip-btn span.nm { display: none; }
  .hero { grid-template-columns: 1fr; padding: 20px; }
  .hero canvas { display: none; }
  .play { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .grid-stage { gap: 6px; }
  .bar .lab b { font-size: 15px; }
  .bar .lab span { font-size: 10px; letter-spacing: .2em; }
  .bar .lab small { font-size: 10px; }
  .coach { flex-direction: row; }
  .coach .panel { flex-direction: row; align-items: center; width: 100%; }
  .coach .figs { width: 190px; flex: none; }
  .coach canvas { width: 100%; }
  .coach h3 { font-size: 16px; }
  .coach .cue { font-size: 14px; }
  .builder-grid { grid-template-columns: 1fr; }
  .ex { grid-template-columns: 52px 1fr; }
  .ex canvas { width: 52px; height: 78px; }
  .ex .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .sum-row { gap: 8px; }
  .sq { width: 88px; border-radius: 20px; font-size: 15px; }
  .score-box .stars { font-size: 27px; }
  .score-box .score { font-size: 50px; }
  .score-box .muted { font-size: 12px; }
  .stage-btns .btn { padding: 6px 9px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* rep counter, live tip, extra coach views, critique */
.repChip { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none; display: flex; align-items: baseline; gap: 8px; padding: 6px 18px; border-radius: 16px; background: rgba(6, 8, 15, .72); border: 1px solid rgba(53, 224, 255, .4); backdrop-filter: blur(6px); box-shadow: 0 0 24px rgba(53, 224, 255, .2); }
.repChip b { font-size: clamp(30px, 5vw, 56px); line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.repChip span { color: var(--mute); font-weight: 700; font-size: clamp(13px, 1.6vw, 20px); }
.liveTip { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(10px); z-index: 4; pointer-events: none; opacity: 0; transition: .2s; max-width: 92%; text-align: center; padding: 8px 16px; border-radius: 12px; font-weight: 700; font-size: clamp(13px, 1.7vw, 19px); background: rgba(255, 176, 32, .18); border: 1px solid rgba(255, 176, 32, .6); color: #ffe2a8; }
.liveTip.on { opacity: 1; transform: translateX(-50%); }
.coach figure.wide { grid-column: 1 / -1; }
.coach figure.wide canvas { aspect-ratio: 2 / 1; background: radial-gradient(240px 120px at 50% 90%, rgba(52, 240, 138, .15), transparent 70%), #080b16; }
.res { flex-wrap: wrap; }
.restip { flex-basis: 100%; font-size: 12.5px; color: #ffe2a8; padding-left: 2px; }
.focus { max-width: 760px; width: 100%; text-align: left; }
.focus ul { margin: 6px 0 0; padding-left: 20px; line-height: 1.6; }
@media (max-width: 860px) { .repChip { top: 6px; padding: 3px 12px; } .coach .figs { width: 220px; } }
.hud .btn { white-space: nowrap; }
.hud h2 { min-width: 0; }
.avprev { width: 72px; height: 72px; border-radius: 50%; background: #090d1a; border: 1px solid var(--line); flex: none; }
