:root {
  --plum: #2A0B2E;
  --plum-2: #3E1341;
  --plum-3: #561C58;
  --rani: #E2266F;
  --rani-dark: #B5155A;
  --marigold: #F5A524;
  --gold: #F7D774;
  --ivory: #FFF3DC;
  --muted: #D2B3CF;
  --teal: #19B3A6;
  --display: "Rozha One", Georgia, serif;
  --body: "Mukta", system-ui, sans-serif;
  --radius-lg: 22px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% 0%, #4A1450 0%, transparent 60%),
    var(--plum);
  color: var(--ivory);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Marigold garland strung across the top */
.garland {
  height: 30px;
  margin-top: env(safe-area-inset-top);
  background:
    radial-gradient(circle at 15px 12px, var(--gold) 0 4px, var(--marigold) 5px 10px, #D9730D 11px 12px, transparent 13px) 0 0 / 30px 30px repeat-x;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35));
}
.garland::after {
  content: "";
  display: block;
  height: 14px;
  margin-top: -6px;
  background:
    radial-gradient(circle at 15px 6px, var(--rani) 0 5px, transparent 6px) 15px 0 / 60px 14px repeat-x;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.1; margin: 0; }
h2 { font-size: 2rem; color: var(--gold); }
h3 { font-size: 1.35rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.center { text-align: center; }

/* The poster title — the one loud thing */
.marquee {
  text-align: center;
  padding: 18px 0 8px;
}
.marquee h1 {
  font-size: clamp(3rem, 15vw, 4.6rem);
  color: var(--gold);
  text-shadow:
    3px 3px 0 var(--rani),
    6px 6px 0 var(--plum-3),
    0 0 40px rgba(245, 165, 36, .35);
  letter-spacing: .01em;
  transform: rotate(-3deg);
}
.marquee h1 span { display: block; }
.marquee h1 .line-2 { font-size: .62em; color: var(--ivory); margin-top: .1em; }
.marquee p { margin-top: 22px; color: var(--muted); }

/* Buttons */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--rani);
  color: var(--ivory);
  font: 800 1.1rem/1.2 var(--body);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--rani-dark);
  transition: transform .08s ease, box-shadow .08s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rani-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.gold { background: var(--marigold); color: var(--plum); box-shadow: 0 4px 0 #B8730A; }
.btn.ghost {
  background: transparent;
  border: 2px solid var(--plum-3);
  box-shadow: none;
  color: var(--ivory);
  font-weight: 600;
}
.btn.link {
  background: none; box-shadow: none; min-height: 44px; width: auto;
  padding: 8px 4px; color: var(--muted); font-weight: 600; text-decoration: underline;
}
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* Panels */
.panel {
  background: var(--plum-2);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--plum-3);
}

/* Forms */
label.field { display: block; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--plum-3);
  background: var(--plum);
  color: var(--ivory);
  font: 400 1.05rem/1.4 var(--body);
}
input[type="text"]:focus, textarea:focus { border-color: var(--marigold); outline: none; }
textarea { min-height: 170px; resize: vertical; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 800 !important; text-align: center; font-size: 1.4rem !important; }
.hint { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.error { color: #FF9DB8; font-weight: 600; }

/* Category editor */
.cat-row { display: flex; gap: 8px; align-items: center; }
.cat-row input { flex: 1; }
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--plum-3); background: transparent; color: var(--muted);
  font-size: 1.3rem; cursor: pointer;
}

/* Mode choice */
.choice { display: grid; gap: 10px; }
.choice label {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 2px solid var(--plum-3); cursor: pointer;
}
.choice input { margin-top: 6px; accent-color: var(--rani); width: 18px; height: 18px; flex: none; }
.choice label:has(input:checked) { border-color: var(--marigold); background: rgba(245, 165, 36, .08); }
.choice strong { display: block; }

/* Ballot */
fieldset.ballot-cat { border: 1px solid var(--plum-3); padding: 18px 20px 20px; margin: 0; min-width: 0; }
fieldset.ballot-cat legend { padding: 0; margin-bottom: 4px; float: left; width: 100%; }
fieldset.ballot-cat legend + * { clear: both; }
fieldset.ballot-cat legend h3 { color: var(--gold); }
fieldset.ballot-cat .cat-hint { color: var(--muted); font-size: .95rem; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: 10px 16px; border-radius: 999px;
  border: 2px solid var(--plum-3); background: var(--plum); font-weight: 600;
  min-height: 44px;
}
.chip input:checked + span { background: var(--marigold); border-color: var(--marigold); color: var(--plum); }
.chip input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Host lobby */
.room-code {
  font-family: var(--display); font-size: 3.4rem; color: var(--gold);
  letter-spacing: .12em; text-align: center; line-height: 1;
}
.qr { display: flex; justify-content: center; }
.qr svg { width: 220px; height: 220px; background: var(--ivory); border-radius: 16px; padding: 6px; }
.status { display: flex; align-items: center; gap: 8px; justify-content: center; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--marigold); }
.dot.live { background: var(--teal); box-shadow: 0 0 0 4px rgba(25, 179, 166, .25); }
.dot.down { background: #FF5C8A; }
.count-big { font-family: var(--display); font-size: 3rem; color: var(--ivory); line-height: 1; }
.voters { display: flex; flex-wrap: wrap; gap: 6px; }
.voters span { background: var(--plum); border-radius: 999px; padding: 4px 12px; font-size: .9rem; }

/* Tally bars */
.tally h3 { color: var(--gold); margin-bottom: 10px; }
.bar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 10px; align-items: center; margin-bottom: 6px; font-size: .95rem; }
.bar .track { height: 12px; background: var(--plum); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--rani); border-radius: 999px; }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reveal */
.reveal { text-align: center; min-height: 60vh; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
.reveal .award-for { color: var(--muted); font-size: 1.1rem; }
.reveal .award-title { font-family: var(--display); font-size: clamp(2rem, 9vw, 2.8rem); color: var(--gold); }
.envelope {
  margin: 0 auto; width: 220px; height: 140px; position: relative;
  background: var(--rani); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.envelope::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom right, transparent 49.5%, var(--rani-dark) 50%) left / 50% 100% no-repeat,
              linear-gradient(to bottom left, transparent 49.5%, var(--rani-dark) 50%) right / 50% 100% no-repeat;
  border-radius: 10px;
}
.envelope::after {
  content: "🌼"; position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: 2.4rem;
}
.winner-name {
  font-family: var(--display); color: var(--ivory);
  font-size: clamp(2.8rem, 14vw, 4.2rem); line-height: 1.05;
  text-shadow: 3px 3px 0 var(--rani);
  animation: drumroll .9s cubic-bezier(.2, 1.4, .4, 1) both;
}
.winner-votes { color: var(--muted); }
@keyframes drumroll {
  from { transform: scale(.3) rotate(-8deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.finale li { padding: 12px 0; border-bottom: 1px dashed var(--plum-3); list-style: none; }
.finale ul { padding: 4px 20px; margin: 0; }
.finale li:last-child { border-bottom: 0; }
.finale .cat { color: var(--muted); font-size: .95rem; }
.finale .who { font-family: var(--display); font-size: 1.6rem; color: var(--gold); }

.progress { color: var(--muted); font-size: .95rem; text-align: center; }

#petals { position: fixed; inset: 0; pointer-events: none; width: 100%; height: 100%; z-index: 10; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--ivory); color: var(--plum);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 20;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}

.noscript { text-align: center; padding: 40px 16px; }

.footer-note { text-align: center; font-size: .8rem; color: var(--muted); margin-top: 40px; }

@media (prefers-reduced-motion: reduce) {
  .winner-name { animation: none; }
  .marquee h1 { transform: none; }
  .btn { transition: none; }
}
