:root {
    --ground: #f2f5f9; --surface: #ffffff;
    --ink: #10213a; --ink-2: #4b5a70; --ink-3: #8593a8;
    --line: #d5dce6; --line-soft: #e6ebf2;
    --bar: #1f5fbf; --bar-soft: #9fbde8;
    --band: rgba(250, 204, 60, 0.42);
    --over: #1f5fbf; --under: #c9702f; --neutral: #e3e8ef;
    --focus: #1f5fbf;
    --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
    --body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --ground: #0e1520; --surface: #151e2b;
      --ink: #e9eef6; --ink-2: #a9b5c6; --ink-3: #6f7d91;
      --line: #2b3746; --line-soft: #1f2937;
      --bar: #6ea2f0; --bar-soft: #34527f;
      --band: rgba(242, 201, 76, 0.30);
      --over: #6ea2f0; --under: #d98a52; --neutral: #263242;
      --focus: #8fb6f5;
    }
  }
  :root[data-theme="dark"] {
    --ground: #0e1520; --surface: #151e2b;
    --ink: #e9eef6; --ink-2: #a9b5c6; --ink-3: #6f7d91;
    --line: #2b3746; --line-soft: #1f2937;
    --bar: #6ea2f0; --bar-soft: #34527f;
    --band: rgba(242, 201, 76, 0.30);
    --over: #6ea2f0; --under: #d98a52; --neutral: #263242;
    --focus: #8fb6f5;
  }

  * { box-sizing: border-box; }
  body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
  a { color: inherit; }
  button { font: inherit; color: inherit; }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  .wrap { max-width: 1060px; margin: 0 auto; padding-inline: clamp(16px, 4vw, 40px); padding-block: 28px 64px; }
  h2 { margin: 0 0 6px; font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: -0.01em; }
  .muted { color: var(--ink-2); }
  .small { font-size: 13.5px; }
  .tnum { font-variant-numeric: tabular-nums; }

  /* top */
  .top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
  .top .brand { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); }
  .top .eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }

  /* hero */
  .ask { margin-top: clamp(36px, 8vh, 84px); font-family: var(--display); font-weight: 500; font-size: clamp(34px, 7vw, 76px); line-height: 1.05; letter-spacing: -0.02em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.28em; }
  .ask h1 { margin: 0; font: inherit; display: contents; }
  .namebox { position: relative; display: inline-block; max-width: 100%; white-space: nowrap; }
  .namebox .q { margin-left: 0.08em; }
  .namebox input { font: inherit; letter-spacing: inherit; color: var(--bar); background: transparent; border: 0; border-bottom: 3px solid var(--bar); padding: 0 0.06em; margin: 0; min-width: 3ch; max-width: 100%; width: 8ch; outline: none; border-radius: 0; caret-color: var(--bar); }
  .namebox input::placeholder { color: var(--bar-soft); opacity: 1; }
  .namebox input:hover { border-bottom-color: var(--ink); cursor: text; }
  .namebox input:focus-visible { border-bottom-color: var(--ink); }
  .chip.search { border-color: var(--ink); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
  .chip.search svg { width: 14px; height: 14px; display: inline; }
  .mirror { position: absolute; visibility: hidden; white-space: pre; font: inherit; letter-spacing: inherit; padding: 0 0.06em; }
  .suggest { position: absolute; top: calc(100% + 10px); left: 0; z-index: 20; min-width: 300px; max-height: 340px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 18px 40px -20px rgba(16,33,58,0.45); font-family: var(--body); font-size: 16px; letter-spacing: 0; line-height: 1.3; padding: 6px; display: none; }
  .suggest.open { display: block; }
  .suggest ul { margin: 0; padding: 0; }
  .suggest li { list-style: none; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
  .suggest li[aria-selected="true"], .suggest li:hover { background: var(--line-soft); }
  .suggest .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
  .suggest .empty { padding: 10px; color: var(--ink-2); font-size: 14px; }
  .helpers { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 14px; color: var(--ink-2); align-items: center; }
  .chip { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--ink); }
  .chip:hover { border-color: var(--ink-3); }

  /* answer */
  .answer { margin-top: clamp(32px, 6vh, 64px); display: grid; grid-template-columns: auto 1fr; gap: 0 clamp(24px, 5vw, 64px); align-items: end; }
  .big { font-family: var(--display); font-weight: 800; font-size: clamp(120px, 24vw, 240px); line-height: 0.82; letter-spacing: -0.045em; display: flex; align-items: baseline; gap: 0.08em; }
  .big small { font-size: 0.22em; font-weight: 500; letter-spacing: -0.01em; color: var(--ink-2); }
  .readout { max-width: 36rem; padding-bottom: 6px; }
  .readout p { margin: 0; }
  .readout .lead { font-family: var(--display); font-size: clamp(20px, 2.6vw, 27px); font-weight: 500; line-height: 1.25; letter-spacing: -0.01em; }
  .readout .lead b { font-weight: 700; background: var(--band); padding: 0 0.15em; border-radius: 3px; }
  .readout .sub { margin-top: 10px; color: var(--ink-2); font-size: 15px; }
  @media (max-width: 640px) { .answer { grid-template-columns: 1fr; gap: 12px; } }

  /* facts */
  .facts { margin-top: 28px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 20px; border-top: 1px solid var(--line); }
  .fact { padding: 16px 0 8px; border-bottom: 1px solid var(--line-soft); }
  .fact .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
  .fact .v { font-family: var(--display); font-weight: 600; font-size: 28px; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
  .fact .v small { font-size: 0.5em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: 2px; }
  .fact .n { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
  .spell { margin-top: 16px; font-size: 14px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
  .spell button { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 13.5px; color: var(--ink); }
  .spell button b { font-weight: 600; }
  .spell button.cur { border-color: var(--ink); }

  /* cards + charts */
  .card { margin-top: clamp(28px, 5vh, 48px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 20px 14px; position: relative; }
  .card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
  .card-head h2 { font-size: 18px; }
  .legend { font-size: 13px; color: var(--ink-2); display: flex; gap: 14px; flex-wrap: wrap; }
  .legend i { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; margin-right: 6px; border-radius: 2px; }
  .legend .l-bar i { background: var(--bar); }
  .legend .l-band i { background: var(--band); }
  .legend .l-med i { width: 0; height: 12px; border-left: 2px dashed var(--ink); border-radius: 0; margin-right: 8px; }
  svg { display: block; width: 100%; height: auto; overflow: visible; }
  .grid line { stroke: var(--line-soft); stroke-width: 1; }
  .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--body); font-variant-numeric: tabular-nums; }
  .axis .age { fill: var(--ink-2); font-weight: 500; }
  .axis .base { stroke: var(--line); stroke-width: 1; }
  .bars rect { fill: var(--bar); }
  .bars rect.hot { fill: var(--ink); }
  .bars rect.est { fill: var(--bar-soft); }
  .band rect { fill: var(--band); }
  .med line { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 4; }
  .med text { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--body); }
  .hit rect { fill: transparent; }
  .tip { position: absolute; pointer-events: none; display: none; background: var(--ink); color: var(--ground); font-size: 13px; line-height: 1.35; padding: 8px 10px; border-radius: 8px; white-space: nowrap; z-index: 5; font-variant-numeric: tabular-nums; }
  .tip b { font-weight: 600; }
  .tip.show { display: block; }
  .card-foot { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-3); }

  /* geography */
  .geo { display: grid; grid-template-columns: minmax(200px, 250px) 1fr; gap: 24px clamp(20px, 4vw, 48px); align-items: start; }
  .mapcol { position: relative; }
  @media (max-width: 720px) { .geo { grid-template-columns: 1fr; } }
  .map path { stroke: var(--surface); stroke-width: 0.6; fill: var(--neutral); transition: fill 0.25s; }
  .map path:hover { stroke: var(--ink); stroke-width: 1.2; }
  .map-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
  .map-legend .grad { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--under), var(--neutral), var(--over)); max-width: 160px; }
  .qbars { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; height: 170px; margin-top: 10px; }
  .qbars .zero { position: absolute; left: 0; right: 0; border-top: 1px solid var(--ink-3); pointer-events: none; }
  .qbar { position: relative; height: 100%; }
  .qbar .col { position: absolute; left: 6px; right: 6px; background: var(--over); border-radius: 3px; min-height: 2px; }
  .qbar .col.neg { background: var(--under); }
  .qbar .val { position: absolute; left: -6px; right: -6px; font-size: 13px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; }
  .qlegend { font-size: 12px; color: var(--ink-2); margin-top: 8px; }
  .qlabels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; font-size: 11.5px; color: var(--ink-2); text-align: center; margin-top: 6px; line-height: 1.25; }
  .idx { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
  .idx .num { font-family: var(--display); font-weight: 700; font-size: 44px; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
  .idx .num small { font-size: 15px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: 4px; }
  .kom-list { margin: 4px 0 0; padding: 0; font-size: 14px; }
  .kom-list li { list-style: none; display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
  .kom-list .x { font-weight: 600; font-variant-numeric: tabular-nums; }
  .kom-list .x.over { color: var(--over); }
  .kom-list .x.under { color: var(--under); }
  .subhead { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 18px 0 4px; }
  .twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
  .pair { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto 170px auto auto; grid-auto-flow: column; column-gap: 28px; row-gap: 4px; align-items: end; }
  .pair .subhead, .pair .idx { align-self: start; }
  .pair .qbars { margin-top: 6px; }
  @media (max-width: 520px) { .twocol { grid-template-columns: 1fr; } .pair { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; } }
  .scatter { margin-top: 18px; }
  .scatter svg { overflow: visible; }
  .scatter { max-width: 900px; }
  .scatter .dot { fill: var(--ink-3); opacity: 0.35; }
  .scatter .dot:hover { opacity: 1; fill: var(--ink); }
  .scatter circle.me { fill: var(--bar); stroke: var(--surface); stroke-width: 2; }
  .scatter .lbl { font-size: 12px; fill: var(--ink-2); font-family: var(--body); }
  .scatter .lbl.me { fill: var(--ink); font-weight: 600; font-size: 13px; }
  .scatter .ax { stroke: var(--line); stroke-width: 1; }
  .scatter .axl { font-size: 11px; fill: var(--ink-3); font-family: var(--body); }
  .scatter .mid { stroke: var(--line-soft); stroke-width: 1; stroke-dasharray: 3 3; }
  .note { font-size: 13px; color: var(--ink-2); margin-top: 14px; max-width: 60ch; }

  /* peers + explore */
  .section { margin-top: 44px; }
  .section p.intro { margin: 0 0 14px; color: var(--ink-2); font-size: 15px; max-width: 52rem; }
  .peer-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
  .peer-list li { list-style: none; }
  .peer-list button { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px 7px 12px; cursor: pointer; display: inline-flex; align-items: baseline; gap: 8px; }
  .peer-list button:hover { border-color: var(--ink-3); }
  .peer-list .nm { font-family: var(--display); font-weight: 600; }
  .peer-list .ag { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
  .explore { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 28px; }
  .explore h3 { margin: 0 0 4px; font-family: var(--display); font-weight: 600; font-size: 16px; }
  .explore p { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }
  .explore ol { margin: 0; padding: 0; counter-reset: n; }
  .explore li { list-style: none; display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
  .explore li button { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-align: left; }
  .explore li button:hover { text-decoration: underline; }
  .explore li .m { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

  /* share, about */
  .share { margin-top: 44px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
  .share button.primary { background: var(--ink); color: var(--ground); border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 600; cursor: pointer; font-size: 15px; }
  .share .toast { font-size: 14px; color: var(--ink-2); min-height: 1.4em; }
  .share a.chip { text-decoration: none; padding: 11px 16px; }
  .about { margin-top: 56px; max-width: 48rem; color: var(--ink-2); font-size: 14.5px; }
  .about p { margin: 0 0 10px; }
  .about ul { margin: 0 0 10px; padding-left: 18px; }
  .about li { margin-bottom: 4px; }
  [hidden] { display: none !important; }

  /* year view */
  .yearv { margin-top: clamp(28px, 6vh, 64px); }
  .yearv .ask-y { font-family: var(--display); font-weight: 500; font-size: clamp(34px, 7vw, 76px); line-height: 1.05; letter-spacing: -0.02em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.28em; }
  .yearv .ask-y input { font: inherit; letter-spacing: inherit; color: var(--bar); background: transparent; border: 0; border-bottom: 3px solid var(--bar); width: 2.75em; min-width: 4.4ch; padding: 0 0.06em; outline: none; font-variant-numeric: tabular-nums; -moz-appearance: textfield; text-align: center; }
  .yearv .ask-y input::-webkit-outer-spin-button, .yearv .ask-y input::-webkit-inner-spin-button { -webkit-appearance: none; }
  .yearv .ask-y input:focus { border-bottom-color: var(--ink); }
  .yearv input[type=range] { max-width: 640px; margin: 14px 0 4px; }
  .yearv .lead { font-family: var(--display); font-size: clamp(22px, 3vw, 32px); font-weight: 500; letter-spacing: -0.01em; margin: 26px 0 6px; max-width: 40rem; line-height: 1.2; }
  .yearv .lead b { font-weight: 700; background: var(--band); padding: 0 0.15em; border-radius: 3px; }
  .yearv .sub { color: var(--ink-2); margin: 0 0 8px; max-width: 48rem; }
  .ycols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 28px; margin-top: 20px; }
  .ycol h3 { margin: 0 0 4px; font-family: var(--display); font-weight: 600; font-size: 16px; }
  .ycol p { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }
  .ycol ol { margin: 0; padding: 0; }
  .ycol li { list-style: none; display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
  .ycol li button { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-align: left; font-family: var(--display); font-size: 16px; }
  .ycol li button:hover { text-decoration: underline; }
  .ycol li .m { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }

  /* game */
  .game { margin-top: clamp(28px, 6vh, 64px); max-width: 640px; }
  .game .eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: var(--ink-3); }
  .game h1 { margin: 6px 0 8px; font-family: var(--display); font-weight: 700; font-size: clamp(34px, 6vw, 56px); letter-spacing: -0.02em; line-height: 1.05; }
  .game p.intro { margin: 0 0 24px; color: var(--ink-2); max-width: 44rem; }
  .round { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px 24px 20px; }
  .round .meta { font-size: 13px; color: var(--ink-3); display: flex; justify-content: space-between; }
  .round .meta .dots { letter-spacing: 2px; }
  .round .rname { font-family: var(--display); font-weight: 700; font-size: clamp(40px, 8vw, 72px); letter-spacing: -0.03em; line-height: 1; margin: 10px 0 4px; color: var(--bar); }
  .round .rq { color: var(--ink-2); margin: 0 0 18px; }
  .guess { display: flex; align-items: baseline; gap: 8px; font-family: var(--display); font-weight: 800; font-size: 96px; letter-spacing: -0.04em; line-height: 0.9; font-variant-numeric: tabular-nums; }
  .guess small { font-size: 22px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
  .guess input { font: inherit; width: 2.4ch; border: 0; border-bottom: 3px solid var(--line); background: transparent; color: var(--ink); padding: 0; text-align: left; outline: none; -moz-appearance: textfield; }
  .guess input::-webkit-outer-spin-button, .guess input::-webkit-inner-spin-button { -webkit-appearance: none; }
  .guess input:focus { border-bottom-color: var(--bar); }
  input[type=range] { width: 100%; margin: 18px 0 8px; accent-color: var(--bar); height: 32px; }
  .range-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-bottom: 16px; }
  .round .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .btn { background: var(--ink); color: var(--ground); border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 600; cursor: pointer; font-size: 15px; }
  .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
  .reveal { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
  .reveal .verdict { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: -0.01em; }
  .reveal .verdict .pts { color: var(--bar); }
  .reveal p { margin: 6px 0 12px; color: var(--ink-2); }
  .result { text-align: left; }
  .result .score { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 12vw, 120px); letter-spacing: -0.04em; line-height: 0.9; font-variant-numeric: tabular-nums; }
  .result .score small { font-size: 0.3em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
  .result .rank { font-family: var(--display); font-weight: 600; font-size: 24px; margin: 10px 0 4px; }
  .result .grid { font-size: 28px; letter-spacing: 2px; margin: 8px 0 16px; }
  .result ul { margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
  .result li { list-style: none; }
  .result li button { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
  .result li button b { font-family: var(--display); }
  .result li button span { color: var(--ink-2); font-size: 13px; margin-left: 6px; font-variant-numeric: tabular-nums; }

  @media (prefers-reduced-motion: no-preference) {
    .answer, .card, .facts, .section { animation: rise 0.5s ease-out both; }
    .card { animation-delay: 0.06s; } .facts { animation-delay: 0.12s; } .section { animation-delay: 0.18s; }
    @keyframes rise { from { opacity: 0.001; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  }
