/* Layout: one framed survey-chart map fills the screen; the case file floats bottom-left (stacks under the map on phones). */
:root {
  --bg: #e9eef0;
  --ink: #17242b;
  --muted: #5b6b73;
  --ocean: #cfdde2;
  --grat: #b7c9cf;
  --land: #f6f7f4;
  --land-hi: #ffffff;
  --border: #9fb0b7;
  --panel: #ffffffee;
  --field: #ffffff;
  --line: #c9d5da;
  --born: #0b7f72;
  --died: #b8322b;
  --life: #17242b;
  --btn: #17242b;
  --btn-fg: #f6f7f4;
  --good: #1f7a3d;
  /* Newsreader carries names, dates and scores (optical sizing keeps it crisp from pin labels to the
     final score); Work Sans carries the interface. Mono is only the share-text fallback, so no webfont. */
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --body: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1419; --ink: #e4ecee; --muted: #8fa2aa; --ocean: #0f1e26; --grat: #1b313c;
    --land: #23353e; --land-hi: #2b4049; --border: #3f5864; --panel: #13222aee; --field: #0f1c23; --line: #2a3f49;
    --born: #3fd1bd; --died: #ff7065; --life: #e4ecee; --btn: #e4ecee; --btn-fg: #0b1419; --good: #5fd38a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1419; --ink: #e4ecee; --muted: #8fa2aa; --ocean: #0f1e26; --grat: #1b313c;
  --land: #23353e; --land-hi: #2b4049; --border: #3f5864; --panel: #13222aee; --field: #0f1c23; --line: #2a3f49;
  --born: #3fd1bd; --died: #ff7065; --life: #e4ecee; --btn: #e4ecee; --btn-fg: #0b1419; --good: #5fd38a; color-scheme: dark;
}
html, body { height: 100%; margin: 0; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px;
  padding-inline: 16px; padding-block: 12px;
}
.app { height: 100%; display: grid; grid-template-rows: auto 1fr; gap: 10px; max-width: 1500px; margin: 0 auto; }
header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1; margin: 0; letter-spacing: -.01em; }
.brand h1 i { color: var(--muted); font-weight: 400; }
.brand p { margin: 0; color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 15px; }
.tally { display: flex; align-items: center; gap: 22px; }
.tally div { display: flex; align-items: baseline; gap: 7px; }
.tally span { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; font-weight: 600; }
.tally b { font-family: var(--serif); font-size: 19px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
/* Light/dark toggle: shows the moon in light mode and the sun in dark, i.e. the mode it switches to. */
.theme { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; }
.theme:hover { border-color: var(--ink); }
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme .moon { fill: currentColor; stroke: none; }
.theme .sun { display: none; }
:root[data-theme="dark"] .theme .sun { display: block; } :root[data-theme="dark"] .theme .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { display: block; } :root:not([data-theme="light"]) .theme .moon { display: none; }
}

.stage { position: relative; min-height: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--ocean); }
#map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
.sphere { fill: var(--ocean); }
.grat { fill: none; stroke: var(--grat); stroke-width: .6; vector-effect: non-scaling-stroke; }
.land { fill: var(--land); }
.border { fill: none; stroke: var(--border); stroke-width: .6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.coast { fill: none; stroke: var(--border); stroke-width: .9; vector-effect: non-scaling-stroke; }
.life { fill: none; stroke: var(--life); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: .7; }
.pin text { pointer-events: none; }
.pin .dot { stroke: var(--panel); stroke-width: 2.5; }
.pin.b .dot { fill: var(--born); } .pin.d .dot { fill: var(--died); }
/* Pins wait unseen through the flight, then land: the dot springs up, the label fades in, one ripple. */
.pin.live { opacity: 0; transition: opacity .3s ease-out; }
.pin.live.landed { opacity: 1; }
.pin.landed .dot { transform-box: fill-box; transform-origin: center; animation: pop .5s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes pop { from { transform: scale(0); } }
.pin .halo { fill: none; stroke-width: 2; transform-box: fill-box; transform-origin: center; opacity: 0; }
.pin.landed .halo { animation: halo 1.3s cubic-bezier(.2, .7, .3, 1) .05s 1; }
.pin.b .halo { stroke: var(--born); } .pin.d .halo { stroke: var(--died); }
@keyframes halo { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(4.5); opacity: 0; } }
.countries { transition: opacity .45s ease-out; }
.countries.hush { opacity: 0; transition-duration: .2s; }
.countries text {
  font-family: var(--body); font-weight: 500; text-transform: uppercase; letter-spacing: .12em; text-anchor: middle;
  dominant-baseline: central; fill: var(--muted); opacity: .75; pointer-events: none;
  paint-order: stroke; stroke: var(--land); stroke-width: 3px; stroke-linejoin: round;
}
.scalebar .bg { fill: var(--panel); stroke: var(--line); }
.scalebar path { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.scalebar text { font-family: var(--body); font-size: 10px; font-weight: 500; letter-spacing: .04em; fill: var(--ink); text-anchor: middle; font-variant-numeric: tabular-nums; }
.pin .tag { font-family: var(--serif); font-size: 15px; font-weight: 600; font-variant-numeric: lining-nums; dominant-baseline: central; }
.pin.b .tag { fill: var(--born); } .pin.d .tag { fill: var(--died); }
.pin .place { font-family: var(--serif); font-style: italic; font-size: 14px; font-weight: 500; fill: var(--ink); dominant-baseline: central; }

.zoomctl { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--panel); }
.zoomctl button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink); font: 500 18px var(--body); cursor: pointer; }
.zoomctl button + button { border-top: 1px solid var(--line); }
.zoomctl button:hover { background: var(--line); }

.card {
  position: absolute; left: 14px; bottom: 14px; width: 380px; max-width: calc(100% - 28px); max-height: calc(100% - 28px); overflow: auto;
  background: var(--panel); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 8px;
  padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px #0000001f;
}
.eyebrow { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.clue { border: 1.5px solid var(--line); border-radius: 6px; padding: 10px 12px 11px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.clue .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.clue.b .k { color: var(--born); } .clue.d .k { color: var(--died); }
.clue .yr { font-family: var(--serif); font-size: 30px; line-height: 1.1; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: lining-nums; }
.clue .pl { font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.extra { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.extra div b { font-weight: 600; }
.extra small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; margin-right: 6px; }

.span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: -4px; line-height: 1.45; }
.play { display: flex; flex-direction: column; gap: 10px; }
.suggest { font-size: 14px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; padding: 9px 11px; border-radius: 6px; background: var(--line); }
.suggest button { border: 0; background: none; padding: 0; color: var(--born); font: 600 14px var(--body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.suggest span { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.hints { display: flex; flex-wrap: wrap; gap: 6px; }
.hints button {
  border: 1px dashed var(--border); background: transparent; color: var(--ink); border-radius: 99px; padding: 5px 10px;
  font: 500 12px var(--body); cursor: pointer;
}
.hints button span { color: var(--muted); margin-left: 5px; font-variant-numeric: tabular-nums; }
.hints button:hover { border-style: solid; }
.hints button:disabled { opacity: .35; cursor: default; text-decoration: line-through; }

form.ask { display: flex; gap: 8px; }
form.ask input {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--field);
  color: var(--ink); font: 500 16px var(--body);
}
form.ask input:focus { outline: none; border-color: var(--ink); }
form.ask input.shake { animation: shake .35s; border-color: var(--died); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.go {
  border: 0; border-radius: 6px; padding: 11px 14px; background: var(--btn); color: var(--btn-fg);
  font: 600 14px var(--body); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.go kbd { font: 500 10.5px var(--body); letter-spacing: .06em; text-transform: uppercase; opacity: .55; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.link { border: 0; background: none; color: var(--muted); font: 500 13px var(--body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }
.misses { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.misses s { color: var(--died); }
.worth { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
button:focus-visible { outline: 2px solid var(--born); outline-offset: 2px; }

.reveal { display: flex; gap: 16px; align-items: flex-start; }
.reveal-text { min-width: 0; display: flex; flex-direction: column; }
.portrait {
  flex: none; width: 104px; aspect-ratio: 4 / 5; margin: 0; border-radius: 3px; overflow: hidden; background: var(--line);
  box-shadow: 0 0 0 1px var(--line), 0 0 0 5px var(--panel), 0 0 0 6px var(--border); margin: 6px;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; opacity: 0; }
.portrait img.in { opacity: 1; animation: develop .7s ease-out both; }
@keyframes develop { from { opacity: 0; filter: sepia(1) blur(3px); } to { opacity: 1; filter: none; } }
.wiki { margin-top: 6px; font-size: 13px; color: var(--muted); text-underline-offset: 3px; }
.wiki:hover { color: var(--ink); }
td .face { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: center 20%; vertical-align: middle; margin-right: 8px; background: var(--line); }
.answer h2 { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.02; letter-spacing: -.015em; margin: 4px 0 6px; text-wrap: balance; }
.answer .verdict { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; }
.answer .verdict.win { color: var(--good); } .answer .verdict.lose { color: var(--died); }
.answer .desc { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--muted); line-height: 1.3; }
.answer .row { margin-top: 12px; }
.answer .pts { font-family: var(--serif); font-size: 24px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.note { font-size: 12px; color: var(--muted); margin: 0; }

.final { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); padding: 16px; }
.sheet { width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 26px; display: flex; flex-direction: column; gap: 16px; }
.sheet h2 { font-family: var(--serif); font-weight: 500; font-size: 40px; line-height: 1.05; letter-spacing: -.015em; margin: 4px 0 0; }
.big { font-family: var(--serif); font-size: 60px; line-height: 1; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.big small { font-size: 20px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.rank { font-family: var(--serif); font-style: italic; font-size: 17px; color: var(--muted); margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 8px 4px; border-top: 1px solid var(--line); text-align: left; }
th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; border-top: 0; }
td.n, th.n { text-align: right; }
td.n { font-family: var(--serif); font-size: 16px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }

@media (max-width: 680px) {
  .stage { display: flex; flex-direction: column; border: 0; background: transparent; overflow: visible; }
  #map { flex: 1; min-height: 240px; border: 1px solid var(--line); border-radius: 6px; background: var(--ocean); }
  .card { position: static; width: 100%; max-width: none; max-height: none; margin-top: 10px; box-shadow: none; padding: 14px; gap: 12px; }
  .brand p { display: none; }
  /* Keep brand and tally on one line: the serif score is wider than the old mono one. */
  header { flex-wrap: nowrap; align-items: center; }
  .brand h1 { font-size: 26px; }
  .tally { gap: 12px; }
  .tally span { font-size: 9.5px; letter-spacing: .08em; }
  .tally b { font-size: 17px; }
  .theme { width: 36px; height: 36px; }
  .hints button { padding: 8px 12px; font-size: 13px; }
  .link { padding: 6px 0; }
  .zoomctl button { width: 40px; height: 40px; }
  body { padding-block: 10px max(12px, env(safe-area-inset-bottom)); }
}
.fresh { animation: fresh .4s cubic-bezier(.2, .7, .3, 1) both; }
.fresh + .fresh { animation-delay: .05s; }
@keyframes fresh { from { opacity: 0; transform: translateY(5px); } }
.final { animation: veil .3s ease-out both; }
.final .sheet { animation: rise .5s cubic-bezier(.2, .8, .2, 1) .05s both; }
@keyframes veil { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }

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

.best { font-size: 13px; color: var(--muted); margin-top: 2px; }
.table-wrap { overflow-x: auto; }
.ghost { border: 1.5px solid var(--line); background: transparent; color: var(--ink); border-radius: 6px; padding: 9px 14px; font: 600 13px var(--body); cursor: pointer; }
.ghost:hover { border-color: var(--ink); }
.share-msg { font-size: 13px; color: var(--muted); }
.share-text { width: 100%; font: 13px var(--mono); padding: 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--field); color: var(--ink); resize: none; }
