:root {
  --bg: #f3f0e8;
  --surface: #fffdf8;
  --ink: #1b2130;
  --muted: #687082;
  --line: #e1dccf;
  --accent: #1f3c88;
  --accent-soft: #e3e8f6;
  --gold: #a87b16;
  --shadow: 0 1px 2px rgb(27 33 48 / .06), 0 10px 30px rgb(27 33 48 / .08);
  --cover-shadow: drop-shadow(0 8px 14px rgb(20 24 36 / .22));
  --radius: 16px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1016;
    --surface: #151a23;
    --ink: #e9e5dc;
    --muted: #959cab;
    --line: #262d3b;
    --accent: #93acff;
    --accent-soft: #1d2640;
    --gold: #d9b45a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .35);
    --cover-shadow: drop-shadow(0 8px 14px rgb(0 0 0 / .5));
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
img { display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  padding: 12px max(16px, calc((100% - 1040px) / 2 + 16px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 600 20px/1 var(--serif); }
.brand svg { color: var(--accent); }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 13px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 14.5px; font-weight: 500; white-space: nowrap; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 72px; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 72px 16px; color: var(--muted); }
.empty h1 { color: var(--ink); font-size: 28px; margin: 0 0 8px; }

/* buttons and inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 14.5px/1.2 var(--sans); color: var(--ink); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; cursor: pointer; transition: border-color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.ghost { background: transparent; }
select {
  font: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; font-size: 14.5px; color: var(--muted); }
.toolbar label { display: flex; align-items: center; gap: 8px; }
.toolbar > .btn { margin-left: auto; }

/* passport pool picker */
.picker { position: relative; }
.picker summary { list-style: none; }
.picker summary::-webkit-details-marker { display: none; }
.picker summary::after { content: "▾"; color: var(--muted); }
.picker summary strong { color: var(--accent); font-weight: 600; }
.picker-panel {
  position: absolute; z-index: 20; top: calc(100% + 8px); left: 0;
  width: min(540px, calc(100vw - 32px)); padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--ink);
}
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.picker-panel label { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; }
.picker-panel .count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.picker-terr { margin-top: 10px; padding-top: 12px !important; border-top: 1px solid var(--line); color: var(--muted); }
.picker-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }

/* progress */
.progress { margin: 20px 0 6px; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--muted); }
.bar { height: 6px; margin-top: 7px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .4s ease; }

.prompt { font-size: clamp(22px, 3.2vw, 30px); text-align: center; margin: 24px 0 18px; }

/* the duel */
.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; }
.vs { font: italic 600 18px var(--serif); color: var(--muted); }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 16px 16px;
  transition: transform .15s ease, border-color .15s, box-shadow .15s;
  animation: rise .25s ease both;
}
.pick + .vs + .pick { animation-delay: .05s; }
.pick:hover { transform: translateY(-3px); border-color: var(--accent); }
.pick:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.pick.chosen { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), var(--shadow); transform: scale(1.02); }
.cover { display: flex; align-items: center; justify-content: center; width: 100%; height: min(52vh, 440px); margin-bottom: 12px; }
.cover img { width: 100%; height: 100%; object-fit: contain; filter: var(--cover-shadow); }
.pick-name { font: 600 20px/1.25 var(--serif); text-align: center; }
.pick-region { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 24px; }
.hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 14px; }
kbd { font: 12px var(--sans); background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }

/* my ranking */
.hero {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px;
}
.hero-cover { width: 170px; border-radius: 5px; filter: var(--cover-shadow); }
.hero h1 { font-size: clamp(30px, 4.4vw, 44px); margin: 6px 0 8px; }
.hero p { margin: 0; }
.hero .actions { justify-content: flex-start; margin-top: 18px; }
.eyebrow { font-size: 12.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.section-title { font-size: 22px; margin: 36px 0 14px; }

.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; }
.tile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px 10px; text-align: center; font-size: 13.5px; }
.tile img { width: 100%; height: 150px; object-fit: contain; margin-bottom: 8px; border-radius: 3px; }
.tile-name { display: block; font-weight: 600; line-height: 1.3; }
.tile-sub { display: block; font-size: 12px; color: var(--muted); }
.rank {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px;
  border-radius: 13px; background: var(--accent); color: var(--surface);
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.tile .rank { position: absolute; top: 8px; left: 8px; }
.rank.r1 { background: #c9a227; color: #1b2130; }
.rank.r2 { background: #a7adb8; color: #1b2130; }
.rank.r3 { background: #b4774a; color: #fff; }

/* you vs the world */
.versus { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.versus-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.versus h2 { font-size: 22px; margin: 0; }
.versus > p { margin: 6px 0 0; font-size: 14.5px; }
.match { color: var(--muted); }
.match strong { font: 600 28px var(--serif); color: var(--gold); margin-right: 4px; }
.versus-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; margin-top: 16px; }
.versus h3 { font: 600 13px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.versus ul { list-style: none; margin: 0; padding: 0; }
.versus li { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.versus li:first-child { border-top: 0; }
.versus li img { width: 30px; height: 42px; object-fit: contain; flex: none; }
.versus li strong { display: block; font-weight: 600; }
.versus li small { display: block; font-size: 12.5px; color: var(--muted); }
.versus-cols p { font-size: 14px; margin: 0; }
.versus-note { margin: 18px 0 0; }
.lean { position: absolute; top: 9px; right: 10px; font-size: 13px; line-height: 1; }
.lean.up { color: #2f8a4e; }
.lean.down { color: #c0563a; }

/* world ranking */
.world-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.world-head h1 { font-size: clamp(28px, 4vw, 38px); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 22px; }
.chip { font: inherit; font-size: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip:hover { color: var(--ink); }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; }
.podium-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 12px 16px;
}
.podium-item img { width: 100%; height: 190px; object-fit: contain; margin-bottom: 10px; border-radius: 5px; filter: var(--cover-shadow); }
.podium-item.p1 { order: 2; padding-top: 28px; }
.podium-item.p1 img { height: 250px; }
.podium-item.p2 { order: 1; }
.podium-item.p3 { order: 3; }
.podium-name { font: 600 19px/1.25 var(--serif); }
.table { list-style: none; margin: 22px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: grid; grid-template-columns: 40px 34px 1fr auto 92px; align-items: center; gap: 14px; padding: 8px 18px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.head { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 18px; }
.row img { width: 34px; height: 46px; object-fit: contain; border-radius: 2px; }
.row-rank { text-align: right; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-name { font-weight: 600; line-height: 1.3; }
.row-name small { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.row-score { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.row-record { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

/* about */
.prose { max-width: 680px; }
.prose h1 { font-size: clamp(30px, 4.4vw, 40px); margin: 8px 0 12px; }
.prose h2 { font-size: 22px; margin: 32px 0 6px; }
.prose p { margin: 8px 0; }
.prose details { margin-top: 12px; }
.prose summary { cursor: pointer; font-weight: 600; }
.credits { font-size: 13.5px; padding-left: 18px; }
.credits li { margin: 3px 0; }

/* clickable covers */
[data-card], [data-cover] { cursor: pointer; }
[data-card]:focus-visible, [data-cover]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile[data-card] { transition: border-color .15s, transform .15s; }
.tile[data-card]:hover { border-color: var(--accent); transform: translateY(-2px); }
.podium-item[data-cover] { transition: border-color .15s, transform .15s; }
.podium-item[data-cover]:hover { border-color: var(--accent); transform: translateY(-2px); }
.row[data-cover]:hover { background: var(--accent-soft); }

/* big views */
.viewer { border: 0; padding: 0; background: transparent; color: var(--ink); width: min(900px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: visible; }
.viewer::backdrop { background: rgb(10 12 18 / .62); backdrop-filter: blur(3px); }
.viewer-body {
  position: relative; max-height: calc(100dvh - 32px); overflow: auto; padding: 32px;
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgb(0 0 0 / .35);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.viewer-close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  font: 16px var(--sans); color: var(--muted); background: var(--bg); border: 1px solid var(--line); cursor: pointer;
}
.viewer-close:hover { color: var(--ink); border-color: var(--accent); }
.viewer h2 { font-size: clamp(26px, 3.6vw, 34px); margin: 0 0 6px; }
.viewer-cover { display: block; border-radius: 6px; filter: var(--cover-shadow); }
.cover-view { text-align: center; }
.cover-view .viewer-cover { max-width: 100%; max-height: min(70dvh, 760px); width: auto; height: auto; margin: 0 auto 20px; }
.cover-view p { margin: 4px 0; }
.card { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 32px; align-items: start; }
.card .viewer-cover { width: 100%; }
.card .eyebrow { margin: 4px 0 0; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.facts dt { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font: 600 30px/1.1 var(--serif); }
.facts dd small { font: 400 14px var(--sans); color: var(--muted); }
.facts > div > small { display: block; font-size: 12.5px; margin-top: 2px; }
.compare { border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 12px; }
.compare h3 { font: 600 12px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.verdict { font-weight: 600; margin: 0 0 12px; }
.verdict.up { color: #2f8a4e; }
.verdict.down { color: #c0563a; }
.meter-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px; font-size: 14px; margin: 6px 0; }
.meter-row > span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); }
.meter { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; }
.meter.you > span { background: var(--accent); }
.meter.world > span { background: var(--gold); }
.small { font-size: 13px; }
.credit { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }

@media (hover: none) { .hint { display: none; } }   /* keyboard shortcuts, useless on touch screens */

@media (max-width: 640px) {
  .duel { grid-template-columns: 1fr 1fr; gap: 10px; }
  .vs { display: none; }
  .pick { padding: 12px 8px 10px; }
  .cover { height: 36vh; margin-bottom: 8px; }
  .pick-name { font-size: 16px; }
  .toolbar > .btn { margin-left: 0; }
  .picker { width: 100%; }
  .picker summary { width: 100%; }
  .picker summary::after { margin-left: auto; }
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 16px; padding: 22px; }
  .hero-cover { width: 120px; }
  .hero .actions { justify-content: center; }
  .podium { gap: 8px; }
  .podium-item { padding: 12px 6px 10px; }
  .podium-item img { height: 120px; }
  .podium-item.p1 img { height: 150px; }
  .podium-name { font-size: 15px; }
  .row { grid-template-columns: 28px 30px 1fr auto; gap: 10px; padding: 8px 12px; }
  .row.head { padding: 10px 12px; }
  .row-record { display: none; }
  .versus { padding: 18px; }
  .viewer-body { padding: 22px 18px; }
  .card { grid-template-columns: 1fr; gap: 16px; }
  .card .viewer-cover { width: min(200px, 60%); margin: 0 auto; }
  .card-info { text-align: left; }
  .meter-row { grid-template-columns: 1fr auto; }
  .meter-row .meter { grid-column: 1 / -1; grid-row: 2; }
  .versus-cols { grid-template-columns: 1fr; }
}
