/* Creepy carnival theme. Mobile first. */
:root {
  --bg: #120608;
  --bg-2: #1e0b0e;
  --panel: #241013;
  --line: #4a2026;
  --text: #efe3cf;
  --muted: #b39a86;
  --blood: #a3121f;
  --blood-bright: #d8263a;
  --cream: #e9d8b4;
  --gold: #d9a441;
  --green: #7fbf6a;
  --radius: 10px;
  --font-display: 'Creepster', 'Impact', fantasy;
  --font-sign: 'Rye', Georgia, serif;
  --font-type: 'Special Elite', 'Courier New', monospace;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(163, 18, 31, .28), transparent 60%),
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, .75) 100%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 var(--font-body);
  padding-bottom: env(safe-area-inset-bottom);
}

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

a { color: var(--gold); }

/* ---------- Marquee header ---------- */
.marquee {
  position: relative;
  text-align: center;
  padding: 34px 16px 22px;
  margin-bottom: 20px;
  background:
    linear-gradient(to bottom, rgba(18, 6, 8, .15), var(--bg) 96%),
    repeating-linear-gradient(90deg, #6e0f18 0 36px, #3a2a22 36px 72px);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 6px 30px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.marquee::after { /* scalloped tent edge */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 14px;
  background: radial-gradient(circle at 18px -4px, transparent 15px, var(--bg) 16px) 0 0 / 36px 14px repeat-x;
}

.bulbs {
  position: absolute;
  top: 10px; left: 0; right: 0;
  height: 10px;
  background: radial-gradient(circle, #ffd27a 0 3px, rgba(255, 190, 80, .35) 4px, transparent 6px) 0 0 / 28px 10px repeat-x;
  animation: flicker 4s infinite steps(1);
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: .35; }
  43% { opacity: 1; }
  77% { opacity: .6; }
  78% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .bulbs { animation: none; } }

.eyebrow {
  margin: 0;
  font-family: var(--font-sign);
  color: var(--gold);
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .8rem;
}

h1 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 11vw, 4.2rem);
  line-height: 1;
  color: var(--blood-bright);
  text-shadow: 0 0 2px #000, 0 3px 0 #2b0005, 0 0 24px rgba(216, 38, 58, .55);
  letter-spacing: .03em;
}

h2 {
  font-family: var(--font-sign);
  font-weight: 400;
  color: var(--cream);
  font-size: 1.35rem;
  margin: 0 0 12px;
}

.intro {
  font-family: var(--font-type);
  color: var(--muted);
  text-align: center;
  max-width: 34em;
  margin: 0 auto 24px;
}
.intro strong { color: var(--cream); }
.zoom-icon { color: var(--gold); }

.fineprint {
  text-align: center;
  font-family: var(--font-type);
  color: #6c5246;
  font-size: .8rem;
  padding: 0 16px 100px;
}

/* ---------- Notices ---------- */
.notice {
  text-align: center;
  border: 1px dashed var(--line);
  background: rgba(36, 16, 19, .7);
  border-radius: var(--radius);
  padding: 22px 16px;
  margin: 0 auto 24px;
  max-width: 560px;
  font-family: var(--font-type);
  color: var(--muted);
}
.notice .big {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.1;
  color: var(--blood-bright);
  margin: 0 0 8px;
}
.notice.sealed { border-color: var(--gold); }
.notice.sealed .big { color: var(--gold); }

/* ---------- Ballot ---------- */
.category {
  margin: 0 0 34px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.category h2 {
  font-size: 1.6rem;
  margin-top: 14px;
}
.category.complete h2::after {
  content: ' \2713';
  color: var(--green);
  font-family: var(--font-body);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  position: relative;
  border-radius: var(--radius);
  background: var(--panel);
  border: 2px solid var(--line);
  overflow: hidden;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card .pick {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  filter: sepia(.25) contrast(1.05) brightness(.9);
  transition: filter .15s;
}
.card .title {
  display: block;
  padding: 8px 10px 10px;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.card .zoom {
  position: absolute;
  top: 6px; right: 6px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(233, 216, 180, .4);
  background: rgba(18, 6, 8, .7);
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
}

.card.ranked { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(217, 164, 65, .25), 0 6px 20px rgba(0, 0, 0, .5); }
.card.ranked img { filter: none; }
.card[data-rank="1"] { border-color: var(--gold); }
.card[data-rank="2"] { border-color: #c9c9c9; }
.card[data-rank="3"] { border-color: #b8743a; }
.card:active { transform: scale(.97); }

/* Admission-ticket rank badge */
.ticket {
  position: absolute;
  top: 10px; left: -4px;
  padding: 4px 14px 4px 12px;
  font-family: var(--font-sign);
  font-size: 1.05rem;
  color: #2a0a0a;
  background: var(--gold);
  -webkit-mask: radial-gradient(circle at 100% 50%, transparent 6px, #000 7px);
          mask: radial-gradient(circle at 100% 50%, transparent 6px, #000 7px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  transform: rotate(-6deg);
  display: none;
}
.card.ranked .ticket { display: block; }
.card[data-rank="2"] .ticket { background: #d6d6d6; }
.card[data-rank="3"] .ticket { background: #c98a4f; }

.submit-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(18, 6, 8, .94);
  border-top: 2px solid var(--blood);
  backdrop-filter: blur(6px);
  z-index: 10;
}
#progress { font-family: var(--font-type); color: var(--muted); font-size: .9rem; }

/* ---------- Buttons & fields ---------- */
.btn {
  font-family: var(--font-sign);
  font-size: 1.05rem;
  padding: 12px 20px;
  min-height: 48px;
  border-radius: 999px;
  border: 2px solid var(--gold);
  background: linear-gradient(var(--blood-bright), var(--blood));
  color: var(--cream);
  cursor: pointer;
  box-shadow: 0 3px 0 #4a060d, 0 6px 16px rgba(0, 0, 0, .4);
  white-space: nowrap;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #4a060d; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { font-size: .85rem; padding: 6px 12px; min-height: 38px; box-shadow: none; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { border-color: var(--blood-bright); }
.btn.ghost.danger { color: #ff8a95; }

input[type=text] {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  min-height: 44px;
  font: inherit;
  font-size: 16px; /* stops iOS zoom on focus */
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input[type=text]:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- Lightbox ---------- */
dialog#lightbox {
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  padding: 12px;
  max-width: min(94vw, 900px);
  max-height: 92vh;
  text-align: center;
}
dialog#lightbox::backdrop { background: rgba(0, 0, 0, .85); }
dialog#lightbox img { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 6px; }
dialog#lightbox .caption { font-family: var(--font-sign); font-size: 1.2rem; margin: 10px 0; }

/* ---------- Admin ---------- */
.admin-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 14px;
  font-family: var(--font-sign);
}
.admin-nav a { color: var(--cream); text-decoration: none; border-bottom: 1px dashed var(--gold); }

.panel {
  background: rgba(36, 16, 19, .85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 18px;
}
.help { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }

.stats { display: flex; gap: 16px; justify-content: space-around; text-align: center; font-family: var(--font-type); color: var(--muted); }
.stats .num { display: block; font-family: var(--font-display); font-size: 2.6rem; color: var(--gold); line-height: 1; }

.status-open { color: var(--green); }
.status-closed { color: var(--blood-bright); }

form.inline { display: flex; gap: 8px; align-items: center; margin: 0; }
form.inline.grow { flex: 1 1 220px; }

.cat-list, .costume-list { list-style: none; margin: 0 0 14px; padding: 0; }
.cat-list li, .costume-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.cat-actions { display: flex; gap: 6px; flex-wrap: wrap; }
li.inactive { opacity: .5; }

.costume-list img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: none; }
.costume-edit { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.costume-edit form.inline.grow { flex: none; }

.upload-form { display: grid; gap: 14px; }
.photo-drop {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 200px;
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  background: var(--bg-2);
  cursor: pointer;
  overflow: hidden;
}
.photo-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-drop img { width: 100%; max-height: 50vh; object-fit: contain; }
.photo-drop img:not([hidden]) + .photo-prompt { display: none; }
.photo-prompt { font-family: var(--font-sign); color: var(--cream); padding: 16px; text-align: center; }
.field { display: grid; gap: 6px; font-family: var(--font-sign); color: var(--cream); }
.status { margin: 0; min-height: 1.5em; font-family: var(--font-type); }
.status.good { color: var(--green); }
.status.bad { color: #ff8a95; }

.qr-panel { text-align: center; }
.qr { display: inline-block; padding: 14px; background: #fff; border-radius: 8px; }
.qr img, .qr canvas { display: block; width: min(70vw, 300px) !important; height: auto !important; }
.qr-url { font-family: var(--font-type); word-break: break-all; color: var(--muted); }

/* ---------- Results ---------- */
.podium { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.podium .reveal {
  position: relative;
  width: 100%;
  padding: 0 0 8px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
}
.podium .place-1 .reveal { border-color: var(--gold); }
.podium .place-2 .reveal { border-color: #c9c9c9; }
.podium .place-3 .reveal { border-color: #b8743a; }
.podium img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.podium .place { display: block; font-family: var(--font-sign); padding: 4px; background: rgba(0, 0, 0, .4); }
.podium .title { display: block; padding: 6px 6px 0; font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }

body.announce .podium .reveal:not(.shown) img,
body.announce .podium .reveal:not(.shown) .title { filter: blur(18px) brightness(.4); }
body.announce .podium .reveal:not(.shown)::after {
  content: '?';
  position: absolute;
  inset: 30px 0 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 3.5rem;
  color: var(--blood-bright);
}

.rounds { margin-top: 8px; }
.rounds summary { cursor: pointer; color: var(--gold); font-family: var(--font-type); padding: 6px 0; }
.table-wrap { overflow-x: auto; }
.rounds table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.rounds th, .rounds td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.rounds tbody th { text-align: left; font-weight: 500; }
.rounds tr.winner th { color: var(--gold); }
.rounds td.eliminated { color: #ff8a95; text-decoration: line-through; }
.rounds td.out { color: #6c5246; }
.rounds tr.exhausted { color: var(--muted); font-style: italic; }

/* ---------- Print the QR sign ---------- */
@media print {
  body { background: #fff; color: #000; }
  .marquee, .admin-nav, .panel:not(.qr-panel), .fineprint, .btn { display: none !important; }
  .qr-panel { border: 0; background: none; }
  .qr-panel h2 { color: #000; font-family: var(--font-display); font-size: 3rem; }
  .qr-panel h2::after { content: ' \2014 Vote Here'; }
  .qr img, .qr canvas { width: 4in !important; }
  .qr-url { color: #000; }
}
