*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, sans-serif;
  background: #111;
  color: #f7f7f7;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 60px;
}

header {
  text-align: center;
  margin-bottom: 32px;
}

h1 {
  font-size: 2.8rem;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-top: 6px;
  letter-spacing: 0.05em;
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#controls {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

#instrument-switch {
  display: inline-flex;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.instr-btn {
  background: transparent;
  border: none;
  color: #999;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.instr-btn:hover {
  background: #2a2a2a;
  color: #ddd;
}

.instr-btn.active {
  background: #2563eb;
  color: #fff;
}

.instr-btn.active:hover {
  background: #2563eb;
  color: #fff;
}

#drums {
  display: none;   gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0 28px;
}

.drum-pad {
  width: 118px;
  height: 140px;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 35%, #3a3a3a, #1a1a1a);
  border: 2px solid #555;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 0.05s, background 0.05s, box-shadow 0.05s;
}

.drum-pad .di {
  width: 74px;
  height: 50px;
  pointer-events: none;
}

.drum-pad[data-drum="crash"],
.drum-pad[data-drum="ride"] {
  background: radial-gradient(circle at 50% 35%, #4a4230, #241f12);
  border-color: #7a6a3e;
}

.drum-pad:hover {
  border-color: #777;
}

.drum-pad.hit {
  background: radial-gradient(circle at 50% 35%, #93c5fd, #2563eb);
  border-color: #93c5fd;
  transform: scale(0.96);
  box-shadow: 0 0 24px rgba(37, 99, 235, 0.7);
}

.drum-name {
  font-size: 15px;
  font-weight: 600;
  color: #e5e5e5;
  letter-spacing: 0.04em;
}

.drum-pad kbd {
  background: #111;
  border: 1px solid #555;
  border-radius: 5px;
  padding: 3px 10px;
  font-family: monospace;
  font-size: 13px;
  color: #bbb;
}

.drum-pad.hit .drum-name,
.drum-pad.hit kbd {
  color: #fff;
}

#bass {
  display: none;   justify-content: center;
  margin: 10px 0 28px;
  width: 100%;
}

#bass-keys {
  position: relative;
  display: flex;
  width: 480px;   filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.7));
  user-select: none;
  touch-action: none;
}

.bass-key {
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: background 0.05s, transform 0.05s, box-shadow 0.05s;
}

.bass-key.white {
  width: 60px;
  height: 175px;
  background: linear-gradient(to bottom, #f3e7d0, #fffaf2);
  border: 1px solid #b79b6e;
  border-top: none;
  border-radius: 0 0 6px 6px;
  position: relative;
  z-index: 1;
}

.bass-key.white:hover {
  background: linear-gradient(to bottom, #f7edd8, #fffdf8);
}

.bass-key.white.active {
  background: linear-gradient(to bottom, #f59e0b, #d97706);
  transform: translateY(2px);
}

.bass-key.black {
  width: 38px;
  height: 112px;
  background: linear-gradient(to bottom, #3a2a18, #140d06);
  border: 1px solid #000;
  border-top: none;
  border-radius: 0 0 4px 4px;
  position: absolute;
  top: 0;
  z-index: 2;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.bass-key.black:hover {
  background: linear-gradient(to bottom, #4a381f, #1c1206);
}

.bass-key.black.active {
  background: linear-gradient(to bottom, #b45309, #7c2d12);
}

.bass-key.white.remote-active {
  background: var(--remote-color);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.bass-key.black.remote-active {
  background: var(--remote-color);
  box-shadow: 0 0 12px var(--remote-color), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.bk-label {
  display: none;
  font-size: 11px;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.5;
  color: #7a5a2e;
  pointer-events: none;
}

body.beginner-mode .bk-label {
  display: block;
}

.bass-key.black .bk-label {
  color: #cbb088;
  font-size: 10px;
  margin-bottom: 6px;
}

.bk-label kbd {
  display: inline-block;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
  font-size: 10px;
}

.bass-key.black .bk-label kbd {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.15);
}

body.mode-drums #drums { display: flex; }
body.mode-bass  #bass  { display: flex; }

body.mode-drums #piano-scroll,
body.mode-drums #octave-control,
body.mode-drums #beginner-toggle,
body.mode-drums #sustain-toggle,
body.mode-bass #piano-scroll,
body.mode-bass #sustain-toggle {
  display: none;
}

#octave-control {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #aaa;
  font-size: 14px;
}

#octave-display {
  min-width: 80px;
  text-align: center;
  font-weight: 600;
  color: #e0e0e0;
  font-size: 14px;
}

#key-size {
  display: inline-flex;
  gap: 4px;
}
#key-size button {
  padding: 8px 10px;
  font-size: 13px;
}

.octave-hint {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 6px 11px;
  font-size: 13px;
  font-family: monospace;
  color: #ccc;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.octave-hint:hover { background: #3a3a3a; }
.octave-hint:active { background: #4a4a4a; transform: scale(0.94); }

.sustain-key {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  margin-left: 3px;
}

button {
  background: #2a2a2a;
  color: #e0e0e0;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 9px 20px;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.03em;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

button:hover {
  background: #383838;
  color: #fff;
  border-color: #777;
}

button.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

#collab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

#collab-lobby,
#collab-room {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.hidden { display: none !important; }

.collab-or {
  color: #555;
  font-size: 12px;
}

#join-code {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #f0f0f0;
  padding: 8px 12px;
  width: 110px;
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-family: monospace;
}

#join-code:focus {
  outline: none;
  border-color: #2563eb;
}

#create-room {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

#create-room:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button.ghost {
  padding: 6px 12px;
  font-size: 12px;
}

.room-label {
  font-size: 12px;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#room-code-display {
  font-family: monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #fff;
}

#players {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  font-size: 12px;
  color: #ccc;
}

.player-chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#collab-status {
  font-size: 12px;
  color: #888;
  min-height: 16px;
}

#loading-msg {
  font-size: 13px;
  color: #666;
  margin-bottom: 16px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

#piano-scroll {
  margin: 0 auto;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
#piano-scroll::-webkit-scrollbar { height: 7px; }
#piano-scroll::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

#piano-track {
  position: relative;
  overflow: hidden;
}

#piano {
  position: relative;
  display: flex;
  width: 840px;   filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.7));
  user-select: none;
  touch-action: pan-x;
  transition: opacity 0.3s;
  transform-origin: top left;
}

#piano.loading {
  opacity: 0.45;
  pointer-events: none;
}

.key.white {
  width: 60px;
  height: 200px;
  background: linear-gradient(to bottom, #f0f0f0, #ffffff);
  border: 1px solid #aaa;
  border-top: none;
  border-radius: 0 0 6px 6px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1;
  transition: background 0.05s, transform 0.05s;
}

.key.white:hover {
  background: linear-gradient(to bottom, #e8f0ff, #f5f5ff);
}

.key.white.active {
  background: linear-gradient(to bottom, #bfdbfe, #dbeafe);
  transform: translateY(2px);
}

.key.black {
  width: 38px;
  height: 128px;
  background: linear-gradient(to bottom, #222, #000);
  border: 1px solid #000;
  border-top: none;
  border-radius: 0 0 4px 4px;
  position: absolute;
  top: 0;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2;
  transition: background 0.05s;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.key.black:hover {
  background: linear-gradient(to bottom, #3a3a3a, #1a1a1a);
}

.key.black.active {
  background: linear-gradient(to bottom, #1e3a6e, #0f2040);
}

.key.white.remote-active {
  background: var(--remote-color);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.key.black.remote-active {
  background: var(--remote-color);
  box-shadow: 0 0 12px var(--remote-color), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.key-label {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
  pointer-events: none;
}

.key.white .note-name {
  font-size: 10px;
  color: #666;
}

.key.white .key-shortcut {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  background: rgba(0, 0, 0, 0.07);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  padding: 0 4px;
  font-family: monospace;
}

.key.black .note-name {
  font-size: 9px;
  color: #999;
}

.key.black .key-shortcut {
  font-size: 9px;
  font-weight: 600;
  color: #ccc;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  padding: 0 3px;
  font-family: monospace;
}

body.beginner-mode .key-label {
  display: flex;
}

#song-toggle {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}

#song-toggle:hover {
  background: #6d28d9;
  border-color: #6d28d9;
  color: #fff;
}

body.song-open #controls,
body.song-open #collab,
body.song-open #record-panel,
body.song-open #loading-msg {
  display: none !important;
}

body.song-open #piano-scroll,
body.song-open #bass,
body.song-open #drums {
  margin-top: 0;
  margin-bottom: 0;
}
body.song-open { padding: 12px; }
body.song-open header { margin-bottom: 8px; }
body.song-open h1 { font-size: 1.5rem; }
body.song-open .subtitle { display: none; }
body.song-open #song-topbar { margin-bottom: 8px; }
body.song-open #drums { flex-wrap: nowrap; }
body.song-narrow #song-ghosts,
body.song-narrow #song-players { display: none; }
@media (max-height: 520px) {
  body.song-open header { display: none; }
}

#song-title {
  font-size: 14px;
  font-weight: 600;
  color: #a78bfa;
  min-width: 60px;
  text-align: right;
}

#song-list {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 20px 0 40px;
}

.song-card {
  width: 200px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  opacity: 0.55;
}

.song-card.playable {
  opacity: 1;
  border-color: #7c3aed;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.song-card.playable:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
}

.song-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
}

.song-req {
  font-size: 18px;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.song-status {
  font-size: 12px;
  color: #888;
}

.song-card.playable .song-status {
  color: #4ade80;
}

#explore-songs {
  display: block;
  margin: 0 auto 34px;
}

#explore-page {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
#explore-page.open {
  grid-template-rows: 1fr;
}

.explore-inner {
  overflow: hidden;
  min-height: 0;
}

#explore-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  margin-bottom: 10px;
}

#explore-title {
  color: #ddd;
  font-weight: 600;
  font-size: 15px;
}

#explore-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  padding: 4px 0 26px;
}

.song-row {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 16px 20px;
  text-align: left;
}

.song-row .sr-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.song-row .sr-note {
  flex: 0 0 auto;
  font-size: 12px;
  color: #777;
}

.song-row.live {
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.song-row.live:hover {
  background: #23252d;
  border-color: #4a4d57;
}
.song-row.live .sr-note { color: #4ade80; }

.summary-line b { color: #a78bfa; }

.summary-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

#song-again {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}
#song-again:hover { background: #6d28d9; border-color: #6d28d9; color: #fff; }

#song-mode {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#song-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  width: 100%;
  max-width: 520px;
}

#song-hud {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: #999;
}

#song-hud b {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

#song-start {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

#song-start:hover {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}

#song-start:disabled {
  opacity: 0.5;
  cursor: default;
}

#song-highway {
  position: relative;
  height: 300px;
  margin: 0 auto;
  background: linear-gradient(#0a0a0a, #161616);
  border: 1px solid #333;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

#hit-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
  z-index: 3;
  pointer-events: none;
}

.note {
  position: absolute;
  border-radius: 5px;
  background: linear-gradient(#818cf8, #6366f1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  z-index: 2;
  overflow: hidden;   }

.note.note-black { background: linear-gradient(#a78bfa, #7c3aed); }
.note.perfect { background: linear-gradient(#4ade80, #16a34a); }
.note.good    { background: linear-gradient(#fbbf24, #d97706); }
.note.miss    { background: linear-gradient(#6b7280, #374151); opacity: 0.5; }

.note-cover {
  position: absolute;
  left: 0;
  right: 0;
  background: #86efac;     pointer-events: none;
}

#song-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 84px;
  font-weight: 800;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  z-index: 5;
}

#song-summary {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.85);
  z-index: 6;
  text-align: center;
  padding: 20px;
}

#song-summary h2 {
  font-size: 26px;
  margin-bottom: 4px;
}

#song-summary .summary-line {
  font-size: 15px;
  color: #ccc;
}

#song-summary .rank {
  font-size: 44px;
  font-weight: 800;
  margin: 4px 0;
}

#song-players {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

body:not(.song-open) #song-players,
#song-players:empty {
  display: none;
}

#song-ghosts {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}
body:not(.song-open) #song-ghosts,
#song-ghosts:empty {
  display: none;
}
.ghost {
  width: 160px;
}
.ghost-label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #eee;
  margin-bottom: 4px;
  text-transform: capitalize;
}
.ghost-lane {
  position: relative;
  height: 150px;            background: linear-gradient(#0a0a0a, #161616);
  border: 1px solid #333;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
}
.ghost-lane::after {         content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: #e11d48;
  opacity: 0.7;
}
.ghost-note {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  background: #3b82f6;
}
.gn-piano { background: #3b82f6; }
.gn-bass  { background: #a855f7; }
.gn-drums { background: #f59e0b; }

.player-status {
  width: 150px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 10px 12px;
}

.player-status.done {
  border-color: #16a34a;
}

.player-status .ps-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #eee;
  margin-bottom: 8px;
}

.player-status .ps-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.player-status .ps-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #999;
}

.player-status .ps-stats b {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

#song-instruments {
  margin: 0 auto 18px;
  max-width: 640px;
}
.instr-title {
  text-align: center;
  color: #bbb;
  font-size: 14px;
  margin-bottom: 10px;
}
.instr-cols {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.instr-col {
  flex: 1 1 0;
  min-width: 128px;
  background: #1e2230;
  border: 1px solid #2c3242;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.instr-col.mine {
  border-color: #22c55e;
  background: #1c2a22;
}
.instr-col-head {
  font-weight: 700;
  color: #f0f2f6;
  margin-bottom: 8px;
}
.instr-col-players {
  min-height: 46px;
  margin-bottom: 10px;
}
.instr-player {
  font-size: 13px;
  color: #dfe3ea;
  padding: 2px 0;
}
.instr-empty { color: #5a6272; }
.instr-pick {
  width: 100%;
  background: #2b6cb0;
  border: 0;
  border-radius: 8px;
  color: #fff;
  padding: 9px 8px;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
}
.instr-pick:hover { background: #3a7cc0; }
.instr-pick:active { transform: scale(0.97); }
.instr-you {
  color: #22c55e;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 8px;
}

#manual-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: #2b6cb0;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  z-index: 900;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#manual-btn:hover { background: #3a7cc0; }

#lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 950;
}

#lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

#lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 130px;
  background: #1c1c1c;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#lang-menu.hidden { display: none; }

.lang-opt {
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  padding: 8px 12px;
  width: 100%;
}

.lang-opt:hover { background: #2f2f2f; }

.lang-opt.active {
  background: #2563eb;
  border: 0;
  color: #fff;
}

#manual {
  position: fixed;
  right: 20px;
  bottom: 80px;
  width: 560px;
  height: 440px;
  min-width: 300px;
  min-height: 240px;
  max-width: 95vw;
  max-height: 90vh;
  background: #14161c;
  border: 1px solid #2c3242;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 901;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
}
#manual-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1e2230;
  cursor: move;
  user-select: none;
  touch-action: none;
}
#manual-title { font-weight: 700; color: #f0f2f6; }
#manual-close {
  background: transparent;
  border: 0;
  color: #9aa3b2;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
#manual-close:hover { background: #2c3242; color: #fff; }
#manual-body { display: flex; flex: 1; min-height: 0; }
#manual-tabs {
  flex: 0 0 132px;
  background: #10121a;
  border-right: 1px solid #2c3242;
  overflow-y: auto;
  padding: 8px 0;
}
.manual-tab {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  color: #cfd5df;
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}
.manual-tab:hover { background: #1a1d27; }
.manual-tab.active { background: #22283a; color: #fff; border-left-color: #2b6cb0; }
#manual-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  color: #dfe3ea;
  line-height: 1.55;
  font-size: 14px;
}
#manual-content h2 { margin: 0 0 10px; font-size: 18px; color: #fff; }
#manual-content h3 { margin: 16px 0 6px; font-size: 14px; color: #a9b2c2; }
#manual-content p { margin: 8px 0; }
#manual-content ul, #manual-content ol { margin: 6px 0; padding-left: 20px; }
#manual-content li { margin: 4px 0; }
#manual-content kbd {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 12px;
  color: #ddd;
  margin: 0 1px;
}
#manual-content .m-tip {
  margin-top: 14px;
  background: #1c2a22;
  border: 1px solid #2f5a3f;
  border-radius: 8px;
  padding: 8px 12px;
  color: #bfe9cf;
  font-size: 13px;
}
@media (max-width: 640px) {
  #manual { right: 2.5vw; left: 2.5vw; width: 95vw; height: 70vh; }
  #manual-tabs { flex-basis: 108px; }
}

#record-toggle.recording {
  background: #b91c1c;
  color: #fff;
  animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

#record-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 620px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  background: #1e2230;
  border: 1px solid #2c3242;
  border-radius: 12px;
}
#record-panel .rec-title { font-weight: 700; color: #f0f2f6; }
#record-panel audio { height: 34px; max-width: 240px; }
#record-download, #record-share {
  background: #22c55e;
  border: 0;
  border-radius: 8px;
  color: #06210f;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
}
#record-download:hover, #record-share:hover { filter: brightness(1.08); }
#record-dismiss { padding: 6px 10px; }

.hidden { display: none !important; }

/* ---- First-time onboarding ---- */
#manual-restart {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #2a2a2a;
}
#manual-restart-label { font-size: 12px; color: #9aa3b2; }
.manual-restart-btn { font-size: 12px; padding: 6px 10px; }

#onboard {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

#onboard-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: auto;
}

#onboard-spot {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.62);
  outline: 3px solid #a78bfa;
  outline-offset: 2px;
  pointer-events: none;
  z-index: 1001;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}

#onboard-pop {
  position: fixed;
  z-index: 1002;
  width: min(360px, calc(100vw - 24px));
  background: #17181d;
  color: #f2f2f2;
  border: 1px solid #34363f;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}
#onboard-pop.centered {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#onboard-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.onb-dots { display: flex; gap: 6px; }
.onb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a3d45;
}
.onb-dot.done { background: #7c3aed; }
.onb-dot.current {
  background: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}
.onb-steplabel { font-size: 12px; color: #9aa3b2; }

#onboard-title { font-size: 19px; margin-bottom: 6px; }
#onboard-body { font-size: 14px; color: #cfd2da; line-height: 1.5; }
.onb-line { display: block; }
.onb-line + .onb-line { margin-top: 8px; }
.onb-prompt { margin-top: 14px !important; font-weight: 600; color: #f2f2f2; white-space: pre-line; }

#onboard-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 2px;
}
.onb-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 16px 12px;
  background: #1e2029;
  border: 1px solid #34363f;
  border-radius: 12px;
  cursor: pointer;
  color: #f2f2f2;
}
.onb-choice:hover, .onb-choice:focus-visible {
  border-color: #7c3aed;
  background: #242634;
}
.onb-choice .onb-emoji { font-size: 28px; }
.onb-choice .onb-name { font-weight: 700; font-size: 14px; }
.onb-choice .onb-desc { font-size: 12px; color: #9aa3b2; }

#onboard-choices.two { grid-template-columns: repeat(2, 1fr); }

#onboard-songnote {
  margin-top: 14px;
  padding: 10px 12px;
  background: #201b2e;
  border: 1px solid #4a3a6b;
  border-radius: 10px;
  font-size: 12.5px;
  color: #cdb9f0;
  line-height: 1.45;
}

#onboard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}
#onboard-nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
#onboard-next {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
}
#onboard-next:hover { background: #6d28d9; border-color: #6d28d9; color: #fff; }
.onboard-link {
  background: none;
  border: none;
  color: #8a8f99;
  text-decoration: underline;
  padding: 6px 2px;
  font-size: 12px;
  cursor: pointer;
}
.onboard-link:hover { color: #ccc; }

#onboard-pop.docked {
  top: 12px;
  right: 12px;
  left: auto;
  width: min(300px, calc(100vw - 24px));
  padding: 14px;
}
#onboard-pop.docked {
  border: 2px solid #a78bfa;
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.25), 0 18px 50px rgba(0, 0, 0, 0.55);
  animation: onb-pulse 1.4s ease-in-out 3;
}
@keyframes onb-pulse {
  50% { box-shadow: 0 0 0 10px rgba(167, 139, 250, 0.35), 0 18px 50px rgba(0, 0, 0, 0.55); }
}
#onboard-pop.docked #onboard-title { font-size: 16px; }
#onboard-pop.docked #onboard-body { font-size: 13px; }
#onboard-pop.docked #onboard-foot { margin-top: 12px; }

body.song-demo #song-hud { visibility: hidden; }

@media (max-width: 520px) {
  #onboard-choices { grid-template-columns: 1fr; }
  #onboard-pop { width: calc(100vw - 20px); }
  #onboard-pop.docked { top: auto; bottom: 10px; right: 10px; }
}

#piano-scroll, #bass, #drums, #song-highway, #song-ghosts {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.instr-tip {
  margin-top: 10px;
  font-size: 12.5px;
  color: #cdb9f0;
  text-align: center;
  line-height: 1.45;
}
#onboard-body { white-space: pre-line; }

body.onb-song-tour #song-mode * { pointer-events: none; }
body.onb-song-tour #song-back { pointer-events: auto; }

.diff {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  white-space: nowrap;
}
.diff-1 { background: rgba(74, 222, 128, 0.16); color: #4ade80; }
.diff-2 { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
.diff-3 { background: rgba(248, 113, 113, 0.16); color: #f87171; }
