:root {
  --bg: #07070d;
  --panel: #0d0e19;
  --panel2: #14162a;
  --line: #262a48;
  --text: #ecedff;
  --dim: #8b8fb8;
  --accent: #00e5ff;
  --accent2: #ff2bd6;
  --miss: #ff2a3c;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(1200px 400px at 15% -10%, rgba(255, 43, 214, .10), transparent 60%),
    radial-gradient(1000px 380px at 90% -20%, rgba(0, 229, 255, .10), transparent 60%),
    var(--bg);
}

/* ---------- Panel ---------- */
#panel {
  flex: none;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.row { display: flex; align-items: center; gap: 10px; }
.row.top { flex-wrap: nowrap; min-width: 0; }
.row.main { margin-top: 8px; align-items: stretch; gap: 12px; }
.spacer { flex: 1; }

.brand { font-size: 20px; font-weight: 300; letter-spacing: .5px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand b { font-weight: 800; color: var(--accent); text-shadow: 0 0 10px rgba(0, 229, 255, .7); }
.logo { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent2), var(--accent)); box-shadow: 0 0 12px rgba(255, 43, 214, .6); }

.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex: none; }
.seg button {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--dim); white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.seg button.on { background: #1f2340; color: #fff; box-shadow: inset 0 0 0 1px rgba(0, 229, 255, .55), 0 0 14px rgba(0, 229, 255, .25); }

.soundpick { position: relative; flex: 0 0 170px; }
.soundpick select { width: 100%; height: 36px; border-radius: 999px; font-size: 14px; }
.sstat { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.soundpick .sstat {
  position: absolute; left: 50%; top: calc(100% + 2px); transform: translateX(-50%); z-index: 3;
  font-size: 10px; padding: 1px 7px; border-radius: 6px; background: #0b1c26; border: 1px solid rgba(0, 229, 255, .4);
}
.sstat:empty { display: none; }
#soundSel { min-width: 220px; }
.small a { color: var(--accent); }
.tbtn {
  border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.tbtn.primary { background: linear-gradient(135deg, #ff2bd6, #7a3cff); border-color: transparent; box-shadow: 0 0 16px rgba(255, 43, 214, .45); }
.tbtn.primary.playing { background: linear-gradient(135deg, #ff6a3c, #ff2bd6); }
.tbtn[aria-pressed="true"] { border-color: var(--accent); color: #fff; box-shadow: 0 0 14px rgba(0, 229, 255, .5), inset 0 0 10px rgba(0, 229, 255, .25); }
.tbtn.big { font-size: 18px; padding: 14px 34px; }

.ibtn {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2);
  display: inline-grid; place-items: center; padding: 0; font-size: 15px;
}
.ibtn.sm { width: 36px; height: 36px; font-size: 13px; }
.ibtn:active, .tbtn:active, .chip:active { transform: scale(.96); }

/* Display (chord readout) */
.display {
  flex: none; width: 250px; min-height: 120px; border-radius: var(--radius); padding: 8px 14px;
  background: linear-gradient(180deg, #0a0b16, #111329);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 30px rgba(0, 229, 255, .06);
  display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden;
}
.display.win { animation: winpulse .7s ease-out; }
@keyframes winpulse {
  0% { box-shadow: inset 0 0 0 2px #39ff14, 0 0 30px rgba(57, 255, 20, .7); }
  100% { box-shadow: inset 0 0 30px rgba(0, 229, 255, .06); }
}
.dtop { display: flex; justify-content: space-between; align-items: center; min-height: 18px; }
.numeral { font-family: Georgia, "Times New Roman", serif; font-size: 16px; color: var(--accent2); text-shadow: 0 0 8px rgba(255, 43, 214, .6); letter-spacing: .5px; }
.streak { font-size: 13px; font-weight: 700; color: #ffb347; }
.cname { font-size: 42px; font-weight: 800; line-height: 1.05; letter-spacing: -.5px; color: #fff; text-shadow: 0 0 18px rgba(0, 229, 255, .55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cname small { font-size: 18px; font-weight: 600; color: var(--dim); text-shadow: none; margin-left: 6px; }
.tones { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; min-height: 22px; }
.tone { font-weight: 700; font-size: 15px; padding: 1px 7px; border-radius: 6px; border: 1px solid currentColor; text-shadow: 0 0 8px currentColor; background: rgba(255, 255, 255, .03); }
.tone i { font-style: normal; font-size: 10px; opacity: .8; margin-left: 3px; vertical-align: 2px; }
.tone.held { background: currentColor; }
.tone.held span, .tone.held i { color: #07070d; text-shadow: none; }
.status { font-size: 13px; color: var(--dim); margin-top: 5px; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status b.good { color: #39ff14; text-shadow: 0 0 8px rgba(57, 255, 20, .7); }
.pbar { height: 4px; border-radius: 4px; background: #1d2040; margin-top: 4px; overflow: hidden; }
.pbar > div { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); box-shadow: 0 0 8px var(--accent); transition: width .15s; }

/* Controls */
.controls { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.ctl { display: none; flex-direction: column; gap: 6px; }
.ctl.show { display: flex; }
.crow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crow > label, .srow > label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); font-weight: 700; flex: none; min-width: 64px; }
.crow > label + * + label { margin-left: 10px; min-width: 0; }
.chips { display: flex; gap: 5px; min-width: 0; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 1px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--panel2); color: #cfd2f5; font-weight: 700; font-size: 14px;
  min-width: 36px; height: 34px; padding: 0 10px; border-radius: 9px; transition: background .12s, box-shadow .12s, color .12s;
}
.chip.on { background: #1d2246; color: #fff; border-color: var(--accent); box-shadow: 0 0 12px rgba(0, 229, 255, .45), inset 0 0 8px rgba(0, 229, 255, .2); }
.chip.ghost { margin-left: auto; color: var(--dim); }
.chip:disabled { opacity: .3; }
.hint { margin: 0; color: var(--dim); font-size: 15px; line-height: 1.5; }
.hint b { color: #fff; }
#arpCtl { display: none; }
#arpCtl.show { display: flex; }

select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; height: 36px; padding: 0 30px 0 12px; font-weight: 700; font-size: 15px;
  -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat;
}
#progSel { flex: 1; min-width: 0; max-width: 340px; }

.strip { gap: 8px; }
.pstrip { flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; padding: 4px 2px; }
.pstrip::-webkit-scrollbar { display: none; }
.pchip {
  flex: none; min-width: 58px; padding: 4px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
  display: flex; flex-direction: column; align-items: center; line-height: 1.15; position: relative;
}
.pchip .pn { font-family: Georgia, serif; font-size: 12px; color: var(--dim); }
.pchip .pc { font-weight: 800; font-size: 15px; }
.pchip.on { border-color: var(--accent2); background: #241a3c; box-shadow: 0 0 14px rgba(255, 43, 214, .5), inset 0 0 10px rgba(255, 43, 214, .2); }
.pchip.on .pn { color: var(--accent2); }
.pchip.done::after { content: "✓"; position: absolute; top: -6px; right: -4px; font-size: 11px; background: #39ff14; color: #07070d; border-radius: 50%; width: 16px; height: 16px; display: grid; place-items: center; font-weight: 900; box-shadow: 0 0 8px #39ff14; }

/* HUD (shown when panel hidden) */
#hud { display: none; flex: none; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
#hud .hudname { font-size: 22px; font-weight: 800; min-width: 110px; text-align: center; text-shadow: 0 0 12px rgba(0, 229, 255, .5); display: flex; align-items: baseline; gap: 8px; justify-content: center; }
#hud .status { margin: 0 0 0 8px; }
body.hidepanel #panel { display: none; }
body.hidepanel #hud { display: flex; }
body.mode-free #hudPrev, body.mode-free #hudNext, body.src-single #hudPrev, body.src-single #hudNext { visibility: hidden; }

/* Free play: no picker panel, just the detected chord in the top bar */
.freeread { display: none; align-items: baseline; gap: 12px; min-width: 0; flex: 0 1 auto; overflow: hidden; white-space: nowrap; padding-left: 6px; }
body.mode-free .freeread { display: flex; }
body.mode-free #srcSeg, body.mode-free .display { display: none; }
body.mode-free .row.main { margin-top: 6px; }

/* Auto Chords */
.autoopts { display: none; align-items: center; gap: 10px; flex: 1; min-width: 0; }
#freeCtl.on .autoopts { display: flex; }
.autoopts > label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); font-weight: 700; }
#autoStrip { touch-action: none; }
#autoStrip .pchip { cursor: pointer; }
.key.inscale::before {
  content: ""; position: absolute; left: 50%; bottom: 6px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: #00e5ff; box-shadow: 0 0 6px #00e5ff; opacity: .75; pointer-events: none;
}
.key.inscale.tonic::before { background: #ff2bd6; box-shadow: 0 0 6px #ff2bd6; }
.key.black.inscale::before { bottom: 4px; }
.freeread .numeral { font-size: 18px; margin-right: 2px; }
#fName { font-size: 24px; font-weight: 800; color: #fff; text-shadow: 0 0 14px rgba(0, 229, 255, .7); }
#fNotes { min-width: 0; font-size: 14px; font-weight: 700; color: var(--accent); overflow: hidden; text-overflow: ellipsis; }

/* ---------- Songs ---------- */
body.mode-songs #srcSeg, body.mode-songs .display { display: none; }
body.mode-songs .freeread { display: flex; }
body.mode-songs .row.main { margin-top: 6px; }
body.mode-songs #hudPrev, body.mode-songs #hudNext { visibility: hidden; }
.freeread #fNotes b.good { color: #39ff14; text-shadow: 0 0 8px rgba(57, 255, 20, .7); }
body.mode-songs #fName { font-size: 18px; }
#songCtl .crow { gap: 10px; }
.songpick {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 260px; height: 44px; padding: 0 12px 0 14px;
  border-radius: 12px; border: 1px solid var(--accent2); background: #1d1530; color: #fff; text-align: left;
  box-shadow: 0 0 14px rgba(255, 43, 214, .3);
}
.sp-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.15; }
.sp-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-sub { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#songPlay { min-width: 96px; }
.tl { position: relative; flex: 1; height: 16px; border-radius: 8px; background: #1a1d38; border: 1px solid var(--line); cursor: pointer; touch-action: none; }
.tl-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 8px; background: linear-gradient(90deg, rgba(255,43,214,.6), rgba(0,229,255,.6)); pointer-events: none; }
.tl-loop { display: none; position: absolute; top: -3px; bottom: -3px; border-radius: 6px; border: 2px solid var(--accent2); background: rgba(255, 43, 214, .18); box-shadow: 0 0 10px rgba(255, 43, 214, .5); pointer-events: none; }
.tl-head { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; border-radius: 2px; background: #fff; box-shadow: 0 0 8px #00e5ff, 0 0 16px #00e5ff; pointer-events: none; }
.tl-time { font-size: 12px; font-weight: 700; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.loopctl { display: flex; align-items: center; gap: 5px; }
.loopctl label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); font-weight: 700; margin-right: 2px; }
.loopctl .chip { min-width: 34px; height: 30px; padding: 0 8px; }
.loopctl .chip.on { border-color: var(--accent2); box-shadow: 0 0 12px rgba(255, 43, 214, .5); }

#rollWrap { display: none; position: relative; min-height: 0; }
#roll { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.mode-songs #kbdWrap { display: flex; flex-direction: column; }
body.mode-songs #rollWrap {
  display: block; flex: 42 1 0;
  background: linear-gradient(180deg, #07070d 0%, #0c0d1c 100%);
  border-radius: 10px 10px 0 0; overflow: hidden;
}
body.mode-songs #kbd { flex: 58 1 0; height: auto; border-radius: 0 0 14px 14px; }
.key .lab .dg:empty { display: none; }

/* song picker */
.songs-card { display: flex; flex-direction: column; gap: 10px; height: min(640px, 100%); }
.song-tools { display: flex; gap: 10px; align-items: center; }
#songSearch {
  flex: 1; min-width: 0; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2);
  padding: 0 14px; font-size: 16px; color: var(--text); outline: none; -webkit-user-select: text; user-select: text;
}
#songSearch:focus { border-color: var(--accent); box-shadow: 0 0 12px rgba(0, 229, 255, .35); }
.importbtn { cursor: pointer; white-space: nowrap; }
#songFilter { align-self: flex-start; flex-wrap: wrap; border-radius: 14px; }
.song-list { flex: 1; min-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
.song-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding-right: 8px; }
.song-row.on { border-color: var(--accent); box-shadow: 0 0 12px rgba(0, 229, 255, .3); }
.song-pick { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; background: none; border: 0; text-align: left; }
.song-pick .st { font-weight: 800; font-size: 15px; }
.song-pick .sc { font-size: 12px; color: var(--dim); }
.lvl { flex: none; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; border: 1px solid currentColor; }
.lvl-1 { color: #39ff14; } .lvl-2 { color: #00e5ff; } .lvl-3 { color: #ff9500; } .lvl-mine { color: #b26bff; }
.song-del { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: none; color: var(--dim); }
.import-panel { border: 1px solid var(--accent2); border-radius: 12px; padding: 10px 12px; background: #1a1328; display: flex; flex-direction: column; gap: 8px; }
.import-panel[hidden] { display: none; }
.imp-row { display: flex; align-items: center; gap: 10px; }
.imp-row label { min-width: 100px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); font-weight: 700; }
.imp-row input, .imp-row select { flex: 1; min-width: 0; }
.imp-row input { height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); padding: 0 10px; font-size: 16px; -webkit-user-select: text; user-select: text; }
.imp-btns { justify-content: flex-end; }
.imp-err { margin: 0; color: #ff6a7a; font-weight: 700; }

/* ---------- Keyboard ---------- */
#kbdWrap { flex: 1; min-height: 0; position: relative; padding: 10px 8px 8px; }
.kbd {
  position: relative; width: 100%; height: 100%;
  border-radius: 6px 6px 14px 14px;
  background: #000;
  box-shadow: 0 -2px 0 #1a1c33, 0 0 0 1px #15172a;
  touch-action: none;
  overflow: hidden;
}
.kbd::before { /* felt strip */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; z-index: 6;
  background: linear-gradient(90deg, #ff2bd6, #7a3cff, #00e5ff, #39ff14, #ff9500, #ff2bd6);
  box-shadow: 0 0 16px rgba(122, 60, 255, .8); opacity: .85; pointer-events: none;
}

.key { position: absolute; top: 0; border-radius: 0 0 8px 8px; overflow: visible; touch-action: none; }
.key.white {
  height: 100%; z-index: 1;
  background: linear-gradient(180deg, #e9e9f2 0%, #fbfbff 12%, #ffffff 80%, #e4e4ee 100%);
  border-right: 1px solid #b7b8c9;
  box-shadow: inset 0 -8px 0 #d6d7e4, inset 0 -10px 8px rgba(0,0,0,.05);
}
.key.black {
  height: 61%; z-index: 4;
  background: linear-gradient(180deg, #1b1c26 0%, #2a2c3a 85%, #3a3c4d 92%, #15161e 100%);
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0 -6px 0 #0c0d12, 0 3px 6px rgba(0,0,0,.6), inset 1px 0 0 #3b3d4f, inset -1px 0 0 #000;
}
.key.white.down { background: linear-gradient(180deg, #d2d3e2 0%, #e9e9f4 70%, #dddeea 100%); box-shadow: inset 0 -3px 0 #c6c7d6, inset 0 6px 10px rgba(0,0,0,.15); }
.key.black.down { background: linear-gradient(180deg, #111219 0%, #22232f 94%, #111219 100%); box-shadow: inset 0 -2px 0 #0c0d12, 0 1px 3px rgba(0,0,0,.6); }

/* plain labels */
.key .base { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; font-size: 13px; font-weight: 700; color: #9a9cb5; pointer-events: none; }
.key.black .base { color: #b4b6cc; bottom: 12px; font-size: 11px; line-height: 1.25; }

/* neon guide */
.key .led, .key .lab { display: none; pointer-events: none; }
.key.lit .base { display: none; }
.key.lit .led {
  display: block; position: absolute; left: 14%; right: 14%; bottom: 12px; height: 7px; border-radius: 7px;
  background: #fff;
  box-shadow: 0 0 4px 1px var(--g), 0 0 10px 3px var(--g), 0 0 24px 6px var(--ga);
}
.key.black.lit .led { bottom: 10px; height: 5px; left: 18%; right: 18%; }
.key.lit .lab {
  display: flex; flex-direction: column; align-items: center; position: absolute; left: 0; right: 0; bottom: 28px; line-height: 1;
}
.key.black.lit .lab { bottom: 22px; }
.key .lab .nm {
  font-size: 18px; font-weight: 900; color: var(--g);
  text-shadow: 0 0 6px var(--g), 0 0 14px var(--ga);
}
.key.white.lit .lab .nm { color: #fff; text-shadow: 0 0 2px var(--g), 0 0 8px var(--g), 0 0 18px var(--g); -webkit-text-stroke: .4px var(--g); }
.key .lab .dg {
  margin-top: 4px; font-style: normal; font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 6px;
  background: var(--g); color: #07070d; box-shadow: 0 0 10px var(--g);
}
.key.black .lab .nm { font-size: 13px; color: #fff; }
.key.black .lab .dg { font-size: 9px; padding: 1px 4px; }

.key.white.lit {
  z-index: 2;
  background: linear-gradient(180deg, #ffffff 0%, var(--gc) 45%, var(--gb) 100%);
  box-shadow: 0 0 14px 1px var(--ga), inset 0 0 0 2px var(--g), inset 0 -26px 34px -10px var(--g), inset 0 -8px 0 rgba(0,0,0,.08);
}
.key.black.lit {
  z-index: 5;
  background: linear-gradient(180deg, #16171f 0%, var(--gd) 55%, var(--g) 100%);
  box-shadow: 0 0 14px 2px var(--ga), inset 0 0 0 1px var(--g), inset 0 -16px 22px -6px #fff;
}
.key.lit.down { filter: brightness(1.15) saturate(1.2); }
.key.lit.faint { opacity: 1; }
.key.lit.faint .led { opacity: .45; box-shadow: 0 0 4px var(--g); }
.key.white.lit.faint { background: linear-gradient(180deg, #ffffff 0%, #fafaff 55%, var(--gc) 100%); box-shadow: inset 0 0 0 1px var(--ga); }
.key.black.lit.faint { background: linear-gradient(180deg, #1b1c26 0%, #2a2c3a 70%, var(--gd) 100%); box-shadow: inset 0 0 0 1px var(--ga), 0 3px 6px rgba(0,0,0,.6); }
.key.lit.faint .lab { opacity: .55; }
.key.lit.next { animation: nextpulse 0.9s ease-in-out infinite; }
.key.lit.next .led { animation: ledpulse 0.9s ease-in-out infinite; }
@keyframes nextpulse { 50% { filter: brightness(1.25) saturate(1.3); } }
@keyframes ledpulse { 50% { box-shadow: 0 0 6px 2px var(--g), 0 0 16px 6px var(--g), 0 0 40px 12px var(--ga); } }
.key.done-note .led { box-shadow: 0 0 3px var(--g); opacity: .35; }

.key.hit::after, .key.miss::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  animation: flash .45s ease-out forwards;
}
.key.hit::after { background: radial-gradient(ellipse at 50% 85%, #fff 0%, var(--g) 35%, transparent 75%); }
.key.miss::after { background: radial-gradient(ellipse at 50% 80%, rgba(255,42,60,.95) 0%, rgba(255,42,60,.5) 40%, transparent 80%); }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.kbd.win .key.lit { animation: winkey .8s ease-out; }
@keyframes winkey {
  0% { filter: brightness(1.8) saturate(1.5); }
  100% { filter: none; }
}

.ripple {
  position: absolute; width: 20px; height: 20px; border-radius: 50%; pointer-events: none; z-index: 8;
  border: 3px solid var(--g); box-shadow: 0 0 14px var(--g), inset 0 0 10px var(--g);
  transform: translate(-50%, -50%) scale(.4); animation: ripple .6s ease-out forwards;
}
@keyframes ripple { to { transform: translate(-50%, -50%) scale(4.5); opacity: 0; } }

/* ---------- Settings sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(3, 3, 8, .72); display: grid; place-items: center; padding: 16px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet[hidden] { display: none; }
.sheet-card { width: min(640px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px 20px 18px; box-shadow: 0 0 40px rgba(122, 60, 255, .3); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid #191b31; flex-wrap: wrap; }
.srow > label { min-width: 140px; }
.srow .seg { flex-wrap: wrap; border-radius: 14px; }
.srow input[type=range] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.muted { color: var(--dim); font-size: 13px; }
.small { font-size: 12px; line-height: 1.5; margin: 12px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }
.legend span { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; border: 1px solid currentColor; text-shadow: 0 0 6px currentColor; }

/* ---------- Splash / rotate ---------- */
#splash { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #1a1036 0%, #07070d 65%); transition: opacity .35s; }
#splash.gone { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-inner h1 { font-size: 52px; font-weight: 300; margin: 18px 0 4px; }
.splash-inner h1 b { font-weight: 800; color: var(--accent); text-shadow: 0 0 20px rgba(0, 229, 255, .8); }
.splash-inner p { color: var(--dim); margin: 0 0 26px; font-size: 17px; }
.splash-logo { display: inline-flex; gap: 6px; height: 90px; align-items: flex-end; }
.splash-logo span { width: 22px; height: 90px; border-radius: 0 0 6px 6px; background: #fff; box-shadow: 0 0 0 1px #333; animation: splashkey 1.6s ease-in-out infinite; }
.splash-logo span:nth-child(1) { --g: #ff2bd6; animation-delay: 0s; }
.splash-logo span:nth-child(2) { --g: #7a3cff; animation-delay: .15s; }
.splash-logo span:nth-child(3) { --g: #00e5ff; animation-delay: .3s; }
.splash-logo span:nth-child(4) { --g: #39ff14; animation-delay: .45s; }
.splash-logo span:nth-child(5) { --g: #ff9500; animation-delay: .6s; }
@keyframes splashkey { 0%, 60%, 100% { background: #fff; box-shadow: 0 0 0 1px #333; } 25% { background: linear-gradient(180deg, #fff, var(--g)); box-shadow: 0 0 22px var(--g); } }

#rotate { position: fixed; inset: 0; z-index: 55; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(7, 7, 13, .96); text-align: center; padding: 24px; }
#rotate div { font-size: 64px; color: var(--accent); text-shadow: 0 0 20px var(--accent); animation: spin 2.5s ease-in-out infinite; }
#rotate p { color: var(--dim); font-size: 17px; max-width: 260px; }
@keyframes spin { 50% { transform: rotate(90deg); } }
@media (orientation: portrait) and (max-width: 600px) {
  body:not(.rotate-ok) #rotate { display: flex; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .brand { font-size: 0; gap: 0; }
  .seg button { padding: 7px 10px; font-size: 13px; }
  .display { width: 210px; }
  .cname { font-size: 36px; }
}
@media (max-width: 860px) {
  .songpick { flex-basis: 180px; height: 38px; }
  #songModeSeg button { padding: 6px 7px; }
  #songSpeedSeg button[data-v="0.75"] { display: none; }
  .loopctl label, .tl-time { display: none; }
  .row.top { gap: 6px; }
  .seg button { padding: 6px 8px; font-size: 12px; }
  .tbtn { padding: 7px 10px; font-size: 13px; }
  #sustainBtn, .soundpick { display: none; }
  .display { width: 170px; padding: 6px 10px; }
  .cname { font-size: 30px; }
  .crow > label { min-width: 0; font-size: 10px; }
  .chip { min-width: 30px; height: 30px; padding: 0 7px; font-size: 13px; }
}
@media (max-height: 520px) {
  #panel { padding: 4px 8px 6px; }
  .row.main { margin-top: 4px; }
  .display { min-height: 0; }
  .cname { font-size: 26px; }
  .tones .tone { font-size: 12px; }
  .status { margin-top: 2px; }
  .chip { height: 28px; font-size: 12px; }
  .ibtn { width: 34px; height: 34px; }
  .crow { gap: 5px; }
  .ctl { gap: 4px; }
  .pchip { padding: 2px 6px; min-width: 48px; }
  .pchip .pc { font-size: 13px; }
  .key .lab .nm { font-size: 14px; }
  #kbdWrap { padding: 6px 6px 4px; }
}
