:root {
  --bg: #f6efe3;
  --card: #fffaf1;
  --ink: #221d17;
  --muted: #6f6556;
  --line: #e3d7c3;
  --accent: #d9481f;
  --accent-ink: #ffffff;
  --tag: #fff3c9;
  --tag-edge: #e6c96f;
  --good: #3f9c5a;
  --ok: #d7a91e;
  --meh: #e07b2a;
  --bad: #cf3d32;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 8px 24px -12px rgba(60,40,10,.35);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1814;
    --card: #25211b;
    --ink: #f3ebdd;
    --muted: #a99d8a;
    --line: #3a342b;
    --accent: #ff6a3d;
    --accent-ink: #1b1814;
    --tag: #3a3220;
    --tag-edge: #6b5a2c;
    --shadow: 0 8px 24px -12px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.45;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 480px; width: 100%; margin: 0 auto;
  padding: 12px 16px 4px;
}
.brand { text-align: center; }
.logo {
  margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
}
.logo span { color: var(--accent); }
.edition { margin: 4px 0 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--card);
  font-weight: 700; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--muted); }

main { flex: 1; width: 100%; max-width: 480px; margin: 0 auto; padding: 8px 16px 24px; }
.screen { display: flex; flex-direction: column; gap: 16px; }

/* Progress pips */
.pips { list-style: none; display: flex; gap: 6px; justify-content: center; margin: 4px 0 0; padding: 0; }
.pips li { width: 36px; height: 8px; border-radius: 4px; background: var(--line); }
.pips li.now { background: var(--ink); }
.pips li.g { background: var(--good); } .pips li.o { background: var(--ok); }
.pips li.m { background: var(--meh); } .pips li.b { background: var(--bad); }

/* Price tag card */
.tag {
  position: relative;
  background: var(--tag);
  border: 2px solid var(--tag-edge);
  border-radius: 18px 18px 18px 18px;
  padding: 28px 20px 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.tag-hole {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--tag-edge);
}
.tag-year {
  display: inline-block; margin-top: 6px;
  font-family: var(--mono); font-weight: 800; font-size: 20px; letter-spacing: .08em;
  background: var(--ink); color: var(--bg); padding: 2px 12px; border-radius: 6px;
}
.tag-emoji { font-size: 64px; line-height: 1.2; margin: 10px 0 2px; }
.tag-name { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -0.01em; }
.tag-unit { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.tag-hint {
  display: inline-block; margin: 12px 0 0; padding: 4px 12px; border-radius: 999px;
  border: 1.5px dashed var(--tag-edge); font-size: 15px; font-variant-numeric: tabular-nums;
}
.tag-hint strong { font-family: var(--mono); }

/* Guess */
.guess { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.guess-label { text-align: center; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.guess-value {
  text-align: center; font-family: var(--mono); font-weight: 800;
  font-size: 44px; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.slider-row { display: flex; align-items: center; gap: 10px; }
.nudge {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--card); font-size: 22px; font-weight: 700;
}
input[type=range] {
  flex: 1; min-width: 0; height: 44px; background: transparent;
  -webkit-appearance: none; appearance: none; touch-action: pan-y;
}
input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--line); }
input[type=range]::-moz-range-track { height: 8px; border-radius: 4px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; margin-top: -11px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
input[type=range]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.slider-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 54px; font-family: var(--mono); }

.btn {
  display: block; width: 100%; padding: 14px 18px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 17px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }

/* Reveal */
.reveal, .halfway, .result-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow);
  animation: rise .25s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal, .halfway, .result-card { animation: none; } }
.reveal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.reveal-label { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.reveal-answer { margin: 2px 0 0; font-family: var(--mono); font-size: 38px; font-weight: 800; line-height: 1.1; }
.score-badge {
  flex: none; min-width: 72px; padding: 8px 10px; border-radius: 12px; text-align: center;
  font-weight: 800; font-size: 26px; color: #fff; line-height: 1;
}
.score-badge small { display: block; font-size: 11px; font-weight: 600; opacity: .9; margin-top: 3px; }
.score-badge.g { background: var(--good); } .score-badge.o { background: var(--ok); color: #221d17; }
.score-badge.m { background: var(--meh); } .score-badge.b { background: var(--bad); }
.reveal-yours { margin: 8px 0 0; color: var(--muted); }
.facts { margin: 12px 0 0; padding: 12px 0 0; list-style: none; border-top: 1px dashed var(--line); display: grid; gap: 6px; }
.facts li { padding-left: 22px; position: relative; }
.facts li::before { position: absolute; left: 0; }
.facts li:first-child::before { content: "🏷️"; }
.facts li:last-child::before { content: "📈"; }
.source { margin: 10px 0 14px; font-size: 12px; color: var(--muted); }

.halfway { text-align: center; }
.halfway-title { margin: 0; font-size: 22px; font-weight: 800; }

/* Results */
.result-card { text-align: center; }
.result-card > p { margin: 0; }
.result-total { font-family: var(--mono); font-weight: 800; font-size: 64px; line-height: 1.1; margin: 4px 0 !important; }
.result-total small { font-size: 22px; color: var(--muted); }
.result-verdict { font-weight: 700; font-size: 18px; }
.result-squares { font-size: 30px; letter-spacing: 4px; margin: 10px 0 14px !important; }
.toast { min-height: 1.4em; margin-top: 8px !important; font-size: 14px; color: var(--muted); }
.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; }
.breakdown th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1.5px solid var(--line); }
.breakdown td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.breakdown td:nth-child(n+2), .breakdown th:nth-child(n+2) { text-align: right; font-family: var(--mono); white-space: nowrap; }
.breakdown .yr { display: block; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.next-game { text-align: center; color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }

.ad-slot:empty { display: none; }
.ad-slot { margin: 8px 0; min-height: 100px; }

/* Dialogs */
.dlg {
  width: min(440px, calc(100vw - 32px)); border: none; border-radius: 18px;
  background: var(--card); color: var(--ink); padding: 22px 20px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.dlg::backdrop { background: rgba(20,14,6,.55); }
.dlg h2 { margin: 0 0 12px; font-size: 22px; }
.dlg h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dlg p { margin: 0 0 10px; }
.dlg-close { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 28px; line-height: 1; color: var(--muted); }
.dlg form { margin: 0; }
.dlg .btn { margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat-grid strong { display: block; font-family: var(--mono); font-size: 26px; }
.stat-grid span { font-size: 12px; color: var(--muted); }
.dist { display: grid; gap: 5px; }
.dist-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; font-size: 13px; font-family: var(--mono); }
.dist-bar { background: var(--line); color: var(--ink); border-radius: 4px; padding: 2px 6px; text-align: right; min-width: 24px; font-weight: 700; }
.dist-bar.today { background: var(--accent); color: var(--accent-ink); }

.foot { max-width: 480px; margin: 0 auto; padding: 8px 16px 28px; font-size: 12px; color: var(--muted); text-align: center; }
.foot p { margin: 0; }
