:root {
  --bg: #070d12;
  --panel: #0d1821;
  --border: #1e3346;
  --gold: #ffd166;
  --text: #f1f5f9;
  --muted: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #0f1f2c 0%, var(--bg) 75%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.stage {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
}

.hud {
  width: min(540px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(13, 24, 33, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat strong {
  font-size: 16px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.lives {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-height: 18px;
}

.life-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: conic-gradient(from 35deg, transparent 0 70deg, var(--gold) 70deg 360deg);
}

.icon-btn {
  background: #132433;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--gold); }

.board-wrap {
  position: relative;
  width: min(525px, 92vw, 68dvh);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

canvas#board {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 12px;
  border: 2px solid #1d3557;
  background: #050a0f;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 10, 15, 0.78);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 16px;
}

.overlay.hidden { display: none; }

.card {
  max-width: 340px;
  text-align: center;
  background: #0d1821;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--gold);
  font-weight: 700;
}

.card h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.card p {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.45;
  color: #cbd5e1;
}

.primary-btn {
  background: var(--gold);
  color: #091118;
  border: 0;
  border-radius: 9px;
  padding: 11px 28px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn:hover { filter: brightness(1.06); }

.hint {
  margin-top: 12px !important;
  margin-bottom: 0 !important;
  font-size: 12px !important;
  color: var(--muted) !important;
}

.dpad {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 44px);
  gap: 6px;
}

.pad {
  background: #102130;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}

.pad:active { background: #1c3a52; border-color: var(--gold); }
.pad.up { grid-column: 2; grid-row: 1; }
.pad.left { grid-column: 1; grid-row: 2; }
.pad.down { grid-column: 2; grid-row: 2; }
.pad.right { grid-column: 3; grid-row: 2; }

@media (pointer: coarse), (max-width: 720px) {
  .dpad { display: grid; }
  .board-wrap { width: min(460px, 94vw, 56dvh); }
}
