:root {
  --ink: #070707;
  --wine: #141414;
  --rose: #d4af37;
  --gold: #e8c56a;
  --gold-deep: #b8860b;
  --cream: #f4ead0;
  --blush: #c9a227;
  --muted: rgba(244, 234, 208, 0.68);
  --glass: rgba(232, 197, 106, 0.08);
  --line: rgba(232, 197, 106, 0.32);
  --danger: #ffb4b4;
  --font-display: "Cormorant Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --font-ui: "Outfit", "Segoe UI", system-ui, sans-serif;
  --safe-top: max(16px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  height: 100%;
  height: -webkit-fill-available;
}

body {
  margin: 0;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  color: var(--cream);
  font-family: var(--font-ui);
  background: var(--ink);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  display: block;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(232, 197, 106, 0.16), transparent 55%),
    radial-gradient(900px 600px at 110% 10%, rgba(184, 134, 11, 0.14), transparent 50%),
    radial-gradient(800px 500px at 50% 120%, rgba(0, 0, 0, 0.78), transparent 55%),
    linear-gradient(180deg, #141414 0%, #070707 45%, #050505 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite;
}

.orb-a {
  width: min(48vw, 280px);
  height: min(48vw, 280px);
  left: -8%;
  top: 18%;
  background: rgba(232, 197, 106, 0.22);
}

.orb-b {
  width: min(40vw, 240px);
  height: min(40vw, 240px);
  right: -6%;
  top: 8%;
  background: rgba(232, 197, 106, 0.2);
  animation-duration: 22s;
  animation-delay: -6s;
}

.orb-c {
  width: min(52vw, 320px);
  height: min(52vw, 320px);
  left: 28%;
  bottom: -12%;
  background: rgba(20, 20, 20, 0.7);
  animation-duration: 26s;
  animation-delay: -12s;
}

.dust {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.2px 1.2px at 12% 22%, rgba(255, 236, 205, 0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 68%, rgba(255, 236, 205, 0.45) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 63% 18%, rgba(255, 236, 205, 0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 81% 42%, rgba(255, 236, 205, 0.4) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 74% 78%, rgba(255, 236, 205, 0.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 40% 36%, rgba(255, 236, 205, 0.35) 50%, transparent 51%);
  animation: twinkle 7s ease-in-out infinite;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.38) 100%);
}

.topbar,
.page,
.foot {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  padding: var(--safe-top) 16px 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--cream);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn .icon-sound path:first-child,
.icon-btn .icon-muted path:first-child {
  fill: var(--cream);
  stroke: none;
}

.icon-btn .icon-muted,
.icon-btn.is-muted .icon-sound {
  display: none;
}

.icon-btn.is-muted .icon-muted {
  display: block;
}

.page {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 0 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.intro {
  text-align: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.title-line {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 5vw, 1.7rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.monogram {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}

.intro h1 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8.5vw, 3.2rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 0.92;
}

.lede {
  margin: 6px auto 0;
  max-width: 21rem;
  color: var(--muted);
  font-size: clamp(0.82rem, 3.2vw, 0.98rem);
  line-height: 1.4;
  font-style: italic;
}

.stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.wheel-wrap {
  position: relative;
  width: min(78vw, 360px, calc(100svh - 360px));
  aspect-ratio: 1;
  flex-shrink: 0;
  border-radius: 50%;
  filter: drop-shadow(0 18px 32px rgba(0, 0, 0, 0.45));
}

.wheel-wrap.is-spinning {
  filter:
    drop-shadow(0 22px 40px rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 28px rgba(232, 197, 106, 0.32));
}

#wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.pointer {
  position: absolute;
  top: -18px;
  left: 50%;
  width: 46px;
  transform: translateX(-50%);
  z-index: 3;
  transform-origin: 50% 18%;
}

.pointer svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pointer-shadow {
  fill: rgba(0, 0, 0, 0.28);
}

.pointer-body {
  fill: url(#none);
  fill: var(--gold);
  stroke: #fff6df;
  stroke-width: 1.2;
}

.pointer-jewel {
  fill: #fff8ea;
  stroke: var(--gold-deep);
  stroke-width: 1.4;
}

.pointer.is-ticking {
  animation: pointer-nudge 90ms ease-out;
}

.hub {
  position: absolute;
  inset: 34%;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--gold);
  background: #111;
  box-shadow:
    0 0 0 6px rgba(232, 197, 106, 0.14),
    0 10px 22px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.hub-photo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 244, 224, 0.16), transparent 42%),
    linear-gradient(160deg, #2a2a2a, #0a0a0a);
}

.hub-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spins-left,
.status {
  margin: 0;
  text-align: center;
  color: var(--gold);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.spin-btn {
  width: min(80%, 17rem);
  min-height: 3.25rem;
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  padding: 0 1.5rem;
  background: linear-gradient(180deg, #f0d78a 0%, #e8c56a 46%, #b8860b 100%);
  color: #111;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  box-shadow:
    0 10px 28px rgba(201, 150, 82, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.spin-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.spin-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.spin-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 8px;
}

.foot {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  padding: 8px 20px calc(12px + env(safe-area-inset-bottom));
}

.start-gate {
  position: fixed;
  inset: 0;
  z-index: 5;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.start-gate[hidden] {
  display: none;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: end center;
  padding: 20px 16px var(--safe-bottom);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.64);
}

.modal-card {
  position: relative;
  width: min(100%, 420px);
  margin-bottom: 12vh;
  padding: 28px 22px 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(28, 28, 28, 0.96), rgba(10, 10, 10, 0.98));
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.modal-card.compact {
  margin-bottom: 20vh;
  text-align: left;
}

.modal-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--gold);
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 600;
  line-height: 1.05;
}

.modal-detail {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-btn {
  margin-top: 22px;
  min-height: 3.4rem;
  letter-spacing: 0.16em;
}

.modal-card.compact .modal-btn {
  width: auto;
  min-width: 10rem;
  margin-top: 0;
}

#reset-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

#passcode-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--cream);
  padding: 0 14px;
}

#passcode-input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.noscript {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--cream);
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(18px, -24px, 0) scale(1.08);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

@keyframes pointer-nudge {
  0% {
    transform: translateX(-50%) rotate(0deg);
  }
  40% {
    transform: translateX(-50%) rotate(-9deg);
  }
  100% {
    transform: translateX(-50%) rotate(0deg);
  }
}

@media (min-width: 720px) {
  .modal {
    place-items: center;
  }

  .modal-card,
  .modal-card.compact {
    margin-bottom: 0;
  }

  .wheel-wrap {
    width: min(420px, calc(100dvh - 280px));
  }

  .memory-frame {
    width: 100px;
  }
}

.photo-cluster {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: min(100%, 360px);
  height: 108px;
  flex-shrink: 0;
  margin-top: 8px;
}

.memory-frame {
  position: relative;
  width: 80px;
  margin: 0;
  padding: 6px 6px 22px;
  background: #f4ead0;
  border: 0;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.34);
  transform: rotate(var(--tilt)) translateY(var(--nudge, 0px));
  animation: frame-float 16s ease-in-out infinite;
}

#photos-bottom .memory-frame:nth-child(1) { --nudge: -4px; }
#photos-bottom .memory-frame:nth-child(2) { --nudge: 6px; }
#photos-bottom .memory-frame:nth-child(3) { --nudge: -2px; }

.memory-frame img,
.memory-frame .slot {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.memory-frame .slot {
  background:
    linear-gradient(160deg, rgba(232, 197, 106, 0.28), rgba(17, 17, 17, 0.08)),
    repeating-linear-gradient(
      -18deg,
      rgba(184, 134, 11, 0.08) 0 8px,
      rgba(184, 134, 11, 0.16) 8px 16px
    );
}

.memory-frame figcaption {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: #1a1a1a;
  text-align: center;
}

@keyframes frame-float {
  0%,
  100% {
    transform: rotate(var(--tilt)) translateY(var(--nudge, 0px));
  }
  50% {
    transform: rotate(calc(var(--tilt) + 2deg)) translateY(calc(var(--nudge, 0px) - 6px));
  }
}

.prize-history {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}

.prize-history li {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.prize-history strong {
  display: block;
  color: var(--cream);
}

.prize-history span {
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 719px) {
  .topbar {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .lede {
    display: block;
  }

  .memory-frame {
    animation: none;
  }
}

@media (max-height: 760px) {
  .wheel-wrap {
    width: min(70vw, 300px, calc(100svh - 340px));
  }

  .photo-cluster {
    height: 96px;
    gap: 10px;
  }

  .memory-frame {
    width: 70px;
  }

  .spins-left {
    font-size: 0.8rem;
  }

  .spin-btn {
    min-height: 3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .dust,
  .memory-frame,
  .pointer.is-ticking,
  .spin-btn:hover:not(:disabled) {
    animation: none;
    transform: none;
  }

  .memory-frame {
    transform: rotate(var(--tilt)) translateY(var(--nudge, 0px));
  }
}
