:root {
  color-scheme: dark;
  --ink: #f6f1e6;
  --muted: #d9d0e4;
  --gold: #e7c36a;
  --panel: rgba(28, 22, 48, 0.92);
  --edge: rgba(231, 195, 106, 0.4);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1a1430; color: var(--ink); font-family: var(--font); }
body { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
#hud {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 4; pointer-events: none;
}
#hud[hidden] { display: none; }
#hud div {
  min-width: 78px; padding: 6px 10px; border-radius: 12px; text-align: center;
  background: rgba(20, 14, 36, 0.78); border: 1px solid var(--edge);
}
#hud span { display: block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#hud b { font-size: 18px; }
#topbar { position: fixed; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 6; }
.icon {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(20, 14, 36, 0.78); color: var(--ink); display: grid; place-items: center; padding: 0;
}
.icon svg { width: 20px; height: 20px; }
#muteBtn.muted .on, #muteBtn:not(.muted) .off { display: none; }
body:not(.playing) #pauseBtn { display: none; }
#pad {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 6;
  width: min(540px, calc(100% - 16px)); display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
#pad[hidden] { display: none !important; }
#pad button {
  width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(250, 244, 230, 0.92); color: #241833; font-weight: 800; font-size: 18px;
}
#pad button.on { background: #e7c36a; }
#pad #noteBtn, #pad #eraseBtn { width: auto; min-width: 76px; padding: 0 14px; }
.overlay {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(12, 8, 24, 0.45); overflow: auto;
}
.overlay[hidden] { display: none !important; }
.panel {
  width: min(460px, 100%); background: var(--panel); border: 1px solid var(--edge);
  border-radius: 22px; padding: 22px 22px 16px; text-align: center;
}
h1 {
  margin: 0; font-size: clamp(42px, 10vw, 64px); line-height: 0.95;
  background: linear-gradient(100deg, #f6f1e6, #e7c36a 50%, #b9a6e8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { margin: 0 0 6px; font-size: 30px; }
.tag, .sub { color: var(--muted); margin: 8px 0 14px; font-size: 15px; }
.btn { border: 0; border-radius: 999px; padding: 12px 18px; margin: 4px; font-weight: 800; font-size: 16px; }
.btn.primary { background: linear-gradient(100deg, #f3e2b0, #e7c36a); color: #2a2212; min-width: 150px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--edge); }
.choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.cards, .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.card { background: rgba(246, 241, 230, 0.05); border: 1px solid var(--edge); border-radius: 12px; padding: 8px; }
.card .k { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card .v { font-size: 16px; font-weight: 800; margin-top: 2px; }
.howto { list-style: none; padding: 0; margin: 12px 0 0; text-align: left; color: var(--muted); font-size: 13px; line-height: 1.55; }
.howto b { color: var(--ink); }
kbd { border: 1px solid var(--edge); border-radius: 5px; padding: 0 5px; font-size: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (max-width: 420px) {
  .panel { padding: 16px 14px; }
  .cards, .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #pad button { width: 40px; height: 40px; }
  .btn.ghost, .btn.primary { width: calc(100% - 8px); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
