:root {
  --red: #c8102e;
  --red-deep: #9e0b23;
  --red-ink: #7a0a1b;
  --green: #0f7a3e;
  --green-deep: #0b5e30;
  --gold: #ffd34d;
  --butter: #ffe08a;
  --ink: #1a1a1a;
  --muted: #5b5b5b;
  --line: #ececec;
  --chip: #f3f3f3;
  --card: #ffffff;
  --radius: 22px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.2, .9, .3, 1.15);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 400 17px/1.45 var(--font);
  color: #fff;
  min-height: 100dvh;
  background-color: var(--red);
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,.13) 2px, transparent 3px),
    radial-gradient(circle at 75% 75%, rgba(255,255,255,.13) 2px, transparent 3px);
  background-size: 30px 30px;
  background-attachment: fixed;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
#app { max-width: 520px; margin: 0 auto; padding: 0 18px calc(40px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; }
.screen { display: flex; flex-direction: column; flex: 1; animation: screenIn .38s var(--ease-out) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 10px; gap: 8px; }
.brand { font-weight: 800; font-size: 15px; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; color: var(--butter); text-transform: uppercase; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 18px; transition: transform .12s var(--ease-out), background .2s; }
.icon-btn:active { transform: scale(.92); background: rgba(255,255,255,.24); }
.top-actions { display: flex; gap: 8px; }

/* ---------- type ---------- */
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--butter); }
.title { font-size: clamp(34px, 9vw, 44px); line-height: 1.02; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; }
.h2 { font-size: 24px; line-height: 1.12; font-weight: 800; letter-spacing: -.02em; }
.h3 { font-size: 19px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
.lead { font-size: 18px; line-height: 1.45; opacity: .95; margin-top: 10px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }

/* ---------- cards ---------- */
.card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 20px; box-shadow: 0 12px 30px rgba(0, 0, 0, .16); }
.card + .card { margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.card .card-top { display: flex; align-items: center; gap: 12px; }
.card .emoji-badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: #fff3c4; flex: none; }
.card .emoji-badge.green { background: #dff3e6; }
.card .emoji-badge.red { background: #fde3e7; }
.card p { margin-top: 8px; }
.card.next { outline: 3px solid var(--butter); outline-offset: 3px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--chip); color: var(--ink); }
.pill.green { background: #dff3e6; color: var(--green-deep); }
.pill.gold { background: #fff3c4; color: #6b4e00; }
.pill.red { background: #fde3e7; color: var(--red-ink); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 14px 18px; border-radius: 16px; font-weight: 800; font-size: 17px; transition: transform .12s var(--ease-out), opacity .2s, background .2s; user-select: none; text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--butter); color: var(--red-ink); box-shadow: 0 6px 0 #e3b84a; }
.btn-primary:active:not(:disabled) { box-shadow: 0 3px 0 #e3b84a; transform: translateY(3px) scale(.99); }
.btn-red { background: var(--red); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-ghost { background: var(--chip); color: var(--ink); }
.btn-light { background: rgba(255,255,255,.16); color: #fff; }
.btn-sm { min-height: 42px; padding: 9px 14px; font-size: 15px; border-radius: 12px; width: auto; }
.link-btn { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 10px 15px; border-radius: 999px; background: var(--chip); color: var(--ink); font-weight: 600; font-size: 16px; transition: transform .12s var(--ease-out), background .18s, color .18s; }
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] { background: var(--green); color: #fff; }
.chip .check { display: none; }
.chip[aria-pressed="true"] .check { display: inline; }

.vibe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vibe { text-align: left; background: var(--chip); color: var(--ink); border-radius: 18px; padding: 14px; min-height: 108px; display: flex; flex-direction: column; gap: 4px; transition: transform .12s var(--ease-out), background .18s, color .18s; border: 2px solid transparent; }
.vibe:active { transform: scale(.97); }
.vibe .em { font-size: 28px; }
.vibe .lbl { font-weight: 800; font-size: 17px; }
.vibe .hint { font-size: 14px; color: var(--muted); line-height: 1.3; }
.vibe[aria-pressed="true"] { background: #e3f4e9; border-color: var(--green); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.label { font-size: 15px; font-weight: 700; color: var(--ink); }
.input, .textarea { width: 100%; background: #f6f6f6; border: 2px solid transparent; border-radius: 14px; padding: 13px 14px; font-size: 17px; color: var(--ink); outline: none; transition: border-color .15s, background .15s; }
.input:focus, .textarea:focus { border-color: var(--green); background: #fff; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.4; }
.input::placeholder, .textarea::placeholder { color: #8a8a8a; }

/* ---------- login ---------- */
.login-hero { text-align: center; padding-top: 1vh; }
.login-hero img { width: 100%; aspect-ratio: 1200 / 789; object-fit: cover; border-radius: var(--radius); background: #fff; margin: 0 auto 18px; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.pin { position: relative; display: flex; justify-content: center; gap: 12px; margin: 22px 0 8px; }
.pin input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; }
.pin .box { width: 62px; height: 74px; border-radius: 18px; background: #fff; color: var(--ink); display: grid; place-items: center; font-size: 34px; font-weight: 800; box-shadow: 0 6px 0 rgba(0,0,0,.12); transition: transform .15s var(--spring); }
.pin .box.filled { transform: translateY(-3px); }
.pin .box.cursor { outline: 3px solid var(--butter); outline-offset: 2px; }
.pin.shake { animation: shake .42s; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.error-msg { min-height: 26px; text-align: center; font-weight: 700; color: var(--butter); }

/* ---------- countdown ---------- */
.countdown { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 18px; }
.countdown .num { font-size: 64px; line-height: 1; font-weight: 800; letter-spacing: -.04em; color: var(--butter); }
.countdown .txt { font-size: 18px; font-weight: 700; line-height: 1.2; }

/* ---------- budget vote ---------- */
.vote-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.vote-btn { min-height: 72px; border-radius: 18px; background: var(--chip); color: var(--ink); font-size: 24px; font-weight: 800; transition: transform .12s var(--ease-out), background .18s, color .18s; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.vote-btn small { font-size: 13px; font-weight: 700; opacity: .7; }
.vote-btn:active { transform: scale(.95); }
.vote-btn[aria-pressed="true"] { background: var(--green); color: #fff; }
.meter { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; margin-top: 12px; }
.meter > i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .5s var(--ease-out); }

/* ---------- wizard ---------- */
.wiz-head { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 0 12px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.35); transition: background .2s, transform .2s var(--spring); }
.dots i.on { background: #fff; }
.dots i.now { transform: scale(1.35); background: var(--butter); }
.wiz-body { flex: 1; display: flex; flex-direction: column; }
.wiz-q { margin: 6px 0 14px; }
.wiz-foot { position: sticky; bottom: 0; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; background: linear-gradient(to top, var(--red) 70%, rgba(200,16,46,0)); margin-top: 16px; }
.wiz-foot .btn-back { flex: 0 0 auto; width: 64px; }
.step-anim { animation: stepIn .34s var(--ease-out) both; }
@keyframes stepIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.group-label { font-size: 14px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.group-label:first-child { margin-top: 0; }

.idea-row { background: #f6f6f6; border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; animation: stepIn .25s var(--ease-out) both; }
.idea-row + .idea-row { margin-top: 10px; }
.idea-row .top { display: flex; gap: 8px; align-items: center; }
.idea-row .input { background: #fff; padding: 11px 12px; }
.idea-row .num { width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; flex: none; }
.idea-row .sub { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.idea-row .x { width: 36px; height: 36px; border-radius: 50%; color: var(--muted); font-size: 20px; flex: none; }
.progress-note { display: flex; align-items: center; gap: 10px; font-weight: 800; margin: 2px 0 12px; }
.progress-note .ring { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); font-size: 15px; }
.progress-note.ok .ring { background: var(--green); color: #fff; }

/* ---------- present + reveal ---------- */
.present-wrap { display: grid; place-items: center; padding: 10px 0; }
.present { width: 210px; height: 210px; position: relative; cursor: pointer; transition: transform .2s var(--ease-out); }
.present:active { transform: scale(.96); }
.present svg { width: 100%; height: 100%; overflow: visible; }
.present .lid { transform-origin: 50% 40%; transition: transform .7s var(--spring), opacity .5s; }
.present.wiggle { animation: wiggle 1.8s ease-in-out infinite; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); } 85% { transform: rotate(-3deg); } 90% { transform: rotate(2deg); } }
.present.shake { animation: bigshake .5s ease-in-out; }
@keyframes bigshake { 0%,100% { transform: none; } 20% { transform: rotate(-9deg) scale(1.04); } 40% { transform: rotate(8deg) scale(1.06); } 60% { transform: rotate(-6deg) scale(1.06); } 80% { transform: rotate(4deg) scale(1.03); } }
.present.open .lid { transform: translateY(-140px) rotate(-24deg); opacity: 0; }
.present.open .box-body { animation: boxDrop .6s var(--ease-out) forwards; }
@keyframes boxDrop { to { transform: translateY(30px) scale(.9); opacity: 0; } }
.reveal-name { text-align: center; }
.reveal-name .big { font-size: clamp(56px, 18vw, 92px); font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--butter); text-shadow: 0 6px 0 var(--red-deep); animation: nameIn .7s var(--spring) both; }
@keyframes nameIn { from { opacity: 0; transform: scale(.4) translateY(30px); } to { opacity: 1; transform: none; } }
.reveal-name .lead { animation: screenIn .5s .35s var(--ease-out) both; }

/* ---------- giver / board ---------- */
.idea-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 18px; background: #f7f7f7; }
.idea-card + .idea-card { margin-top: 10px; }
.idea-card .t { font-weight: 800; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.idea-card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.facts { display: grid; gap: 12px; }
.fact .k { font-size: 14px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fact .v { margin-top: 3px; overflow-wrap: anywhere; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(255,255,255,.16); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { min-height: 44px; border-radius: 11px; font-weight: 800; color: #fff; transition: background .2s, color .2s; }
.seg button[aria-selected="true"] { background: #fff; color: var(--red-ink); }
.claim { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.claim:first-child { border-top: 0; }
.total { font-size: 32px; font-weight: 800; letter-spacing: -.02em; color: var(--green); }
.sticky-bottom { position: sticky; bottom: 0; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--red) 70%, rgba(200,16,46,0)); margin-top: 8px; }
.banner { background: #fff3c4; color: #5a4100; border-radius: 14px; padding: 12px 14px; font-weight: 600; font-size: 15px; }

/* ---------- sheet ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 60; opacity: 0; transition: opacity .22s; }
.sheet-scrim.show { opacity: 1; }
.sheet { width: 100%; max-width: 520px; background: #fff; color: var(--ink); border-radius: 24px 24px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .32s var(--ease-out); }
.sheet-scrim.show .sheet { transform: none; }

/* ---------- toast + confetti ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); background: #111; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .35s var(--spring); z-index: 50; max-width: calc(100% - 36px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }

.hero-img { width: 100%; border-radius: 20px; margin: 4px 0 16px; box-shadow: 0 14px 30px rgba(0,0,0,.2); }
.foot-note { text-align: center; font-size: 14px; opacity: .85; margin-top: 22px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spin .8s linear infinite; margin: 30vh auto 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .present.open .lid { transform: none; }
}
@media (min-width: 700px) {
  #app { padding-top: 20px; }
}
