:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #b8c3d1;
  --panel: rgba(11, 18, 32, 0.78);
  --panel-solid: #101827;
  --line: rgba(255, 255, 255, 0.16);
  --field: rgba(255, 255, 255, 0.08);
  --green: #33d17a;
  --teal: #20c7b5;
  --red: #ff4f6d;
  --gold: #ffd166;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: #07111f;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.hero {
  min-height: 92vh;
  display: grid;
  grid-template-rows: auto 1fr;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background-image:
    linear-gradient(90deg, rgba(6, 12, 24, 0.92), rgba(6, 12, 24, 0.56) 46%, rgba(6, 12, 24, 0.24)),
    linear-gradient(0deg, #07111f 0%, rgba(7, 17, 31, 0) 28%),
    url("assets/stadium-hero.png");
  background-size: cover;
  background-position: center;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 18vh;
  z-index: -1;
  background: linear-gradient(0deg, #07111f, rgba(7, 17, 31, 0));
}

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.nav-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  color: var(--gold);
  font-size: 0.88rem;
}

.nav-actions {
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 15, 28, 0.45);
  backdrop-filter: blur(16px);
}

.nav-actions a {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.nav-actions a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.hero-content {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 9vh 0 18vh;
  align-self: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 790px;
  margin-bottom: 20px;
  font-size: clamp(2.8rem, 7vw, 6.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.24rem);
  line-height: 1.65;
}

.hero-actions,
.custom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-action,
.secondary-action,
.submit-button,
.ghost-button {
  min-height: 48px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  padding: 0 20px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action,
.submit-button {
  background: var(--green);
  color: #06130d;
}

.secondary-action,
.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: -7vh auto 80px;
  position: relative;
  z-index: 2;
}

.vote-shell,
.results {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.results {
  margin-top: 22px;
  background: rgba(11, 18, 32, 0.62);
}

.ad-slot {
  position: relative;
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.ad-label {
  color: rgba(184, 195, 209, 0.74);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ad-frame {
  width: min(100%, 728px);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  padding: 14px 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(10, 18, 31, 0.68);
  color: rgba(229, 237, 247, 0.82);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}

.ad-frame-live {
  padding: 0;
  background: transparent;
}

.ad-frame-live iframe {
  display: block;
  max-width: 100%;
  border: 0;
  background: transparent;
}

.ad-reward-button {
  min-height: 38px;
  border: 1px solid rgba(51, 209, 122, 0.45);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(51, 209, 122, 0.12);
  color: #d9ffe9;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.ad-reward-button:hover,
.ad-reward-button:focus-visible {
  border-color: rgba(51, 209, 122, 0.85);
  background: rgba(51, 209, 122, 0.22);
  outline: none;
}

.ad-reward-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.ad-slot-wide {
  justify-items: center;
}

.ad-slot-wide .ad-label {
  width: min(100%, 728px);
}

.ad-slot-inline {
  margin-bottom: 18px;
}

.ad-slot-inline .ad-frame {
  width: min(100%, 728px);
  min-height: 72px;
  justify-self: center;
}

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

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.ballot {
  display: grid;
  gap: 24px;
}

.quota-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(51, 209, 122, 0.24);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(51, 209, 122, 0.08);
}

.share-panel {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(255, 211, 105, 0.22);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 211, 105, 0.065);
}

.quota-panel strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.05rem;
}

.share-panel strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.02rem;
}

.quota-label {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#quota-detail {
  max-width: 420px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-actions button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  cursor: pointer;
}

.share-actions button:hover,
.share-actions button:focus-visible {
  border-color: rgba(255, 211, 105, 0.75);
  background: rgba(255, 211, 105, 0.14);
  outline: none;
}

.share-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.share-actions svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 14px;
  font-weight: 800;
  color: #e5edf7;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.team-search {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.team-search input {
  width: min(100%, 420px);
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  outline: none;
}

.team-search input:focus {
  border-color: var(--green);
}

.team-search input::placeholder {
  color: rgba(184, 195, 209, 0.8);
}

.group-pager,
.group-dots {
  display: none;
}

.group-pages,
.team-group {
  display: contents;
}

.search-empty {
  grid-column: 1 / -1;
}

.team-option {
  position: relative;
}

.team-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.team-card {
  min-height: 104px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--field);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.team-card:hover {
  transform: translateY(-2px);
  border-color: rgba(51, 209, 122, 0.55);
}

.team-option input:checked + .team-card {
  border-color: var(--green);
  background: rgba(51, 209, 122, 0.16);
}

.team-flag,
.result-flag {
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.team-flag {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.team-body {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.team-name-row {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.team-code {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
}

.team-name {
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.team-meta,
.data-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.data-note {
  max-width: 720px;
  margin: -2px 0 0;
}

.custom-team {
  display: grid;
  gap: 10px;
}

.custom-team label {
  color: var(--muted);
  font-weight: 700;
}

.custom-row input {
  width: min(100%, 340px);
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  outline: none;
}

.custom-row input:focus {
  border-color: var(--green);
}

.submit-button {
  width: fit-content;
  min-width: 170px;
}

.status {
  min-height: 24px;
  margin: -8px 0 0;
  color: var(--gold);
  font-weight: 700;
}

.vote-toast {
  width: fit-content;
  max-width: 100%;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(51, 209, 122, 0.45);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(51, 209, 122, 0.14);
  color: #d9ffe9;
  font-size: 0.92rem;
  font-weight: 900;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
}

.vote-toast.is-visible {
  opacity: 1;
}

.ballot.vote-animate .submit-button {
  animation: submit-pop 520ms ease both;
}

.vote-toast.vote-animate {
  animation: toast-rise 1500ms ease both;
}

.result-panel.vote-animate,
.country-panel.vote-animate {
  animation: panel-pulse 1200ms ease both;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.country-panel,
.result-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.country-panel {
  margin-bottom: 18px;
}

.country-panel .eyebrow {
  margin-bottom: 8px;
}

.country-panel h3,
.country-panel h4 {
  margin-bottom: 0;
}

.country-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.country-results h4 {
  margin-bottom: 12px;
  color: #e5edf7;
  font-size: 0.95rem;
}

.geo-status {
  margin: -6px 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-header h3 {
  margin-bottom: 0;
}

.panel-header span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #dce7f3;
  font-size: 0.92rem;
  font-weight: 800;
}

.result-team {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.result-team span {
  overflow-wrap: anywhere;
}

.result-team-text {
  display: grid;
  gap: 2px;
}

.result-team-sub {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.result-flag {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--teal));
  transition: width 220ms ease;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

@keyframes submit-pop {
  0% {
    transform: scale(1);
  }
  42% {
    transform: scale(0.97);
  }
  72% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes toast-rise {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  18%,
  76% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px) scale(0.99);
  }
}

@keyframes panel-pulse {
  0% {
    border-color: var(--line);
    box-shadow: none;
  }
  34% {
    border-color: rgba(51, 209, 122, 0.72);
    box-shadow: 0 0 0 4px rgba(51, 209, 122, 0.12);
  }
  100% {
    border-color: var(--line);
    box-shadow: none;
  }
}

@media (max-width: 760px) {
  .hero {
    min-height: 86vh;
  }

  .topbar {
    width: min(100% - 28px, 1180px);
  }

  .nav-actions a {
    padding: 0 10px;
  }

  .hero-content,
  main {
    width: min(100% - 28px, 1180px);
  }

  .hero-content {
    padding-bottom: 16vh;
  }

  .vote-shell,
  .results {
    padding: 18px;
  }

  .ad-slot {
    margin: 14px 0;
  }

  .ad-frame,
  .ad-slot-inline .ad-frame {
    width: min(100%, 320px);
    min-height: 50px;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    font-size: 0.76rem;
  }

  .ad-reward-button {
    min-height: 34px;
    white-space: normal;
  }

  .ad-slot-wide .ad-label {
    width: min(100%, 320px);
  }

  .section-heading,
  .scoreboard,
  .panel-header {
    display: grid;
    align-items: start;
  }

  .scoreboard {
    grid-template-columns: 1fr;
  }

  .country-results {
    grid-template-columns: 1fr;
  }

  .quota-panel {
    align-items: start;
    flex-direction: column;
  }

  .share-actions {
    display: flex;
  }

  #quota-detail {
    max-width: none;
    text-align: left;
  }

  .team-grid {
    display: block;
  }

  .team-search {
    margin-bottom: 12px;
  }

  .team-search input {
    width: 100%;
  }

  .group-pager {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }

  .pager-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    cursor: pointer;
    font-weight: 900;
  }

  .pager-button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
  }

  .group-pager-label {
    min-height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #e5edf7;
    font-weight: 900;
  }

  .group-dots {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 12px;
  }

  .group-dot {
    min-width: 0;
    min-height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--muted);
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: 900;
  }

  .group-dot.is-active {
    border-color: var(--green);
    background: rgba(51, 209, 122, 0.16);
    color: var(--ink);
  }

  .group-pages {
    display: block;
    overflow: hidden;
    touch-action: pan-y;
  }

  .team-group {
    display: none;
    gap: 10px;
  }

  .team-group.is-active {
    display: grid;
    grid-template-columns: 1fr;
  }

  .grouped-team-grid.is-searching .group-pages {
    display: grid;
    gap: 10px;
  }

  .grouped-team-grid.is-searching .team-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .team-card {
    min-height: 86px;
    padding: 12px;
  }

  .submit-button,
  .primary-action,
  .secondary-action,
  .ghost-button,
  .custom-row input,
  .vote-toast {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
