/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #1a0a00;
  --surface:  #2d1200;
  --accent:   #ff8c00;
  --accent2:  #ffd166;
  --text:     #fff8f0;
  --muted:    #c8a97a;
  --danger:   #e63946;
  --success:  #2dc653;
  --radius:   12px;
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
button { cursor: pointer; font-family: inherit; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}
.muted { color: var(--muted); font-size: 0.875rem; }
.error-msg { color: var(--danger); font-size: 0.875rem; margin-top: 0.25rem; }
.success-msg { color: var(--success); font-size: 0.875rem; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  background: var(--surface);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 2px solid var(--accent);
}
.page-header h1 { font-size: 1.25rem; color: var(--accent2); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  border: none; border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  font-size: 1rem; font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  min-height: 44px; min-width: 44px;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary   { background: var(--accent);  color: #000; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--accent); }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-ghost     { background: transparent;    color: var(--muted); border: 1px solid var(--muted); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.875rem; min-height: 36px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
input[type="text"], input[type="number"], input[type="password"], textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  min-height: 44px;
}
input:focus, textarea:focus {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}
label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 0.25rem; }
.field { margin-bottom: 1rem; }

/* ── Segmented control ────────────────────────────────────────────────────── */
.seg-control {
  display: flex; border: 1px solid var(--accent); border-radius: var(--radius); overflow: hidden;
}
.seg-control button {
  flex: 1; padding: 0.5rem; font-size: 0.875rem; font-weight: 600;
  background: transparent; color: var(--muted); border: none;
  transition: background 0.15s, color 0.15s;
  min-height: 40px;
}
.seg-control button.active { background: var(--accent); color: #000; }

/* ── Cookie card grid ─────────────────────────────────────────────────────── */
.cookie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
}

.cookie-card {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
  touch-action: manipulation;
  user-select: none;
}
.cookie-card:active { transform: scale(0.97); }
.cookie-card.picked-1 { border-color: gold; }
.cookie-card.picked-2 { border-color: silver; }
.cookie-card.picked-3 { border-color: #cd7f32; }

.cookie-card img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: #333;
}
.cookie-card .no-photo {
  width: 100%; aspect-ratio: 1; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}
.cookie-card .card-info {
  padding: 0.4rem 0.5rem;
}
.cookie-card .card-num  { font-size: 0.75rem; color: var(--muted); }
.cookie-card .card-name { font-size: 0.9rem; font-weight: 600; }
.cookie-card .card-baker{ font-size: 0.75rem; color: var(--muted); }

.pick-badge {
  position: absolute; top: 4px; left: 4px;
  font-size: 1.25rem; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.8));
}

/* ── Vote submit bar ──────────────────────────────────────────────────────── */
.submit-bar {
  position: sticky; bottom: 0;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  padding: 0.75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.submit-bar .status-text { font-size: 0.875rem; color: var(--muted); }

/* ── Review overlay ───────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.overlay-box {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%; max-width: 480px;
  max-height: 90dvh; overflow-y: auto;
}
.overlay-box h2 { color: var(--accent2); margin-bottom: 1rem; }
.review-list { list-style: none; }
.review-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; }
.review-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }

/* ── Section headings ─────────────────────────────────────────────────────── */
.section-title {
  font-size: 1.1rem; font-weight: 700;
  color: var(--accent2);
  padding: 0.75rem 1rem 0.25rem;
  border-bottom: 1px solid var(--accent);
  margin-bottom: 0.5rem;
}

/* ── Admin ────────────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex; overflow-x: auto; border-bottom: 2px solid var(--accent);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.admin-tabs button {
  flex-shrink: 0; padding: 0.6rem 1rem; font-size: 0.9rem; font-weight: 600;
  background: transparent; color: var(--muted); border: none;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  min-height: 44px;
}
.admin-tabs button.active { color: var(--accent2); border-bottom-color: var(--accent2); }

.admin-panel { display: none; padding: 1rem; }
.admin-panel.active { display: block; }

.vote-row {
  background: var(--surface); border-radius: var(--radius);
  padding: 0.6rem 0.75rem; margin-bottom: 0.5rem;
  font-size: 0.8rem;
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: start;
}
.vote-row.flagged { border-left: 3px solid var(--danger); }

.reveal-controls {
  display: flex; gap: 1rem; align-items: center;
  flex-wrap: wrap; padding: 1rem 0;
}
.reveal-label { font-size: 0.875rem; color: var(--muted); flex: 1; min-width: 120px; }

/* ── Screen page ──────────────────────────────────────────────────────────── */
body.screen-page { overflow: hidden; }
.screen-root {
  width: 100vw; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
}

.screen-standby h1 { font-size: clamp(2.5rem, 8vw, 5rem); color: var(--accent2); text-align: center; }
.screen-standby p  { font-size: clamp(1rem, 3vw, 1.75rem); color: var(--muted); text-align: center; margin-top: 1rem; }

.screen-vote {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.screen-vote .qr-wrap { display: flex; align-items: center; justify-content: center; }
.screen-vote .vote-count {
  font-size: clamp(1rem, 2.5vw, 1.75rem); color: var(--muted);
  margin-top: clamp(0.5rem, 1.5vh, 1.5rem);
  letter-spacing: 0.05em;
}

/* ── Gallery ──────────────────────────────────────────────────────────────── */
.gallery-container {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* QR corner — top-right, persists across slides */
.gallery-qr-corner {
  position: absolute; top: clamp(0.75rem,1.5vw,1.5rem); right: clamp(0.75rem,1.5vw,1.5rem);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  background: rgba(26,10,0,0.75); border-radius: var(--radius);
  padding: clamp(0.4rem,0.8vw,0.75rem);
  z-index: 10;
}
.gallery-qr-label {
  font-size: clamp(0.6rem,1.2vw,0.85rem); color: var(--muted);
  letter-spacing: 0.03em; white-space: nowrap;
}

/* Content area — fades between slides */
.gallery-content {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.35s ease;
}

/* ── Recap slide (all cookies grid) ───────────────────────────────────────── */
.gallery-recap {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; padding: clamp(0.5rem,1.5vw,1.5rem) clamp(0.75rem,2vw,2rem);
  gap: clamp(0.5rem,1.5vh,1.5rem);
}
.gallery-recap-title {
  font-size: clamp(1.25rem,3vw,2.25rem); color: var(--accent2); font-weight: 700;
  letter-spacing: 0.03em;
}
.gallery-recap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(90px,10vw,160px), 1fr));
  gap: clamp(0.4rem,1vw,1rem);
  width: 100%;
}
.gallery-recap-card {
  background: var(--surface); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden; padding-bottom: 0.4rem;
}
.gallery-recap-card img,
.gallery-recap-nophoto {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.5rem,4vw,3rem);
  background: var(--bg);
}
.gallery-recap-num  { font-size: clamp(0.6rem,1.2vw,0.85rem); color: var(--muted); margin-top: 0.25rem; }
.gallery-recap-name { font-size: clamp(0.7rem,1.4vw,1rem); font-weight: 600; color: var(--text); text-align: center; padding: 0 0.25rem; }

/* ── Single-cookie slide ──────────────────────────────────────────────────── */
.gallery-single {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(0.75rem,2vh,2rem);
  animation: g-fade-up 0.4s ease forwards;
}
.gallery-single-photo {
  max-height: clamp(220px, 60vh, 680px); max-width: clamp(220px, 65vw, 820px);
  object-fit: contain; border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.gallery-single-nophoto {
  width: clamp(220px, 55vh, 500px); height: clamp(220px, 55vh, 500px);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(5rem,20vh,12rem); background: var(--surface); border-radius: var(--radius);
}
.gallery-single-info { text-align: center; }
.g-num  { font-size: clamp(1rem,2.5vw,1.75rem); color: var(--muted); }
.g-name { font-size: clamp(1.75rem,5vw,3.5rem); color: var(--accent2); font-weight: 700; }
.g-baker{ font-size: clamp(0.9rem,2vw,1.5rem); color: var(--muted); }

@keyframes g-fade-up {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Reveal (winners + countdown) ─────────────────────────────────────────── */
.reveal-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 100%; height: 100%;
  padding: clamp(1rem,3vw,3rem);
  gap: clamp(1rem,3vh,3rem);
}

.winners-row {
  display: flex; gap: clamp(1.5rem,5vw,5rem);
  align-items: stretch; justify-content: center;
  flex-wrap: wrap;
}

.winner-card {
  background: var(--surface);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: clamp(1rem,2.5vw,2.5rem);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.6rem;
  min-width: clamp(180px,30vw,340px);
  animation: pop-in 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.winner-cat  { font-size: clamp(1rem,2.5vw,1.75rem); color: var(--accent); font-weight: 700; }
.winner-photo {
  width: clamp(100px,20vw,260px); height: clamp(100px,20vw,260px);
  object-fit: cover; border-radius: var(--radius);
}
.winner-no-photo {
  width: clamp(100px,20vw,260px); height: clamp(100px,20vw,260px);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(2.5rem,8vw,8rem);
  background: var(--bg); border-radius: var(--radius);
}
.winner-name  { font-size: clamp(1.25rem,3.5vw,2.5rem); font-weight: 700; color: var(--accent2); }
.winner-baker { font-size: clamp(0.875rem,2vw,1.25rem); color: var(--muted); }
.winner-pts   { font-size: clamp(0.875rem,1.75vw,1.1rem); color: var(--muted); }

.reveal-countdown-wrap {
  text-align: center;
}
.reveal-cd-label { font-size: clamp(0.875rem,2vw,1.25rem); color: var(--muted); margin-bottom: 0.25rem; }
.reveal-cd-num   {
  font-size: clamp(2.5rem,8vw,6rem); font-weight: 700;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ── Full results (TV) ────────────────────────────────────────────────────── */
.results-wrap {
  display: flex; gap: clamp(1rem,3vw,3rem);
  width: 100%; height: 100%;
  padding: clamp(0.75rem,2vw,2rem);
  overflow-y: auto;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}
.results-section { flex: 1; min-width: clamp(260px,40vw,520px); }
.results-cat-title {
  font-size: clamp(1.25rem,3vw,2.25rem);
  color: var(--accent2); font-style: italic;
  margin-bottom: clamp(0.5rem,1.5vh,1rem);
  text-align: center;
}

.results-table { width: 100%; border-collapse: collapse; }
.results-table th { color: var(--muted); font-size: clamp(0.7rem,1.2vw,0.9rem); text-align: left; padding: 0.3rem 0.5rem; border-bottom: 2px solid var(--accent); }
.results-table td { padding: clamp(0.3rem,0.8vh,0.6rem) 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.12); font-size: clamp(0.8rem,1.6vw,1.1rem); }
.results-table .r-thumb { width: clamp(32px,4vw,56px); height: clamp(32px,4vw,56px); object-fit: cover; border-radius: 4px; vertical-align: middle; }

.fullscreen-hint {
  position: fixed; bottom: 1rem; right: 1rem;
  font-size: 0.75rem; color: var(--muted);
  opacity: 1; transition: opacity 1s;
  pointer-events: none;
}
.fullscreen-hint.hidden { opacity: 0; }

.fullscreen-btn {
  position: fixed; top: 0.75rem; right: 0.75rem;
  background: rgba(0,0,0,0.45); border: 1px solid var(--accent);
  color: var(--accent); font-size: 1.1rem;
  padding: 0.3rem 0.6rem; border-radius: 6px;
  cursor: pointer; z-index: 50; line-height: 1;
  transition: opacity 0.3s;
}
.fullscreen-btn:hover { opacity: 0.8; }
.fullscreen-btn.hidden { opacity: 0; pointer-events: none; }

/* ── PIN screen ───────────────────────────────────────────────────────────── */
.pin-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.pin-box {
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 320px;
  text-align: center;
}
.pin-box h2 { color: var(--accent2); margin-bottom: 1rem; }

/* ── Commands tab ─────────────────────────────────────────────────────────── */
.cmd-block {
  background: #0d0600; border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 0.6rem 0.75rem;
  font-family: monospace; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin: 0.4rem 0;
  overflow-x: auto;
  white-space: nowrap;
}
.cmd-block code { flex: 1; color: var(--accent2); }
.copy-btn { background: none; border: 1px solid var(--muted); border-radius: 6px; padding: 0.2rem 0.5rem; color: var(--muted); font-size: 0.75rem; cursor: pointer; flex-shrink: 0; }
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.checklist { list-style: none; }
.checklist li { padding: 0.4rem 0; border-bottom: 1px solid var(--surface); font-size: 0.9rem; }
.checklist li::before { content: "[ ] "; font-family: monospace; color: var(--muted); }
