:root {
  --bg: #0d0d1a;
  --panel: #13132a;
  --grid: #252550;
  --accent: #a78bfa;
  --accent2: #f472b6;
  --text: #e2e8f0;
  --muted: #64748b;
  --hit-line: #f472b6;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.board {
  position: relative;
  width: min(94vw, calc(82vh * 3 / 4));
  aspect-ratio: 3 / 4;
  max-height: 82vh;
  border: 2px solid var(--grid);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, #0d0d2e 0%, #130d26 60%, #0d0d1a 100%);
}

.wrap:fullscreen,
.wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  padding: 0;
  gap: 0;
}
.wrap:fullscreen .board,
.wrap:-webkit-full-screen .board {
  width: min(100vw, calc(100vh * 3 / 4));
  max-height: 100vh;
  border-radius: 0;
  border: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* HUD bar */
.bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  pointer-events: none;
  z-index: 10;
  background: linear-gradient(180deg, rgba(13,13,26,.85) 0%, transparent 100%);
}

.bar h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.scores { display: flex; align-items: center; gap: 8px; }
.score { font-size: 12px; color: var(--muted); }
.score strong { color: var(--text); margin-left: 3px; }

.mute {
  pointer-events: auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(19, 19, 42, 0.75);
  border: 1px solid var(--grid);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px; line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
  text-decoration: none;
}
.mute:hover { border-color: var(--accent); }

/* Screens (overlays inside .board) */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 16px 16px;
  z-index: 5;
  background: linear-gradient(180deg, rgba(13,13,26,.97) 0%, rgba(13,13,42,.97) 100%);
}

.screen.hidden { display: none; }

.screen-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.5px;
}

/* Character grid */
.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}

.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border: 2px solid var(--grid);
  border-radius: 10px;
  cursor: pointer;
  background: var(--panel);
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.char-card:hover { border-color: var(--accent); }
.char-card.selected { border-color: var(--accent2); background: rgba(244,114,182,.12); }

.char-canvas {
  width: 54px;
  height: 66px;
  display: block;
}

.char-name {
  font-size: 9px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}

/* Song list */
.song-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  overflow-y: auto;
  max-height: 65%;
}

.song-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--grid);
  border-radius: 10px;
  cursor: pointer;
  background: var(--panel);
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.song-item:hover { border-color: var(--accent); }
.song-item.selected { border-color: var(--accent2); background: rgba(244,114,182,.12); }

.song-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-kids    { background: #1d4ed8; color: #fff; }
.badge-rock    { background: #b91c1c; color: #fff; }
.badge-pop     { background: #be185d; color: #fff; }
.badge-calming { background: #065f46; color: #d1fae5; }

.song-title { font-size: 13px; font-weight: 600; }
.song-diff  { font-size: 10px; color: var(--muted); margin-left: auto; }

/* Play button */
.btn-play {
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity .15s, transform .1s;
  flex-shrink: 0;
}
.btn-play:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-play:not(:disabled):hover { opacity: 0.9; transform: scale(1.03); }

/* Song announcement */
.announce {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 8;
  background: rgba(13,13,26,.92);
  pointer-events: none;
}
.announce.hidden { display: none; }
#ann-title { font-size: 22px; font-weight: 800; color: var(--accent); text-align: center; }
#ann-sub   { font-size: 14px; color: var(--text); text-align: center; }

/* Game over overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 7;
  background: rgba(13,13,26,.88);
}
.overlay.hidden { display: none; }
#ov-title { font-size: 26px; font-weight: 800; color: var(--accent2); }
#ov-sub   { font-size: 14px; color: var(--text); text-align: center; max-width: 220px; }

.foot {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.5;
}
