:root {
  --bg: #faf8f3;
  --card: #ffffff;
  --ink: #1b1a17;
  --ink-2: #5a5750;
  --line: #e2ded4;
  --accent: #1d6b4f;
  --accent-ink: #ffffff;
  --hidden: #efebe2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171714;
    --card: #222220;
    --ink: #f2efe7;
    --ink-2: #b8b4aa;
    --line: #3a3934;
    --accent: #4fb38c;
    --accent-ink: #0f1a15;
    --hidden: #2b2a26;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
header h1 { margin: 0; font-size: 28px; letter-spacing: -0.01em; }
.sub { margin: 2px 0 16px; color: var(--ink-2); font-size: 14px; }
.how { margin: 0 0 16px; color: var(--ink-2); font-size: 15px; }
.how strong { color: var(--ink); }

.clues { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.clue {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
}
.clue .label { color: var(--ink-2); font-size: 15px; }
.clue .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clue.hidden { background: var(--hidden); border-style: dashed; }
.clue.hidden .label { font-style: italic; }
.clue.new { animation: reveal 0.35s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .clue.new { animation: none; } }

form { display: flex; gap: 8px; }
input[type=number] {
  flex: 1; min-width: 0; font: inherit; font-size: 20px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
  -moz-appearance: textfield; appearance: textfield;
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
button {
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 10px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.feedback { min-height: 1.5em; margin: 8px 0; color: var(--ink-2); }
.guesses { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.guesses li { display: flex; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.guesses .year { font-weight: 650; min-width: 3.2em; }
.guesses .hint { color: var(--ink-2); font-size: 15px; }

.end { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.verdict { font-size: 20px; font-weight: 650; margin: 0 0 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.next { color: var(--ink-2); font-size: 14px; }
.end h2 { font-size: 17px; margin: 20px 0 8px; }
.sources { width: 100%; border-collapse: collapse; font-size: 14px; }
.sources th, .sources td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.sources td:nth-child(2) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sources a { color: var(--accent); }

footer { margin-top: 32px; color: var(--ink-2); font-size: 13px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* How to play */
details.how { margin: 0 0 16px; color: var(--ink-2); font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; background: var(--card); }
details.how summary { cursor: pointer; color: var(--ink); font-weight: 600; }
details.how p { margin: 8px 0; }
details.how strong { color: var(--ink); }
.legend { list-style: none; padding: 0; margin: 4px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; }

/* A link that looks like a button */
a.button { display: inline-block; font-weight: 600; padding: 10px 18px; border-radius: 10px;
  text-decoration: none; }
a.button.secondary { color: var(--ink); border: 1px solid var(--line); }
.share-text { width: 100%; margin-top: 8px; font: 14px/1.4 ui-monospace, Consolas, monospace;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

/* Stats */
.stats h2, .end h2 { font-size: 17px; margin: 20px 0 8px; }
.numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.numbers div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.numbers dt { color: var(--ink-2); font-size: 13px; }
.numbers dd { margin: 0; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.dist-h { color: var(--ink-2); font-size: 13px; margin: 12px 0 4px; }
.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dist li { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.dist .n { width: 1em; color: var(--ink-2); font-size: 14px; }
.dist .bar { width: var(--w, 8%); min-width: 1.8em; background: var(--hidden); border-radius: 4px;
  padding: 1px 6px; text-align: right; font-size: 13px; }
.dist .bar.this { background: var(--accent); color: var(--accent-ink); }

/* Archive */
.archive { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; font-size: 14px; }
.archive a { color: var(--accent); font-weight: 600; }
.archive .state { color: var(--ink-2); }
footer a { color: var(--accent); }

/* About page */
a.home { color: inherit; text-decoration: none; }
.plain { padding-left: 20px; }
.plain li { margin: 4px 0; }
.built { color: var(--ink-2); font-size: 13px; }

/* ---- Rate Shock ---- */
h2 { font-size: 17px; margin: 20px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; }
.card h2 { margin-top: 0; }
.note { color: var(--ink-2); font-size: 14px; font-weight: 400; }
p.note { margin: 6px 0 0; }
.note a { color: var(--accent); }

.curve { width: 100%; height: auto; display: block; }
.curve .grid { stroke: var(--line); stroke-width: 1; }
.curve .axis { fill: var(--ink-2); font-size: 12px; }
.curve .val { fill: var(--ink); font-size: 13px; font-weight: 650; }
.curve .mid { text-anchor: middle; }
.curve .end { text-anchor: end; }
.curve .line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.curve .line.now { stroke: var(--accent); }
.curve .line.before { stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 4 5; opacity: 0.6; }
.curve .dot { fill: var(--accent); }

:root { --cash: #8a8f98; --short: #3f8fd2; --long: #1f4e8c; --loans: #c9772b; --bad: #b3261e; }
@media (prefers-color-scheme: dark) { :root { --cash: #9aa0a8; --short: #6fb1ea; --long: #4a7fc4; --loans: #e09a55; --bad: #ff8a80; } }
.mixbar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 10px 0 12px; background: var(--hidden); }
.seg.cash, .swatch.cash { background: var(--cash); }
.seg.short, .swatch.short { background: var(--short); }
.seg.long, .swatch.long { background: var(--long); }
.seg.loans, .swatch.loans { background: var(--loans); }
.mixrow { margin: 0 0 10px; }
.mixrow label { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.mixrow label strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
input[type=range] { width: 100%; margin: 4px 0 0; accent-color: var(--accent); }

.news { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }
.squares { list-style: none; display: flex; gap: 4px; margin: 0 0 4px; padding: 0; font-size: 20px; }
.sheet { width: 100%; border-collapse: collapse; font-size: 15px; }
.sheet th { text-align: left; font-weight: 400; padding: 5px 8px 5px 0; }
.sheet td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; padding: 5px 0; vertical-align: top; }
.sheet tr { border-bottom: 1px solid var(--line); }
.sheet tr.sep { border-top: 2px solid var(--line); }
.sheet tr.total th { font-weight: 650; }
.sheet tr.bad td { color: var(--bad); }
.slabel { display: block; font-size: 16px; }
.slabel .note { display: block; }
.sells { margin: 12px 0 4px; display: grid; gap: 6px; }
.sell { display: flex; gap: 8px; align-items: baseline; font-size: 15px; }
#decide .actions, #setup .actions { margin-top: 14px; }
.reveal { font-size: 18px; font-weight: 650; margin: 8px 0 12px; }
.sources td { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.squares li { width: 1.25em; height: 1.25em; line-height: 1.25em; text-align: center; }
.squares li.todo { border: 2px dashed var(--line); border-radius: 4px; width: 1.05em; height: 1.05em; align-self: center; margin: 0 0.1em; }

/* Phones. The sliders and tick boxes are the whole game, so give a thumb
   something to hit (the browser defaults are 16px and 13px tall), and keep
   the chart's labels readable when its 520-unit drawing shrinks to a phone. */
input[type=range] { height: 32px; touch-action: manipulation; }
.sell { align-items: flex-start; cursor: pointer; }
.sell input[type=checkbox] { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
button, a.button { touch-action: manipulation; }
/* The about page's rule values are sentences; nowrap pushed them 360px off a phone. */
#rules td:nth-child(2) { white-space: normal; }
@media (max-width: 480px) {
  .curve .axis { font-size: 17px; }
  .curve .val { font-size: 18px; }
}
