:root {
  --bg: #0a0a14;
  --bg-2: #14142a;
  --fg: #f4f4ff;
  --muted: #8a8aa8;
  --neon: #00ffd1;
  --neon-2: #ff00e6;
  --hit: #ff3860;
  --good: #00ff88;
  --warn: #ffcc00;
  --tile: #0a0a14;
  --lane-bg: #fafaff;
  --lane-line: #d0d0e0;
  --card: rgba(18,18,40,0.96);
}
:root.colorblind {
  --neon: #00bfff;
  --neon-2: #ffaa00;
  --good: #ffffff;
  --hit: #ff7700;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; width: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; }

#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  background: var(--bg); touch-action: none; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,20,42,0.6), rgba(10,10,20,0.95));
  z-index: 10; padding: 16px; overflow-y: auto; }
.overlay.hidden, .hidden { display: none !important; }

.menu-card { width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid rgba(0,255,209,0.25); border-radius: 18px; padding: 24px;
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  box-shadow: 0 0 40px rgba(0,255,209,0.15), 0 10px 40px rgba(0,0,0,0.5);
  max-height: 92vh; overflow-y: auto; }
.menu-card.narrow { max-width: 320px; align-items: center; text-align: center; }

.logo { font-size: 56px; line-height: 0.9; font-weight: 900; letter-spacing: 2px; text-align: center;
  color: var(--fg); text-shadow: 0 0 12px var(--neon), 0 0 22px var(--neon-2); margin: 8px 0; }
h2 { font-size: 22px; letter-spacing: 1px; text-align: center; margin-bottom: 4px;
  color: var(--neon); text-shadow: 0 0 8px rgba(0,255,209,0.6); }
.tag { text-align: center; color: var(--muted); margin-bottom: 10px; }
.small { font-size: 12px; color: var(--muted); }

.btn { display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.04); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 12px;
  padding: 14px 16px; font-size: 16px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; transition: transform .08s, background .15s, border-color .15s;
  font-family: inherit; }
.btn:hover, .btn:focus { background: rgba(0,255,209,0.10); border-color: var(--neon); outline: none; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, var(--neon), var(--neon-2));
  color: #0a0a14; border-color: transparent; text-shadow: none; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.15); }
.btn.danger { color: var(--hit); border-color: rgba(255,56,96,0.4); }
.btn span { font-weight: 400; font-size: 12px; color: var(--muted); }
.btn.primary span { color: rgba(10,10,20,0.7); }

.menu-nav, .mode-list, .settings-list, .song-list { display: flex; flex-direction: column; gap: 8px; }
.mode-btn { text-align: left; align-items: flex-start; }

.daily { margin-top: 8px; padding: 10px; border-radius: 10px;
  background: linear-gradient(135deg, rgba(255,0,230,0.15), rgba(0,255,209,0.15));
  border: 1px dashed var(--neon-2); font-size: 13px; text-align: center; }

.song-row { display: flex; align-items: center; gap: 10px; padding: 12px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px; cursor: pointer; font-family: inherit; color: var(--fg);
  text-align: left; }
.song-row:hover, .song-row:focus { border-color: var(--neon); outline: none; }
.song-row.locked { opacity: 0.5; cursor: not-allowed; }
.song-row .info { flex: 1; }
.song-row .title { font-weight: 700; font-size: 16px; }
.song-row .meta { font-size: 12px; color: var(--muted); }
.song-row .best { font-size: 12px; color: var(--neon); }
.song-row .preview-btn { background: transparent; border: 1px solid var(--neon);
  color: var(--neon); border-radius: 50%; width: 36px; height: 36px;
  font-family: inherit; cursor: pointer; font-size: 14px; }

.lb-tabs { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.lb-tab { padding: 6px 10px; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 8px;
  font-family: inherit; color: var(--muted); cursor: pointer; font-size: 12px; }
.lb-tab.active { color: var(--neon); border-color: var(--neon); }
.lb-list { list-style: none; padding: 0; max-height: 50vh; overflow-y: auto; }
.lb-list li { display: grid; grid-template-columns: 32px 1fr auto auto;
  gap: 6px; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 14px; }
.lb-list .rank { color: var(--muted); }
.lb-list .name { font-weight: 700; }
.lb-list .acc { color: var(--muted); font-size: 12px; }
.lb-empty { text-align: center; color: var(--muted); padding: 24px; }

.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 4px; font-size: 14px; }
.setting-row input[type=range] { flex: 1; max-width: 60%; }
.setting-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--neon); }
.calibrate-status { font-size: 12px; color: var(--muted); text-align: center; min-height: 16px; }

.howto-list { list-style: none; padding: 0; }
.howto-list li { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 14px; }

#nameInput { font-size: 36px; text-align: center; letter-spacing: 12px; padding: 12px;
  width: 100%; text-transform: uppercase; background: rgba(255,255,255,0.06);
  color: var(--fg); border: 2px solid var(--neon); border-radius: 12px;
  font-family: inherit; font-weight: 900; }
.score-big { font-size: 48px; font-weight: 900; color: var(--neon);
  text-shadow: 0 0 12px var(--neon); margin: 8px 0; }

.go-stats { display: flex; flex-direction: column; gap: 6px; width: 100%; margin: 10px 0; }
.go-stats > div { display: flex; justify-content: space-between; padding: 8px 12px;
  background: rgba(255,255,255,0.04); border-radius: 8px; }
.go-stats .lbl { color: var(--muted); font-size: 13px; }

/* HUD */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.hud-top { position: absolute; top: 12px; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 16px; }
.hud-bottom { position: absolute; bottom: 12px; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 16px; }
.icon-btn { pointer-events: auto; background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2); color: var(--fg);
  font-family: inherit; font-weight: 900; font-size: 14px;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.combo { font-size: 48px; font-weight: 900; color: var(--neon);
  text-shadow: 0 0 12px var(--neon); transition: transform 0.1s; pointer-events: none; }
.score { font-size: 22px; font-weight: 700; color: var(--fg);
  text-shadow: 0 0 6px rgba(0,0,0,0.8); pointer-events: none; min-width: 60px; text-align: right; }
.acc { font-size: 14px; color: var(--muted); pointer-events: none; }
.timer { font-size: 18px; color: var(--warn); font-weight: 700; pointer-events: none; }

.toast { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: var(--fg); padding: 10px 18px;
  border-radius: 20px; font-size: 13px; z-index: 100;
  border: 1px solid var(--neon); }

@media (min-width: 900px) {
  .menu-card { max-width: 480px; }
  .logo { font-size: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

/* ===== LIGHT THEME =====
 * Neon accents kept (they read fine on warm off-white). Only adjust the
 * surrounding UI surfaces, not the in-canvas falling-tile colors.
 */
:root[data-theme="light"] {
  --bg: #f6f6fb;
  --bg-2: #e9ebf5;
  --fg: #15192e;
  --muted: #5b6280;
  --card: rgba(255, 255, 255, 0.96);
}
:root[data-theme="light"] body { background: var(--bg); color: var(--fg); }
:root[data-theme="light"] .overlay {
  background: radial-gradient(ellipse at center, rgba(233,235,245,0.65), rgba(246,246,251,0.95));
}
:root[data-theme="light"] .menu-card {
  background: #ffffff;
  border-color: rgba(0, 200, 168, 0.35);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 10px 40px rgba(15,18,40,0.10);
}
:root[data-theme="light"] .logo { color: #15192e; text-shadow: 0 0 8px var(--neon); }
:root[data-theme="light"] .btn {
  background: rgba(15, 18, 40, 0.04);
  color: #15192e;
  border-color: rgba(15, 18, 40, 0.12);
}
:root[data-theme="light"] .btn:hover, :root[data-theme="light"] .btn:focus {
  background: rgba(0, 200, 168, 0.10);
}
:root[data-theme="light"] .btn.ghost { background: transparent; border-color: rgba(15,18,40,0.15); }
:root[data-theme="light"] .btn span { color: #5b6280; }
:root[data-theme="light"] .song-row {
  background: rgba(15, 18, 40, 0.04);
  border-color: rgba(15, 18, 40, 0.10);
  color: #15192e;
}
:root[data-theme="light"] .toast { background: rgba(15, 18, 40, 0.9); color: #fff; }
:root[data-theme="light"] .hud-top .icon-btn { background: rgba(255,255,255,0.85); color: #15192e; }
:root[data-theme="light"] .score { color: #15192e; text-shadow: 0 0 6px rgba(255,255,255,0.7); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f6fb;
    --bg-2: #e9ebf5;
    --fg: #15192e;
    --muted: #5b6280;
    --card: rgba(255, 255, 255, 0.96);
  }
  :root:not([data-theme="dark"]) body { background: var(--bg); color: var(--fg); }
  :root:not([data-theme="dark"]) .menu-card { background: #ffffff; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
  :root:not([data-theme="dark"]) .btn { background: rgba(15, 18, 40, 0.04); color: #15192e; border-color: rgba(15, 18, 40, 0.12); }
  :root:not([data-theme="dark"]) .song-row { background: rgba(15, 18, 40, 0.04); border-color: rgba(15, 18, 40, 0.10); color: #15192e; }
}
