:root {
  --bg: #0a0b12;
  --bg2: #12152400;
  --ink: #eef2fb;
  --muted: #9aa3bd;
  --accent: #6ea8fe;
  --accent2: #b58cff;
  --hot: #ff7a59;
  --ok: #43d17a;
  --perfect: #ffd34e;
  --white-note: #6ea8fe;
  --black-note: #b58cff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(60% 50% at 50% -10%, rgba(110,168,254,.18), transparent 60%),
    radial-gradient(50% 50% at 90% 10%, rgba(181,140,255,.14), transparent 60%),
    var(--bg);
  user-select: none;
}

/* ---- screens ---- */
.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }
#game.active, #results.active, #menu.active { display: block; }

.menu-inner {
  max-width: 760px; margin: 0 auto; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px; text-align: center; overflow-y: auto;
}

.logo {
  font-size: clamp(40px, 9vw, 78px); font-weight: 800; letter-spacing: -.02em;
  margin: 0; line-height: 1;
  background: linear-gradient(120deg, #fff, #9fc0ff 50%, var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 30px rgba(110,168,254,.35));
}
.logo span { color: var(--accent2); -webkit-text-fill-color: var(--accent2); }
.tagline { color: var(--muted); margin: 0; max-width: 46ch; line-height: 1.5; }

.streak { min-height: 22px; font-weight: 600; color: var(--hot); letter-spacing: .02em; }

.panel { width: 100%; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); margin: 0 0 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile {
  border: 1px solid rgba(255,255,255,.1); border-radius: 16px; padding: 18px 16px;
  background: rgba(255,255,255,.03); cursor: pointer; transition: .15s; text-align: left;
  display: flex; flex-direction: column; gap: 6px;
}
.tile:hover { border-color: rgba(110,168,254,.5); transform: translateY(-2px); background: rgba(110,168,254,.08); }
.tile.sel { border-color: var(--accent); background: rgba(110,168,254,.14); box-shadow: 0 8px 30px rgba(110,168,254,.2); }
.tile .ic { font-size: 26px; }
.tile .t { font-weight: 700; }
.tile .m { font-size: 12px; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; padding: 10px 22px; cursor: pointer;
  font: inherit; font-weight: 600; transition: .15s;
}
.seg button.active { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #0a0b12; }

.cta {
  margin-top: 6px; border: 0; border-radius: 14px; padding: 16px 40px; cursor: pointer;
  font: inherit; font-weight: 800; font-size: 18px; color: #07101f;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  box-shadow: 0 12px 40px rgba(110,168,254,.35); transition: .15s;
}
.cta:hover { transform: translateY(-2px); filter: brightness(1.06); }
.cta:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); transform: none; }

.ghost { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); color: var(--ink);
  border-radius: 12px; padding: 12px 22px; cursor: pointer; font: inherit; font-weight: 600; transition: .15s; }
.ghost:hover { background: rgba(255,255,255,.12); }

.midi { font-size: 13px; color: var(--muted); }
.midi.on { color: var(--ok); }
.hint { font-size: 12px; color: #6c7494; max-width: 50ch; line-height: 1.5; }

/* ---- game ---- */
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 24px; pointer-events: none;
}
.hud .ghost { pointer-events: auto; }
.hud-left, .hud-right { display: flex; flex-direction: column; }
.hud-right { align-items: flex-end; gap: 8px; }
.score, .acc { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.acc { font-size: 26px; }
.score-label { font-size: 10px; letter-spacing: .2em; color: var(--muted); margin-top: 4px; }
.hud-mid { flex: 1; text-align: center; }
.combo { font-size: 30px; font-weight: 900; color: var(--perfect); letter-spacing: .04em;
  text-shadow: 0 0 30px rgba(255,211,78,.6); transition: transform .08s; min-height: 36px; }

.countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 22vh; font-weight: 900; color: #fff; pointer-events: none;
  text-shadow: 0 0 60px rgba(110,168,254,.6); z-index: 6;
}
.countdown:not(:empty) { animation: cdpop .7s ease forwards; }
@keyframes cdpop {
  0% { transform: scale(.4); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* ---- results ---- */
.result-title { font-size: clamp(36px, 8vw, 64px); margin: 0;
  background: linear-gradient(120deg, #fff, var(--perfect)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats { display: flex; gap: 28px; margin: 6px 0; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat span { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat label { font-size: 11px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.breakdown { color: var(--muted); font-size: 14px; }
.breakdown b { color: var(--ink); }
.best { color: var(--perfect); font-weight: 600; min-height: 20px; }
.result-actions { display: flex; gap: 12px; margin-top: 8px; }
