:root {
  --bg-0: #0b1026;
  --bg-1: #1b1046;
  --accent: #ff3d7f;
  --accent-2: #ffd166;
  --ink: #ffffff;
  --ink-dim: rgba(255, 255, 255, 0.68);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* iOS: kill scroll-bounce, text selection, tap highlight and double-tap zoom */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--bg-1) 0%, var(--bg-0) 70%);
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: calc(var(--safe-t) + 10px);
  left: 12px;
  right: 12px;
  z-index: 10;
  pointer-events: none;
}

.hud-row { display: flex; justify-content: space-between; gap: 10px; }

.pill {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-variant-numeric: tabular-nums;
}

.pill .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); }
.pill .value { font-size: 20px; font-weight: 700; }
.pill .sep, .pill .unit { font-size: 13px; color: var(--ink-dim); }

#timePill.urgent { background: rgba(255, 61, 127, 0.28); border-color: rgba(255, 61, 127, 0.6); }
#timePill.urgent .value { animation: tick 1s steps(2) infinite; }
@keyframes tick { 50% { opacity: 0.45; } }

.bar {
  margin-top: 8px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.18s ease-out;
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: calc(var(--safe-t) + 28px) 26px calc(var(--safe-b) + 28px);
  text-align: center;
  background: rgba(11, 16, 38, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fade 0.35s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.hero {
  width: 108px;
  height: 108px;
  object-fit: contain;
  filter: drop-shadow(0 12px 30px rgba(255, 61, 127, 0.45));
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-12px) rotate(6deg); } }

.big-emoji { font-size: 68px; }

h1 {
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.win-title {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.win-name { font-size: clamp(24px, 8vw, 38px); font-weight: 800; }

.sub { font-size: 16px; color: var(--ink-dim); max-width: 30ch; line-height: 1.45; }
.tiny { font-size: 13px; color: var(--ink-dim); }

.rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 15px;
  color: var(--ink-dim);
}
.rules b { color: var(--ink); }

.btn {
  margin-top: 8px;
  padding: 17px 40px;
  font-size: 19px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #ff8a3d);
  box-shadow: 0 10px 30px rgba(255, 61, 127, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.1s ease;
}
.btn:active { transform: scale(0.94); }
.btn-gift { background: linear-gradient(135deg, var(--accent-2), #ff8a3d); color: #2a1400; }

/* ---------- Balloons & confetti ---------- */
.balloon {
  position: fixed;
  bottom: -160px;
  z-index: 21;
  width: 62px;
  height: 78px;
  border-radius: 50% 50% 48% 48%;
  pointer-events: none;
  transform: scale(var(--scale, 1));
  animation: rise linear forwards;
}
.balloon::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 1px;
  height: 70px;
  background: rgba(255, 255, 255, 0.4);
}
@keyframes rise {
  from { transform: translateY(0) rotate(0deg) scale(var(--scale, 1)); }
  to   { transform: translateY(-125vh) rotate(var(--spin, 12deg)) scale(var(--scale, 1)); }
}
