@font-face { font-family: 'JBM'; src: url('/fonts/jbm-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JBM'; src: url('/fonts/jbm-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f6f4ef; --surface: #ffffff; --fg: #15171c; --muted: #646a78; --grid: #e2dfd7; --line: #d9d5cb;
  --you: #e4481b; --crowd: #6e5ce6; --real: #15171c; --lead: #9aa0ac; --accent: #e4481b; --on-accent: #ffffff;
  --tab: #ebe8e0; --ok: #1d7a4f;
  --mono: 'JBM', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1014; --surface: #171920; --fg: #eef0f4; --muted: #8a90a0; --grid: #262a33; --line: #2c303a;
    --you: #ff6b3d; --crowd: #a194ff; --real: #eef0f4; --lead: #6b7180; --accent: #ff6b3d; --on-accent: #120a06;
    --tab: #1f222b; --ok: #4fd39a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--sans); overflow-x: hidden; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--mono); letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 10px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* header */
.top { max-width: 760px; margin: 0 auto; padding: 12px 16px 6px; display: flex; align-items: center; gap: 12px; }
.top .brand { display: flex; line-height: 0; }
.top .brand img { height: 28px; width: auto; }
.top nav { margin-left: auto; display: flex; gap: 14px; font: 600 14px var(--mono); }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: var(--fg); }
.streak { font: 700 12px var(--mono); color: var(--accent); border: 1.5px solid var(--accent); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

/* buttons and tabs */
.btn { font: 700 14px var(--mono); padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.big { font-size: 16px; padding: 14px 20px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin: 6px 0 10px; }
.tabs, .toggle { display: inline-flex; background: var(--tab); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button, .toggle button { font: 700 13px var(--mono); border: 0; background: transparent; color: var(--muted); padding: 8px 10px; border-radius: 8px; cursor: pointer; min-height: 36px; }
.tabs button[aria-selected="true"], .toggle button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* the game */
.price { margin: 0; font: 400 14px var(--mono); color: var(--muted); }
.price b { color: var(--fg); font-size: 18px; }
.price .up { color: var(--ok); }
.round { margin: 2px 0 8px; font: 700 15px/1.35 var(--mono); }
.round .cd { color: var(--accent); }
.draw { position: relative; margin: 0 -4px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; container-type: inline-size; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
/* the drawing chart's final height, held from the first paint (before the data arrives): the script draws it at
   clamp(260, 0.72 × the box's width, 400) px, so nothing below it moves when it renders */
.chart.live { height: 400px; height: clamp(260px, 72cqi, 400px); }
.chart .lbl { font: 400 11px var(--mono); fill: var(--muted); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.chart .tag { font: 700 11px var(--mono); fill: var(--fg); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.pad { position: absolute; touch-action: none; cursor: crosshair; }
.hint { position: absolute; margin: 0; pointer-events: none; font: 700 13px/1.3 var(--mono); color: var(--accent); text-align: center; }
.controls { display: flex; gap: 8px; margin-top: 8px; }
.controls .primary { flex: 1; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.err { color: var(--you); font: 700 14px var(--mono); }
.done { margin-top: 12px; padding: 12px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); }
.done p { margin: 0 0 6px; }
.done .link a { font: 700 15px var(--mono); overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* last round, your drawings */
section.last, section.mine, section.about, #token { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); }
.legend { font: 400 12px var(--mono); color: var(--muted); margin: 6px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.legend .k { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-left: 4px; }
.k.you { background: var(--you); } .k.real { background: var(--real); } .k.crowd { background: var(--crowd); opacity: .6; } .k.lead { background: var(--lead); }
.stats { font: 400 14px/1.5 var(--mono); margin: 6px 0; }
.stats b { font-size: 15px; }
.hist { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; align-items: end; height: 56px; margin-top: 8px; }
.hist div { background: var(--crowd); opacity: .75; border-radius: 3px 3px 0 0; min-height: 2px; }
.histlbl { display: flex; justify-content: space-between; font: 400 11px var(--mono); color: var(--muted); margin: 2px 0 0; }
.mine ul { list-style: none; padding: 0; margin: 0; }
.mine li a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg); font: 400 14px var(--mono); }
.mine li .st { color: var(--muted); white-space: nowrap; }
.mine li .st b { color: var(--accent); }
.about ol { padding-left: 20px; margin: 0 0 8px; }
.about li { margin-bottom: 4px; }

/* token section */
#token h3 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.addr { display: flex; gap: 8px; align-items: center; }
.addr code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 400 13px var(--mono); }
.addr .btn { min-height: 36px; padding: 6px 12px; }
.links a { margin-right: 16px; font-family: var(--mono); font-size: 14px; }
.foot { margin-top: 40px; padding-bottom: 32px; font-size: 12px; color: var(--muted); }

/* the result page */
.result .card { margin-top: 10px; }
.kicker { font: 400 12px var(--mono); color: var(--muted); margin: 0; text-transform: none; }
.result h1 { font-size: clamp(22px, 6.4vw, 34px); line-height: 1.15; margin: 4px 0 4px; }
.result h1 b { color: var(--accent); }
.sub { font: 400 15px var(--mono); margin: 0 0 10px; }
.chartbox { margin: 0 -4px; }
.mine-note, .mine { font-size: 14px; }
.cta { margin: 24px 0 8px; }
.src { font-size: 12px; color: var(--muted); }

/* the method page */
.how main { padding-bottom: 40px; }
.how h1 { font-size: 26px; margin: 18px 0 6px; }
.how h2 { margin-top: 26px; }
.how code, .how .formula { font-family: var(--mono); font-size: 14px; }
.how .formula { display: block; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.how table { border-collapse: collapse; width: 100%; font: 400 13px var(--mono); }
.how th, .how td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); }

@media (min-width: 700px) {
  .top { padding-top: 18px; }
  .round { font-size: 16px; }
  .chart .lbl { font-size: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 1.6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
}
