:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-hover: #f5f5f4;
  --border: #e7e5e4;
  --text: #1c1917;
  --text-muted: #78716c;
  --accent: #16a34a;
  --accent-soft: rgba(22, 163, 74, 0.12);
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --radius: 14px;
}

:root[data-theme="dark"] {
  --bg: #0b0b0d;
  --surface: #15151a;
  --surface-hover: #1d1d23;
  --border: #26262e;
  --text: #f5f5f4;
  --text-muted: #a8a29e;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.18);
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 6px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; }

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  z-index: 10;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 14px;
  text-decoration: none;
}
.brand span { color: var(--accent); margin: 0 2px; }

.topbar nav {
  display: flex;
  align-items: center;
  gap: 18px;
}
.topbar nav a {
  text-decoration: none;
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}
.topbar nav a:hover { color: var(--text); }

#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
#theme-toggle:hover { background: var(--surface-hover); }
#theme-toggle .icon-sun { display: none; }
#theme-toggle .icon-moon { display: inline; }
:root[data-theme="dark"] #theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* --- Voting page --- */
main.vote {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 40px 48px;
  text-align: center;
  /* Make the arena fill the available viewport so jerseys are big on laptops. */
  min-height: calc(100vh - 73px);
  display: flex;
  flex-direction: column;
}

.prompt {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0 0 22px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 500;
}

.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.2s ease, background 0.18s ease;
  overflow: hidden;
}
.card:disabled { cursor: default; opacity: 0.5; }
.card:not(:disabled):hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 10px 32px var(--accent-soft);
}
.card:not(:disabled):hover .kbd { opacity: 1; transform: translateY(0); }
.card:not(:disabled):active { transform: translateY(-1px); }
.card.picked {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 14px 40px var(--accent-soft);
}
.card.fading { opacity: 0; transform: translateY(6px); }

.card-image {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  min-height: 0;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 16px;
  gap: 12px;
}
.country {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.kit-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.kbd {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  z-index: 1;
}

.vs {
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vs span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  text-transform: uppercase;
  box-shadow: var(--shadow);
}

.hint {
  margin: 22px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.hint a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 3px; }
.hint a:hover { color: var(--text); }
.hint kbd {
  display: inline-block;
  padding: 2px 6px;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}
.hint-mobile { display: none; }
.hint-desktop { display: inline; }

/* --- Leaderboard --- */
main.board {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.board-head h1 {
  font-size: 28px;
  margin: 0;
  letter-spacing: -0.02em;
}
.sort-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.sort-toggle button {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.sort-toggle button.active {
  background: var(--accent);
  color: white;
}
.board-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 6px 0 24px;
}

.ranks {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row {
  display: grid;
  grid-template-columns: 36px 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.15s ease;
}
.row:hover { background: var(--surface-hover); }
.row .rank {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 14px;
}
.row:nth-child(1) .rank { color: var(--accent); font-weight: 800; }
.row:nth-child(2) .rank, .row:nth-child(3) .rank { color: var(--text); font-weight: 700; }
.row .thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row .thumb img { width: 100%; height: 100%; object-fit: contain; }
.row .name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .name .c { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .name .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.row .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.row .num .big { font-weight: 700; font-size: 15px; }
.row .num .small { font-size: 11px; color: var(--text-muted); display: block; }

.board-foot {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.board-foot a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.board-foot a:hover { border-bottom-color: var(--accent); }

/* --- About / prose page --- */
main.prose {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  font-size: 16px;
  line-height: 1.7;
}
main.prose h1 {
  font-size: 32px;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  line-height: 1.15;
}
main.prose .lede {
  font-size: 17px;
  color: var(--text-muted);
  margin: 0 0 36px;
}
main.prose section { margin-bottom: 36px; }
main.prose h2 {
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
main.prose p { margin: 0 0 14px; }
main.prose ul {
  padding-left: 22px;
  margin: 0 0 16px;
}
main.prose li { margin-bottom: 6px; }
main.prose strong { color: var(--text); font-weight: 600; }
main.prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
main.prose a:hover { border-bottom-color: var(--accent); }
.prose-foot {
  margin-top: 48px !important;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}
.prose-foot a {
  color: var(--text-muted) !important;
  border-bottom: 0 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose-foot a:hover { color: var(--text) !important; }

/* --- Responsive --- */
@media (max-width: 720px) {
  .topbar { padding: 14px 18px; }
  .topbar nav { gap: 12px; }
  main.vote {
    padding: 22px 14px 32px;
    min-height: calc(100vh - 65px);
  }
  .prompt { font-size: 13px; margin-bottom: 16px; }
  .arena {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .vs span { width: 36px; height: 36px; font-size: 10px; }
  .card { padding: 14px; }
  .card-image img { max-height: 36vh; }
  .country { font-size: 16px; }
  .kbd { display: none; }
  .hint-mobile { display: inline; }
  .hint-desktop { display: none; }
  main.board { padding: 24px 14px 60px; }
  .board-head h1 { font-size: 22px; }
  .row { grid-template-columns: 28px 44px 1fr auto; gap: 10px; padding: 8px 10px; }
  .row .thumb { width: 44px; height: 44px; }
  .row .name .c { font-size: 14px; }
  main.prose { padding: 28px 18px 60px; }
  main.prose h1 { font-size: 26px; }
  main.prose .lede { font-size: 15px; margin-bottom: 28px; }
  main.prose h2 { font-size: 18px; }
}

/* Short laptop screens — don't let cards get cramped vertically. */
@media (min-width: 721px) and (max-height: 760px) {
  main.vote { padding: 22px 32px 28px; }
  .prompt { margin-bottom: 16px; }
  .hint { margin-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
