:root {
  --bg1: #fff6e6;
  --bg2: #fbe3c0;
  --bg3: #f2c48d;
  --ink: #3b1f0e;
  --ink-soft: #6b3415;
  --chili: #a4300c;
  --chili-dark: #8a2c0d;
  --chili-deeper: #5c1f06;
  --orange: #c0601e;
  --gold: #f3b25e;
  --gold-bright: #ffe15a;
  --cream: #fff4e2;
  --card: rgba(255, 255, 255, 0.88);
  --line: #c0601e;
  --ok: #2f6b2f;
  --shadow: 0 8px 0 #8a2c0d;
  --sans: "Trebuchet MS", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Palatino Linotype", Palatino, "Times New Roman", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 28%, var(--bg1) 0%, var(--bg2) 55%, var(--bg3) 100%);
  line-height: 1.45;
}

.page {
  min-height: 100vh;
  padding: 24px 16px 48px;
}

.wrap {
  width: min(920px, 100%);
  margin: 0 auto;
}

.tv .wrap {
  width: min(1280px, 100%);
}

.kicker {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: #7a2e0b;
  text-align: center;
  font-weight: 700;
}

h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 4.2rem);
  color: var(--chili);
  text-align: center;
  line-height: 0.95;
  text-shadow: 3px 3px 0 var(--gold);
  margin-top: 6px;
}

h1 span {
  display: block;
  font-size: 0.62em;
  color: #5c2e0e;
  text-shadow: none;
  margin-top: 4px;
}

.sub, .when {
  text-align: center;
  color: var(--ink-soft);
  margin-top: 10px;
}

.banner {
  display: inline-block;
  background: var(--chili-dark);
  color: var(--cream);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 22px 6px;
  border-radius: 10px;
  box-shadow: 0 4px 0 var(--chili-deeper);
  margin: 14px auto 0;
}

.center { text-align: center; }

.card-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.chili-card {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  color: var(--ink);
  cursor: pointer;
  min-height: 72px;
  box-shadow: 0 3px 0 rgba(92, 31, 6, 0.15);
  font: inherit;
}

.chili-card:focus-visible {
  outline: 3px solid var(--chili);
  outline-offset: 3px;
}

.chili-card.selected {
  border-color: var(--chili-dark);
  background: #fff1d4;
  box-shadow: 0 0 0 3px var(--gold-bright), 0 3px 0 var(--chili-dark);
}

.chili-num {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--chili-dark);
  letter-spacing: 0.02em;
}

.chili-name {
  font-size: 1.15rem;
  margin-top: 2px;
}

.chili-desc {
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 4px;
}

.actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 40px;
  background: var(--orange);
  color: #fff;
  font: 800 1.2rem/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 18px 28px;
  min-height: 56px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--chili-dark);
}

.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--chili-dark); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.secondary {
  background: var(--cream);
  color: var(--chili-dark);
  border: 2px solid var(--chili-dark);
  box-shadow: none;
}

.btn.danger {
  background: var(--chili);
  box-shadow: 0 4px 0 var(--chili-deeper);
}

.btn.good { background: var(--ok); box-shadow: 0 4px 0 #1d4a1d; }

.msg, .status-box {
  margin-top: 18px;
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
  text-align: center;
}

.msg h2, .status-box h2 {
  font-family: var(--serif);
  color: var(--chili);
  font-size: 2rem;
  margin-bottom: 8px;
}

.hidden { display: none !important; }

.error {
  color: var(--chili);
  font-weight: 700;
  text-align: center;
  margin-top: 12px;
}

.nav-links {
  margin-top: 28px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.nav-links a {
  color: var(--chili-dark);
  font-weight: 700;
}

.pin-row, .field-row, .entry-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

label { font-weight: 700; color: var(--chili-deeper); }

input[type="text"],
input[type="number"],
input[type="password"] {
  font: 1.1rem/1.3 var(--sans);
  padding: 14px 14px;
  border: 2.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  min-height: 52px;
  width: 100%;
}

.entry-block {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.entry-block h3 {
  color: var(--chili-dark);
  margin-bottom: 8px;
}

.admin-panel section {
  margin-top: 28px;
}

.admin-panel h2 {
  font-family: var(--serif);
  color: var(--chili);
  font-size: 1.7rem;
}

.toggle-state {
  font-weight: 800;
  font-size: 1.2rem;
  margin: 8px 0 12px;
}

.toggle-state.open { color: var(--ok); }
.toggle-state.closed { color: var(--chili); }

.confirm-box {
  background: #fff3d1;
  border: 2px dashed var(--chili);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
}

/* Results / TV */
.live-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--chili-dark);
  color: var(--cream);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
}

.live-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7dff7d;
  box-shadow: 0 0 0 0 rgba(125, 255, 125, 0.8);
  animation: pulse 1.6s infinite;
}

.live-dot.final {
  background: #5c2e0e;
}

.live-dot.final::before {
  background: var(--gold-bright);
  animation: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(125, 255, 125, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(125, 255, 125, 0); }
  100% { box-shadow: 0 0 0 0 rgba(125, 255, 125, 0); }
}

.total-count {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--chili-deeper);
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 28px;
}

.rank-row {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px 16px;
}

.rank-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.rank-label {
  font-size: clamp(1.4rem, 3.6vw, 2.6rem);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.rank-label .place {
  color: var(--orange);
  margin-right: 8px;
}

.rank-votes {
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-weight: 800;
  color: var(--chili);
  white-space: nowrap;
}

.bar-track {
  margin-top: 10px;
  height: clamp(28px, 5vw, 48px);
  background: #f3d7aa;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #e0b37a;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #c0601e 0%, #a4300c 100%);
  border-radius: 999px;
  transition: width 0.6s ease;
  min-width: 0;
}

.bar-fill.lead {
  background: linear-gradient(90deg, #e07a22 0%, #8a2c0d 100%);
}

.rank-desc {
  margin-top: 4px;
  color: var(--ink-soft);
  font-style: italic;
}

.empty {
  text-align: center;
  font-size: 1.4rem;
  color: var(--ink-soft);
  margin-top: 40px;
}

.qr-wrap { text-align: center; width: min(640px, 100%); }
.qr-frame {
  margin: 24px auto;
  width: min(420px, 90vw);
  padding: 12px;
  background: var(--cream);
  border: 4px solid var(--chili-dark);
  border-radius: 18px;
}
.qr-frame svg { width: 100%; height: auto; display: block; }
.qr-url {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 800;
  color: var(--chili-dark);
  word-break: break-all;
  margin: 10px 0 16px;
}
.hint { color: var(--ink-soft); max-width: 36em; margin: 0 auto; }

@media (min-width: 720px) {
  .actions { flex-direction: row; justify-content: center; }
  .btn { min-width: 240px; }
}

/* --- one-screen results layout --- */
body.tv { height: 100vh; overflow: hidden; }
body.tv .wrap { height: 100vh; box-sizing: border-box; display: flex; flex-direction: column; padding-top: 2vh; padding-bottom: 2vh; max-width: 96vw; }
body.tv h1 { font-size: clamp(28px, 5vh, 64px); margin: .2em 0; }
body.tv .kicker, body.tv .when { font-size: clamp(12px, 2vh, 22px); margin: .2em 0; }
body.tv .rank-list { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1.5vh; }
.podium { display: grid; grid-template-rows: repeat(3, auto); gap: 1.2vh; }
.podium-card, .mini-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.5vw; background: rgba(255,255,255,.75); border-radius: 14px; padding: 1.2vh 1.5vw; }
.podium-card .p-place { font-weight: 800; font-size: clamp(28px, 7vh, 80px); color: #b22222; min-width: 2.2em; }
.podium-card .p-name { font-weight: 800; font-size: clamp(20px, 4.2vh, 52px); }
.podium-card .p-votes { font-weight: 900; font-size: clamp(28px, 7vh, 84px); }
.podium-card .bar-track { height: clamp(10px, 2vh, 26px); margin-top: .6vh; }
.podium-card.place-1 { border: 4px solid #e0a800; box-shadow: 0 4px 18px rgba(224,168,0,.35); }
.podium-card.place-1 .p-place::after { content: " 🏆"; font-size: .6em; }
.p-name span { font-weight: 500; opacity: .8; }
.rest-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--cols,1), 1fr); grid-auto-rows: minmax(0, max-content); gap: .8vh 1.5vw; overflow: hidden; align-content: start; }
.mini-row { padding: .6vh 1vw; border-radius: 10px; }
.mini-row .p-place { font-weight: 700; font-size: clamp(14px, 2.4vh, 28px); color: #7a3b1d; min-width: 2.2em; }
.mini-row .p-name { font-weight: 700; font-size: clamp(13px, 2.2vh, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-row .p-votes { font-weight: 800; font-size: clamp(14px, 2.6vh, 30px); }
.mini-row .bar-track { height: clamp(5px, .9vh, 12px); margin-top: .3vh; }
.p-body { min-width: 0; }
body.tv .wrap { max-width: 98vw; }
body.tv h1 { font-size: clamp(24px, 4.2vh, 56px); }
.podium-card .p-place { font-size: clamp(24px, 6vh, 72px); }
.podium-card .p-name { font-size: clamp(18px, 3.6vh, 46px); }
.podium-card .p-votes { font-size: clamp(24px, 6vh, 72px); }
.podium-card { padding: .9vh 1.5vw; }

.qr-corner { position: fixed; right: 1.5vw; bottom: 2vh; background: #fff; border-radius: 14px; padding: 1vh; box-shadow: 0 4px 18px rgba(0,0,0,.18); text-align: center; z-index: 5; }
.qr-corner img { display: block; width: clamp(110px, 22vh, 260px); height: auto; }
.qr-corner .qr-caption { font-weight: 800; color: #b22222; font-size: clamp(13px, 2.2vh, 26px); margin-top: .4vh; }
body.tv .wrap { padding-right: clamp(130px, 25vh, 290px); }

.qr-corner { top: 2vh; bottom: auto; }

/* --- site nav and multi-page layout --- */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 1rem;
  background: rgba(255, 244, 226, 0.94);
  border-bottom: 2px solid var(--line);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-nav a {
  color: var(--chili-dark);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 4px 2px;
}
.site-nav a:hover { text-decoration: underline; }
.site-nav a.active {
  color: var(--chili);
  box-shadow: inset 0 -3px 0 var(--gold);
}
.site-page .site-wrap { padding-top: 8px; padding-bottom: 48px; }
.site-hero { text-align: center; margin-bottom: 28px; }
.site-hero h1 { margin-bottom: 8px; }

.home-cards {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  margin-top: 8px;
}
@media (min-width: 800px) {
  .home-cards { grid-template-columns: repeat(3, 1fr); }
}
.home-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 18px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(92, 31, 6, 0.15);
  min-height: 200px;
}
.home-card:hover {
  border-color: var(--chili-dark);
  box-shadow: 0 0 0 3px var(--gold-bright), 0 3px 0 var(--chili-dark);
}
.home-card .card-kicker {
  font-weight: 800;
  color: var(--chili-dark);
  letter-spacing: 0.04em;
  font-size: 0.9rem;
}
.home-card h2 {
  font-family: var(--serif);
  color: var(--chili);
  font-size: 1.7rem;
  margin: 8px 0 10px;
}
.home-card p { color: var(--ink-soft); flex: 1; }
.home-card .card-go {
  margin-top: 16px;
  font-weight: 800;
  color: var(--chili-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.idea-form, .bulletin-body, .ideas-list-wrap {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px;
  margin-top: 20px;
}
.ideas-list-wrap h2,
.admin-panel h2 {
  font-family: var(--serif);
  color: var(--chili);
}
.idea-card {
  border-top: 1px solid #e0b37a;
  padding: 14px 0 8px;
}
.idea-card:first-of-type { border-top: 0; padding-top: 4px; }
.idea-meta { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: 6px; }
.idea-text { white-space: pre-wrap; }
.idea-form textarea,
#bulletin-text,
textarea {
  font: 1.1rem/1.4 var(--sans);
  padding: 14px;
  border: 2.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-height: 140px;
  resize: vertical;
}
#bulletin-text { min-height: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem; }
.char-count { margin-top: 6px; text-align: right; }
.bulletin-body { font-size: 1.08rem; line-height: 1.6; }
.bulletin-body p { margin: 0 0 1em; }
.bulletin-body h1, .bulletin-body h2, .bulletin-body h3 {
  font-family: var(--serif);
  color: var(--chili);
  margin: 0.4em 0 0.5em;
}
.admin-idea { background: var(--cream); border: 2px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 12px; }
.admin-idea .actions { margin-top: 10px; }
.admin-idea .btn { min-width: 0; padding: 10px 18px; font-size: 0.95rem; min-height: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }

/* slim nav so the results TV layout still fits one screen */
body.tv {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0;
  overflow: hidden;
}
body.tv .site-nav,
.site-nav.slim {
  position: relative;
  flex: 0 0 auto;
  padding: 0.35vh 1.2vw;
  gap: 0.25rem 0.9vw;
  font-size: clamp(11px, 1.45vh, 15px);
  background: rgba(255, 244, 226, 0.9);
}
body.tv .site-nav a { font-size: inherit; padding: 1px 2px; }
body.tv .wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding-top: 1vh;
  padding-bottom: 1vh;
}
