:root {
  --night: #141b3f;
  --night-2: #263268;
  --card: #fbf6ea;
  --card-ink: #2b2a48;
  --text: #f3f1fb;
  --muted: #b9c0e3;
  --warm: #ffd27a;
  --red: #c9443c;
  --green: #2f7a55;
  --title-font: 'Mountains of Christmas', Georgia, serif;
  --body-font: 'Gaegu', 'Comic Sans MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background:
    radial-gradient(ellipse at 50% 120%, rgba(255, 210, 122, 0.18), transparent 60%),
    linear-gradient(var(--night), var(--night-2));
  background-color: var(--night);
  color: var(--text);
  font-family: var(--body-font);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hud, .status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: var(--board-w, 560px);   /* never wider than the game board (set by game.js) */
  margin: 0 auto;
  padding: 8px 4px 0;
}
.hud { container-type: inline-size; height: calc(74px + env(safe-area-inset-top)); padding-top: calc(8px + env(safe-area-inset-top)); }   /* fixed, so the score growing never resizes the board; below the notch / Dynamic Island when the page runs full screen (the iOS app) */

.hud h1 {
  font-family: var(--title-font);
  font-weight: 700;
  font-size: clamp(22px, 10cqi, 40px);
  line-height: 1;
  letter-spacing: 1px;
  margin: 0;
  color: #fff6d8;
  text-shadow: 0 2px 0 #0b0f2a, 0 0 18px rgba(255, 210, 122, 0.35);
}

.title { min-width: 0; }
.tagline { margin: 2px 0 0; line-height: 1.15; font-size: clamp(11px, 3.6cqi, 15px); font-weight: 700; color: var(--muted); text-wrap: balance; }
.scores { flex-shrink: 0; }

.scores { display: flex; gap: clamp(8px, 3cqi, 14px); }

.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.stat .label { font-size: clamp(10px, 3cqi, 13px); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat span:last-child { min-width: 3.2ch; text-align: right; font-size: clamp(18px, 7cqi, 28px); font-weight: 700; font-variant-numeric: tabular-nums; }

.status { padding-top: 6px; padding-bottom: 6px; }

.lives { display: flex; gap: 2px; min-width: 84px; height: 28px; }
.lives img { width: 28px; height: 28px; }

.cold { flex: 1; display: flex; align-items: center; gap: 6px; }
.cold-icon { font-size: 16px; }
.cold-bar {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
}
.cold-fill {
  height: 100%;
  background: linear-gradient(90deg, #7fc6ff, #ffd27a 70%, #ff9a5a);
  transform-origin: left;
  transition: transform 0.1s linear;
}
.cold-fill.low { background: #7fc6ff; animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.cold-fill.warming { filter: brightness(1.35) saturate(1.3); box-shadow: 0 0 10px #ffb37a; }

.nog {
  display: inline-block;
  font-weight: 700;
  color: #2b2a48;
  background: var(--warm);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 14px;
}

.nog.tipsy { animation: tipsy 1.2s ease-in-out infinite; }
@keyframes tipsy { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .nog.tipsy { animation: none; } }

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 8px;
  touch-action: none;
}
/* phones held upright: the board runs edge to edge */
#stage.fill { padding: 0 0 env(safe-area-inset-bottom); align-items: flex-start; }
#stage.fill #game { border-radius: 0; box-shadow: none; }

#board { position: relative; line-height: 0; }

#game {
  display: block;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 246, 216, 0.25);
}

.board-btns { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(20, 27, 63, 0.55);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 40, 0.45);
  touch-action: manipulation;
}
.hidden { display: none !important; }

.card {
  width: min(380px, 100%);
  background: var(--card);
  color: var(--card-ink);
  border-radius: 22px;
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  border: 4px solid #fff;
  outline: 3px dashed rgba(201, 68, 60, 0.55);
  outline-offset: -12px;
}
.card h2 {
  font-family: var(--title-font);
  font-size: 42px;
  margin: 0 0 8px;
  color: var(--red);
  line-height: 1;
}
.card p { margin: 8px 0; font-size: 19px; line-height: 1.25; }
.card .small { font-size: 17px; color: #555476; }
.card .keys { font-size: 16px; color: #6a6990; margin-top: 12px; }
.final { font-size: 28px !important; font-weight: 700; }
.new-best { color: var(--green); font-weight: 600; }

.big-btn {
  margin-top: 10px;
  font-family: var(--body-font);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(#d9473c, #a3332d);
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  box-shadow: 0 4px 0 #6e211c;
  cursor: pointer;
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #6e211c; }
@media (max-width: 380px) {
  .hud { padding: calc(8px + env(safe-area-inset-top)) 10px 0; }
  .tagline { font-size: 12.5px; }
  .scores { gap: 8px; }
  .stat .label { font-size: 11px; letter-spacing: 0.5px; }
  .stat span:last-child { font-size: 22px; }
}

.link-btn {
  margin-top: 6px;
  background: none;
  border: none;
  font-family: var(--body-font);
  font-size: 17px;
  font-weight: 700;
  color: #6a6990;
  text-decoration: underline;
  cursor: pointer;
}

.card .intro { font-size: 21px; line-height: 1.4; margin: 10px 4px 18px; text-wrap: balance; }
