/* Pointless Data — shared styles
   Color tokens follow the validated data-viz reference palette.
   Light + dark are both explicitly selected via prefers-color-scheme. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;      /* blue — default magnitude hue */
  --series-2: #eb6834;      /* orange */
  --series-3: #1baf7a;      /* aqua */
  --seq-150: #b7d3f6;       /* light blue ramp steps for fills */
  --seq-250: #86b6ef;
  --good-text: #006300;
  --bad: #d03b3b;
  --accent: var(--series-1);
  --card-shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --seq-150: #184f95;
    --seq-250: #1c5cab;
    --good-text: #0ca30c;
    --bad: #e66767;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.display {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

a { color: var(--accent); }

/* ---------- header / nav ---------- */

.pd-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 20;
}

.pd-header .bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  flex-wrap: wrap;
}

.pd-logo {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.pd-logo .dot { color: var(--series-2); }

.pd-nav { display: flex; gap: 4px; flex: 1; }

.pd-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.94rem;
}

.pd-nav a:hover { background: var(--page); color: var(--text-primary); }
.pd-nav a[aria-current="page"] { background: var(--page); color: var(--text-primary); font-weight: 600; }

.player-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.player-chip:hover { color: var(--text-primary); border-color: var(--baseline); }

/* ---------- generic pieces ---------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--card-shadow);
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  background: var(--accent);
  color: #fff;
}
.btn:hover { filter: brightness(1.06); }

.btn.ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--baseline);
  font-weight: 500;
}
.btn.ghost:hover { background: var(--surface-1); filter: none; }

.btn.small { padding: 6px 14px; font-size: 0.9rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.topic-chip {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.94rem;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.topic-chip:hover { border-color: var(--accent); }
.topic-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: 0.88rem; }

.banner {
  border: 1px solid var(--border);
  border-left: 4px solid var(--series-2);
  background: var(--surface-1);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.trouble-bar {
  background: var(--bad);
  color: #fff;
  padding: 10px 16px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.trouble-bar code { background: rgba(255, 255, 255, 0.2); padding: 0 4px; border-radius: 3px; }

/* ---------- play screen ---------- */

.play-stage { min-height: calc(100vh - 58px); display: flex; flex-direction: column; }

.play-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.play-hud .chip-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.play-hud .chip-row::-webkit-scrollbar { display: none; }
.play-hud .topic-chip { flex-shrink: 0; }
.play-hud #hud-right { flex-shrink: 0; white-space: nowrap; }

.q-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 0 40px;
  animation: rise 0.28s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.q-topic {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 8px;
}

.q-prompt {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(1.5rem, 4.5vw, 2.2rem);
  line-height: 1.2;
  margin: 0 0 26px;
}

.q-prompt.long {
  font-size: clamp(1.1rem, 3.1vw, 1.45rem);
  line-height: 1.35;
  margin-bottom: 20px;
}

.opt-list { display: flex; flex-direction: column; gap: 10px; }

.opt {
  border: 1.5px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 1.05rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, transform 0.08s;
}
.opt:hover { border-color: var(--accent); transform: translateY(-1px); }
.opt .key { color: var(--text-muted); font-size: 0.8rem; margin-right: 8px; }

.scale-row { display: flex; gap: 6px; flex-wrap: wrap; }
.scale-btn {
  flex: 1 1 0;
  min-width: 40px;
  border: 1.5px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 12px 0;
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.08s;
}
.scale-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.num-row { display: flex; gap: 10px; align-items: center; }
.num-input {
  flex: 1;
  border: 1.5px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 1.2rem;
  font-family: inherit;
  width: 100%;
}
.num-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.reveal { margin-top: 10px; }

.reveal .verdict {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  margin: 0 0 4px;
}
.verdict.good { color: var(--good-text); }
.verdict.bad { color: var(--bad); }

.next-row { display: flex; gap: 10px; margin-top: 22px; align-items: center; }

.streak { font-weight: 600; color: var(--text-primary); }

/* ---------- charts (data-viz layer) ---------- */

.viz {
  background: var(--surface-1);
  border-radius: 10px;
  padding: 4px 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.viz-title { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); margin: 0 0 10px; }

.hbar-row { display: grid; grid-template-columns: minmax(90px, 32%) 1fr; gap: 8px; align-items: center; margin: 7px 0; }
.hbar-label {
  font-size: 0.88rem;
  color: var(--text-secondary);
  text-align: right;
  overflow-wrap: anywhere;
}
.hbar-label .you-tag {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.75rem;
  margin-left: 5px;
}
.hbar-track { position: relative; height: 22px; }
.hbar-fill {
  position: absolute;
  left: 0; top: 3px; bottom: 3px;
  min-width: 3px;
  background: var(--series-1);
  border-radius: 0 4px 4px 0;
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.hbar-fill.dim { background: var(--seq-250); }
.hbar-val {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hbar-val.inside { color: #fff; }
.hbar-correct { color: var(--good-text); font-weight: 700; margin-left: 5px; font-size: 0.8rem; }

.tiles { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.tile {
  flex: 1 1 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-1);
}
.tile .t-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tile .t-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.tile .t-note { font-size: 0.8rem; color: var(--text-secondary); }

.hist { width: 100%; height: auto; display: block; }
.hist .bin { fill: var(--series-1); }
.hist .bin:hover { fill: var(--series-2); }
.hist .axis-text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.hist .baseline { stroke: var(--baseline); stroke-width: 1; }
.hist .marker-line { stroke: var(--text-secondary); stroke-width: 2; stroke-dasharray: 3 3; }
.hist .marker-text { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }

.pd-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page);
  font-size: 0.8rem;
  padding: 5px 9px;
  border-radius: 7px;
  opacity: 0;
  transition: opacity 0.1s;
  max-width: 240px;
}

.data-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; margin-top: 8px; }
.data-table th, .data-table td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--grid); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table td.num { font-variant-numeric: tabular-nums; }

details.table-view summary { cursor: pointer; color: var(--text-muted); font-size: 0.82rem; margin-top: 8px; }

/* ---------- leaderboard ---------- */

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th, .lb-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--grid); }
.lb-table th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.lb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lb-table th.num { text-align: right; }
.lb-table tr.me td { background: color-mix(in srgb, var(--series-1) 9%, transparent); font-weight: 600; }
.lb-rank { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- blog ---------- */

.blog-header { padding: 40px 0 10px; }
.blog-kicker {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--series-2);
}
.blog-title {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  line-height: 1.15;
  margin: 6px 0 10px;
}
.byline { color: var(--text-muted); font-size: 0.9rem; }

.q-section { margin: 34px 0; }
.q-section h2 {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.35rem;
  margin: 0 0 6px;
}
.q-section .analysis { color: var(--text-secondary); margin: 10px 0; }

.locked {
  border: 1.5px dashed var(--baseline);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--text-muted);
  margin: 22px 0;
}

.progress-track { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--series-1); border-radius: 4px; }

/* ---------- home ---------- */

.hero { text-align: center; padding: 52px 0 30px; }
.hero h1 {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  margin: 0 0 10px;
  line-height: 1.1;
}
.hero h1 .dot { color: var(--series-2); }
.hero p.tag { font-size: 1.12rem; color: var(--text-secondary); max-width: 540px; margin: 0 auto 24px; }

.section-h {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.4rem;
  margin: 40px 0 14px;
}

.article-list { display: flex; flex-direction: column; gap: 12px; }
.article-card { display: block; text-decoration: none; color: inherit; }
.article-card h3 { margin: 0 0 4px; font-size: 1.12rem; }
.article-card:hover { border-color: var(--accent); }
.article-card .status { font-size: 0.82rem; }
.status.live { color: var(--good-text); font-weight: 700; }

.card-links { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.article-card h3 a { color: inherit; text-decoration: none; }
.article-card h3 a:hover { color: var(--accent); }

.footer {
  margin: 70px 0 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.footer a { color: var(--text-muted); }

dialog.name-dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 26px;
  max-width: 380px;
  width: calc(100vw - 48px);
  box-shadow: var(--card-shadow);
}
dialog.name-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.name-dialog h3 { margin: 0 0 6px; font-family: "Fredoka", system-ui, sans-serif; }

@media (max-width: 560px) {
  .pd-nav a { padding: 5px 8px; font-size: 0.88rem; }
  .hbar-row { grid-template-columns: minmax(76px, 36%) 1fr; }
}
