:root {
  --bg-cream: #f7efe2;
  --bg-warm: #f4dac1;
  --bg-caramel: #dea16f;
  --ink-dark: #3b2415;
  --ink-soft: #6f4b2f;
  --chip: #4d2a1a;
  --chip-milk: #8d5835;
  --mint-accent: #5b8e7d;
  --gold: #f4b742;
  --danger: #b33a3a;
  --white: #fffdf9;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 18px 35px rgba(99, 63, 36, 0.16);
  --shadow-soft: 0 8px 22px rgba(92, 55, 29, 0.12);
  --space: clamp(12px, 2vw, 20px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-dark);
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(255, 236, 211, 0.95), transparent 42%),
    radial-gradient(circle at 85% 24%, rgba(234, 166, 111, 0.34), transparent 38%),
    radial-gradient(circle at 20% 90%, rgba(208, 150, 97, 0.24), transparent 40%),
    linear-gradient(155deg, var(--bg-cream), #f9f3ea 30%, #f3e2cf 88%);
  background-attachment: fixed;
}

.cookie-noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.08;
  background-image:
    radial-gradient(circle at 15% 17%, #5f3b25 0 2px, transparent 3px),
    radial-gradient(circle at 70% 40%, #4d2a1a 0 2px, transparent 3px),
    radial-gradient(circle at 43% 72%, #5f3b25 0 1px, transparent 2px),
    radial-gradient(circle at 88% 80%, #4d2a1a 0 1px, transparent 2px);
  background-size: 140px 140px;
}

main {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 30px);
}

.hero {
  position: relative;
  background: linear-gradient(135deg, #f9f0e2, #f8dabc 64%, #f3c39a);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 38px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.hero::after {
  content: "";
  pointer-events: none;
  position: absolute;
  width: 260px;
  height: 260px;
  right: -90px;
  top: -46px;
  opacity: 0.34;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 220 220'%3E%3Ccircle cx='108' cy='112' r='88' fill='%23d98b43'/%3E%3Ccircle cx='150' cy='46' r='34' fill='%23f9f0e2'/%3E%3Ccircle cx='86' cy='76' r='9' fill='%234d2a1a'/%3E%3Ccircle cx='126' cy='74' r='8' fill='%234d2a1a'/%3E%3Ccircle cx='146' cy='106' r='10' fill='%234d2a1a'/%3E%3Ccircle cx='112' cy='128' r='8' fill='%234d2a1a'/%3E%3Ccircle cx='76' cy='116' r='8' fill='%234d2a1a'/%3E%3Ccircle cx='94' cy='150' r='9' fill='%234d2a1a'/%3E%3Ccircle cx='136' cy='156' r='7' fill='%234d2a1a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero h1,
.hero p,
.hero .nav-wrap {
  max-width: min(72%, 690px);
}

.hero h1,
.hero p {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

h1,
h2,
h3 {
  font-family: "Baloo 2", "Verdana", sans-serif;
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
}

h2 {
  font-size: clamp(1.4rem, 3.6vw, 2.1rem);
}

p {
  margin: 0;
  line-height: 1.55;
}

.muted {
  color: var(--ink-soft);
}

.grid {
  display: grid;
  gap: var(--space);
}

.home-grid {
  margin-top: var(--space);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 249, 0.85);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(166, 109, 65, 0.2);
  padding: clamp(16px, 2.4vw, 24px);
}

.panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(125, 78, 45, 0.24);
  border-radius: var(--radius-md);
  padding: 14px;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  font-weight: 700;
  color: #4b2c19;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(111, 75, 47, 0.34);
  background: #fff;
  color: var(--ink-dark);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.field {
  display: grid;
  gap: 6px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(244, 224, 201, 0.7);
  border: 1px solid rgba(130, 84, 53, 0.23);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.94rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(140deg, #9a5a2f, #7e4623 65%, #603117);
  box-shadow: 0 8px 16px rgba(92, 52, 27, 0.28);
}

.btn-ghost {
  color: var(--ink-dark);
  background: #f7e9d8;
  border: 1px solid rgba(121, 75, 44, 0.3);
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
}

a.btn {
  color: inherit;
}

.link-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-mobile {
  display: none;
}

.nav-mobile-panel {
  display: none;
}

.nav-mobile-panel.open {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.notice {
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid rgba(85, 138, 117, 0.37);
  background: rgba(230, 253, 245, 0.72);
  color: #2d5f4e;
  font-weight: 700;
}

.error {
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid rgba(178, 58, 58, 0.38);
  background: rgba(253, 227, 227, 0.78);
  color: #7f2727;
  font-weight: 700;
}

.cookie-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.cookie-item {
  border-radius: var(--radius-md);
  border: 1px solid rgba(113, 76, 46, 0.24);
  background: rgba(255, 255, 255, 0.8);
  padding: 12px;
  display: grid;
  gap: 6px;
  text-align: left;
}

.cookie-item.active {
  border-color: #7c4b29;
  box-shadow: 0 0 0 2px rgba(124, 75, 41, 0.13);
}

.cookie-photo {
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(126, 84, 49, 0.2);
  box-shadow: var(--shadow-soft);
  background: #f4e1cd;
}

.cookie-photo--thumb {
  width: 100%;
  max-width: 160px;
  aspect-ratio: 4 / 3;
  margin-bottom: 6px;
}

.cookie-photo--preview {
  margin-top: 8px;
  width: min(100%, 280px);
  aspect-ratio: 4 / 3;
}

.cookie-photo--large {
  width: min(100%, 380px);
  aspect-ratio: 4 / 3;
}

.cookie-photo--winner {
  width: 78px;
  height: 58px;
  flex-shrink: 0;
}

.cookie-photo--winner-main {
  width: min(100%, 240px);
  aspect-ratio: 4 / 3;
  display: block;
  margin: 0 auto 10px;
}

.winner-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vote-badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.vote-badge.is-voted {
  background: rgba(85, 138, 117, 0.2);
  color: #225848;
}

.vote-badge.is-unvoted {
  background: rgba(122, 112, 101, 0.16);
  color: #5e4f42;
}

.cookie-rating {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cookie-rate-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

.cookie-rate-btn .cookie-glyph {
  width: 44px;
  height: 44px;
  transition: transform 120ms ease, filter 140ms ease;
}

.cookie-rate-btn:hover .cookie-glyph {
  transform: translateY(-1px) scale(1.03);
}

.cookie-rate-btn:not(.active) .cookie-glyph {
  filter: saturate(0.25) brightness(1.07);
}

.cookie-rate-btn.active .cookie-glyph {
  filter: saturate(1.05) brightness(1.02);
}

.vote-flow {
  margin-top: 12px;
}

.sticky-actions {
  position: sticky;
  bottom: 10px;
  background: rgba(255, 247, 236, 0.95);
  border: 1px solid rgba(122, 73, 41, 0.24);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(6px);
}

.results-grid {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.podium {
  border-radius: var(--radius-lg);
  border: 2px solid rgba(170, 110, 60, 0.3);
  background: linear-gradient(155deg, #fff4e5, #f9ddbd);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.podium .score {
  font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  font-family: "Baloo 2", sans-serif;
  color: #7b451f;
}

.winner-main {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.trophy {
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(133, 86, 18, 0.25));
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid rgba(122, 78, 48, 0.2);
  vertical-align: top;
}

.qr-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.qr {
  width: min(90vw, 420px);
  border-radius: var(--radius-sm);
  border: 6px solid #f7e9d8;
  box-shadow: var(--shadow-soft);
}

.qr-clean {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
  text-align: center;
  gap: 16px;
}

main.print-qr {
  max-width: 1000px;
}

@media (max-width: 820px) {
  .nav-desktop {
    display: none;
  }

  .nav-mobile {
    display: block;
  }

  .nav-mobile-panel a {
    width: 100%;
    justify-content: flex-start;
  }

  .sticky-actions {
    position: static;
  }

  .hero::after {
    width: 200px;
    height: 200px;
    right: -86px;
    top: -42px;
    opacity: 0.26;
  }

  .hero h1,
  .hero p,
  .hero .nav-wrap {
    max-width: 100%;
  }

  .winner-main {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

@media (min-width: 1300px) {
  main.tv-mode {
    max-width: 1480px;
  }

  main.tv-mode .card {
    padding: 28px;
  }

  main.tv-mode h1 {
    font-size: 4.3rem;
  }

  main.tv-mode h2 {
    font-size: 2.8rem;
  }

  main.tv-mode p,
  main.tv-mode td,
  main.tv-mode th {
    font-size: 1.25rem;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .cookie-noise,
  .link-row,
  .btn,
  .hero,
  #results-lock,
  #toggle-tv {
    display: none !important;
  }

  main.print-qr {
    padding: 0;
    max-width: none;
  }

  .qr-clean {
    min-height: 100vh;
  }

  .qr {
    width: 70vmin;
    box-shadow: none;
    border: 0;
  }
}

.fade-in {
  animation: fadeIn 360ms ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
