:root {
  --navy: #102a43;
  --blue: #246b8e;
  --teal: #2f8f83;
  --gold: #f2b84b;
  --ink: #183042;
  --muted: #64798a;
  --paper: #fff;
  --wash: #f3f7f8;
  --line: #dfe7ec;
  --shadow: 0 16px 38px rgba(16,42,67,.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 0, rgba(47,143,131,.1), transparent 28rem),
    radial-gradient(circle at 92% 5%, rgba(36,107,142,.11), transparent 30rem),
    var(--wash);
}

button, input { font: inherit; }

button { cursor: pointer; }

.page-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
}

header { padding: 46px 0 24px; }

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  position: relative;
  overflow: hidden;
  padding: clamp(30px, 5vw, 62px);
  border-radius: 30px;
  color: white;
  background: linear-gradient(135deg, #102a43, #246b8e 60%, #2f8f83);
  box-shadow: 0 26px 64px rgba(16,42,67,.22);
}

.hero::after {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  right: -150px;
  top: -175px;
  border: 52px solid rgba(255,255,255,.08);
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 10px;
  color: #bde8df;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow.dark { color: var(--teal); }

h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 4.8rem);
  line-height: .98;
  letter-spacing: -.05em;
}

.intro {
  max-width: 690px;
  margin: 22px 0 0;
  color: rgba(255,255,255,.82);
  font-size: 1.08rem;
  line-height: 1.62;
}

.reviewer-card {
  z-index: 1;
  flex: 0 0 220px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(10px);
}

.reviewer-label {
  display: block;
  margin-bottom: 4px;
  color: rgba(255,255,255,.7);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.reviewer-card strong {
  display: block;
  overflow: hidden;
  margin-bottom: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reviewer-card button {
  padding: 0;
  border: 0;
  color: white;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toolbar-wrap {
  position: sticky;
  z-index: 20;
  top: 0;
  padding: 10px 0 18px;
  background: linear-gradient(var(--wash) 72%, transparent);
  backdrop-filter: blur(11px);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(16,42,67,.1);
  border-radius: 18px;
  background: rgba(255,255,255,.91);
  box-shadow: 0 10px 28px rgba(16,42,67,.08);
}

.summary {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 230px;
  padding: 8px 10px;
}

.summary span { color: var(--muted); }
.summary strong span { color: inherit; }

.toolbar button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: white;
  transition: .18s ease;
}

.toolbar button:hover {
  transform: translateY(-1px);
  border-color: #abc1ce;
  box-shadow: 0 7px 18px rgba(16,42,67,.08);
}

.toolbar button.active {
  border-color: var(--navy);
  color: white;
  background: var(--navy);
}

.toolbar .primary {
  margin-left: auto;
  border-color: var(--teal);
  color: white;
  background: var(--teal);
}

main { padding-bottom: 72px; }

section {
  margin-top: 38px;
  scroll-margin-top: 112px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-heading.compact { align-items: center; }

.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.85rem, 3vw, 2.85rem);
  letter-spacing: -.035em;
}

.section-heading > p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  color: #276d68;
  background: #e3efef;
  font-size: .82rem;
  font-weight: 850;
}

.leaders {
  padding: 26px;
  border: 1px solid rgba(16,42,67,.1);
  border-radius: 22px;
  background: rgba(255,255,255,.7);
}

.leader-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.leader-group {
  padding: 18px;
  border-radius: 17px;
  background: white;
  box-shadow: 0 7px 20px rgba(16,42,67,.06);
}

.leader-group h3 {
  margin: 0 0 13px;
  color: var(--navy);
}

.leader-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid #edf1f3;
}

.leader-item:first-of-type { border-top: 0; }

.rank {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--navy);
  background: #e8eff2;
  font-size: .8rem;
  font-weight: 900;
}

.leader-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-votes {
  color: var(--teal);
  font-weight: 900;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
}

.card {
  grid-column: span 4;
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid rgba(16,42,67,.1);
  border-radius: 20px;
  background: white;
  box-shadow: 0 7px 22px rgba(16,42,67,.07);
  transition: .2s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242,184,75,.28), var(--shadow);
}

.card.hidden { display: none; }

.image-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #dce7ea;
  cursor: zoom-in;
}

.image-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 5;
}

.image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.card:hover img { transform: scale(1.025); }

.option-badge,
.vote-badge {
  position: absolute;
  top: 14px;
  padding: 8px 10px;
  border-radius: 999px;
  color: white;
  background: rgba(16,42,67,.85);
  font-size: .77rem;
  font-weight: 850;
  backdrop-filter: blur(8px);
}

.option-badge { left: 14px; }
.vote-badge { left: 14px; top: auto; bottom: 14px; }

.favorite {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #617787;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 22px rgba(16,42,67,.17);
  transition: .18s ease;
}

.favorite:hover { transform: scale(1.06); }

.favorite svg {
  width: 24px;
  height: 24px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.8;
}

.card.selected .favorite {
  color: var(--navy);
  background: var(--gold);
}

.card.selected .favorite svg { fill: currentColor; }

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px 17px;
}

.file-name {
  overflow: hidden;
  color: var(--navy);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-state {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .78rem;
}

.card.selected .saved-state {
  color: #8a650e;
  font-weight: 800;
}

.empty-state {
  padding: 44px;
  border: 1px dashed #afc2cc;
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(255,255,255,.6);
}

dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: white;
  box-shadow: 0 30px 100px rgba(0,0,0,.4);
}

dialog::backdrop {
  background: rgba(7,17,24,.76);
  backdrop-filter: blur(6px);
}

#nameForm { padding: 30px; }

#nameForm h2 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 2rem;
}

#nameForm p {
  color: var(--muted);
  line-height: 1.5;
}

#nameForm label {
  display: block;
  margin: 22px 0 15px;
  color: var(--navy);
  font-weight: 850;
}

#nameForm input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  border: 1px solid #b7c8d1;
  border-radius: 11px;
  color: var(--ink);
  outline: none;
}

#nameForm input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47,143,131,.15);
}

.save-name {
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--teal);
  font-weight: 900;
}

.error {
  min-height: 20px;
  margin: 0 0 8px !important;
  color: #a43d3d !important;
}

#lightbox {
  width: min(1120px, calc(100% - 28px));
  max-height: calc(100vh - 28px);
  background: #0c1d29;
}

#lightbox img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 15px;
  color: white;
  background: var(--navy);
}

.lightbox-bar button {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  color: white;
  background: transparent;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 24px;
  opacity: 0;
  transform: translate(-50%, 12px);
  padding: 11px 16px;
  border-radius: 999px;
  color: white;
  background: var(--navy);
  box-shadow: 0 12px 30px rgba(16,42,67,.28);
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .hero { align-items: start; flex-direction: column; }
  .reviewer-card { width: min(100%, 320px); flex-basis: auto; }
  .toolbar .primary { margin-left: 0; }
  .card { grid-column: span 6; }
}

@media (max-width: 680px) {
  .page-shell { width: calc(100% - 22px); }
  header { padding-top: 18px; }
  .hero { border-radius: 22px; }
  .summary { width: 100%; min-width: 0; }
  .leader-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: start; }
  .section-heading.compact { align-items: start; flex-direction: column; }
  .card { grid-column: 1 / -1; }
}
