:root {
  --bg: #fafaf7;
  --fg: #111;
  --muted: #777;
  --border: #ddd;
  --future: #f0f0ea;
  --you: #19c43b;
  --them: #111;
  --zone: 214, 64, 48;
  --truth: #b00020;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); }
#app { max-width: 900px; height: 100vh; margin: auto; display: grid; grid-template-rows: auto auto 1fr auto; }
header { padding: 12px 16px 0; }
h1 { font-family: Georgia, serif; font-weight: 400; margin: 0 0 6px; }
h1 small { font-size: 0.55em; color: var(--muted); }
.muted, .label { color: var(--muted); }
header p { margin: 0 0 10px; max-width: 70ch; line-height: 1.4; }

.scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.account { padding: 10px 16px; display: flex; flex-direction: column; gap: 4px; }
.account + .account { border-left: 1px solid var(--border); }
.account strong { font-family: Georgia, serif; font-weight: 400; font-size: 26px; }
.account.you .label:first-child::before, .account.them .label:first-child::before {
  content: ""; display: inline-block; width: 14px; margin-right: 6px; vertical-align: middle; border-top: 3px solid var(--you);
}
.account.them .label:first-child::before { border-color: var(--them); }
.gain { color: #1c7a2e; }
.loss { color: #c0392b; }
.risk[data-level="watch"] strong { color: #b7791f; }
.risk[data-level="warning"] strong { color: #d35400; }
.risk[data-level="critical"] strong { color: #c0392b; }

.chart-wrap { position: relative; min-height: 220px; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#result { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); background: rgba(250, 250, 247, 0.95); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 12px 16px; }
#result[hidden] { display: none; }
#result h2 { font-family: Georgia, serif; font-weight: 400; font-size: 28px; margin: 0; }
#result p { margin: 0; max-width: 60ch; }
.result-actions { display: flex; gap: 8px; }
#result-table { border-collapse: collapse; margin: 4px 0; }
#result-table :is(th, td) { padding: 3px 14px; text-align: right; }
#result-table :is(th, td):first-child { text-align: left; color: var(--muted); }
#result-table th { font-weight: 400; color: var(--muted); border-bottom: 1px solid var(--border); }
#result-table tr:nth-child(2) td:not(:first-child) { font-family: Georgia, serif; font-size: 22px; }
#result-table tr.payout td { border-top: 1px solid var(--border); font-weight: 700; }

footer { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; padding: 10px 16px 16px; border-top: 1px solid var(--border); align-items: center; }
.clock { display: flex; gap: 8px; align-items: baseline; }
.clock strong { font-family: Georgia, serif; font-weight: 400; font-size: 22px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: flex-end; color: var(--muted); }
.key { display: inline-block; width: 16px; height: 0; margin-right: 6px; vertical-align: middle; border-top: 3px solid var(--you); }
.key.them { border-color: var(--them); }
.key.zone { height: 10px; border: 0; background: linear-gradient(to top, rgba(var(--zone), 0.05), rgba(var(--zone), 0.45)); }
.key.truth { border-top: 2px dashed var(--truth); }
.key.truth.them { border-top-color: var(--muted); }

button { font: inherit; cursor: pointer; border: 1px solid var(--fg); background: var(--bg); color: var(--fg); padding: 10px 16px; }
#accelerator { grid-column: 1 / -1; min-height: 52px; background: var(--fg); color: var(--bg); touch-action: none; user-select: none; -webkit-user-select: none; }
#accelerator[aria-pressed="true"] { background: var(--you); color: #000; border-color: var(--you); }
#accelerator:disabled { background: var(--future); color: var(--muted); border-color: var(--border); cursor: default; }
#accelerator small { opacity: 0.6; margin-left: 8px; }

body:not([data-mode="advanced"]) .advanced-only, body:not([data-mode="original"]) .original-only,
body:not([data-mode="simple"]) .simple-only { display: none; }
body[data-mode="original"] .dynamics-only { display: none; }
header a { color: inherit; }
.control { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; color: var(--muted); }
/* Neutral track: a filled segment would suggest the left label owns the left share. */
.control input { flex: 1; min-width: 80px; appearance: none; -webkit-appearance: none; height: 4px; background: var(--muted); border-radius: 2px; }
.control input::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--you); border: 2px solid var(--fg); cursor: pointer; }
.control input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--you); border: 2px solid var(--fg); cursor: pointer; }
.control > span { width: 30ch; flex: none; white-space: nowrap; }
.control > span:first-child { text-align: right; }
.key.latent { border-top: 2px dashed var(--you); }
.key.internal { border-top: 1.5px solid var(--you); }
#takeoff { grid-column: 1 / -1; margin: 0; color: var(--muted); }
#takeoff[data-level="dominant"] { color: #d35400; }
#takeoff[data-level="takeoff"] { color: #c0392b; font-weight: 700; }
#game-speed { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); margin-left: 4px; }
#inspect { position: absolute; top: 24px; z-index: 3; background: rgba(250, 250, 247, 0.96); border: 1px solid var(--border); padding: 8px 10px; pointer-events: none; font-size: 12px; }
#inspect table { border-collapse: collapse; }
#inspect :is(th, td) { padding: 1px 8px; text-align: right; white-space: nowrap; }
#inspect :is(th, td):first-child { text-align: left; color: var(--muted); }
#inspect th { font-weight: 400; color: var(--muted); }
.inspect-title { font-weight: 700; margin-bottom: 4px; }
.inspect-note { margin-top: 6px; color: var(--muted); max-width: 46ch; }
.key.zone.them { background: linear-gradient(to top, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.2)); }
