:root {
  --bg: #06060f;
  --ink: #f4ecd8;
  --flame: #ffb347;
  --flame-hot: #ffe08a;
  --accent: #7fd4ff;
  --danger: #ff5a5a;
  --panel: rgba(12, 12, 24, 0.86);
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Square, letterboxed play area (SPEC §2.9). JS sets its px size. */
#stage {
  position: relative;
  width: 100vmin;
  height: 100vmin;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

.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;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none; /* clicks pass through to the arena... */
  padding: clamp(8px, 2.2vmin, 20px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.hud-cluster {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hud-cluster.center {
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat {
  font-size: clamp(15px, 2.8vmin, 22px);
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}

.stat.small {
  font-size: clamp(11px, 2vmin, 15px);
  opacity: 0.8;
}

#flames {
  color: var(--flame);
  filter: drop-shadow(0 0 8px rgba(255, 179, 71, 0.55));
}

.stat.score .cap {
  font-size: 0.55em;
  letter-spacing: 0.25em;
  opacity: 0.65;
}

.stat.mult {
  color: var(--accent);
  font-weight: bold;
}

.icon-btn {
  pointer-events: auto; /* ...but the controls themselves are clickable */
  min-width: 44px;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--ink);
  border-radius: 12px;
  font-size: clamp(14px, 2.6vmin, 18px);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.muted {
  opacity: 0.5;
}

.hud-bottom {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.meter {
  position: relative;
  flex: 1;
  height: clamp(16px, 2.6vmin, 22px);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  overflow: hidden;
}

.meter.recharge {
  flex: 0 0 32%;
  max-width: 220px;
}

.meter-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #1b2a5e, #7fb2ff, #ffe08a);
  transition: transform 0.08s linear;
}

.recharge .meter-fill {
  background: linear-gradient(90deg, #6a4b1f, var(--flame));
}

.recharge.ready .meter-fill {
  background: linear-gradient(90deg, var(--flame), var(--flame-hot));
}

.meter-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 1.5vmin, 11px);
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10, 10, 20, 0.55), rgba(6, 6, 14, 0.92));
  backdrop-filter: blur(2px);
  padding: 16px;
  z-index: 10;
}

.panel {
  width: min(540px, 94%);
  max-height: 96%;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: clamp(20px, 4.5vmin, 38px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 60px rgba(255, 179, 71, 0.08);
}

.title {
  font-size: clamp(38px, 11vmin, 72px);
  letter-spacing: 0.22em;
  color: var(--flame-hot);
  text-shadow: 0 0 24px rgba(255, 179, 71, 0.55), 0 0 60px rgba(255, 179, 71, 0.25);
  margin-left: 0.22em;
}

.tagline {
  margin-top: 6px;
  opacity: 0.8;
  letter-spacing: 0.12em;
  font-size: clamp(12px, 2.4vmin, 16px);
}

.screen {
  margin-top: clamp(14px, 3.5vmin, 26px);
}

.how {
  font-size: clamp(12px, 2.3vmin, 15px);
  line-height: 1.6;
  opacity: 0.9;
  max-width: 46ch;
  margin: 0 auto;
}

.how-goal {
  margin-top: 10px;
  color: var(--flame);
}

.how strong {
  color: var(--flame-hot);
  font-weight: 600;
}

.controls-note {
  margin-top: 14px;
  font-size: clamp(11px, 2vmin, 13px);
  opacity: 0.7;
  letter-spacing: 0.04em;
}

kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.95em;
}

.best {
  margin-top: 14px;
  letter-spacing: 0.15em;
  opacity: 0.75;
  font-size: clamp(12px, 2.2vmin, 15px);
}

.btn {
  margin-top: 20px;
  pointer-events: auto;
  min-height: 44px;
  background: linear-gradient(180deg, var(--flame), #e8933a);
  color: #1a1206;
  border: none;
  padding: clamp(12px, 2.4vmin, 16px) clamp(22px, 5vmin, 34px);
  font-size: clamp(15px, 2.8vmin, 19px);
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.15s ease;
  box-shadow: 0 8px 24px rgba(255, 179, 71, 0.28);
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 32px rgba(255, 179, 71, 0.4);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.end-title {
  font-size: clamp(24px, 6.5vmin, 42px);
  letter-spacing: 0.08em;
}

.end-title.win {
  color: var(--flame-hot);
  text-shadow: 0 0 24px rgba(255, 224, 138, 0.5);
}

.end-title.lose {
  color: var(--danger);
  text-shadow: 0 0 24px rgba(255, 90, 90, 0.4);
}

.end-sub {
  margin-top: 8px;
  opacity: 0.82;
  font-size: clamp(12px, 2.4vmin, 16px);
  min-height: 1.2em;
}

.scores {
  display: flex;
  justify-content: center;
  gap: clamp(24px, 8vmin, 60px);
  margin-top: 20px;
}

.scores > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scores .cap {
  font-size: 0.7em;
  letter-spacing: 0.25em;
  opacity: 0.6;
}

.scores span:last-child {
  font-size: clamp(26px, 6vmin, 40px);
  font-variant-numeric: tabular-nums;
}

.hint {
  margin-top: 22px;
  font-size: clamp(10px, 1.9vmin, 12px);
  letter-spacing: 0.14em;
  opacity: 0.4;
}

/* ---------- Focus visibility (a11y) ---------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
