:root {
  --bg: #120d16;
  --panel: #1e1624;
  --panel-2: #2a1f33;
  --line: #3b2d46;
  --text: #f4ede4;
  --muted: #b8a9c2;
  --accent: #ff7a1a;
  --accent-ink: #1a0d02;
  --good: #7fd17a;
  --bad: #ff6b6b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 120px;
}

h1 {
  font-family: "Creepster", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin: 8px 0 4px;
}

h2 { font-size: 1.3rem; margin: 0 0 8px; }

p { margin: 0 0 12px; }

.muted { color: var(--muted); }

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-top: 18px;
}

[hidden] { display: none !important; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
label .muted { font-weight: 400; }

input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

button, .button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

button.secondary, .button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

button.small { padding: 7px 12px; font-size: 0.9rem; }
button:disabled { opacity: 0.5; cursor: default; }
.wide { width: 100%; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
input { caret-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: 0.75; }

.photo-pick {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  max-height: 380px;
  width: 100%;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg) center / cover no-repeat;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  padding: 16px;
  margin: 0;
  font-weight: 600;
}
.photo-pick:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.photo-pick.has-photo { border-style: solid; border-color: var(--accent); color: transparent; }
.photo-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.badge {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  border-radius: 8px;
  padding: 1px 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.card {
  padding: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel-2);
  color: var(--text);
  border: 3px solid transparent;
  text-align: left;
  font-weight: 400;
  display: flex;
  flex-direction: column;
}
.card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--bg); }
.card .meta { padding: 8px 10px 10px; }
.card .meta strong { display: block; line-height: 1.25; margin-top: 4px; overflow-wrap: anywhere; }
.card .meta > span:not(.badge) { display: block; }
.card .tag { font-size: 0.85rem; font-weight: 700; margin-top: 4px; }
.card[aria-pressed="true"] { border-color: var(--accent); }
.card .yours { color: var(--accent); }

.votebar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(18, 13, 22, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.votebar > div { max-width: 720px; margin: 0 auto; }

.notice { border-radius: 10px; padding: 10px 12px; background: var(--panel-2); margin-top: 12px; }
.notice.error { color: var(--bad); }
.notice.ok { color: var(--good); }

.hint { font-size: 0.9rem; color: var(--muted); margin: 6px 0 0; }

/* Winner card, shown inline on the guest page after the reveal */
.result { display: grid; gap: 10px; justify-items: center; text-align: center; margin-top: 12px; }
.result img { width: min(100%, 320px); aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius); border: 3px solid var(--accent); background: var(--bg); }
.result .name { font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }

/* The reveal: one shared moment on every phone */
.reveal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 80% at 50% 40%, #2a1530 0%, var(--bg) 70%);
  text-align: center;
  overflow-y: auto;
}
.reveal-stage { display: grid; gap: 16px; justify-items: center; width: min(100%, 520px); }
.reveal h1 { margin: 0; }
.reveal-count {
  font-family: "Creepster", system-ui, sans-serif;
  font-size: 6rem;
  line-height: 1;
  color: var(--accent);
  min-height: 1em;
}
.reveal-count:empty { min-height: 0; }
.reveal-winner { margin: 0; display: grid; gap: 12px; justify-items: center; }
.reveal-winner img {
  width: min(100%, 420px);
  max-height: 58vh;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius);
  border: 4px solid var(--accent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.reveal-winner figcaption { display: grid; gap: 4px; }
.reveal-name { font-size: 1.6rem; font-weight: 800; overflow-wrap: anywhere; }
.reveal-meta { color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .reveal-count.pop { animation: pop 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
  .reveal-winner:not([hidden]) img { animation: unveil 1.1s cubic-bezier(0.16, 1, 0.3, 1); }
  .reveal-winner:not([hidden]) figcaption { animation: rise 0.8s 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes pop { from { transform: scale(1.8); opacity: 0; filter: blur(6px); } to { transform: none; opacity: 1; filter: none; } }
@keyframes unveil { from { clip-path: circle(0% at 50% 50%); filter: brightness(2); } to { clip-path: circle(75% at 50% 50%); filter: none; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
