/* ── 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 ──────────────────────────────────────────────────────────── */
.screen-root {
  width: 100vw; height: 100vh; 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 { width: 100%; text-align: center; }
.screen-vote .qr-wrap { margin: 0 auto 1.5rem; display: inline-block; }
.screen-vote .vote-url { font-size: clamp(1rem, 3vw, 2rem); color: var(--accent2); }
.screen-vote .vote-count { font-size: clamp(1.25rem, 4vw, 2.5rem); color: var(--text); margin-top: 0.75rem; }

.screen-gallery { width: 100%; text-align: center; }
.screen-gallery img { max-height: 65vh; max-width: 90vw; object-fit: contain; border-radius: var(--radius); }
.screen-gallery .g-info { margin-top: 1rem; }
.screen-gallery .g-num  { font-size: clamp(1.25rem,3vw,2rem); color: var(--muted); }
.screen-gallery .g-name { font-size: clamp(2rem,6vw,4rem); color: var(--accent2); font-weight: 700; }
.screen-gallery .g-baker{ font-size: clamp(1rem,3vw,2rem); color: var(--muted); }

/* Podium */
.podium-wrap { display: flex; gap: clamp(1rem,3vw,3rem); align-items: flex-end; justify-content: center; padding: 2rem; }
.podium-col { display: flex; flex-direction: column; align-items: center; }
.podium-box {
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: var(--radius);
  width: clamp(120px, 20vw, 220px);
  padding: 1rem 0.75rem;
  text-align: center;
  transition: transform 0.4s, opacity 0.4s;
}
.podium-box.unrevealed { opacity: 0.35; border-style: dashed; }
.podium-box img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  margin-bottom: 0.5rem;
}
.podium-box .p-place { font-size: clamp(1rem,2vw,1.5rem); color: var(--muted); }
.podium-box .p-name  { font-size: clamp(0.9rem,2vw,1.25rem); font-weight: 700; color: var(--accent2); }
.podium-box .p-baker { font-size: clamp(0.75rem,1.5vw,1rem); color: var(--muted); }
.podium-box .p-pts   { font-size: clamp(0.75rem,1.5vw,1rem); color: var(--muted); }
.podium-box.just-revealed { animation: pop-in 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards; }

@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.podium-category { font-size: clamp(1rem,3vw,2rem); color: var(--accent); font-style: italic; margin-bottom: 0.5rem; text-align: center; }

/* Full results */
.results-table { width: 100%; border-collapse: collapse; }
.results-table th { color: var(--muted); font-size: 0.75rem; text-align: left; padding: 0.3rem 0.5rem; }
.results-table td { padding: 0.4rem 0.5rem; border-top: 1px solid var(--surface); font-size: clamp(0.75rem,1.5vw,1rem); }
.results-table .r-thumb { width: clamp(32px,4vw,56px); height: clamp(32px,4vw,56px); object-fit: cover; border-radius: 4px; }

.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; }

/* ── 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); }
