:root {
  color-scheme: dark;
  --ink: #fff6ee;
  --muted: #e7cbb8;
  --gold: #f0c36a;
  --coral: #ff5d4a;
  --panel: rgba(36, 12, 20, 0.88);
  --edge: rgba(240, 195, 106, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1a0b12; color: var(--ink); font-family: var(--font); }
body { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
button, canvas { font-family: inherit; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { 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: 76px; padding: 6px 10px; border-radius: 12px;
  background: rgba(28, 10, 16, 0.72); border: 1px solid var(--edge); text-align: center;
}
#hud span { display: block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#hud b { font-size: 18px; }

.icon {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(28, 10, 16, 0.72); 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; }
#topbar { position: fixed; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 6; }
body:not(.playing) #pauseBtn { display: none; }

.overlay {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(16, 6, 10, 0.42); overflow: auto;
}
.overlay[hidden] { display: none !important; }
.panel {
  width: min(440px, 100%); background: var(--panel); border: 1px solid var(--edge);
  border-radius: 22px; padding: 22px 22px 16px; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
h1 {
  margin: 0; font-size: clamp(42px, 10vw, 68px); line-height: 0.95; letter-spacing: -1px;
  background: linear-gradient(100deg, #ffe7bf, #f0c36a 40%, #ff5d4a);
  -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 22px; margin: 4px; font-weight: 800; font-size: 16px;
}
.btn.primary { background: linear-gradient(100deg, #ffe0a8, #f0c36a 45%, #ff7a5c); color: #3a160f; min-width: 160px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--edge); }
.stats, .cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.card { background: rgba(255, 244, 232, 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: 20px; 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.6; }
.howto b { color: var(--ink); }
kbd { border: 1px solid var(--edge); border-radius: 5px; padding: 0 5px; font-size: 12px; }
.pad {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 6; display: none;
  grid-template-columns: 58px 58px 58px; grid-template-areas: ". up ." "left down right"; gap: 6px;
}
.pad button {
  height: 54px; border-radius: 14px; border: 1px solid var(--edge);
  background: rgba(28, 10, 16, 0.8); color: var(--ink); font-size: 20px;
}
.pad .up { grid-area: up; }
.pad .left { grid-area: left; }
.pad .down { grid-area: down; }
.pad .right { grid-area: right; }
@media (pointer: coarse) {
  body.playing .pad { display: grid; }
}
.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; }
  .btn.primary { width: calc(100% - 8px); }
  .stats, .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #hud b { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
