:root {
  --cream: #FFF4E2;
  --paper: #FFFCF6;
  --ink: #4A2C17;
  --ink-soft: #85603F;
  --pumpkin: #E8711A;
  --pumpkin-deep: #B9520B;
  --pumpkin-soft: #FFE6CC;
  --cranberry: #B23A1E;
  --cranberry-deep: #7E2913;
  --mustard: #F2B33D;
  --line: #F0DCC0;
  --track: #F1E1C8;
  --radius: 22px;
  --shadow: 0 5px 0 #EBD2AE, 0 10px 24px rgba(122, 70, 20, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(242, 179, 61, .25) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 30%, rgba(232, 113, 26, .12) 0 160px, transparent 161px),
    radial-gradient(circle at 6% 70%, rgba(178, 58, 30, .08) 0 140px, transparent 141px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(120px + env(safe-area-inset-bottom));
}

svg { display: block; width: 100%; height: 100%; }

/* ---- Falling leaves ---------------------------------------------------- */
.leaves { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.leaf { position: absolute; top: -60px; width: 30px; height: 30px; opacity: .5; animation: fall 14s linear infinite; }
.leaf:nth-child(1) { left: 6%;  animation-duration: 15s; animation-delay: -2s; }
.leaf:nth-child(2) { left: 24%; animation-duration: 19s; animation-delay: -11s; width: 22px; height: 22px; }
.leaf:nth-child(3) { left: 46%; animation-duration: 17s; animation-delay: -6s; }
.leaf:nth-child(4) { left: 64%; animation-duration: 21s; animation-delay: -15s; width: 24px; height: 24px; }
.leaf:nth-child(5) { left: 80%; animation-duration: 16s; animation-delay: -8s; }
.leaf:nth-child(6) { left: 92%; animation-duration: 20s; animation-delay: -1s; width: 20px; height: 20px; }
@keyframes fall {
  0%   { transform: translate(0, -60px) rotate(0deg); }
  50%  { transform: translate(40px, 55vh) rotate(180deg); }
  100% { transform: translate(-10px, 115vh) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .leaves { display: none; }
}

/* ---- Hero -------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 18px 16px 22px;
  margin-bottom: 18px;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(160deg, #F28C28 0%, #D9581A 55%, var(--cranberry) 100%);
  box-shadow: 0 6px 0 var(--cranberry-deep), 0 14px 30px rgba(126, 41, 19, .25);
}
.hero-art { display: flex; justify-content: center; align-items: flex-end; gap: 6px; height: 76px; }
.hero-leaf { width: 36px; height: 36px; transform: rotate(-20deg); margin-bottom: 26px; }
.hero-leaf--flip { transform: rotate(25deg) scaleX(-1); }
.hero-pumpkin { width: 86px; height: 78px; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .15)); }
.hero-acorn { width: 40px; height: 40px; margin-left: -10px; }
.hero h1 {
  margin: 8px 0 4px;
  font-size: clamp(1.9rem, 8.5vw, 2.5rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -.01em;
  text-shadow: 0 3px 0 rgba(126, 41, 19, .45);
}
.hero-sub { margin: 6px 0 0; font-size: 1.05rem; font-weight: 800; color: #FFF1D6; }

/* ---- Cards ------------------------------------------------------------- */
.card {
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease;
}
.card.is-set { border-color: #F5B979; }
.card.has-error { border-color: var(--cranberry); }

.card-head { display: flex; align-items: center; gap: 12px; }
.card-head h3 { margin: 0; font-size: 1.3rem; font-weight: 900; line-height: 1.15; }
.art-box {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 6px;
  border-radius: 18px;
  background: var(--pumpkin-soft);
}

/* ---- Name -------------------------------------------------------------- */
.big-label { display: block; margin-bottom: 10px; font-size: 1.35rem; font-weight: 900; }
.text-input {
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 16px;
  outline: none;
}
.text-input:focus, .count-input:focus {
  border-color: var(--pumpkin);
  box-shadow: 0 0 0 4px rgba(232, 113, 26, .25);
}

.field-error, .form-error { margin: 8px 0 0; color: var(--cranberry); font-weight: 900; }
.field-error:empty, .form-error:empty { display: none; }
.form-error {
  padding: 14px 16px;
  margin-bottom: 14px;
  text-align: center;
  font-size: 1.15rem;
  background: #FDE3DA;
  border: 3px solid var(--cranberry);
  border-radius: 18px;
}

/* ---- Sections ---------------------------------------------------------- */
.section { margin-top: 26px; }
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 8px 18px;
  font-size: 1.5rem;
  font-weight: 900;
  background: var(--mustard);
  border-radius: 999px;
  box-shadow: 0 4px 0 #C98E1D;
}
.section-hint { margin: 8px 4px 14px; color: var(--ink-soft); font-weight: 700; font-size: 1rem; }

/* ---- Steppers ---------------------------------------------------------- */
.stepper { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.step {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 0 0 4px;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  background: var(--pumpkin);
  box-shadow: 0 4px 0 var(--pumpkin-deep);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.step:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pumpkin-deep); }
.step:focus-visible { outline: 4px solid var(--mustard); outline-offset: 2px; }

.readout {
  flex: 1;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.weight-card:not(.is-set) .readout { font-size: 1.1rem; font-weight: 800; color: var(--ink-soft); }

.count-input {
  flex: 1;
  min-width: 0;
  height: 64px;
  padding: 0 8px;
  text-align: center;
  font: inherit;
  font-size: 2rem;
  font-weight: 900;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 16px;
  outline: none;
}
.count-input::placeholder { color: #D8BE9A; }

.skip {
  margin-left: auto;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: .9rem;
  font-weight: 800;
  color: var(--ink-soft);
  background: #F6EAD8;
  cursor: pointer;
  visibility: hidden;
}
.weight-card.is-set .skip { visibility: visible; }

/* ---- Slider ------------------------------------------------------------ */
.weight-card { --fill: #E4D2B6; --thumb: #C4AC8C; }
.weight-card.is-set { --fill: var(--pumpkin); --thumb: var(--pumpkin-deep); }

.slider {
  --pct: 50%;
  display: block;
  width: 100%;
  height: 48px;
  margin: 10px 0 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.slider:focus { outline: none; }
.slider::-webkit-slider-runnable-track {
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--fill) var(--pct), var(--track) var(--pct));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 42px;
  height: 42px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--thumb);
  border: 5px solid #fff;
  box-shadow: 0 2px 8px rgba(74, 44, 23, .35);
}
.slider::-moz-range-track { height: 16px; border-radius: 999px; background: var(--track); }
.slider::-moz-range-progress { height: 16px; border-radius: 999px; background: var(--fill); }
.slider::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--thumb);
  border: 5px solid #fff;
  box-shadow: 0 2px 8px rgba(74, 44, 23, .35);
}
.slider:focus-visible::-webkit-slider-thumb { outline: 4px solid var(--mustard); }

.scale {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  font-size: .85rem;
  font-weight: 800;
  color: var(--ink-soft);
}

/* ---- Buttons ----------------------------------------------------------- */
.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(255, 244, 226, 0), var(--cream) 35%);
}
.submit-bar .btn-big, .submit-bar .form-error { max-width: 448px; margin: 0 auto; }
.submit-bar .form-error { margin-bottom: 10px; padding: 10px 14px; }

.btn-big {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 66px;
  padding: 0 20px;
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  text-decoration: none;
  background: var(--cranberry);
  box-shadow: 0 5px 0 var(--cranberry-deep);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--cranberry-deep); }
.btn-big:disabled { opacity: .7; }

/* ---- Thank you / closed ------------------------------------------------ */
.thanks-card, .closed-card { text-align: center; padding: 24px 18px; }
.thanks-art { width: 110px; height: 100px; margin: 0 auto 6px; }
.thanks-card h1, .closed-card h2 { margin: 6px 0 2px; font-size: 2rem; font-weight: 900; line-height: 1.1; }
.thanks-lead, .closed-card p { margin: 0 0 18px; font-size: 1.25rem; font-weight: 800; color: var(--ink-soft); }
.recap { list-style: none; margin: 0 0 18px; padding: 0; text-align: left; }
.recap li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 2px dashed var(--line);
  font-weight: 700;
}
.recap li strong { font-weight: 900; white-space: nowrap; }
.recap li.is-skipped strong { color: #C2A47E; font-weight: 700; }
.fair-note {
  margin: 0 0 18px;
  padding: 12px 14px;
  font-weight: 900;
  font-size: 1.1rem;
  background: #FFF0C9;
  border: 3px dashed var(--mustard);
  border-radius: 16px;
}

/* ---- Admin ------------------------------------------------------------- */
.admin .wrap { max-width: 1000px; padding-bottom: 48px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.admin-head h1 { margin: 0; font-size: 2rem; font-weight: 900; }
.admin h2 { margin: 30px 0 12px; font-size: 1.5rem; font-weight: 900; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  color: #fff;
  text-decoration: none;
  background: var(--pumpkin);
  box-shadow: 0 4px 0 var(--pumpkin-deep);
  cursor: pointer;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--pumpkin-deep); }
.btn-ghost { color: var(--ink); background: #fff; border: 3px solid var(--line); box-shadow: none; }
.btn-ghost:active { box-shadow: none; }
.btn-danger { background: var(--cranberry); box-shadow: 0 4px 0 var(--cranberry-deep); }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: .9rem; border-radius: 12px; }

.flash { padding: 12px 16px; margin-bottom: 14px; font-weight: 800; border-radius: 16px; background: #E4F2D6; border: 3px solid #8DBA5E; }
.flash.is-error { background: #FDE3DA; border-color: var(--cranberry); }
.warn { padding: 12px 16px; margin-bottom: 14px; font-weight: 800; border-radius: 16px; background: #FFF0C9; border: 3px solid var(--mustard); }

.status-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.status-card form { margin: 0; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 900; }
.pill-open { color: #fff; background: #5E9A35; }
.pill-closed { color: #fff; background: var(--cranberry); }
.status-count { font-weight: 800; color: var(--ink-soft); margin-right: auto; }

.results { display: grid; gap: 14px; }
@media (min-width: 760px) { .results { grid-template-columns: 1fr 1fr; } }
.results .card { margin: 0; }
.result-answer { margin-left: auto; text-align: right; font-size: .9rem; font-weight: 800; color: var(--ink-soft); }
.result-answer strong { display: block; font-size: 1.15rem; color: var(--ink); white-space: nowrap; }
.podium { list-style: none; margin: 14px 0 0; padding: 0; }
.podium li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 2px dashed var(--line); }
.medal { flex: none; font-size: 2rem; line-height: 1; }
.winner-names { font-size: 1.2rem; font-weight: 900; }
.winner-names small { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.winner-guess { font-weight: 700; color: var(--ink-soft); }
.tag-over { display: inline-block; margin-left: 6px; padding: 2px 10px; font-size: .8rem; font-weight: 900; color: #fff; background: var(--pumpkin); border-radius: 999px; }
.tag-exact { color: #3F7022; font-weight: 900; }
.empty { margin: 14px 0 0; color: var(--ink-soft); font-weight: 700; }

.answers-grid { display: grid; gap: 12px; }
@media (min-width: 760px) { .answers-grid { grid-template-columns: 1fr 1fr; } }
.answer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; }
.answer-row > span:first-child { flex: 1 1 100%; }
.answer-row input {
  width: 92px;
  min-height: 50px;
  padding: 0 10px;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 12px;
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.entries { width: 100%; border-collapse: collapse; font-size: .95rem; white-space: nowrap; }
.entries th, .entries td { padding: 10px 12px; text-align: left; border-bottom: 2px solid var(--line); }
.entries th { font-weight: 900; background: var(--pumpkin-soft); }
.entries td form { margin: 0; }

.login-card { max-width: 420px; margin: 0 auto; }
.login-card .btn-big { margin-top: 14px; }
