:root {
  --bg: #faf3ea;              /* page cream */
  --card: #fffdf9;            /* raised cards */
  --surface: #f6efdd;         /* chart paper */
  --surface-raised: #fffdf7;
  --paper-major: #d9cdb2;
  --paper-minor: #e9e0c9;
  --line: #ece1cd;            /* card borders on cream */
  --ink-hero: #1d1812;
  --ink: #3f3628;
  --ink-2: #6f6450;
  --ink-3: #a4936f;
  --accent: #ea6543;
  --accent-deep: #d94f2b;
  --good: #1d9e5f;
  --shadow-sm: 0 1px 3px rgba(63, 54, 40, .08), 0 4px 14px rgba(63, 54, 40, .07);
  --shadow-lg: 0 2px 6px rgba(63, 54, 40, .07), 0 14px 44px rgba(63, 54, 40, .13);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --page-pad: clamp(16px, 4.5vw, 72px);
  --content-max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.kicker {
  font: 700 12px var(--mono);
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--accent);
}
.linklike { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font: inherit; }
.linklike.accent { color: var(--accent); font-weight: 700; text-decoration: none; }
.linklike.accent:hover { text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.dot-accent { background: var(--accent); }

/* ---------- top nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--page-pad);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: -.4px; color: var(--ink-hero); text-decoration: none; }
.brand-mark { width: 20px; height: 20px; fill: var(--ink-hero); }
.navlinks { display: flex; gap: 30px; }
.navlinks a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14.5px; }
.navlinks a:hover { color: var(--accent); }
.btn-pill {
  background: var(--card); color: var(--ink-hero); border: 1px solid var(--line);
  border-radius: 999px; font: 600 14px var(--font); padding: 10px 20px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .12s ease, box-shadow .12s ease;
}
.btn-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.btn-accent {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff; border: 0; border-radius: 14px;
  font: 700 15px var(--font); padding: 14px 24px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(217, 79, 43, .35), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s ease, filter .12s ease;
}
.btn-accent:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-accent:disabled { opacity: .55; cursor: default; transform: none; }
.btn-accent .arr { display: inline-block; transition: transform .15s ease; }
.btn-accent:hover .arr { transform: translateX(3px); }

/* ---------- hero ---------- */
.hero {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: clamp(30px, 6vh, 64px) var(--page-pad) 8px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-sm);
  padding: 8px 16px; font-size: 13px; color: var(--ink-2);
}
.live-pill b { color: var(--ink-hero); font-variant-numeric: tabular-nums; }
.hero h1 {
  margin: 2px 0 0;
  font-size: clamp(44px, 8.4vw, 88px);
  font-weight: 900; letter-spacing: -.035em; line-height: 1.02;
  color: var(--ink-hero);
}
.h1-price {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: .075em;
  text-underline-offset: .1em;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  font-variant-numeric: tabular-nums;
}
.hero-sub {
  margin: 4px 0 10px; max-width: 640px;
  font-size: clamp(15px, 2vw, 19px); line-height: 1.55; color: var(--ink-2);
}

/* the checkout widget — the hero of the hero */
.widget {
  display: flex; align-items: stretch; gap: 10px;
  width: min(880px, 100%);
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
}
.w-url {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 0 14px;
}
.w-url:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.w-arrow { color: var(--accent); font-weight: 800; }
.w-url input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font: 15px var(--font); color: var(--ink-hero); padding: 15px 0;
}
.w-url input::placeholder { color: var(--ink-3); }
.w-stepper {
  display: flex; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 13px;
}
.w-stepper > button {
  width: 44px; align-self: stretch; border: 0; background: none; cursor: pointer;
  font: 400 20px var(--font); color: var(--ink-2); border-radius: 12px;
}
.w-stepper > button:hover { color: var(--accent); background: var(--bg); }
.w-target { display: flex; flex-direction: column; align-items: center; padding: 6px 6px; min-width: 86px; }
.w-target-cap { font: 700 9.5px var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.w-amount-wrap { display: flex; align-items: baseline; font: 800 18px var(--font); color: var(--accent); }
.w-amount-wrap input {
  width: 5.2ch; border: 0; outline: 0; background: none; padding: 0;
  font: 800 18px var(--font); color: var(--ink-hero); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield; text-align: left;
}
.w-amount-wrap input::-webkit-outer-spin-button, .w-amount-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.w-help {
  width: min(880px, 100%);
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 0 8px; font-size: 12.5px; color: var(--ink-3);
}
.w-note { text-align: left; }
.w-note.err { color: #b02a1e; font-weight: 600; }
.widget.flash { animation: flash .9s ease; }
@keyframes flash { 0%, 100% { box-shadow: var(--shadow-lg); } 35% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow-lg); } }

/* latest claims strip */
.latest-card {
  width: min(980px, 100%);
  margin-top: 20px;
  display: flex; align-items: center; gap: 22px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 12px 18px;
  overflow-x: auto;
}
.latest-label { display: inline-flex; align-items: center; gap: 7px; font: 700 12px var(--font); color: var(--ink-2); white-space: nowrap; }
#latest-list { display: flex; gap: 26px; margin: 0; padding: 0; list-style: none; }
#latest-list li { display: flex; align-items: center; gap: 10px; cursor: pointer; white-space: nowrap; }
.lt-fav {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; object-fit: contain; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 14px var(--font); color: var(--ink-2);
}
.lt-name { font-weight: 700; font-size: 13px; color: var(--ink-hero); display: block; }
.lt-sub { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- graph section ---------- */
.graph-sec { max-width: var(--content-max); margin: 0 auto; padding: clamp(40px, 8vh, 84px) var(--page-pad) 10px; }
.graph-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 8px 0 14px; }
.graph-head h2 { margin: 0; font-size: clamp(26px, 4.4vw, 42px); font-weight: 900; letter-spacing: -.03em; color: var(--ink-hero); }
.hint-pill {
  flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-sm); padding: 7px 14px; font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.graph-tools { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; font-size: 12px; color: var(--ink-2); }
.jumps { display: inline-flex; align-items: center; gap: 6px; }
.chip {
  background: var(--card); color: var(--ink-2); border: 1px solid var(--line);
  border-radius: 999px; font: 600 11px var(--font); padding: 4px 11px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.grid-chip { font-variant-numeric: tabular-nums; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; background: var(--card); }

#stage {
  position: relative; overflow: hidden;
  height: clamp(420px, 74vh, 820px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
#chart { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; display: block; }

/* ---------- chart internals ---------- */
.grid line.major { stroke: var(--paper-major); stroke-width: 1; }
.grid line.minor { stroke: var(--paper-minor); stroke-width: 1; }
.baseline { stroke: var(--ink); stroke-width: 1.5; }

.yaxis text { fill: var(--ink-2); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.yaxis .domain { display: none; }

.bar { cursor: pointer; }
.bar .bar-body { transform-box: fill-box; transform-origin: bottom center; transition: transform .12s ease-out; }
.bar:hover .bar-body { transform: scale(1.015, 1.03); }
.bar.covered .bar-body { fill-opacity: .55; }
.bar.claim .bar-body { fill: rgba(63, 54, 40, 0); stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.bar.claim:hover .bar-body { fill: rgba(63, 54, 40, .07); stroke: var(--ink-2); }
.bar.next .bar-body {
  fill: rgba(234, 101, 67, .06); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4;
  animation: pulse 2s ease-in-out infinite;
}
.bar.next:hover .bar-body { fill: rgba(234, 101, 67, .13); animation-play-state: paused; stroke-opacity: 1; }
@keyframes pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: .35; } }
.bar.claim.sweep .bar-body, .bar.next.sweep .bar-body {
  fill: rgba(234, 101, 67, .13); stroke: var(--accent); stroke-opacity: 1;
}
.bar text { pointer-events: none; }
.plate { fill: var(--surface-raised); stroke: var(--paper-major); stroke-width: 1; }
.cluster { cursor: zoom-in; }
.cluster rect { fill: var(--surface-raised); stroke: var(--paper-major); stroke-width: 1; pointer-events: all; }
.cluster text { fill: var(--ink-2); font: 700 9px var(--font); text-anchor: middle; font-variant-numeric: tabular-nums; }
.cluster:hover rect { stroke: var(--accent); }
.cluster:hover text { fill: var(--accent); }
.favicon { clip-path: inset(0 round 22%); }
.plate-letter { fill: var(--ink-2); font: 700 12px var(--font); text-anchor: middle; }
.clicks-pill { fill: #fff; font: 600 10px var(--font); text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.35); stroke-width: 2px; }
.claim-price { fill: var(--ink-2); font: 700 12px var(--font); text-anchor: middle; font-variant-numeric: tabular-nums; }
.claim-sub { fill: var(--ink-3); font: 9px var(--font); text-anchor: middle; }
.bar.next .claim-price, .bar.next .claim-sub { fill: var(--accent); }

.xlabels .name { fill: var(--ink); font: 600 11px var(--font); text-anchor: middle; }
.xlabels .date { fill: var(--ink-3); font: 9px var(--font); text-anchor: middle; }
.xlabels .price { fill: var(--ink-2); font: 600 10px var(--font); text-anchor: middle; font-variant-numeric: tabular-nums; }

.crosshair { pointer-events: none; }
.crosshair line { stroke: var(--ink-2); stroke-opacity: .55; stroke-dasharray: 5 3; }
.crosshair .chip-bg { fill: var(--surface-raised); stroke: var(--paper-major); rx: 6; }
.crosshair .chip-text { fill: var(--ink); font: 11px var(--font); font-variant-numeric: tabular-nums; }

#tooltip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 280px;
  background: var(--surface-raised); border: 1px solid var(--paper-major); border-radius: 10px;
  box-shadow: var(--shadow-sm); padding: 9px 11px; font-size: 12px; color: var(--ink-2); line-height: 1.45;
}
#tooltip .tt-head { display: flex; align-items: center; gap: 8px; }
#tooltip .tt-fav {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--paper-minor);
  background: #fff; flex: none; object-fit: contain;
}
#tooltip .tt-fav-letter { display: inline-flex; align-items: center; justify-content: center; font: 700 12px var(--font); color: var(--ink-2); }
#tooltip .tt-headtext { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
#tooltip .tt-value { font-size: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
#tooltip .tt-name { font-weight: 700; color: var(--ink); }
#tooltip .tt-title { margin-top: 5px; font-weight: 600; color: var(--ink); }
#tooltip .tt-desc { margin-top: 3px; }
#tooltip .tt-meta { margin-top: 5px; color: var(--ink-3); }

/* zoom cluster — top-right inside the chart card */
.zoomctl {
  position: absolute; top: 14px; right: 14px; z-index: 4;
  display: flex; flex-direction: column; align-items: stretch;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.zoom-row { display: flex; }
.zoom-row button {
  width: 38px; height: 34px; border: 0; background: none; cursor: pointer;
  font: 500 17px var(--font); color: var(--ink);
}
.zoom-row button:first-child { border-right: 1px solid var(--line); }
.zoom-row button:hover, .zoom-word:hover { background: var(--bg); color: var(--accent); }
.zoom-word {
  border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer;
  padding: 7px 0; font: 700 9.5px var(--mono); letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-2);
}
.zoom-word.hot { color: var(--accent); }

/* ---------- how it works ---------- */
.how { max-width: var(--content-max); margin: 0 auto; padding: clamp(44px, 9vh, 90px) var(--page-pad) 0; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.how-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-sm); padding: 20px;
}
.how-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
  font: 800 13px var(--font);
}
.how-card h3 { margin: 10px 0 6px; font-size: 16.5px; color: var(--ink-hero); letter-spacing: -.01em; }
.how-card p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }

/* ---------- about / footer ---------- */
.about {
  max-width: 680px; margin: 0 auto; text-align: center;
  padding: clamp(44px, 9vh, 90px) var(--page-pad) 46px;
  font-size: 14px; color: var(--ink-2); line-height: 1.65;
}
.about a { color: var(--accent); text-decoration: none; font-weight: 700; }
.about-line { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }
#footer-raised { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- leaderboard sidebar ---------- */
#board {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 30;
  width: min(380px, 94vw); background: var(--card);
  border-left: 1px solid var(--line); box-shadow: -10px 0 34px rgba(63, 54, 40, .2);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  transform: translateX(102%); transition: transform .25s ease; visibility: hidden;
}
#board.open { transform: none; visibility: visible; }
.board-head { display: flex; align-items: center; justify-content: space-between; }
.board-head h2 { margin: 0; font-size: 18px; color: var(--ink-hero); }
.board-head .modal-close { position: static; }
.board-sub { margin: 0; font-size: 12px; color: var(--ink-2); }
.board-sub b { color: var(--ink-hero); font-variant-numeric: tabular-nums; }
#board-list { margin: 4px 0 0; padding: 0; list-style: none; overflow-y: auto; flex: 1; }
#board-list li {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-bottom: 1px solid var(--paper-minor); cursor: pointer;
}
#board-list li:hover { background: var(--bg); }
.b-rank { color: var(--ink-3); font: 700 11px var(--font); width: 28px; flex: none; }
.b-fav {
  width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--paper-minor);
  background: #fff; flex: none; object-fit: contain;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 12px var(--font); color: var(--ink-2);
}
.b-main { flex: 1; min-width: 0; }
.b-name { font-weight: 700; font-size: 13px; color: var(--ink-hero); }
.b-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-right { text-align: right; flex: none; }
.b-amt { font-weight: 700; font-size: 13px; color: var(--ink-hero); font-variant-numeric: tabular-nums; display: block; }
.b-clicks { font-size: 10px; color: var(--ink-3); }
#board-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(63, 54, 40, .32); }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--card);
  color: var(--ink); box-shadow: 0 12px 40px rgba(63, 54, 40, .25);
  padding: 22px; width: min(430px, calc(100vw - 32px)); font-family: var(--font);
}
dialog::backdrop { background: rgba(63, 54, 40, .35); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font-size: 20px; color: var(--ink-hero); }
dialog .modal-body { display: flex; flex-direction: column; gap: 10px; position: relative; }
.modal-close {
  position: absolute; top: -8px; right: -6px; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-2);
  font-size: 16px; cursor: pointer; line-height: 1;
}
.rules { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.7; }

/* ---------- confetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
#confetti span {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
  animation: fall 2.4s ease-in forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .1; } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .navlinks { display: none; }
  .widget { flex-direction: column; }
  .w-stepper { justify-content: space-between; }
  .w-help { flex-direction: column; align-items: center; gap: 4px; text-align: center; }
  .w-note { text-align: center; }
  .graph-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .how-grid { grid-template-columns: 1fr; }
  #stage { height: clamp(380px, 62vh, 640px); }
  .graph-tools { flex-wrap: wrap; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bar .bar-body, .btn-accent, .btn-pill { transition: none; }
  .bar.next .bar-body { animation: none; }
  .widget.flash { animation: none; }
  #confetti span { display: none; }
}
