/* Alpenglow — endless twilight trick sandboarder. Full-bleed canvas, whisper-quiet HUD. */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #262040;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  overscroll-behavior: none;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* subtle vignette over the scene, under the HUD */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 42%, rgba(0, 0, 0, 0) 58%, rgba(4, 3, 12, 0.34) 100%);
}

.confetti { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
.confetti i {
  position: absolute; width: 7px; height: 11px; border-radius: 2px; opacity: 0.95;
  animation: confettiFall var(--d, 900ms) cubic-bezier(0.2, 0.5, 0.6, 1) forwards;
}
@keyframes confettiFall {
  from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  to { transform: translate(var(--dx, 0), var(--dy, 300px)) rotate(var(--rot, 360deg)); opacity: 0; }
}

/* ---------- HUD (nearly vanishes — score, distance, chain chip) ---------- */
.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0; right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}
.hud__score {
  font-size: clamp(1.8rem, 6.5vw, 2.9rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  color: rgba(255, 250, 244, 0.94);
  text-shadow: 0 1px 14px rgba(20, 16, 44, 0.55);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hud__sub {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 248, 240, 0.55);
  text-shadow: 0 1px 8px rgba(20, 16, 44, 0.5);
  font-variant-numeric: tabular-nums;
}
.hud__chain {
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffe9e4;
  background: rgba(229, 72, 77, 0.28);
  border: 1px solid rgba(229, 72, 77, 0.45);
  text-shadow: 0 0 10px rgba(229, 72, 77, 0.6);
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: chainPop 240ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.hud__chain[hidden] { display: none; }
.hud__chain.is-hot {
  color: #fff3df;
  background: rgba(242, 143, 60, 0.4);
  border-color: rgba(255, 190, 110, 0.7);
  text-shadow: 0 0 12px rgba(255, 170, 80, 0.9);
}
@keyframes chainPop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sound-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 6;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 240, 230, 0.28);
  background: rgba(24, 18, 40, 0.42);
  color: #ffe9e0;
  font-size: 1.05rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 140ms ease, background 140ms ease;
}
.sound-btn:hover { border-color: rgba(255, 240, 230, 0.65); }
.sound-btn:focus-visible { outline: 2px solid #ffd9c8; outline-offset: 2px; }
.sound-btn[aria-pressed="false"] { color: rgba(220, 200, 195, 0.35); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 44%, rgba(30, 22, 52, 0.62), rgba(8, 6, 20, 0.9));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: opacity 260ms ease;
}
.overlay[hidden] { display: none; }
.overlay.is-hidden { opacity: 0; pointer-events: none; }

.panel {
  text-align: center;
  max-width: 480px;
  padding: 34px 30px 32px;
  border-radius: 24px;
  color: #e8dcd6; /* inherited by the injected share pill */
  background: rgba(22, 16, 38, 0.88);
  border: 1px solid rgba(242, 166, 90, 0.2);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8), inset 0 0 70px -34px rgba(217, 106, 90, 0.5);
  animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel__title {
  margin: 0 0 6px;
  font-size: clamp(2.2rem, 9vw, 3.7rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 0.95;
  padding-bottom: 0.16em;
  background: linear-gradient(174deg, #ffe9c9 0%, #f2a65a 44%, #d96a5a 74%, #8e4a6e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 4px 26px rgba(226, 122, 90, 0.4));
}
.panel__text { margin: 0 0 26px; font-size: clamp(0.96rem, 3.3vw, 1.06rem); line-height: 1.55; font-weight: 500; color: #dccbc4; }
.panel__text .stat { color: #f2a65a; font-weight: 800; }
.play-btn {
  appearance: none;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: #2b1508;
  background: linear-gradient(180deg, #ffd9a0, #ef8f52);
  border: 0;
  padding: 16px 44px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(239, 143, 82, 0.55);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -8px rgba(239, 143, 82, 0.7); }
.play-btn:active { transform: translateY(0); }
.play-btn:focus-visible { outline: 2px solid #ffe9c9; outline-offset: 3px; }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 240, 228, 0.42);
  text-shadow: 0 1px 8px rgba(20, 16, 44, 0.5);
}
.frame__corner--tl { top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner--tr { top: max(14px, env(safe-area-inset-top)); right: 62px; }
.frame__corner--bl { bottom: max(14px, env(safe-area-inset-bottom)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: #f2a65a; }
.frame__corner a:focus-visible { outline: 2px solid #f2a65a; outline-offset: 2px; }

.hint {
  position: fixed;
  bottom: max(26px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 240, 228, 0.5);
  text-shadow: 0 1px 8px rgba(20, 16, 44, 0.5);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 300ms ease;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 560px) {
  .frame__corner--bl { display: none; }
  .frame__corner--tr { display: none; }
  .hint { font-size: 0.64rem; }
}

/* short landscape phones: compact the overlay so nothing clips */
@media (max-height: 520px) {
  .overlay { padding: 12px; overflow-y: auto; }
  .panel { max-width: min(640px, calc(100vw - 132px)); padding: 14px 26px 16px; border-radius: 18px; }
  .panel__title { font-size: clamp(1.6rem, 9vh, 2.4rem); padding-bottom: 0.1em; margin-bottom: 2px; }
  .panel__text { font-size: 0.85rem; line-height: 1.42; margin-bottom: 12px; }
  .play-btn { padding: 10px 34px; font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  .hud__chain { animation: none; }
  .confetti i { animation-duration: 1ms; }
}
