:root {
  --night: #0b1b33;
  --snow: #e6eef7;
  --snow-alt: #dbe6f2;
  --santa-red: #c8102e;
  --fur: #ffffff;
  --skin: #f2b38c;
  --gold: #ffd966;
  --pine: #0b6b3a;
  --berry-blue: #1d4f91;
  --text: #f4f7fb;
  --text-muted: #9db4d0;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--night);
  /* a few stars */
  background-image:
    radial-gradient(circle, #fff 1px, transparent 1.5px),
    radial-gradient(circle, #fff 1px, transparent 1.5px);
  background-size: 140px 140px, 90px 90px;
  background-position: 20px 30px, 70px 60px;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Falling snow lives behind the game, never over the board */
body::before {
  content: "";
  position: fixed; inset: -200px 0 0 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.9) 2px, transparent 3px),
    radial-gradient(circle, rgba(255,255,255,.7) 1.5px, transparent 2.5px);
  background-size: 180px 180px, 110px 110px;
  background-position: 0 0, 40px 30px;
  animation: snowfall 14s linear infinite;
}
@keyframes snowfall { to { transform: translateY(200px); } }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

main { position: relative; z-index: 1; width: min(92vw, 92vh - 70px, 640px); }
.hud {
  display: flex;
  justify-content: space-between;
  font-size: clamp(18px, 4vw, 28px);
  background: var(--night);
  color: var(--text);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 4px 14px;
  margin-bottom: 10px;
}
.hud b { color: var(--gold); font-variant-numeric: tabular-nums; }
.stage {
  position: relative;
  padding: 8px;
  border-radius: 10px;
  background: repeating-linear-gradient(45deg, var(--santa-red) 0 8px, var(--fur) 8px 16px);
}
canvas {
  width: 100%; aspect-ratio: 1; display: block;
  background: var(--snow);
  border: 4px solid var(--night);
  border-radius: 2px;
}
.overlay {
  position: absolute; inset: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(11, 27, 51, 0.85);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  color: var(--text);
}
.overlay.hidden { display: none; }
.overlay h1 { margin: 0 0 8px; color: var(--gold); font-size: clamp(26px, 7vw, 48px); }
.overlay p { margin: 4px 0; font-size: clamp(14px, 3.5vw, 20px); }
.overlay .hint { color: var(--text-muted); font-size: clamp(12px, 3vw, 16px); }
.newbest { color: var(--gold); font-weight: 700; margin-top: 4px; }
