:root {
  --bg: #0f2a20;
  --bg2: #14382b;
  --card: #fbf7ee;
  --ink: #1d2a24;
  --muted: #6f7a72;
  --line: #e7e0cf;
  --red: #b3282d;
  --red-d: #8e1d22;
  --gold: #d6a84a;
  --cream: #f4ecd8;
  --radius: 18px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg2), var(--bg)) fixed, var(--bg);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #ffffff55, transparent),
    radial-gradient(1.5px 1.5px at 120px 80px, #ffffff40, transparent),
    radial-gradient(2px 2px at 200px 160px, #ffffff35, transparent),
    radial-gradient(1px 1px at 60px 200px, #ffffff50, transparent),
    radial-gradient(1.5px 1.5px at 260px 40px, #ffffff40, transparent);
  background-size: 300px 240px;
  animation: snow 40s linear infinite;
}
@keyframes snow { to { background-position: 60px 960px; } }
@media (prefers-reduced-motion: reduce) { #snow { animation: none; } }

main { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 20px 16px 48px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.hero { text-align: center; color: var(--cream); padding: 28px 0 22px; }
.hero h1 { font-size: 34px; line-height: 1.1; }
.hero .star { font-size: 26px; color: var(--gold); display: block; margin-bottom: 8px; }
.hero .sub { color: #cfd9cf; opacity: .8; margin-top: 8px; font-size: 14px; }

.topbar { display: flex; align-items: center; justify-content: space-between; color: var(--cream); padding: 6px 2px 16px; }
.topbar .hi { font-family: var(--serif); font-size: 22px; }
.topbar .hi small { display: block; font-family: var(--sans); font-size: 12px; opacity: .65; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: 0 10px 30px #00000030; }
.card h2 { font-size: 20px; margin-bottom: 12px; }
.card h3 { font-size: 16px; margin: 16px 0 8px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

button, .btn {
  font: inherit; font-weight: 600; border: 0; cursor: pointer; border-radius: 12px;
  padding: 12px 16px; background: var(--red); color: #fff; transition: transform .08s, background .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
button:active { transform: scale(.97); }
button:hover { background: var(--red-d); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover { background: #00000008; }
button.light { background: #ffffff18; color: var(--cream); }
button.light:hover { background: #ffffff28; }
button.link { background: none; color: var(--muted); padding: 6px 8px; font-weight: 500; }
button.link:hover { background: none; color: var(--ink); }
button.block { width: 100%; }
button.icon { padding: 8px 10px; background: transparent; color: var(--muted); }
button.icon:hover { background: #00000008; color: var(--red); }

input, textarea, select {
  font: inherit; width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); outline: none;
}
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px #d6a84a33; }
textarea { resize: vertical; min-height: 64px; }

/* nomes */
.names { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.name-chip {
  background: var(--card); color: var(--ink); border-radius: 999px; padding: 10px 16px; font-weight: 500;
  border: 0; box-shadow: 0 4px 14px #00000025;
}
.name-chip:hover { background: #fff; }
.name-chip { display: inline-flex; align-items: center; gap: 8px; padding-left: 8px; }
.bot { flex: none; position: relative; }
.me-bot { background: #ffffff14; padding: 4px; border-radius: 16px; }
.me-bot:hover { background: #ffffff24; }
.draw-stage { display: flex; justify-content: center; }
.name-chip.new { background: transparent; color: var(--cream); border: 1.5px dashed #ffffff55; box-shadow: none; }
.name-chip.new:hover { background: #ffffff10; }

/* pin */
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 18px 0 22px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); transition: background .1s; }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; }
.keypad button { background: #fff; color: var(--ink); font-size: 22px; padding: 14px 0; border: 1px solid var(--line); font-weight: 500; }
.keypad button:hover { background: #f5f1e6; }
.keypad button.blank { visibility: hidden; }

/* evento */
.event { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.event .full { grid-column: 1 / -1; }
.event .v { font-weight: 600; }
.countdown { display: flex; gap: 8px; justify-content: space-between; }
.countdown div { flex: 1; text-align: center; background: var(--bg2); color: var(--cream); border-radius: 12px; padding: 10px 4px; }
.countdown b { display: block; font-family: var(--serif); font-size: 26px; line-height: 1; }
.countdown small { font-size: 11px; opacity: .7; }

/* amigo */
.friend { background: linear-gradient(160deg, #fff7e6, var(--card)); border: 1px solid #ecd9a8; }
.friend .who { font-family: var(--serif); font-size: 34px; color: var(--red); line-height: 1.1; margin: 4px 0 2px; }
.draw-box { text-align: center; padding: 14px 0 6px; }
.draw-box .gift { font-size: 54px; display: block; margin-bottom: 10px; }
.roller { font-family: var(--serif); font-size: 34px; height: 46px; color: var(--red); overflow: hidden; margin: 14px 0; }

/* presentes */
.wish { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.wish:first-of-type { border-top: 0; }
.wish .thumb { width: 64px; height: 64px; flex: none; border-radius: 10px; background: #efe8d6 center/cover no-repeat; display: grid; place-items: center; font-size: 26px; overflow: hidden; }
.wish .thumb img { width: 100%; height: 100%; object-fit: cover; }
.wish .info { flex: 1; min-width: 0; }
.wish .t { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.wish .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wish .n { font-size: 14px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.wish a { color: inherit; text-decoration: none; }
.wish a:hover .t { text-decoration: underline; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* perguntas */
.q { padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); margin-top: 8px; }
.q .a { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); color: var(--ink); }
.q .a.none { color: var(--muted); font-style: italic; }
.badge { display: inline-block; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; font-family: var(--sans); }

/* admin */
.person { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person .nm { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot.on { background: #2e8b57; }
.tag { font-size: 11px; color: var(--muted); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { width: auto; transform: scale(1.3); accent-color: var(--red); }
.pairs div { padding: 6px 0; border-top: 1px solid var(--line); }
.pairs div:first-child { border-top: 0; }

/* modal */
.sheet-bg { position: fixed; inset: 0; background: #00000080; z-index: 10; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .2s ease-out; max-height: 92dvh; overflow: auto; }
@media (min-width: 560px) { .sheet-bg { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: .2s; z-index: 20; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

.foot { text-align: center; margin-top: 26px; }
.foot button { color: #ffffff70; }
.foot button:hover { color: var(--cream); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
