:root {
  /* Palette pulled from rccgharvesthouse.org (the "Vibrant Light Theme"): warm
     off-white background, deep forest-green text instead of pure black, and the
     site's harvest-green as the primary accent. --ink and --paper keep the
     names they had under the old dark palette, but now hold the opposite pole:
     --ink is the base/background tone (light, was dark), --paper is the
     foreground/text tone (dark, was light) — same roles as before, just
     inverted for a light theme. --harvest-green replaces --roll-gold;
     --muster-green and --flag-rust are deepened versions of the site's greens/
     coral, tuned to clear 4.5:1 contrast on this background (checked with a
     WCAG contrast calc — the app is used outdoors in direct sunlight, so this
     isn't optional polish). */
  --ink: #fdfaf6;
  --paper: #0a2e1c;
  --muster-green: #1a7a35;
  --harvest-green: #00803f;
  --flag-rust: #b04a35;

  --surface: #ffffff;
  --border: rgba(10, 46, 28, 0.14);
  --text-dim: rgba(10, 46, 28, 0.65);

  --font-serif: 'Cormorant Garamond', serif;
  --font-mono: 'Space Mono', monospace;
  --font-sans: 'Outfit', sans-serif;
}

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

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input {
  font: inherit;
  color: inherit;
}

.screen {
  display: none;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Gate */
#gate.screen.active {
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 18px;
}

.wordmark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(40px, 12vw, 60px);
  letter-spacing: 0.04em;
  color: var(--paper);
}

.gate-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: -8px;
}

#gateForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
}

input[type='text'],
input[type='search'] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--paper);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  min-height: 48px;
  width: 100%;
}

input::placeholder {
  color: var(--text-dim);
}

input:focus {
  outline: 2px solid var(--harvest-green);
  outline-offset: 2px;
  border-color: var(--harvest-green);
}

.btn-primary {
  background: var(--harvest-green);
  color: var(--ink);
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 16px;
  min-height: 48px;
  cursor: pointer;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--paper);
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 48px;
  cursor: pointer;
}

.error-text {
  color: var(--flag-rust);
  font-family: var(--font-mono);
  font-size: 13px;
  min-height: 18px;
}

/* Main screen */
#main.screen.active {
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  background: var(--ink);
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar .wordmark {
  font-size: clamp(26px, 8vw, 32px);
  text-align: left;
}

.tally-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: -6px;
}

.tally-wrap[hidden] {
  display: none;
}

.tally {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--harvest-green);
}

.tally-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.tally-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--harvest-green);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.results {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.hint {
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-align: center;
  padding: 48px 20px;
  font-size: 14px;
}

.error-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

/* Camper card */
.card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--harvest-green);
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--paper);
  margin-bottom: 2px;
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.3;
}

.badge-flag {
  color: var(--flag-rust);
  background: rgba(176, 74, 53, 0.14);
  border: 1px solid rgba(176, 74, 53, 0.4);
  font-weight: 700;
}

.badge-note {
  color: var(--text-dim);
  background: rgba(10, 46, 28, 0.05);
  border: 1px solid var(--border);
}

.card-error {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--flag-rust);
  margin-top: 6px;
}

.card-action {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.btn-checkin {
  white-space: nowrap;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 14px;
}

.checkedin-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--muster-green);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.checkedin-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes cardSuccessFlash {
    0% {
      background: rgba(26, 122, 53, 0.3);
      border-color: var(--muster-green);
    }

    100% {
      background: var(--surface);
      border-color: var(--border);
    }
  }

  .card-success {
    animation: cardSuccessFlash 900ms ease-out;
  }
}

@media (min-width: 640px) {
  .results,
  .topbar {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
  }
}
