:root {
  --bg: #05040b;
  --ink: #ece8ff;
  --muted: #8d86b8;
  --line: rgba(160, 150, 255, 0.14);
  --teal: #2ef2c8;
  --violet: #8b6bff;
  --magenta: #ff4fd8;
  --amber: #ffb547;
  --display: "Syne", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(46, 242, 200, 0.07), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(255, 79, 216, 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  width: min(100%, calc(100dvh - 150px), 720px);
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* HUD */
.hud {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(20px, 4vw, 28px);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand em {
  font-style: normal;
  background: linear-gradient(90deg, var(--teal), var(--violet) 55%, var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-mark {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber), 0 0 28px rgba(255, 181, 71, 0.5);
  animation: pulse 2.2s ease-in-out infinite;
}

.stats { display: flex; gap: 22px; }
.stat { display: flex; flex-direction: column; gap: 2px; position: relative; min-width: 48px; }
.stat .label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat output {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat.combo output { color: var(--teal); transition: transform .15s; }
.stat.combo output.bump { transform: scale(1.25); }
.stat.combo::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  height: 2px;
  width: calc(var(--drain, 0) * 100%);
  background: linear-gradient(90deg, var(--teal), var(--magenta));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--teal);
}

/* Board */
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow:
    0 0 0 6px rgba(139, 107, 255, 0.04),
    0 30px 80px -20px rgba(139, 107, 255, 0.35),
    inset 0 0 60px rgba(0, 0, 0, 0.6);
  touch-action: none;
}
canvas { display: block; width: 100%; height: 100%; }

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px;
  background: radial-gradient(circle at 50% 45%, rgba(10, 8, 24, 0.55), rgba(5, 4, 11, 0.86));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity .35s ease, visibility .35s;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.kicker {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--amber);
}
.overlay h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(36px, 9vw, 72px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, var(--teal), var(--violet) 50%, var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(139, 107, 255, 0.35));
}
.ov-text {
  max-width: 36ch;
  font-size: 13px;
  line-height: 1.6;
  color: #bdb6e6;
}

#ov-btn {
  margin-top: 6px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: var(--bg);
  padding: 12px 34px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(100deg, var(--teal), var(--violet) 55%, var(--magenta));
  box-shadow: 0 8px 30px -6px rgba(255, 79, 216, 0.55), 0 0 0 1px rgba(255,255,255,0.15) inset;
  transition: transform .15s ease, box-shadow .2s ease;
}
#ov-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 36px -6px rgba(46, 242, 200, 0.55); }
#ov-btn:active { transform: translateY(0) scale(.97); }
#ov-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  margin: 0 1px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--ink);
  background: rgba(255,255,255,0.03);
}
.touch-hint { display: none; }
@media (hover: none) and (pointer: coarse) {
  .keys span:not(.touch-hint) { display: none; }
  .touch-hint { display: inline; }
}

/* Footer */
.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.ghost {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.ghost:hover { color: var(--ink); border-color: rgba(160,150,255,.35); }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.75); opacity: .7; }
}

@media (max-width: 480px) {
  body { padding: 12px; }
  .stats { gap: 16px; }
  .stat output { font-size: 18px; }
  .foot span { display: none; }
  .foot { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .brand-mark { animation: none; }
}
