:root {
  --hue: 200; --bg: #0c0e13; --panel: #141821; --panel2: #1a1f2b; --line: #262b38; --text: #e8eaf0; --dim: #8b92a5;
  --accent: hsl(var(--hue) 85% 60%); --gold: #ffcc4d;
  --perfect: #5dffa0; --great: #7cc8ff; --good: #ffc857; --miss: #ff5d6c; --extra: #b28cff;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: radial-gradient(1200px 700px at 50% 20%, hsl(var(--hue) 40% 12%), var(--bg) 70%); color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; display: flex; flex-direction: column; overflow: hidden; transition: background .5s; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
kbd { font: 600 11px "Segoe UI", sans-serif; background: #232836; border: 1px solid #343b4d; border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; color: #cfd4e2; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 16px; padding: 9px 16px; border-bottom: 1px solid var(--line); background: #0f1218dd; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; font-size: 15px; white-space: nowrap; padding: 0; }
.brand b { color: var(--accent); }
.logo { width: 22px; height: 22px; border-radius: 5px; flex: none; background:
  linear-gradient(var(--accent), var(--accent)) 0 12px/10px 10px no-repeat, linear-gradient(var(--accent), var(--accent)) 12px 12px/10px 10px no-repeat,
  linear-gradient(#fff3, #fff3) 0 0/10px 10px no-repeat, linear-gradient(#fff3, #fff3) 12px 0/10px 10px no-repeat; }
.rank { flex: 1; min-width: 120px; max-width: 340px; }
.rankTop { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.rankTop b { color: var(--gold); }
.rankTop span { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; background: #222836; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .6s; }
.hstats { display: flex; gap: 6px; }
.chip { font-size: 12px; color: var(--dim); padding: 3px 9px; border: 1px solid var(--line); border-radius: 20px; white-space: nowrap; }
.chip b { color: var(--text); }
.hbtns { display: flex; gap: 6px; margin-left: auto; }
.hb { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; cursor: pointer; white-space: nowrap; }
.hb:hover { border-color: hsl(var(--hue) 60% 45%); }
.hb.synced { border-color: #2c6b45; color: #9dffc2; }

main { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; }

/* ---------- map ---------- */
#map { overflow-y: auto; padding: 24px clamp(14px, 4vw, 48px) 40px; }
.hero { display: flex; gap: 40px; align-items: center; max-width: 1180px; margin: 0 auto 28px; }
.heroText { flex: 1; }
.hero h1 { font-size: clamp(24px, 3.4vw, 40px); line-height: 1.15; margin: 0 0 12px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: #b9bfce; max-width: 640px; font-size: 15px; margin: 0 0 18px; }
.heroBtns { display: flex; gap: 10px; flex-wrap: wrap; }
.heroGrid { width: 210px; height: 210px; display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: 7px; flex: none; }
.heroGrid i { border-radius: 8px; background: #1a1f2b; border: 1px solid #262b38; transition: background .4s, box-shadow .4s; }
.heroGrid i.on { background: linear-gradient(160deg, hsl(var(--h) 60% 40%), hsl(var(--h) 60% 22%)); border-color: hsl(var(--h) 70% 55%); }
.heroGrid i.hit { box-shadow: 0 0 22px hsl(var(--h) 90% 60%); background: hsl(var(--h) 80% 62%); }
button.big { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 10px; border: 1px solid hsl(var(--hue) 70% 50%);
  background: hsl(var(--hue) 60% 28%); font-weight: 600; font-size: 15px; cursor: pointer; }
button.big:hover { background: hsl(var(--hue) 60% 34%); }
button.big.alt { background: var(--panel2); border-color: var(--line); }
button.big.go { background: var(--accent); color: #0b0d12; border-color: var(--accent); }

.chap { max-width: 1180px; margin: 0 auto 22px; background: #121620cc; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; }
.chap.locked { opacity: .55; }
.chHead { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.mini { width: 38px; height: 38px; display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: 2px; flex: none; }
.mini i { border-radius: 2px; background: #252b39; }
.mini i.on { background: var(--accent); }
.chHead h3 { margin: 0; font-size: 17px; }
.chHead h3 small { color: var(--dim); font-weight: 600; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; display: block; }
.chHead p { margin: 0; color: var(--dim); flex: 1; }
.chHead .cs { color: var(--gold); white-space: nowrap; font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.card { position: relative; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px 10px; cursor: pointer; min-height: 104px;
  display: flex; flex-direction: column; gap: 2px; transition: transform .12s, border-color .12s; }
.card:hover:not(.locked) { transform: translateY(-2px); border-color: hsl(var(--hue) 70% 50%); }
.card .num { font-size: 11px; color: var(--dim); font-weight: 700; letter-spacing: .08em; }
.card b { font-size: 15px; line-height: 1.2; }
.card small { color: var(--dim); font-size: 12px; }
.card .st { margin-top: auto; color: #3a4153; font-size: 16px; letter-spacing: 2px; }
.card .st .on { color: var(--gold); }
.card .crown { position: absolute; top: 8px; right: 10px; }
.card.boss { background: linear-gradient(160deg, hsl(var(--hue) 40% 20%), var(--panel2)); }
.card.boss .num::after { content: ' · CHECKPOINT'; color: var(--gold); }
.card.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px hsl(var(--hue) 80% 50% / .25); }
.card.locked { cursor: not-allowed; opacity: .5; }
.card.locked .st::before { content: '🔒 '; letter-spacing: 0; font-size: 13px; }
.foot { text-align: center; color: var(--dim); font-size: 12px; }

/* ---------- lesson ---------- */
#lesson { display: grid; grid-template-columns: 300px 1fr 280px; }
aside { padding: 14px 16px; overflow-y: auto; background: #10131acc; }
aside::-webkit-scrollbar { width: 8px; } aside::-webkit-scrollbar-thumb { background: #2a3040; border-radius: 4px; }
.info { border-right: 1px solid var(--line); }
.ctl { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.back { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 0; margin-bottom: 10px; }
.back:hover { color: var(--text); }
.info .chl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.info h1 { font-size: 22px; margin: 2px 0 2px; line-height: 1.2; }
.info .tech { color: var(--accent); font-weight: 600; margin-bottom: 10px; }
.info p { color: #c3c8d5; margin: 0 0 10px; }
.info ul { padding-left: 18px; margin: 0 0 12px; color: #c3c8d5; }
.info li { margin-bottom: 6px; }
.info h4 { margin: 14px 0 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.fingers { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.fingers span { color: var(--dim); }
.kitline { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; }
.kitline b { color: var(--text); }
select, input[type=text], textarea { background: #0d1016; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font: inherit; }
textarea { width: 100%; resize: vertical; font-family: Consolas, monospace; font-size: 12px; }

.play { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px 16px 16px; gap: 10px; }
.stripWrap { flex: none; background: #0f1219; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
#strip { display: block; width: 100%; height: 120px; }
.gridWrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; container-type: size; }
.grid { --s: min(100cqw, 100cqh); width: var(--s); height: var(--s); display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); gap: clamp(6px, 1.2vmin, 12px); }
.pad { --ph: 210; position: relative; border-radius: 12px; border: 1px solid hsl(var(--ph) 45% 32%); cursor: pointer; overflow: visible; touch-action: none; user-select: none;
  background: linear-gradient(160deg, hsl(var(--ph) 42% 22%), hsl(var(--ph) 48% 12%)); box-shadow: inset 0 1px 0 #ffffff14, 0 4px 14px #0008;
  display: flex; align-items: center; justify-content: center; padding: 6px; transition: opacity .3s, filter .3s; }
.pad[data-c=kick] { --ph: 4; } .pad[data-c=snare] { --ph: 34; } .pad[data-c=hat] { --ph: 190; }
.pad[data-c=cym] { --ph: 52; } .pad[data-c=tom] { --ph: 135; } .pad[data-c=fx] { --ph: 275; }
.pad .fl { position: absolute; inset: 0; border-radius: 11px; background: radial-gradient(circle, #fff, hsl(var(--ph) 100% 65%) 60%); opacity: 0; pointer-events: none; }
.pad .nm { font-weight: 700; font-size: clamp(10px, 1.7vmin, 16px); text-align: center; line-height: 1.15; text-shadow: 0 1px 3px #000a; pointer-events: none; }
.pad .ky { position: absolute; top: 6px; left: 8px; font-weight: 700; font-size: clamp(11px, 1.8vmin, 16px); color: #ffffffd0; pointer-events: none; }
.pad .ky em { font-style: normal; opacity: .5; margin-left: 4px; font-size: .85em; }
.pad .fg { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: clamp(9px, 1.3vmin, 12px); color: #ffffffb0; pointer-events: none; }
.pad .ring { position: absolute; inset: -2px; border-radius: 14px; border: 3px solid hsl(var(--ph) 100% 70%); opacity: 0; pointer-events: none; will-change: transform, opacity; }
.pad.off { filter: grayscale(1) brightness(.35); cursor: default; }
.pad.off .ky, .pad.off .nm { opacity: .35; }
.pad.you { border-color: hsl(var(--ph) 80% 60%); box-shadow: inset 0 1px 0 #ffffff22, 0 0 0 1px hsl(var(--ph) 80% 55% / .5), 0 4px 14px #0008; }
.pad.need { animation: need 0.7s ease-in-out infinite alternate; }
@keyframes need { from { box-shadow: 0 0 0 2px hsl(var(--ph) 90% 65%), 0 0 10px hsl(var(--ph) 90% 60%); } to { box-shadow: 0 0 0 4px #fff, 0 0 34px hsl(var(--ph) 90% 60%); } }
.pad.wrong { animation: wrong .3s; }
@keyframes wrong { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: min(28vmin, 220px); font-weight: 800; pointer-events: none;
  color: #fff; text-shadow: 0 0 40px var(--accent); opacity: 0; }
.judge { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); pointer-events: none; font-weight: 800; font-size: 22px; letter-spacing: .06em; text-shadow: 0 2px 8px #000; white-space: nowrap; }
.judge small { font-size: 13px; opacity: .75; margin-left: 6px; }
.toast { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: #000c; border: 1px solid var(--line); border-radius: 20px; padding: 7px 16px;
  pointer-events: none; opacity: 0; transition: opacity .3s; white-space: nowrap; }
.toast.on { opacity: 1; }

.modes { display: flex; flex-direction: column; gap: 6px; }
.mode { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; cursor: pointer; display: flex; flex-direction: column; }
.mode b { font-size: 14px; }
.mode small { color: var(--dim); font-size: 12px; }
.mode:hover { border-color: hsl(var(--hue) 60% 45%); }
.mode.on { background: hsl(var(--hue) 55% 24%); border-color: var(--accent); }
.mode.test { border-color: hsl(45 70% 40%); }
.mode.hero { border-color: hsl(45 90% 55%); background: linear-gradient(160deg, #3a2f0d, var(--panel2)); }
.stop { background: #3a1820; border: 1px solid #7a2d3c; border-radius: 10px; padding: 9px; cursor: pointer; font-weight: 700; }
.box { background: #131721; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row label { color: var(--dim); }
.row.small { font-size: 12px; color: var(--dim); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.tg { display: flex; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
.tg input { accent-color: var(--accent); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acc, .combo { display: flex; flex-direction: column; align-items: center; }
.acc b, .combo b { font-size: 26px; line-height: 1.1; }
.acc span, .combo span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.grades { grid-column: span 2; display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); text-transform: uppercase; }
.g { display: flex; flex-direction: column; align-items: center; }
.g b { font-size: 15px; }
.g.perfect b { color: var(--perfect); } .g.great b { color: var(--great); } .g.good b { color: var(--good); } .g.miss b { color: var(--miss); } .g.extra b { color: var(--extra); }
.meter { grid-column: span 2; position: relative; height: 26px; background: #0c0f15; border-radius: 6px; overflow: hidden; }
.meter .zone { position: absolute; left: 35%; right: 35%; top: 0; bottom: 0; background: #5dffa014; }
.meter .mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #5dffa0aa; }
.meter .lbl { position: absolute; bottom: 1px; font-size: 9px; color: #5c6477; text-transform: uppercase; }
.meter .lbl.e { left: 4px; } .meter .lbl.l { right: 4px; }
.meter #ticks i { position: absolute; top: 4px; bottom: 9px; width: 3px; margin-left: -1px; border-radius: 2px; }
.tend { grid-column: span 2; color: var(--dim); font-size: 12px; text-align: center; min-height: 18px; }
.best { font-size: 13px; color: var(--dim); }
.best b { color: var(--text); }
.best .st { color: #3a4153; font-size: 18px; letter-spacing: 2px; }
.best .st .on { color: var(--gold); }

/* ---------- modal ---------- */
.modalBack { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--panel); border: 1px solid #343b4d; border-radius: 16px; padding: 22px 24px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px #000c; }
.modal h2 { margin: 0 0 6px; font-size: 22px; }
.modal h3 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.modal p { color: #c3c8d5; margin: 0 0 10px; }
.modal .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.modal .btns.left { margin-top: 8px; }
.modal button.big { font-size: 14px; padding: 9px 14px; }
.modal .err { color: var(--miss); min-height: 18px; font-size: 13px; }
.modal .okmsg { color: var(--perfect); min-height: 18px; font-size: 13px; }
.bigStars { font-size: 54px; letter-spacing: 8px; text-align: center; color: #343b4d; margin: 6px 0; }
.bigStars .on { color: var(--gold); text-shadow: 0 0 20px #ffcc4d88; display: inline-block; animation: pop .5s backwards; }
.bigStars .on:nth-child(2) { animation-delay: .2s; } .bigStars .on:nth-child(3) { animation-delay: .4s; }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.3); } }
.resAcc { text-align: center; font-size: 40px; font-weight: 800; }
.resAcc small { display: block; font-size: 13px; color: var(--dim); font-weight: 400; }
.resRow { display: flex; justify-content: center; gap: 18px; margin: 8px 0; }
.badge { display: inline-block; background: #2b2410; border: 1px solid #6b5a1d; color: var(--gold); border-radius: 20px; padding: 3px 11px; margin: 3px; font-size: 13px; font-weight: 600; }
.code { font: 700 22px Consolas, monospace; letter-spacing: .05em; color: var(--gold); background: #0d1016; border: 1px dashed #4a4020; border-radius: 10px; padding: 10px 14px; text-align: center; user-select: all; word-break: break-all; }
.inl { display: flex; gap: 8px; }
.inl input { flex: 1; min-width: 0; }
.setRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #1f2430; }
.setRow label { color: #c3c8d5; }
.setRow input[type=range] { width: 180px; }
.calib { text-align: center; font-size: 60px; font-weight: 800; height: 80px; }

.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0008; z-index: 30; font-size: 16px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--dim); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin-right: 10px; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- smaller screens ---------- */
@media (max-width: 1150px) {
  #lesson { grid-template-columns: 250px 1fr 250px; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .hstats { display: none; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  header { flex-wrap: wrap; gap: 8px 12px; }
  .brand span:last-child { font-size: 13px; }
  .rank { order: 3; max-width: none; flex-basis: 100%; }
  .hb span { display: none; }
  main { overflow: visible; }
  .screen { position: static; }
  #lesson { display: flex; flex-direction: column; }
  .play { order: 1; padding: 10px; }
  .ctl { order: 2; border: 0; }
  .info { order: 3; border: 0; }
  .gridWrap { container-type: inline-size; flex: none; }
  .grid { --s: min(100cqw, 560px); }
  .modes { display: grid; grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .hero { flex-direction: column-reverse; gap: 16px; }
  .heroGrid { width: 150px; height: 150px; }
  .chHead p { display: none; }
}
