: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; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; max-width: 1100px; margin: 0 auto; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 20px; letter-spacing: 0.02em; }
.brand b { color: var(--lime); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
body[data-view="play"] .top { display: none; }

.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); }

main { max-width: 1100px; margin: 0 auto; padding: 0 20px 48px; }
body[data-view="play"] main { max-width: none; padding: 0; }

.hero { padding: 28px 0 8px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.05; margin: 0 0 12px; }
.hero p { color: var(--muted); max-width: 62ch; margin: 0 0 18px; font-size: 17px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* Segmented controls */
.settings { display: flex; gap: 10px; flex-wrap: wrap; }
.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); }
.settings-hint { max-width: 80ch; }

h2 { font-size: 20px; margin: 36px 0 14px; }

/* Categories */
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 28px 0 0; }
.cat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; text-align: center; }
.cat:hover { border-color: var(--muted); }
.cat.on { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); background: var(--panel-2); }
.cat-icon { font-size: 30px; line-height: 1.2; }
.cat b { font-size: 18px; }
.cat small { color: var(--muted); font-size: 12px; }
#cat-blurb { margin: 10px 0 16px; }

/* Types */
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.type-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; position: relative; overflow: hidden; transition: transform 0.15s, border-color 0.15s; }
.type-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--accent); }
.type-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.type-icon { font-size: 40px; line-height: 1; }
.type-card h3 { margin: 4px 0 0; font-size: 22px; }
.type-card p { margin: 0; color: var(--muted); flex: 1; }
.type-moves { font-size: 20px; letter-spacing: 4px; }
.type-foot { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.type-foot span:last-child { color: var(--accent); font-weight: 700; }

.steps { color: var(--muted); padding-left: 20px; max-width: 75ch; }
.steps li { margin-bottom: 8px; }
.steps b { color: var(--text); }

/* Type page */
.back { display: inline-block; color: var(--muted); text-decoration: none; margin: 8px 0 12px; }
.back:hover { color: var(--text); }
.type-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.type-head .type-icon { font-size: 56px; }
.type-head h1 { margin: 0; font-size: clamp(30px, 5vw, 44px); line-height: 1.1; color: var(--accent); }
.type-head p { margin: 4px 0 0; color: var(--muted); }
.type-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.practice-btn { border-color: var(--lime); }
.wlist { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.wrow { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.wnum { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); font-weight: 800; }
.wrow.done .wnum { background: var(--lime); color: #111; }
.winfo { display: flex; flex-direction: column; min-width: 0; }
.winfo b { font-size: 17px; }
.winfo span { color: var(--muted); font-size: 14px; }
.wbest { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.wbest b { color: var(--gold); font-size: 18px; margin-right: 4px; }

/* Play */
#play { position: fixed; inset: 0; background: #05060c; overflow: hidden; user-select: none; }
#cam { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 16px; padding: 14px 16px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-left { display: flex; gap: 8px; flex-wrap: wrap; }
.stat { background: rgba(11, 13, 23, 0.72); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; min-width: 88px; }
.stat.player { border-color: var(--pc); }
.stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat.player span { color: var(--pc); font-weight: 800; }
.stat em { font-style: normal; color: var(--gold); }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat .pop, .stat b.pop { color: var(--gold); }
.hud-mid { flex: 1; text-align: center; padding-top: 4px; }
#section { font-weight: 700; text-shadow: 0 1px 4px #000; }
.bar { height: 6px; background: rgba(255, 255, 255, 0.15); border-radius: 99px; margin: 8px auto 0; max-width: 420px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--lime); }
.hud-right { display: flex; gap: 8px; }
.hud-right .chip { background: rgba(11, 13, 23, 0.72); }

#callout { position: absolute; left: 0; right: 0; bottom: 28px; text-align: center; font-size: clamp(22px, 4vw, 38px); font-weight: 800; text-shadow: 0 2px 10px #000; pointer-events: none; }
#count { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(90px, 18vw, 200px); font-weight: 900; color: var(--lime); text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6); pointer-events: none; }
#lost { position: absolute; top: 90px; left: 50%; transform: translateX(-50%); background: var(--right); color: #111; font-weight: 700; padding: 8px 18px; border-radius: 999px; text-align: center; }

.coach-card { position: absolute; left: 16px; bottom: 16px; width: 250px; background: rgba(20, 24, 41, 0.88); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; backdrop-filter: blur(6px); }
.coach-title { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.new { background: var(--gold); color: #111; border-radius: 999px; padding: 1px 8px; font-weight: 800; letter-spacing: 0.04em; animation: blink 1s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: 0.55; } }
#coach { width: 100%; aspect-ratio: 1 / 1; display: block; }
#coach-move { font-weight: 800; font-size: 17px; min-height: 1.4em; }
#coach-how { font-size: 13px; color: var(--text); opacity: 0.85; min-height: 3em; line-height: 1.4; }
#coach-next { font-size: 12px; color: var(--muted); min-height: 1.4em; margin-top: 4px; }

.practice { position: absolute; left: 16px; top: 76px; bottom: 16px; width: min(380px, 42vw); background: rgba(20, 24, 41, 0.92); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; backdrop-filter: blur(6px); overflow-y: auto; }
.prac-step { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
#demo { width: 100%; flex: 1 1 0; min-height: 160px; display: block; }
.practice h2 { margin: 4px 0 0; font-size: 26px; }
.practice p { margin: 0; color: var(--text); opacity: 0.9; }
.reps { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.reps span { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-weight: 800; color: var(--muted); }
.reps span.on { background: var(--lime); border-color: var(--lime); color: #111; }
.reps em { font-style: normal; color: var(--muted); margin-left: 6px; }
.practice .actions { display: flex; gap: 8px; justify-content: space-between; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 6, 12, 0.55); padding: 16px; }
.overlay.see-through { background: none; align-items: end; justify-items: end; padding: 80px 16px 16px; pointer-events: none; }
.overlay.see-through .panel { pointer-events: auto; max-width: 400px; text-align: left; }
.panel { background: rgba(20, 24, 41, 0.95); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 470px; width: 100%; text-align: center; backdrop-filter: blur(6px); }
.panel h2 { margin: 0 0 8px; }
.panel p { color: var(--muted); margin: 0 0 16px; }
.panel .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.overlay.see-through .panel .actions { justify-content: flex-start; }
.status { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 12px; font-size: 17px; }
.status::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--right); flex: none; }
.status.ok::before { background: var(--lime); }
.pos-list { display: grid; gap: 10px; margin-bottom: 10px; }
.pos-row { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.pos-row.ok { border-color: var(--lime); }
.pos-who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--pc, var(--lime)); }
.pos-msg { color: var(--text) !important; margin: 4px 0 8px !important; font-size: 15px; }
.meter { position: relative; height: 28px; }
.meter::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 8px; border-radius: 99px; background: rgba(255, 107, 107, 0.35); }
.meter i { position: absolute; top: 4px; height: 8px; border-radius: 99px; background: var(--lime); }
.meter b { position: absolute; top: 0; width: 4px; height: 16px; margin-left: -2px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px #000; transition: left 0.15s; }
.meter span { position: absolute; bottom: 0; font-size: 11px; color: var(--muted); }
.meter span:last-child { right: 0; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--lime); border-radius: 50%; margin: 0 auto 14px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Result */
.result { max-width: 640px; margin: 24px auto 0; text-align: center; }
.rank { font-size: 120px; font-weight: 900; line-height: 1; color: var(--lime); }
.rank[data-rank="S"] { color: var(--gold); }
.rank[data-rank="C"], .rank[data-rank="D"] { color: var(--muted); }
.result .score { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; background: var(--gold); color: #111; font-weight: 800; border-radius: 999px; padding: 2px 12px; font-size: 14px; margin-left: 8px; vertical-align: middle; }
.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 24px 0; }
.tally div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; }
.tally b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.tally span { font-size: 13px; color: var(--muted); }
.tally .perfect b { color: var(--gold); }
.tally .good b { color: var(--lime); }
.tally .miss b { color: var(--right); }
.result .meta { color: var(--muted); margin-bottom: 20px; }
.result .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.winner { color: var(--pc); font-size: clamp(30px, 6vw, 48px); margin: 8px 0 18px; }
.podium { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; text-align: left; }
.podium li { display: grid; grid-template-columns: 40px 1fr auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--pc); border-radius: 12px; padding: 10px 14px; }
.podium .place { grid-row: span 2; font-size: 26px; text-align: center; }
.podium .who { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.podium b { grid-row: span 2; font-size: 28px; font-variant-numeric: tabular-nums; }
.podium .small { color: var(--muted); font-size: 13px; }

/* Music picker (non-modal so the YouTube preview stays usable) */
.dlg { position: fixed; inset: 0; margin: auto; width: min(560px, calc(100% - 24px)); height: fit-content; max-height: calc(100% - 40px); overflow-y: auto; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.6); z-index: 20; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; }
.tabs { display: flex; gap: 4px; margin: 14px 0 6px; background: var(--bg); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.styles { display: grid; gap: 6px; margin-top: 10px; }
.style-row { display: flex; gap: 6px; align-items: center; }
.style-row .pick { flex: 1; display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.style-row .pick span { font-size: 13px; color: var(--muted); }
.style-row.on .pick { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); }
.file-pick { display: inline-block; margin-top: 10px; }
.file-pick input { display: none; }
.picked { margin: 10px 0 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.picked b { color: var(--text); }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row input, .bpm input[type="number"] { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; }
.yt-results { display: grid; gap: 6px; margin-top: 10px; }
.yt-item { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.yt-item img { border-radius: 6px; flex: none; object-fit: cover; }
.yt-item span { display: flex; flex-direction: column; min-width: 0; }
.yt-item b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.yt-item small { color: var(--muted); }
.bpm { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.bpm label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.bpm input[type="number"] { width: 90px; flex: none; }
.check { flex-basis: 100%; color: var(--muted); }
.vols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.vols label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.vols input { accent-color: var(--lime); }
#yt-box { position: fixed; right: 16px; bottom: 16px; z-index: 30; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #000; width: 256px; height: 200px; }
#yt-box iframe { display: block; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  .top-actions .chip { padding: 5px 10px; font-size: 13px; }
  main { padding: 0 16px 40px; }
  .seg button { padding: 6px 10px; }
  .wrow { grid-template-columns: 36px 1fr auto; }
  .wbest { display: none; }
  .wnum { width: 34px; height: 34px; }
  .hud { flex-wrap: wrap; gap: 8px; padding: 10px; }
  .hud-mid { order: 3; flex-basis: 100%; }
  .stat { min-width: 64px; padding: 4px 10px; }
  .stat b { font-size: 18px; }
  .coach-card { width: 130px; left: 10px; bottom: 10px; padding: 6px; }
  #coach-how, #coach-next { display: none; }
  #coach-move { font-size: 12px; }
  #callout { bottom: 14px; padding-left: 146px; text-align: left; font-size: 18px; }
  .practice { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 55%; }
  #demo { min-height: 110px; }
  .overlay.see-through { justify-items: stretch; }
  .tally { grid-template-columns: repeat(2, 1fr); }
  .vols { grid-template-columns: 1fr; }
  #yt-box { width: 200px; height: 200px; right: 8px; bottom: 8px; }
}
