/* ========================================================================
   A Birthday Game — whimsical, glittery, snowy this-or-that
   ===================================================================== */
:root {
  --plum: #25103f;
  --berry: #5a1c63;
  --rose: #8e2a6b;
  --gold: #ffd66b;
  --gold-deep: #f3a838;
  --pink: #ff90b9;
  --mint: #8fe3c8;
  --ink: #fbf4ff;
  --ink-soft: #e3d3f4;
  --ink-mute: #b9a6d4;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-line: rgba(255, 255, 255, 0.22);
  --shadow: 0 24px 60px rgba(10, 2, 24, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-head: 'Fredoka', system-ui, sans-serif;
  --font-script: 'Pacifico', cursive;
  --font-body: 'Nunito', system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #7d2b86 0%, transparent 55%),
    radial-gradient(90% 70% at 110% 110%, #c84b8c33 0%, transparent 50%),
    radial-gradient(90% 70% at -10% 110%, #4a2bd433 0%, transparent 50%),
    linear-gradient(160deg, var(--plum), var(--berry) 55%, var(--rose));
  background-attachment: fixed;
  min-height: 100svh;
  overflow-x: hidden;
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
}

/* ── Screens ─────────────────────────────────────────────────────────── */
.screen {
  grid-area: 1 / 1;
  min-height: 100svh;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 3vh, 1.6rem);
  padding: clamp(1.1rem, 4vw, 2rem);
  padding-top: max(1.1rem, env(safe-area-inset-top));
  padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
}
.screen.is-active { display: flex; animation: fadeUp 0.6s var(--ease); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── Glass card ──────────────────────────────────────────────────────── */
.card-glass {
  width: min(100%, 30rem);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 28px;
  padding: clamp(1.6rem, 5vw, 2.4rem);
  text-align: center;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ── Type ────────────────────────────────────────────────────────────── */
.kicker {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--gold);
}
.title {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 0.98;
  font-size: clamp(2.6rem, 12vw, 4rem);
  margin: 0.4rem 0 0.2rem;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}
.title--sm { font-size: clamp(1.8rem, 8vw, 2.6rem); }
.title__script {
  font-family: var(--font-script);
  font-weight: 400;
  background: linear-gradient(100deg, var(--gold), #fff3c4 40%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.15em;
}
.lede {
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 30ch;
  margin: 0.6rem auto 0;
}

/* ── Form ────────────────────────────────────────────────────────────── */
.field {
  display: block;
  margin: 1.4rem 0 1.2rem;
  text-align: left;
}
.field > span {
  display: block;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin: 0 0 0.4rem 0.4rem;
}
.field input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--ink);
  padding: 0.85rem 1.1rem;
  border-radius: 16px;
  border: 1.5px solid var(--glass-line);
  background: rgba(0, 0, 0, 0.2);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: var(--ink-mute); }
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 214, 107, 0.18);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.1rem;
  color: #3a1330;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.8rem;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s, filter 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary {
  background: linear-gradient(100deg, var(--gold), var(--gold-deep));
  box-shadow: 0 12px 28px rgba(243, 168, 56, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn--primary:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn--primary:not(:disabled):active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: saturate(0.6); }
.btn--next { width: min(100%, 26rem); margin-top: 0.4rem; }

/* ── Game ────────────────────────────────────────────────────────────── */
.screen--game { justify-content: flex-start; padding-top: max(1.4rem, env(safe-area-inset-top)); }

.game__head {
  width: min(100%, 40rem);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.4rem;
}
.progress {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
  border: 1px solid var(--glass-line);
}
.progress__bar {
  height: 100%;
  width: 7%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  transition: width 0.5s var(--ease);
}
.counter {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.counter__sep { color: var(--ink-mute); }

.prompt {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
  text-align: center;
  margin: clamp(0.8rem, 3vh, 1.6rem) 0 0.4rem;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}

.stage {
  width: min(100%, 40rem);
  flex: 1;
  position: relative;
  align-self: center;
}
.stage--pair {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0;
}
.vs {
  font-family: var(--font-script);
  font-size: 1.5rem;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.choice {
  position: relative;
  border: 2px solid var(--glass-line);
  background: var(--glass);
  border-radius: 24px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.imgwrap {
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #3a2350, #5a2c56 60%, #7d2b62);
}
.imgwrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease), filter 0.3s;
  filter: saturate(1.02);
}
/* elegant labelled placeholder until real photos are dropped in */
.imgwrap--missing::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.6rem;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink-soft);
  background:
    radial-gradient(120% 100% at 30% 0%, rgba(255, 214, 107, 0.18), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04) 0 10px, transparent 10px 20px);
}
.choice__label {
  display: block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.12rem;
  padding: 0.7rem 0.9rem 0.8rem;
  background: linear-gradient(0deg, rgba(20, 4, 30, 0.55), transparent);
}
.choice__check {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--gold), var(--gold-deep));
  color: #3a1330;
  font-weight: 800;
  font-size: 1.1rem;
  transform: scale(0);
  transition: transform 0.3s var(--ease);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.choice:hover { transform: translateY(-2px); }
.choice.is-selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 214, 107, 0.25), 0 18px 40px rgba(243, 168, 56, 0.35);
  transform: translateY(-2px) scale(1.01);
}
.choice.is-selected img { transform: scale(1.06); filter: saturate(1.12) brightness(1.05); }
.choice.is-selected .choice__check { transform: scale(1); }

/* wider screens: side-by-side */
@media (min-width: 720px) {
  .stage--pair { grid-template-columns: 1fr auto 1fr; }
  .stage--pair .imgwrap { aspect-ratio: 4 / 5; }
}

/* ── Done ────────────────────────────────────────────────────────────── */
.done__emoji { font-size: 3.4rem; animation: pop 0.7s var(--ease); }
@keyframes pop { 0% { transform: scale(0) rotate(-20deg); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.done__status { margin-top: 1rem; font-size: 0.84rem; color: var(--ink-mute); min-height: 1.2em; }
.finewhisper { margin-top: 0.9rem; font-size: 0.74rem; font-style: italic; color: var(--ink-mute); opacity: 0.85; }

/* ── Candy jar progress ──────────────────────────────────────────────── */
.jar {
  position: relative;
  width: 34px;
  height: 44px;
  flex: none;
  border: 2px solid var(--glass-line);
  border-radius: 8px 8px 12px 12px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.jar::before {
  content: '';
  position: absolute;
  top: -5px; left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 6px;
  background: var(--gold-deep);
  border-radius: 3px;
}
.jar__fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 8%;
  background: linear-gradient(0deg, var(--gold-deep), var(--pink));
  transition: height 0.5s var(--ease);
}
.jar__face { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1rem; }

/* ── Rank round ──────────────────────────────────────────────────────── */
.stage--rank { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; padding: 0.4rem 0; }
.rankitem {
  position: relative;
  border: 2px solid var(--glass-line);
  background: var(--glass);
  border-radius: 20px;
  padding: 0; cursor: pointer; overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.rankitem .imgwrap { aspect-ratio: 5 / 4; }
.rankitem__label {
  display: block; font-family: var(--font-head); font-weight: 600; font-size: 0.92rem;
  padding: 0.5rem 0.6rem 0.6rem; background: linear-gradient(0deg, rgba(20, 4, 30, 0.55), transparent);
}
.rankitem__badge {
  position: absolute; top: 0.5rem; left: 0.5rem;
  width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: 50%;
  font-family: var(--font-head); font-weight: 700; color: #3a1330;
  background: linear-gradient(120deg, var(--gold), var(--gold-deep));
  transform: scale(0); transition: transform 0.25s var(--ease); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}
.rankitem.is-ranked { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 214, 107, 0.22); }
.rankitem.is-ranked .rankitem__badge { transform: scale(1); }
.rank-reset {
  grid-column: 1 / -1; background: none; border: 1px dashed var(--glass-line);
  color: var(--ink-mute); font-family: var(--font-mono); font-size: 0.75rem;
  padding: 0.5rem; border-radius: 12px; cursor: pointer;
}

/* ── Dream-Slice builder ─────────────────────────────────────────────── */
.screen--builder { justify-content: center; gap: 1rem; }
.slice { width: min(78vw, 15rem); display: flex; flex-direction: column-reverse; gap: 3px; }
.slice__plate { height: 10px; border-radius: 0 0 45% 45% / 0 0 100% 100%; background: rgba(255, 255, 255, 0.18); }
.slice__layer {
  height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 1.2rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 10px rgba(0, 0, 0, 0.3);
  animation: layerIn 0.35s var(--ease);
}
@keyframes layerIn { from { opacity: 0; transform: translateY(-10px) scale(0.9); } to { opacity: 1; transform: none; } }
.bopts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; width: min(100%, 30rem); }
.bopt {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 0.9rem 0.6rem; border-radius: 16px; border: 1.5px solid var(--glass-line);
  background: var(--glass); color: var(--ink); font-family: var(--font-head); font-weight: 600;
  font-size: 0.9rem; cursor: pointer; transition: transform 0.2s var(--ease), border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.bopt:hover { transform: translateY(-2px); border-color: var(--gold); }
.bopt__emoji { font-size: 1.7rem; }

/* ── Scratch reveal ──────────────────────────────────────────────────── */
.scratchbox {
  position: relative; margin: 1.2rem auto 0; max-width: 22rem; min-height: 76px;
  display: grid; place-items: center; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--glass-line);
}
.scratchbox__msg { font-family: var(--font-head); font-weight: 600; color: var(--gold); padding: 0.9rem 1rem; }
#scratch { position: absolute; inset: 0; border-radius: 14px; cursor: crosshair; touch-action: none; }

/* ── Gut-pull badge ──────────────────────────────────────────────────── */
.gutbadge {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 50;
  font-family: var(--font-head); font-weight: 700; color: #3a1330;
  background: linear-gradient(120deg, var(--gold), var(--gold-deep));
  padding: 0.5rem 1rem; border-radius: 999px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  animation: badgePop 1.1s var(--ease) forwards; pointer-events: none;
}
@keyframes badgePop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.8); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ── Motion safety ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.08s !important; }
}
