:root {
  --bg: #E9E3F3; --surface: #FFFFFF; --ink: #2B1B3D; --muted: #6B5A80;
  --ribbon: #C8324B; --ribbon-ink: #FFFFFF; --gold: #E0A526; --line: #D3C8E4;
  --hat: #2B1B3D; --hat-shine: #4A3463; --field: #F6F2FB;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1126; --surface: #261A36; --ink: #F1E9FA; --muted: #B4A3C9;
    --ribbon: #E2506A; --ribbon-ink: #1A1126; --gold: #F0BC4A; --line: #3D2C52;
    --hat: #0F0918; --hat-shine: #3A2A50; --field: #1F1530;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.0625rem; line-height: 1.5;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
main { max-width: 34rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
h1, .big {
  font-family: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-weight: 400; line-height: 1.02; letter-spacing: -0.01em; margin: 0;
}
h1 { font-size: clamp(2.6rem, 11vw, 4rem); }
h2 { font-size: 1.35rem; margin: 0; }
p { margin: 0; }
.lead { color: var(--muted); margin-top: .75rem; max-width: 30rem; }
.hero { display: flex; align-items: flex-end; gap: 1rem; margin-bottom: 2rem; }
.hero svg { flex: none; width: 4.5rem; height: auto; transform: rotate(-8deg); }
.panel { background: var(--surface); border-radius: 1.25rem; padding: 1.5rem; border: 1px solid var(--line); }
.panel + .panel { margin-top: 1rem; }
label { display: block; font-weight: 700; margin-bottom: .35rem; }
.hint { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.field + .field { margin-top: 1.25rem; }
input[type=text], input[type=password], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--field);
  border: 1.5px solid var(--line); border-radius: .75rem; padding: .7rem .85rem;
}
textarea { min-height: 11rem; resize: vertical; line-height: 1.6; }
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
.primary {
  display: block; width: 100%; margin-top: 1.5rem; border: 0; border-radius: 999px;
  background: var(--ribbon); color: var(--ribbon-ink); font-weight: 700; padding: .95rem 1.25rem; font-size: 1.1rem;
}
.ghost {
  border: 1.5px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: .5rem 1rem; font-weight: 600; font-size: .95rem;
}
.copied { background: var(--gold); border-color: var(--gold); color: #2B1B3D; }
.error { color: var(--ribbon); font-weight: 600; margin-top: .75rem; min-height: 1.5em; }
.round { display: inline-block; background: var(--gold); color: #2B1B3D; font-weight: 700; border-radius: .5rem; padding: .1rem .55rem; font-size: .95rem; }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
ul.rows { list-style: none; padding: 0; margin: 1.25rem 0 0; }
ul.rows li { display: grid; grid-template-columns: 1fr auto; gap: .35rem .75rem; align-items: center; padding: .85rem 0; border-top: 1px solid var(--line); }
ul.rows li:first-child { border-top: 0; }
.who { font-weight: 700; }
.state { color: var(--muted); font-size: .95rem; text-align: right; }
.state.done { color: var(--ink); font-weight: 600; }
.msg { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); min-height: 0; }
.footnote { color: var(--muted); font-size: .9rem; margin-top: 1.25rem; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.code-input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; font-size: 1.2rem; text-align: center; }

.reveal { text-align: center; padding-top: 1.5rem; }
.reveal h1 { font-size: clamp(2.2rem, 9vw, 3.2rem); }
.reveal .lead { margin: .75rem auto 0; }
.stage { position: relative; margin: 2.25rem auto 0; width: min(19rem, 86vw); aspect-ratio: 1 / 1.05; }
.name-card {
  position: absolute; left: 6%; right: 6%; bottom: 0; height: 52%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 1.25rem;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 1rem; opacity: 0; transition: opacity .4s ease .35s;
}
.name-card small { color: var(--muted); font-size: .95rem; }
.name-card .big { font-size: clamp(2rem, 10vw, 2.9rem); margin-top: .25rem; color: var(--ribbon); word-break: break-word; }
.hat-btn { position: absolute; inset: 0; border: 0; background: none; padding: 0; transition: transform .9s cubic-bezier(.3,1.4,.5,1); transform-origin: 50% 80%; }
.hat-btn svg { width: 100%; height: 100%; display: block; }
.hat-btn:hover { transform: rotate(-3deg); }
.stage.open .hat-btn { transform: translateY(-62%) rotate(-14deg); pointer-events: none; }
.stage.open .name-card { opacity: 1; }
.stage.closed .hat-btn { pointer-events: none; }
.tap { margin-top: 1.25rem; font-weight: 700; }
.after { margin-top: 2rem; color: var(--muted); }
.after strong { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .hat-btn, .name-card { transition: none; } }
[hidden] { display: none !important; }
