:root {
  --cream:      #f4eee2;
  --paper:      #fcf9f2;
  --ink:        #2a2622;
  --ink-soft:   #6f665b;
  --clay:       #d97757;
  --clay-deep:  #bf5d3d;
  --line:       rgba(42, 38, 34, 0.14);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; padding-top: max(16px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .mark { width: 24px; height: 24px; object-fit: contain; }
.brand-name { font-family: var(--font-display); font-weight: 900; font-size: 18px; letter-spacing: -.01em; color: var(--ink); }
.sound-toggle {
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink); width: 42px; height: 42px; border-radius: 12px;
  font-size: 18px; cursor: pointer; transition: transform .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.sound-toggle:active { transform: scale(.94); }
.sound-toggle.on { border-color: var(--clay); background: #f7e7df; }

/* ── layout ─────────────────────────────────────────────────────────────── */
.stage {
  max-width: 540px; margin: 0 auto;
  padding: 4px 20px calc(56px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center;
}

/* ── hero ───────────────────────────────────────────────────────────────── */
.hero { text-align: center; margin: 4px 0 4px; }
.prize-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px 7px 11px; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 14px;
}
.prize-badge b { color: var(--clay-deep); }
.badge-mark { display: inline-flex; width: 17px; height: 17px; }
.badge-mark svg, .logo-slot svg { width: 100%; height: 100%; display: block; }
.headline {
  font-family: var(--font-display);
  font-weight: 900; font-optical-sizing: auto;
  font-size: clamp(40px, 12vw, 60px); line-height: .95; letter-spacing: -.02em; color: var(--ink);
}
.headline .prize { color: var(--clay); font-style: italic; }
.sub { margin: 14px auto 0; max-width: 420px; font-size: clamp(14.5px, 4vw, 16px); line-height: 1.5; color: var(--ink-soft); }
.sub em { color: var(--ink); font-style: normal; font-weight: 700; }

/* ── wheel ──────────────────────────────────────────────────────────────── */
.wheel-section { margin: 18px 0 4px; width: 100%; display: flex; flex-direction: column; align-items: center; position: relative; }
.wheel-hint {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%) translateY(-4px);
  background: var(--clay); color: #fff; font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: 12px; z-index: 8; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(217,119,87,.4); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.wheel-hint::after {
  content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 7px solid var(--clay);
}
.wheel-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); animation: hintPop .4s; }
@keyframes hintPop { 0%{transform:translateX(-50%) scale(.8)} 60%{transform:translateX(-50%) scale(1.06)} 100%{transform:translateX(-50%) scale(1)} }

.wheel-wrap {
  position: relative; width: min(90vw, 420px); aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none;
}
.wheel {
  width: 100%; height: 100%; overflow: visible; display: block;
  filter: drop-shadow(0 10px 22px rgba(42, 38, 34, 0.16));
}
#wheelSpin { transform: rotate(0deg); }
.pointer {
  position: absolute; top: -2%; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 6;
  border-left: 15px solid transparent; border-right: 15px solid transparent;
  border-top: 28px solid var(--clay);
}
.hub {
  position: absolute; width: 21%; aspect-ratio: 1; border-radius: 50%; z-index: 5;
  background: var(--paper); border: 3px solid var(--clay);
  box-shadow: 0 2px 8px rgba(42, 38, 34, 0.18);
  display: flex; align-items: center; justify-content: center;
}
.hub-mark { width: 52%; height: 52%; display: inline-flex; }
.tap-cue {
  position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font-size: 10.5px; font-weight: 800;
  letter-spacing: .12em; padding: 5px 12px; border-radius: 999px; z-index: 7;
  box-shadow: 0 4px 12px rgba(42,38,34,.28); animation: cuePulse 1.8s ease-in-out infinite;
}
@keyframes cuePulse { 0%,100%{transform:translateX(-50%) scale(1); opacity:.9} 50%{transform:translateX(-50%) scale(1.07); opacity:1} }
.tap-cue.hide { display: none; }

/* ── panel / form / steps ───────────────────────────────────────────────── */
.panel { width: 100%; max-width: 420px; margin-top: 20px; }
.field { margin-bottom: 14px; }
.field label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 7px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--clay); color: #fff;
  font-size: 12px; font-weight: 800; flex: none;
}
.field label .from { color: var(--clay); font-weight: 600; text-transform: none; letter-spacing: 0; }
.field input {
  width: 100%; font-family: var(--font-body); font-size: 17px; font-weight: 600;
  color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 13px; padding: 15px 16px;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none;
}
.field input::placeholder { color: #b6ab9c; font-weight: 500; }
.field input:focus { outline: none; border-color: var(--clay); box-shadow: 0 0 0 4px rgba(217,119,87,.15); }
#code { letter-spacing: .1em; text-transform: uppercase; }
#code::placeholder { text-transform: none; letter-spacing: 0; }
.field.shake input { animation: shake .4s; border-color: var(--clay-deep); }
.field.flash input { border-color: var(--clay); box-shadow: 0 0 0 4px rgba(217,119,87,.22); }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(7px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(3px)} }
.hint { margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: var(--clay-deep); background: #f6e7e0; border-radius: 10px; padding: 8px 10px; }
.hint a { color: var(--clay-deep); font-weight: 800; text-decoration: underline; white-space: nowrap; }
.hint-ic { margin-right: 3px; }
.err { font-size: 13px; font-weight: 600; color: var(--clay-deep); margin-top: 7px; }
.err a { color: var(--clay-deep); text-decoration: underline; cursor: pointer; }

.nudge {
  margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px;
  background: #f7e7df; border: 1px solid var(--clay); color: var(--clay-deep);
  font-weight: 700; font-size: 14px; text-align: center; animation: hintPop .35s;
}

.spin-btn {
  position: relative; width: 100%; margin-top: 4px; cursor: pointer; overflow: hidden;
  border: none; border-radius: 14px; padding: 17px 20px;
  background: var(--clay); color: var(--paper);
  box-shadow: 0 6px 16px rgba(217,119,87,.32);
  transition: transform .12s var(--ease-out), background .15s, box-shadow .15s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  -webkit-tap-highlight-color: transparent; animation: btnBreathe 2.4s ease-in-out infinite;
}
@keyframes btnBreathe { 0%,100%{box-shadow:0 6px 16px rgba(217,119,87,.32)} 50%{box-shadow:0 8px 26px rgba(217,119,87,.5)} }
.spin-btn-label { font-family: var(--font-display); font-weight: 900; font-size: 21px; letter-spacing: .03em; }
.spin-btn-sub { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; opacity: .75; }
.spin-btn:hover { transform: translateY(-2px); background: var(--clay-deep); }
.spin-btn:active { transform: translateY(1px) scale(.99); }
.spin-btn:disabled { cursor: not-allowed; opacity: .85; animation: none; }
.spin-btn.spinning { animation: none; }
.spin-btn.spinning .spin-btn-label, .spin-btn.spinning .spin-btn-sub { opacity: 0; }
.spin-btn.spinning::before {
  content: 'spinning…'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 900; font-size: 19px; letter-spacing: .1em;
}

/* ── banked-spins UI (claim → bank → spin whenever) ─────────────────────── */
.wheel-section .spin-btn { max-width: 420px; }
.spins-badge {
  text-align: center; margin: 16px 0 8px; font-size: 15px; font-weight: 700; color: var(--ink-soft);
}
.spins-badge b { color: var(--ink); font-weight: 800; font-size: 18px; }
.spins-badge.ready { color: var(--clay-deep); }
.spins-badge.ready b { color: var(--clay-deep); }

.claim-head {
  font-family: var(--font-display); font-weight: 900; font-size: 20px; color: var(--ink);
  text-align: center; margin-bottom: 14px;
}
.claim-head span { color: var(--clay); }

.claim-msg {
  margin-top: 12px; text-align: center; font-size: 14px; font-weight: 700;
  border-radius: 12px; padding: 11px 12px; animation: hintPop .35s;
}
.claim-msg.ok { background: #eaf3ea; color: #3f6b45; border: 1px solid #b9d3ba; }
.claim-msg.err { background: #f7e7df; color: var(--clay-deep); border: 1px solid var(--clay); }

.spins-box { text-align: center; margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.spins-box b { color: var(--ink); font-weight: 800; font-size: 15px; }

/* ── invite ─────────────────────────────────────────────────────────────── */
.invite { margin-top: 20px; padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; text-align: center; }
.invite-head { font-family: var(--font-display); font-weight: 900; font-size: 20px; color: var(--ink); }
.invite-copy { font-size: 14px; color: var(--ink-soft); margin: 6px 0 14px; line-height: 1.5; }
.invite-copy b { color: var(--clay-deep); }
.invite-link { display: flex; gap: 8px; margin-bottom: 10px; }
.invite-link input {
  flex: 1; min-width: 0; font-family: var(--font-body); font-size: 13px; font-weight: 600;
  color: var(--ink-soft); background: var(--cream); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px;
}
.invite-link button {
  flex: none; background: var(--ink); color: var(--paper); border: none; border-radius: 10px;
  padding: 0 16px; font-weight: 700; font-size: 13px; cursor: pointer; transition: background .15s;
}
.invite-link button:active { background: #000; }
.share-btn {
  width: 100%; background: var(--clay); color: var(--paper); border: none; border-radius: 12px;
  padding: 14px; font-family: var(--font-body); font-weight: 800; font-size: 15px; cursor: pointer;
  transition: transform .12s, background .15s; -webkit-tap-highlight-color: transparent;
}
.share-btn:hover { background: var(--clay-deep); transform: translateY(-1px); }
.share-btn:active { transform: translateY(1px); }
.invite-count { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--clay-deep); min-height: 0; }

.finePrint { text-align: center; margin-top: 16px; font-size: 11.5px; color: #a99e8f; line-height: 1.5; }

/* ── overlays ───────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center; padding: 22px;
  background: rgba(42, 38, 34, 0.44); backdrop-filter: blur(6px);
}
.overlay.show { display: flex; animation: overlayIn .25s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  position: relative; width: 100%; max-width: 420px; text-align: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
  padding: 32px 26px 28px; box-shadow: 0 24px 60px rgba(42, 38, 34, 0.3);
  animation: cardIn .45s var(--ease-out); max-height: 92vh; overflow-y: auto;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(.95); } to { opacity: 1; transform: none; } }
.lose-card { animation: cardIn .45s var(--ease-out), miss .5s ease .08s; }
@keyframes miss { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 55%{transform:translateX(6px)} 80%{transform:translateX(-3px)} }
.win-card { border-color: var(--clay); }
.big-emoji { font-size: 60px; line-height: 1; margin-bottom: 4px; }
.overlay-title { font-family: var(--font-display); font-weight: 900; font-size: 38px; line-height: 1; color: var(--ink); }
.overlay-title em { color: var(--clay); font-style: italic; }
.overlay-body { font-size: 15px; line-height: 1.55; color: var(--ink-soft); margin: 11px 0; }
.overlay-body b { color: var(--ink); }
.overlay-body.dim { color: #a99e8f; font-size: 13.5px; }
.ghost-btn {
  margin-top: 14px; background: var(--clay); border: none; color: #fff;
  font-family: var(--font-body); font-weight: 800; font-size: 14.5px;
  padding: 13px 22px; border-radius: 12px; cursor: pointer; transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.ghost-btn:hover { background: var(--clay-deep); transform: translateY(-1px); }
.won-kicker { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; color: var(--clay); margin: 4px 0 2px; }
.won-kicker .logo-slot { width: 15px; height: 15px; }
.win-title { font-size: 30px; }
.prize-xl { display: block; font-size: 42px; margin-top: 2px; color: var(--clay); font-style: italic; }
.claim-box { text-align: left; margin: 16px 0 6px; padding: 16px 18px; background: var(--cream); border: 1px solid var(--line); border-radius: 14px; }
.claim-line { font-size: 14px; line-height: 1.5; color: var(--ink-soft); margin-bottom: 8px; }
.claim-line b { color: var(--ink); }
.claim-code {
  font-family: var(--font-display); font-weight: 900; letter-spacing: .08em; font-size: 25px;
  color: var(--clay-deep); text-align: center; margin: 10px 0 6px; padding: 10px;
  background: #f6e7e0; border-radius: 10px; border: 1px dashed var(--clay);
}
.claim-to { text-align: center; font-size: 16px; font-weight: 800; color: var(--clay-deep); }

#confetti { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: none; }
#confetti.show { display: block; }

@media (min-width: 720px) {
  .stage { max-width: 600px; padding-top: 12px; }
  .wheel-wrap { width: 440px; }
}
@media (max-width: 380px) {
  .wheel-wrap { width: 90vw; }
  .headline { font-size: 38px; }
}

/* ── spotlight: wheel pops out big while spinning, everything else darkens ── */
body.no-scroll { overflow: hidden; }
.spotlight {
  position: fixed; inset: 0; z-index: 30; display: none;
  align-items: center; justify-content: center;
  background: rgba(22, 16, 12, 0.88); backdrop-filter: blur(5px);
}
.spotlight.show { display: flex; animation: overlayIn .35s ease; }
.spotlight-stage { display: flex; align-items: center; justify-content: center; }
.spotlight .wheel-wrap { width: min(94vw, 540px) !important; cursor: default; animation: popIn .55s var(--ease-out); }
.spotlight .wheel { filter: drop-shadow(0 18px 50px rgba(0, 0, 0, .5)); }
.spotlight .tap-cue { display: none; }
@keyframes popIn { from { transform: scale(.65); opacity: .3; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .spin-btn, .tap-cue, .overlay.show, .overlay-card, .lose-card, .wheel-hint.show { animation: none !important; }
}
