/* Panda Ice Rush — cheerful candy-ice arcade UI */

:root {
  --ice-deep: #103a57;
  --ice-blue: #1b6480;
  --cyan: #67eadf;
  --cyan-soft: rgba(103, 234, 223, 0.38);
  --magenta: #ff7897;
  --gold: #ffd45f;
  --text: #fffdf8;
  --muted: rgba(255, 253, 248, 0.78);
  --panel-bg: rgba(25, 67, 91, 0.88);
  --panel-outline: rgba(255, 255, 255, 0.38);
  --peach: #ff9a8d;
  --mint: #67eadf;
  --cream: #fff4d7;
  --radius: 22px;
  --font: 'Segoe UI', 'Tahoma', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

/* Author display values must not defeat the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ice-deep);
  font-family: var(--font);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ===================== HUD ===================== */

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  user-select: none;
  padding: calc(10px + var(--safe-top)) 14px calc(12px + var(--safe-bottom));
}

.pause-button {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 14px;
  pointer-events: auto;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  border: 2px solid rgba(255,255,255,0.6);
  background: linear-gradient(160deg, rgba(255, 154, 141, 0.96), rgba(255, 112, 143, 0.94));
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 7px 20px rgba(18, 66, 83, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.42);
}

/* Hearts: three lives, dimmed when lost. */
.hearts-wrap {
  position: absolute;
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: rgba(255, 250, 239, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 20px;
  padding: 8px 16px;
  box-shadow: 0 8px 24px rgba(12, 57, 77, 0.22);
}

.heart {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.45));
  transition: filter 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}

.heart.lost {
  filter: grayscale(1);
  opacity: 0.35;
  transform: scale(0.82);
}

.score-stack {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.score-line {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(160deg, rgba(255, 250, 239, 0.95), rgba(228, 253, 251, 0.94));
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  padding: 7px 14px;
  box-shadow: 0 8px 24px rgba(12, 57, 77, 0.22), inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.hud-score {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #19465f;
  text-shadow: none;
  min-width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.combo-badge {
  background: linear-gradient(160deg, #ff8ea6, #ff6f8e);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(255, 111, 142, 0.32);
  transition: transform 0.15s ease;
}

.combo-badge.bump { transform: scale(1.25); }

.coin-line {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 247, 215, 0.95);
  border: 1.5px solid rgba(255, 211, 83, 0.9);
  border-radius: 16px;
  padding: 4px 12px 4px 14px;
  font-weight: 700;
  font-size: 17px;
  color: #a96a00;
  box-shadow: 0 6px 18px rgba(105, 77, 19, 0.16);
}

.coin-line img { width: 22px; height: 22px; }
.coin-line.collect { animation: coinCollect 0.32s cubic-bezier(.2,.9,.2,1.25); }

@keyframes coinCollect {
  0% { transform: scale(1); }
  45% { transform: scale(1.22) rotate(-3deg); background: #fff3a8; }
  100% { transform: scale(1); }
}

.distance-chip {
  position: absolute;
  top: calc(78px + var(--safe-top));
  left: 14px;
  background: rgba(220, 252, 247, 0.94);
  border: 1.5px solid rgba(255,255,255,0.8);
  border-radius: 15px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 700;
  color: #187d84;
  box-shadow: 0 6px 18px rgba(12, 57, 77, 0.18);
  font-variant-numeric: tabular-nums;
}

/* Hit flash: warm coral pulse on stumble. */
.hit-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(255, 210, 120, 0.12), rgba(255, 84, 108, 0.34));
}

.hit-flash.active { animation: hitPulse 0.45s ease-out; }

@keyframes hitPulse {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===================== Screens ===================== */

.screens { position: fixed; inset: 0; z-index: 10; pointer-events: none; }

.page-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: radial-gradient(ellipse at 50% 35%, #79e9dc, #297899 58%, var(--ice-deep) 100%);
  pointer-events: auto;
}

.page-loader img { width: 84px; height: 84px; animation: bob 1.4s ease infinite alternate; }

@keyframes bob { from { transform: translateY(-6px); } to { transform: translateY(8px); } }

.page-loader p { color: var(--muted); font-size: 15px; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: auto;
}

.screen[hidden] { display: none; }

.start-screen {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 211, 95, 0.3), transparent 24%),
    radial-gradient(circle at 82% 24%, rgba(255, 120, 151, 0.3), transparent 28%),
    radial-gradient(ellipse at 50% 38%, rgba(103, 234, 223, 0.22), rgba(13, 48, 72, 0.6) 74%);
  backdrop-filter: saturate(1.15);
}

.start-glow {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: min(70vw, 420px);
  height: min(70vw, 420px);
  background: radial-gradient(circle, rgba(255, 244, 215, 0.32), rgba(103, 234, 223, 0.12) 45%, transparent 70%);
  pointer-events: none;
}

.game-title {
  position: relative;
  text-align: center;
  line-height: 1.02;
  margin-bottom: 8px;
  font-weight: 900;
  letter-spacing: 2px;
}

.game-title span {
  display: block;
  font-size: clamp(30px, 7vw, 46px);
  color: #fff4d7;
  text-shadow: 0 4px 0 rgba(23, 69, 91, 0.6), 0 10px 28px rgba(8, 39, 57, 0.32);
}

.game-title em {
  display: block;
  font-style: normal;
  font-size: clamp(44px, 11vw, 74px);
  background: linear-gradient(180deg, #fff2a6, #ff9a8d 48%, #ff7897 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 12px rgba(21, 65, 85, 0.3));
}

.game-subtitle {
  color: #fffdf8;
  margin-bottom: 26px;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(8,39,57,.35);
}

.cta-button {
  position: relative;
  border: none;
  border-radius: 20px;
  padding: 18px 44px;
  font-size: 21px;
  font-weight: 900;
  font-family: var(--font);
  color: #7b3d19;
  background: linear-gradient(180deg, #fff5a9, #ffd45f 62%, #ffbc55);
  box-shadow: 0 12px 30px rgba(255, 198, 79, 0.32), inset 0 3px 0 rgba(255, 255, 255, 0.75);
  cursor: pointer;
  animation: ctaPulse 1.6s ease infinite;
}

@keyframes ctaPulse {
  0%, 100% { transform: scale(1) rotate(-0.5deg); }
  50% { transform: scale(1.05) rotate(0.5deg); }
}

.start-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 30px;
  max-width: 420px;
}

.menu-button {
  border: 1.5px solid rgba(255,255,255,0.72);
  background: rgba(255, 253, 248, 0.88);
  color: #24526a;
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  border-radius: 17px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 7px 20px rgba(13, 54, 75, 0.18);
  transition: border-color 0.15s ease, transform 0.1s ease, background 0.15s ease;
}

.menu-button:hover { border-color: #fff5a9; background: #fff9dd; transform: translateY(-3px) rotate(-1deg); }

.best-line { margin-top: 22px; color: #fff2a6; font-weight: 900; font-size: 15px; min-height: 22px; text-shadow: 0 2px 8px rgba(35,70,90,.42); }

.maintenance-note {
  margin-top: 10px;
  color: #ffb1b1;
  background: rgba(120, 20, 30, 0.4);
  border: 1px solid rgba(255, 120, 120, 0.4);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  max-width: 420px;
  text-align: center;
}

/* ===================== Panels / modals ===================== */

.modal-screen { background: rgba(9, 42, 60, 0.54); backdrop-filter: blur(9px) saturate(1.15); }

.panel {
  width: min(92vw, 430px);
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(165deg, rgba(35, 99, 118, 0.97), rgba(27, 65, 88, 0.97));
  border: 2px solid rgba(255,255,255,0.48);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: 0 24px 60px rgba(5, 34, 50, 0.42), inset 0 2px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel h2 { font-size: 22px; }

.kicker { color: var(--magenta); font-weight: 800; font-size: 14px; }

.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }

.panel label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }

.panel input[type="text"], .panel input:not([type]) {
  background: rgba(4, 16, 34, 0.9);
  border: 1.5px solid var(--panel-outline);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
}

.panel input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(56, 229, 255, 0.18); }

.check-row { flex-direction: row !important; align-items: center; gap: 10px !important; font-weight: 400 !important; font-size: 13.5px !important; color: var(--muted); }
.check-row input { width: 20px; height: 20px; accent-color: var(--cyan); }

.form-message { min-height: 20px; font-size: 13.5px; color: #ff9d9d; font-weight: 600; }
.form-message.ok { color: #7bff9e; }

.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.button {
  flex: 1;
  min-width: 120px;
  border: 1.5px solid var(--panel-outline);
  border-radius: 14px;
  padding: 13px 16px;
  font-family: var(--font);
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
  background: rgba(10, 34, 64, 0.9);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
  text-align: center;
}

.button:hover { border-color: var(--cyan); }
.button:active { transform: scale(0.97); }

.button.primary {
  background: linear-gradient(180deg, #fff4a5, #ffd45f 60%, #ffbd5b);
  color: #70411a;
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(255, 205, 86, 0.28);
}

.button.ghost { background: transparent; }

/* ===================== Countdown ===================== */

.countdown-screen { background: transparent; }

.countdown-number {
  font-size: clamp(90px, 26vw, 170px);
  font-weight: 900;
  color: #fff;
  color: #fff5a9;
  text-shadow: 0 5px 0 #ff7897, 0 16px 42px rgba(11, 52, 72, 0.38);
  animation: countPop 1s ease infinite;
}

@keyframes countPop {
  0% { transform: scale(1.5); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.85; }
}

/* ===================== Game over ===================== */

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.result {
  background: rgba(4, 16, 34, 0.75);
  border: 1.5px solid var(--panel-outline);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.result span { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.result strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.result.main { grid-column: 1 / -1; background: linear-gradient(160deg, rgba(56, 229, 255, 0.16), rgba(4, 16, 34, 0.75)); }
.result.main strong { font-size: 34px; color: #fff2a6; text-shadow: 0 4px 14px rgba(11, 52, 72, 0.35); }

.rank-line { text-align: center; color: var(--gold); font-weight: 800; font-size: 15px; }

.offer-button {
  display: block;
  text-align: center;
  text-decoration: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 800;
  font-size: 15.5px;
  color: #3d1200;
  background: linear-gradient(180deg, #ffd98a, var(--gold) 60%, #f0a719);
  box-shadow: 0 8px 22px rgba(255, 201, 60, 0.35);
}

/* ===================== Leaderboard / howto ===================== */

.leaderboard-list { display: flex; flex-direction: column; gap: 8px; min-height: 120px; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(4, 16, 34, 0.7);
  border: 1px solid rgba(56, 229, 255, 0.22);
  border-radius: 12px;
  padding: 10px 14px;
}

.lb-row .rank {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: rgba(56, 229, 255, 0.14);
  border: 1.5px solid var(--panel-outline);
  font-size: 14px;
  flex-shrink: 0;
}

.lb-row:nth-child(1) .rank { background: linear-gradient(160deg, #ffe08a, #f0a719); color: #4d2c00; border-color: transparent; }
.lb-row:nth-child(2) .rank { background: linear-gradient(160deg, #e8f2ff, #9fb8d8); color: #22344c; border-color: transparent; }
.lb-row:nth-child(3) .rank { background: linear-gradient(160deg, #ffb18a, #d97b45); color: #4d2400; border-color: transparent; }

.lb-row .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .score { color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row .dist { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.howto-list { display: flex; flex-direction: column; gap: 12px; list-style: none; font-size: 14.5px; line-height: 1.65; color: var(--muted); }
.howto-list b { color: var(--text); }

/* ===================== Responsive ===================== */

@media (max-width: 380px) {
  .hud-score { font-size: 20px; min-width: 66px; }
  .cta-button { padding: 15px 34px; font-size: 18px; }
  .panel { padding: 20px 16px; }
}

@media (min-width: 900px) and (min-height: 700px) {
  .game-title em { font-size: 84px; }
  .panel { width: min(70vw, 470px); }
}

@media (orientation: landscape) and (max-height: 480px) {
  .start-menu { gap: 8px; margin-top: 16px; }
  .game-subtitle { margin-bottom: 12px; }
  .cta-button { padding: 12px 36px; font-size: 18px; animation: none; }

}

/* Snow Valley art direction: warm paper, sea-glass mint and peach. */
:root { --text: #234957; --muted: #65818a; --panel-outline: #d5e8e8; --cyan: #36a797; --gold: #b27920; --magenta: #dc746f; --radius: 26px; }
.start-screen { align-items: flex-start; justify-content: center; padding: 32px 6vw; background: linear-gradient(270deg,rgba(244,251,247,.95),rgba(244,251,247,.7) 30%,transparent 63%); overflow-y:auto; }
.lobby-panel { width: 380px; max-width:100%; padding:26px; border:1px solid rgba(255,255,255,.9); border-radius:32px; background:rgba(255,254,247,.94); box-shadow:0 22px 65px #437b8824; }
.lobby-kicker { font-size:12px; font-weight:800; color:#478d85; letter-spacing:.2px; margin-bottom:14px; }
.game-title { text-align:right; letter-spacing:-1.5px; margin-bottom:16px; direction:ltr; }
.game-title span { color:#245363; text-shadow:none; font-size:42px; font-weight:950; }
.game-title em { color:#e9857b; background:none; filter:none; font-size:49px; font-weight:950; }
.game-subtitle { color:#6a858b; font-size:13px; line-height:1.8; font-weight:500; text-shadow:none; margin-bottom:23px; }
.garage-heading { display:flex; justify-content:space-between; align-items:center; gap:6px; margin-bottom:10px; }
.garage-heading strong { font-size:13px; } .garage-heading span { font-size:10px; color:#829592; }
.sled-options { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:20px; }
.sled-option { border:2px solid transparent; border-radius:18px; background:#f0f4ef; color:#45666b; padding:12px 4px 10px; cursor:pointer; font-family:var(--font); transition:transform .18s,border-color .18s; }
.sled-option:hover { transform:translateY(-3px); }
.sled-option[aria-pressed="true"] { border-color:#459d91; background:#ecf8ef; box-shadow:0 4px 12px #3d988516; }
.sled-option strong,.sled-option small { display:block; } .sled-option strong { font-size:12px; margin-top:10px; } .sled-option small { font-size:10px; color:#829592; margin-top:4px; }
.sled-mini { --sled:#ef948c; display:block; position:relative; width:57px; height:28px; margin:6px auto 12px; border-radius:50% 50% 35% 35%; background:var(--sled); transform:rotate(-15deg); box-shadow:inset 0 -7px 0 #0000000c,0 3px 0 #cfdfd9; }
.sled-mini::before,.sled-mini::after { content:''; position:absolute; width:66px; height:7px; border-bottom:3px solid #789b9c; border-radius:0 0 9px 15px; left:-5px; bottom:-7px; }
.sled-mini::after { bottom:4px; left:-7px; }
.sled-mini i { position:absolute; inset:5px 12px 8px; border-radius:8px; background:#fff1c9; }
.sled-mint .sled-mini { --sled:#65bfa9; width:62px; } .sled-mint .sled-mini i { border-left:3px solid #bc9f77; border-right:3px solid #bc9f77; }
.sled-violet .sled-mini { --sled:#ac96d1; border-radius:50% 50% 10% 10%; } .sled-violet .sled-mini i { background:#ffdc92; }
.cta-button { display:flex; justify-content:space-between; width:100%; align-items:center; font-size:19px; color:#fffdf7; background:#e8897d; border-radius:17px; padding:15px 23px; box-shadow:0 5px 0 #ce776e,0 12px 22px #de8c7025; animation:none; transition:transform .15s; }
.cta-button:hover { transform:translateY(-2px); background:#e27e72; }
.cta-button:active { transform:translateY(3px); box-shadow:0 2px 0 #ce776e; }
.lobby-tip { color:#8a998e; font-size:10px; text-align:center; margin:13px 0 0; }
.start-menu { gap:8px; margin-top:17px; display:grid; grid-template-columns:1fr 1fr; width:100%; }
.menu-button { color:#627e80; font-size:11px; padding:9px 8px; border:1px solid #dce8df; border-radius:12px; box-shadow:none; background:#fafcf6; }
.best-line { text-shadow:none; color:#ac8845; font-size:12px; margin-top:14px; text-align:center; min-height:0; }
.resort-label { position:absolute; top:32px; left:38px; color:#426e79; font-size:12px; font-weight:800; letter-spacing:2px; }
.resort-label span { display:block; margin-top:8px; font-weight:500; letter-spacing:0; font-size:11px; color:#6a9096; }
.scene-caption { position:absolute; bottom:8%; left:34%; transform:translateX(-50%); display:flex; flex-direction:column; align-items:center; gap:7px; color:#3e777c; padding:15px 25px; background:#f7fff1cc; border:1px solid #ffffffb0; border-radius:18px; }
.scene-caption span { font-size:10px; } .scene-caption strong { font-size:19px; } .scene-caption small { font-size:11px; opacity:.7; }
.panel { background:#fffef6; border:1px solid white; box-shadow:0 30px 90px #426d7744; }
.modal-screen { background:#46717f45; backdrop-filter:blur(12px); }
.panel input:not([type]),.panel input[type="text"] { background:#f1f7f3; border-color:#d0e2dd; color:#234957; }
.button { background:#edf5f0; color:#42666b; border-color:#d3e5db; }
.button.primary { background:#e98f81; color:white; box-shadow:none; }
.result,.lb-row { background:#f0f7f0; border-color:#dceade; }
.result.main { background:#e5f2e9; } .result.main strong { color:#398b7e; text-shadow:none; }
.form-message { color:#c1645d; } .form-message.ok { color:#388570; }
.combo-badge { color:white; background:#e78b80; box-shadow:none; }
.pause-button { background:#fffef4; color:#56777d; box-shadow:0 6px 18px #43798920; }
.score-line { border:1px solid #fff; border-radius:17px; box-shadow:0 6px 18px #43798920; }
.hearts-wrap { border:1px solid #fff; border-radius:30px; box-shadow:0 6px 18px #43798920; }
.heart { filter:none; font-size:23px; }
.distance-chip,.coin-line { box-shadow:0 6px 18px #43798915; }
.countdown-number { color:#fff9e9; text-shadow:0 5px 0 #df8b81,0 14px 25px #698e9566; }
button:focus-visible { outline:3px solid #409b90; outline-offset:4px; }
@media (max-width:760px) {
 .start-screen { padding:18px 14px; align-items:center; justify-content:center; background:#dcefe9aa; }
 .lobby-panel { width:350px; padding:22px; }
 .resort-label,.scene-caption { display:none; }
 .game-title span { font-size:34px; } .game-title em { font-size:42px; }
 .game-subtitle { margin-bottom:17px; }
}
@media (max-height:620px) {
 .start-screen { justify-content:flex-start; padding-top:15px; padding-bottom:15px; }
 .lobby-panel { padding:18px 23px; } .game-title { margin-bottom:8px; }
 .game-title span { font-size:29px; } .game-title em { font-size:36px; }
 .game-subtitle { margin-bottom:10px; } .lobby-kicker { margin-bottom:8px; }
 .sled-options { margin-bottom:12px; } .start-menu { margin-top:10px; }
 .lobby-tip { display:none; } .best-line { margin-top:8px; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none !important; transition:none !important; } }
