:root {
  --bg: #fbf5ee;
  --bg2: #f6e6d6;
  --glow: #fde3cf;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(110, 60, 30, 0.16);
  --text: #3a2418;
  --muted: #7d6253;
  --gold: #b97a24;
  --rose: #e9a7b8;
  --field: rgba(255, 255, 255, 0.85);
  --btn: rgba(255, 255, 255, 0.7);
  --btn-hover: #fff;
  --shade: rgba(255, 249, 242, 0.88);
  --tshadow: 0 2px 22px rgba(255, 250, 244, 0.95);
  --veil: rgba(255, 248, 240, 0.55);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Evening backdrop: dark room. */
body.dark {
  --bg: #120806; --bg2: #24120c; --glow: #4a2416;
  --card: rgba(255, 244, 232, 0.06); --line: rgba(255, 228, 200, 0.16);
  --text: #fbefe3; --muted: #c9b3a2; --gold: #e8b866;
  --field: rgba(0, 0, 0, 0.28); --btn: rgba(255, 255, 255, 0.07); --btn-hover: rgba(255, 255, 255, 0.12);
  --shade: rgba(12, 5, 3, 0.82); --tshadow: 0 4px 30px rgba(0, 0, 0, 0.75); --veil: rgba(18, 8, 6, 0.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  background: radial-gradient(1200px 700px at 50% -10%, var(--glow) 0%, var(--bg2) 40%, var(--bg) 100%) fixed;
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.playing { overflow: hidden; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: none; touch-action: none; }
body.scene #stage { display: block; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 18px; letter-spacing: .02em; display: flex; gap: 8px; align-items: center; }
.langs { display: flex; gap: 4px; background: var(--btn); border: 1px solid var(--line); border-radius: 999px; padding: 3px; backdrop-filter: blur(8px); }
.langs button { background: none; border: 0; padding: 4px 10px; border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--muted); }
.langs button.on { background: var(--text); color: var(--bg); }
body.playing .brand { opacity: .6; }

/* ---------- creator ---------- */
#creator { max-width: 1060px; margin: 0 auto; padding: 88px 16px 32px; display: grid; gap: 32px; grid-template-columns: 1.05fr 1fr; align-items: start; }
@media (max-width: 860px) { #creator { grid-template-columns: 1fr; padding-top: 76px; } }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(34px, 5.4vw, 58px); line-height: 1.05; margin: 8px 0 16px; letter-spacing: -.01em; }
.lead { color: var(--muted); font-size: 18px; max-width: 34em; margin: 0 0 22px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; color: var(--text); }
.steps li::before { content: counter(s); width: 28px; height: 28px; flex: none; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold); display: grid; place-items: center; font-size: 14px; }

.hero-cake { position: relative; width: 180px; height: 150px; margin: 0 0 6px; }
.hero-cake .plate { position: absolute; bottom: 0; left: 0; right: 0; height: 12px; border-radius: 50%; background: linear-gradient(#fff, #d9cfc6); box-shadow: 0 10px 30px rgba(60,30,10,.25); }
.hero-cake .tier { position: absolute; bottom: 8px; left: 18px; right: 18px; height: 70px; border-radius: 10px 10px 14px 14px; background: linear-gradient(90deg, #e7cdb6, #f8e9da 45%, #e2c4ac); }
.hero-cake .tier::before { content: ""; position: absolute; top: -6px; left: -3px; right: -3px; height: 26px; border-radius: 12px; background: radial-gradient(circle at 10% 100%, #e9a7b8 0 10px, transparent 11px) 0 0/24px 26px repeat-x, linear-gradient(#e9a7b8, #e9a7b8) top/100% 12px no-repeat; }
.hero-cake .cndl { position: absolute; bottom: 76px; width: 9px; height: 40px; border-radius: 3px; background: repeating-linear-gradient(135deg, #fff 0 5px, var(--rose) 5px 10px); }
.hero-cake .c1 { left: 52px; } .hero-cake .c2 { left: 86px; height: 46px; } .hero-cake .c3 { left: 120px; }
.hero-cake .flame { position: absolute; width: 12px; height: 22px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #fff7d6 0 25%, #ffc24a 45%, rgba(255,120,30,.0) 72%); filter: drop-shadow(0 0 10px rgba(255,170,60,.9)); animation: flick 1.6s ease-in-out infinite; transform-origin: 50% 100%; }
.hero-cake .f1 { left: 50.5px; bottom: 114px; } .hero-cake .f2 { left: 84.5px; bottom: 120px; animation-delay: -.5s; } .hero-cake .f3 { left: 118.5px; bottom: 114px; animation-delay: -1s; }
@keyframes flick { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08, .94) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .hero-cake .flame { animation: none; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px; backdrop-filter: blur(10px); display: grid; gap: 16px; box-shadow: 0 30px 80px rgba(60,30,10,.12); }
label, legend { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 17px; outline: none; }
input:focus { border-color: var(--gold); }
.row { display: grid; grid-template-columns: auto 1fr; gap: 14px; }
@media (max-width: 420px) { .row { grid-template-columns: 1fr; } }
.stepper { display: flex; align-items: stretch; }
.stepper input { width: 76px; text-align: center; border-radius: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper button { width: 44px; background: var(--btn); border: 1px solid var(--line); cursor: pointer; font-size: 20px; }
.stepper button:first-child { border-radius: 12px 0 0 12px; border-right: 0; }
.stepper button:last-child { border-radius: 0 12px 12px 0; border-left: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.themes label { cursor: pointer; display: block; }
.themes input { position: absolute; opacity: 0; pointer-events: none; }
.themes span { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); color: var(--text); font-size: 14px; background: var(--field); }
.themes i { display: flex; gap: 3px; }
.themes i b { width: 14px; height: 14px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.themes input:checked + span { border-color: var(--gold); background: rgba(232,184,102,.18); box-shadow: 0 0 0 1px var(--gold); }
.themes input:focus-visible + span { outline: 2px solid var(--gold); }
.err { color: #c0392b; margin: 0; font-size: 14px; }
.link-box { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.link-box code { display: block; padding: 10px 12px; border-radius: 10px; background: var(--field); border: 1px dashed var(--line); color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--btn); color: var(--text); border-radius: 999px; padding: 12px 20px; font-size: 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; transition: transform .15s, background .2s; }
.btn:hover { background: var(--btn-hover); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #f2c97e, #d9a14b); color: #2a140c; border-color: transparent; font-weight: 600; }
.foot { grid-column: 1 / -1; display: flex; gap: 14px; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; padding-top: 8px; }
.foot .pb { color: var(--text); text-decoration: none; letter-spacing: .22em; font-weight: 700; font-size: 12px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; }
#invite { background: radial-gradient(circle at 50% 55%, transparent, var(--veil)); }
.invite-card, .final-card { text-align: center; max-width: 560px; }
.invite-card h1, .final-card h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 7vw, 54px); line-height: 1.08; margin: 0 0 12px; text-shadow: var(--tshadow); }
.from-line { color: var(--gold); font-size: 18px; margin: 0 0 8px; }
.hint { color: var(--text); margin: 0 0 24px; text-shadow: var(--tshadow); }
.muted { color: var(--muted); font-size: 14px; }
.btn.play { font-size: 20px; padding: 16px 34px; background: linear-gradient(180deg, #f2c97e, #d9a14b); color: #2a140c; border: 0; font-weight: 700; box-shadow: 0 10px 40px rgba(232,184,102,.35); }
.btn.play:disabled { opacity: .5; }
.tri { width: 0; height: 0; border-left: 14px solid currentColor; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }

.msg { position: fixed; left: 0; right: 0; top: 23%; z-index: 9; text-align: center; padding: 0 16px; font-family: var(--serif); font-size: clamp(28px, 6.5vw, 50px); line-height: 1.15; text-shadow: var(--tshadow); color: var(--text); opacity: 0; transform: translateY(10px); transition: opacity .8s, transform .8s; pointer-events: none; }
.msg.on { opacity: 1; transform: none; }
.msg small { display: block; font-family: var(--sans); font-size: 16px; color: var(--muted); margin-top: 10px; }

.blow-ui { position: fixed; left: 0; right: 0; bottom: 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important; padding-top: 60px !important; background: linear-gradient(transparent, var(--shade) 45%); z-index: 9; display: grid; justify-items: center; gap: 10px; padding: 0 16px; text-align: center; }
.blow-hint { margin: 0; font-size: 17px; }
.meter { width: min(260px, 70vw); height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffcf73, #ff8a3d); border-radius: 3px; transition: width .06s linear; }
.btn.hold { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; font-size: 14px; padding: 9px 16px; }
.btn.hold.active { background: rgba(232,184,102,.35); }
.privacy { margin: 0; font-size: 12px; color: var(--muted); max-width: 30em; }

.final { background: radial-gradient(circle at 50% 50%, transparent, var(--veil)); align-content: start; padding-top: 12vh; pointer-events: none; }
.final .btn { pointer-events: auto; }
.final-card { animation: rise 1s ease both; }
.final-card .sub { color: var(--text); font-size: 18px; margin: 0 0 8px; text-shadow: var(--tshadow); }
.final-actions { justify-content: center; position: fixed; animation: rise 1s .4s ease both; left: 0; right: 0; bottom: 0; padding: 50px 16px calc(20px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--shade) 50%); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #fbefe3; color: #2a140c; padding: 10px 16px; border-radius: 999px; z-index: 30; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

.backdrops { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; align-items: center; }
.backdrops label { display: block; cursor: pointer; position: relative; }
.backdrops input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.backdrops span { display: block; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); box-shadow: inset 0 -8px 14px rgba(0,0,0,.08); }
.backdrops input:checked + span { outline: 2px solid var(--gold); outline-offset: 3px; }
.backdrops input:focus-visible + span { outline: 2px dashed var(--gold); outline-offset: 3px; }
.backdrops .custom span { background: conic-gradient(#f7c6d4, #fde3a7, #cdeccf, #c9def5, #e2d2f5, #f7c6d4); display: grid; place-items: center; font-size: 18px; color: #3a2418; }
.backdrops input[type=color] { position: absolute; inset: 0; opacity: 0; width: 38px; height: 38px; padding: 0; border: 0; cursor: pointer; }
.bd-name { font-size: 13px; color: var(--muted); }
fieldset legend { display: block; }
