:root {
  color-scheme: dark;
  --bg: #07090e;
  --panel: rgba(17, 21, 31, .86);
  --panel-strong: #111620;
  --line: rgba(255, 255, 255, .1);
  --text: #f5f7fb;
  --muted: #929aa9;
  --orange: #ff6510;
  --red: #ee2947;
  --green: #1f9b68;
  --blue: #238bc3;
  --gold: #f2b94b;
  --shadow: 0 24px 80px rgba(0, 0, 0, .46);
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--text); background: radial-gradient(circle at 50% 10%, #191d2b 0, #0a0c13 36%, var(--bg) 75%); }
button, select, input { font: inherit; }
button, a, select, input { outline-offset: 3px; }
button { color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { width: min(1500px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 24px 24px; }
.topbar { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); background: rgba(7, 9, 14, .82); backdrop-filter: blur(20px); }
.raw-link { display: inline-flex; gap: 8px; align-items: center; width: max-content; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.raw-link span { display: grid; place-items: center; width: 29px; height: 29px; color: #080a0e; background: var(--text); border-radius: 8px; }
.brand { display: flex; gap: 10px; align-items: center; font-family: "Barlow Condensed", sans-serif; }
.brand > div { display: grid; }
.brand strong { font-size: 25px; letter-spacing: .08em; line-height: .85; }
.brand small { margin-top: 5px; color: var(--muted); font-family: Inter, sans-serif; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.brand-orbit { position: relative; width: 34px; height: 34px; border: 2px solid var(--orange); border-radius: 50%; box-shadow: 0 0 28px rgba(255, 101, 16, .35); }
.brand-orbit::before, .brand-orbit::after { position: absolute; content: ""; border: 1px solid var(--orange); border-radius: 50%; }
.brand-orbit::before { inset: 5px -2px; }
.brand-orbit::after { inset: -2px 7px; }
.top-actions { display: flex; gap: 8px; justify-content: flex-end; }
.ghost-button, .icon-button { min-height: 37px; color: #dce1e9; border: 1px solid var(--line); background: rgba(255, 255, 255, .045); border-radius: 9px; }
.ghost-button { padding: 0 13px; font-size: 12px; font-weight: 700; }
.ghost-button:hover, .ghost-button[aria-pressed="true"] { border-color: rgba(255, 101, 16, .55); background: rgba(255, 101, 16, .13); }
.icon-button { display: grid; place-items: center; width: 37px; padding: 0; font-weight: 800; }

main { padding-top: 22px; }
.control-strip { display: grid; grid-template-columns: minmax(230px, 310px) 48px minmax(300px, 1fr) minmax(150px, 200px); gap: 12px; align-items: end; padding: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 13px; box-shadow: 0 10px 38px rgba(0,0,0,.22); }
.field { display: grid; gap: 6px; }
.field > span, .timeline-heading span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
select, input[type="search"] { width: 100%; min-height: 40px; padding: 0 11px; color: var(--text); border: 1px solid var(--line); background: #0b0f17; border-radius: 8px; }
.play-button { display: grid; place-items: center; width: 48px; height: 40px; color: #0b0c10; border: 0; background: linear-gradient(135deg, var(--orange), #ff983e); border-radius: 9px; box-shadow: 0 7px 22px rgba(255, 101, 16, .25); }
.play-button.is-playing { background: linear-gradient(135deg, var(--red), #ff687b); }
.timeline-control { min-width: 0; }
.timeline-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.timeline-heading output { font-family: "Barlow Condensed", sans-serif; font-size: 25px; font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--orange); cursor: ew-resize; }
.timeline-ticks { display: flex; justify-content: space-between; color: #70798a; font-size: 9px; }

.headline { margin: 34px auto 10px; text-align: center; }
.headline span { color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .24em; }
.headline h1 { margin: 3px 0 0; font-family: "Barlow Condensed", sans-serif; font-size: clamp(38px, 5.4vw, 78px); line-height: .96; letter-spacing: .015em; text-transform: uppercase; }
.headline p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.visual-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.visual-stage.is-comparing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.world-panel { min-width: 0; text-align: center; }
.world-panel > header { display: flex; justify-content: center; gap: 10px; align-items: baseline; margin-bottom: -4px; }
.world-panel > header span { font-family: "Barlow Condensed", sans-serif; font-size: 30px; font-weight: 800; }
.world-panel > header strong { color: var(--muted); font-size: 11px; font-weight: 600; }
.circle-wrap { position: relative; width: min(720px, 80vw); margin: 0 auto; aspect-ratio: 1; filter: drop-shadow(0 22px 35px rgba(0, 0, 0, .44)); }
.is-comparing .circle-wrap { width: min(620px, 45vw); }
.world-chart { display: block; width: 100%; height: 100%; overflow: visible; }
.slice { stroke: rgba(6, 8, 13, .44); stroke-width: 1.3; transition: d 500ms cubic-bezier(.2,.8,.2,1), opacity 180ms ease, filter 180ms ease; cursor: pointer; }
.slice:hover, .slice:focus { opacity: 1 !important; filter: brightness(1.22); }
.slice-label { fill: white; font-family: Inter, sans-serif; font-size: 12px; font-weight: 700; pointer-events: none; paint-order: stroke; stroke: rgba(4,6,10,.58); stroke-width: 3px; stroke-linejoin: round; }
.slice-value { fill: rgba(255,255,255,.78); font-size: 10px; font-weight: 500; }
.slice-flag { font-family: "Segoe UI Emoji", sans-serif; font-size: 18px; stroke: none; }
.chart-center { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 90px; height: 90px; padding: 10px; pointer-events: none; background: rgba(7,9,14,.92); border: 1px solid rgba(255,255,255,.13); border-radius: 50%; box-shadow: 0 8px 25px rgba(0,0,0,.4); transform: translate(-50%, -50%); }
.chart-center small { color: var(--orange); font: 800 10px Inter, sans-serif; letter-spacing: .16em; }
.chart-center strong { max-width: 72px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.ranking-section { margin-top: 28px; border-top: 1px solid var(--line); }
.ranking-head { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 18px 0 13px; }
.ranking-head > div:first-child { display: grid; gap: 4px; }
.ranking-head span { color: var(--orange); font-size: 9px; font-weight: 800; letter-spacing: .17em; }
.ranking-head strong { font-size: 13px; }
.ranking-actions { display: flex; gap: 8px; }
.ranking-actions input { width: 190px; }
.ranking-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.rank-row { display: grid; grid-template-columns: 30px 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 44px; padding: 5px 8px; border-bottom: 1px solid rgba(255,255,255,.065); }
.rank-row > b { color: var(--muted); font: 700 12px "Barlow Condensed", sans-serif; text-align: center; }
.rank-row .flag { font: 22px "Segoe UI Emoji", sans-serif; text-align: center; }
.rank-country { display: grid; gap: 3px; min-width: 0; }
.rank-country strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.rank-country i { display: block; height: 3px; overflow: hidden; background: rgba(255,255,255,.08); border-radius: 99px; }
.rank-country i span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--orange)); }
.rank-value { text-align: right; }
.rank-value strong { display: block; font-size: 12px; }
.rank-value small { color: var(--muted); font-size: 9px; }

footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 28px; padding-top: 16px; color: #747d8c; border-top: 1px solid var(--line); font-size: 10px; }
.tooltip { position: fixed; z-index: 80; max-width: 260px; padding: 10px 12px; color: var(--text); pointer-events: none; border: 1px solid rgba(255,255,255,.16); background: #111620; border-radius: 9px; box-shadow: var(--shadow); font-size: 11px; }
.tooltip strong { display: block; margin-bottom: 3px; font-size: 12px; }
.tooltip span { color: var(--muted); }

dialog { width: min(650px, calc(100vw - 28px)); padding: 0; color: var(--text); border: 1px solid var(--line); background: #10141d; border-radius: 16px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2,4,8,.74); backdrop-filter: blur(5px); }
dialog form > header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
dialog h2 { margin: 2px 0 0; font: 700 24px "Barlow Condensed", sans-serif; }
dialog header span { color: var(--orange); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.dialog-body { padding: 18px; color: #cad0da; font-size: 12px; line-height: 1.6; }
.sources-list { display: grid; gap: 8px; margin: 16px 0; }
.source-item { display: grid; gap: 3px; padding: 10px; border-left: 3px solid var(--orange); background: rgba(255,255,255,.035); }
.source-item small, .data-note { color: var(--muted); }

@media (max-width: 900px) {
  .control-strip { grid-template-columns: minmax(190px, 1fr) 44px minmax(260px, 2fr); }
  .compare-year-field { grid-column: 1 / -1; }
  .visual-stage.is-comparing { grid-template-columns: 1fr; }
  .is-comparing .circle-wrap { width: min(700px, 86vw); }
}

@media (max-width: 640px) {
  .app-shell { padding-inline: 12px; }
  .topbar { grid-template-columns: auto 1fr auto; min-height: 62px; }
  .brand { justify-self: center; }
  .brand small, .top-actions .ghost-button, .raw-link { font-size: 0; }
  .raw-link span { font-size: 12px; }
  .control-strip { grid-template-columns: 1fr 44px; }
  .metric-field { grid-column: 1 / -1; }
  .timeline-control { grid-column: 1 / -1; grid-row: 2; padding-right: 54px; }
  .play-button { grid-column: 2; grid-row: 2; justify-self: end; }
  .headline { margin-top: 24px; }
  .circle-wrap, .is-comparing .circle-wrap { width: 96vw; max-width: 580px; margin-left: 50%; transform: translateX(-50%); }
  .slice-label { font-size: 11px; }
  .ranking-grid { grid-template-columns: 1fr; }
  .ranking-head { align-items: flex-start; flex-direction: column; }
  .ranking-actions { width: 100%; }
  .ranking-actions label { flex: 1; }
  .ranking-actions input { width: 100%; }
}

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