:root {
  --red: #ee1f27;
  --red-dark: #c4141b;
  --blue: #2b3990;
  --ink: #141414;
  --paper: #faf6ef;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Jost", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;         /* no pull-to-refresh / bounce */
  background: var(--ink);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Full viewport on phones, a sensible column on desktop. */
.stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  touch-action: none;                /* no scroll, zoom or double-tap delay */
  cursor: pointer;
}
@media (min-width: 520px) {
  .stage { box-shadow: 0 0 0 1px #2a2a2a, 0 30px 80px rgba(0, 0, 0, .5); }
}

canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* HUD */
.hud {
  position: absolute; inset: 0 0 auto 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
  z-index: 2;
}
.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(250, 246, 239, .85); border: 2px solid var(--ink); color: var(--ink);
  cursor: pointer; padding: 0;
  touch-action: manipulation;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:focus-visible, .btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
#mute .ico-on { display: none; }
#mute[aria-pressed="true"] .ico-on { display: block; }
#mute[aria-pressed="true"] .ico-off { display: none; }

.score {
  font: 800 clamp(2.6rem, 12vw, 3.6rem)/1 var(--serif);
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--ink);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* Overlays */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  z-index: 1;
}
.overlay[hidden] { display: none; }
.overlay--start { pointer-events: none; justify-content: flex-start; padding-top: max(13vh, 80px); }   /* taps go straight to the game */
.title {
  margin: 0 0 18px;
  font: 800 clamp(2.8rem, 14vw, 4rem)/.9 var(--serif);
  letter-spacing: -.02em;
}
.title span { color: var(--red); }
.hint { margin: 4px 0; font-size: .95rem; color: #5d5a55; }
.hint--big {
  font-weight: 600; font-size: 1.15rem; color: var(--ink);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .hint--big { animation: none; } }

.overlay--over { background: rgba(20, 20, 20, .35); cursor: default; }
.card {
  width: min(100%, 320px);
  padding: 28px 24px 22px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--ink);
  animation: pop .28s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: translateY(24px) scale(.92); opacity: 0; } }
.card h2 { margin: 0 0 18px; font: 800 clamp(1.5rem, 7.6vw, 2rem)/1 var(--serif); white-space: nowrap; text-transform: uppercase; color: var(--red); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.stats > div { background: #fff; border-radius: 12px; padding: 10px 8px; border: 1px solid #e7e0d4; }
.label { display: block; font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: #5d5a55; font-weight: 600; }
.num { display: block; font: 800 2.2rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.new-best { margin: 4px 0 10px; color: var(--blue); font-weight: 600; }
.btn {
  display: block; width: 100%;
  margin-top: 10px; padding: .85em 1em;
  border-radius: 999px; border: 2px solid var(--red);
  background: var(--red); color: #fff;
  font: 600 1.05rem var(--sans); letter-spacing: .04em; text-transform: uppercase;
  cursor: pointer; touch-action: manipulation;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
