/* Layout: one game column. Status cards with meters on top, canvas stage, touch pad (phones only), event log, tuning panel below. */
:root {
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --bg: #e8eee1;
  --panel: #f7f9f3;
  --fg: #1b2a1d;
  --muted: #566a59;
  --line: #c6d1bd;
  --accent: #d99a12;
  --accent-ink: #241900;
  --good: #2c7a43;
  --bad: #b9402a;
  --track-day: #f1d684;
  --track-night: #3a4a74;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101712; --panel: #18211a; --fg: #e4ecdf; --muted: #97a998; --line: #2b392d;
    --accent: #efb53a; --accent-ink: #241900; --good: #6cc386; --bad: #ee7b63;
    --track-day: #8c6f1d; --track-night: #1b2540;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101712; --panel: #18211a; --fg: #e4ecdf; --muted: #97a998; --line: #2b392d;
  --accent: #efb53a; --accent-ink: #241900; --good: #6cc386; --bad: #ee7b63;
  --track-day: #8c6f1d; --track-night: #1b2540;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; line-height: 1.5;
  padding-block: 16px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app { max-width: 1040px; margin: 0 auto; display: grid; gap: 12px; }
header h1 { font-family: var(--font-display); font-size: 30px; line-height: 1.1; margin: 0; text-wrap: balance; }
header p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 65ch; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.stat { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 0; }
.stat .k { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-family: var(--font-display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .v small { font-family: var(--font-body); font-size: 12px; font-weight: 500; color: var(--muted); }
.gain { position: absolute; right: 10px; top: 8px; font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--good); opacity: 0; pointer-events: none; }
.gain.show { animation: gain 1.6s ease-out; }
@keyframes gain { 0% { opacity: 1; transform: translateY(8px) scale(1.15); } 100% { opacity: 0; transform: translateY(-16px) scale(1); } }
.stat.flash { animation: flash 1s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--accent); background: color-mix(in srgb, var(--accent) 40%, var(--panel)); } 100% { box-shadow: 0 0 0 0 transparent; background: var(--panel); } }
.meter { height: 6px; border-radius: 3px; background: var(--line); margin-top: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 50%; background: var(--good); transition: width .15s; }
.meter.low i { background: var(--bad); }
.stat.buy { display: flex; align-items: center; }

.track { position: relative; height: 10px; border-radius: 5px; border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--track-night) 0 25%, var(--track-day) 25% 75%, var(--track-night) 75% 100%); }
.track i { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: var(--fg); transform: translateX(-2px); }
.track-labels { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 8px; }

.choose { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: grid; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: 92%; font-size: 12px; z-index: 5; }
.choose .btn { text-align: left; padding: 6px 10px; font-size: 12px; }
.choose b { font-size: 12px; color: var(--muted); font-weight: 600; }
.stage { box-shadow: 0 2px 0 #4e3820, 0 6px 14px rgba(0,0,0,.25); border-width: 3px !important; border-color: #7b5a36 !important; position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #6f9a52; }
canvas { display: block; margin-inline: auto; image-rendering: pixelated; touch-action: none; }      /* its width is set in whole art pixels by fit() */

.touch { display: none; align-items: center; justify-content: space-between; gap: 16px; }
body.mobile .touch, body.touchdev .touch { display: flex; }
.stick { position: relative; width: 132px; height: 132px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line); touch-action: none; flex: none; }
.stick b { position: absolute; left: 40px; top: 40px; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); pointer-events: none; }
.pad { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.act { width: 92px; height: 92px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-family: var(--font-display); font-size: 30px; font-weight: 700; touch-action: none; }
.act small { display: block; font-family: var(--font-body); font-size: 10px; font-weight: 600; margin-top: -6px; }

.btn { font: inherit; font-size: 14px; font-weight: 500; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
/* every button gives a little as you press it */
button { transition: transform .08s, filter .08s; } button:active:not(:disabled) { transform: translateY(1px) scale(.97); filter: brightness(.93); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.build { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.build-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.tool b { font-family: var(--font-mono); font-weight: 500; margin-left: 4px; }
.build-hint { margin: 0; font-size: 12px; color: var(--muted); }
.shop { position: fixed; inset: 0; z-index: 50; background: rgba(8, 14, 10, .55); display: grid; place-items: center; overflow: auto; padding: 16px; }
.shop-panel { width: min(560px, 100%); max-height: calc(100% - 8px); overflow: auto; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding-bottom: 14px; }
.shop-sign { background: #2e4a31; color: #f1ead2; padding: 14px 16px; border-radius: 12px 12px 0 0; }
.shop-sign h2 { font-family: var(--font-display); margin: 0; font-size: 22px; text-wrap: balance; }
.shop-sign p { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.shop-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 10px 16px 4px; font-size: 12px; color: var(--muted); }
.shop-meta b { color: var(--fg); font-family: var(--font-mono); font-weight: 500; }
.shop-list { list-style: none; margin: 8px 0 0; padding: 0 16px; display: grid; gap: 8px; }
.shop-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.si-main { display: grid; gap: 1px; min-width: 0; }
.si-main small { color: var(--muted); font-size: 12px; }
.si-meta { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 8px; flex: none; }
.stepper output { min-width: 24px; text-align: center; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stepper .btn { padding: 4px 11px; }
.shop-foot { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 12px 16px 0; }
.shop-note { padding: 6px 16px 0; margin: 0; font-size: 12px; color: var(--muted); min-height: 22px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12px; }
kbd { font-family: var(--font-mono); font-size: 10px; background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; color: var(--fg); }

.todo { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.todo h2 { font-family: var(--font-display); font-size: 14px; margin: 0 0 4px; }
.todo ol { list-style: none; margin: 0; padding: 0; font-size: 12px; display: grid; gap: 2px; }
.todo li { display: flex; gap: 8px; align-items: baseline; }
.todo .tag { flex: none; width: 46px; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.todo .now .tag { color: var(--bad); font-weight: 600; } .todo .soon .tag { color: var(--accent); } .todo .later .tag, .todo .none { color: var(--muted); }
.todo .none { font-size: 12px; }
.log { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; margin: 0; list-style: none; font-size: 12px; min-height: 40px; }
.log li { display: flex; gap: 10px; padding: 2px 0; }
.log time { font-family: var(--font-mono); font-size: 10px; color: var(--muted); flex: none; padding-top: 1px; }
.log li.bad { color: var(--bad); }

details.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; }
details.panel summary { cursor: pointer; padding: 12px 0; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.panel-body { display: grid; gap: 16px; padding-bottom: 16px; }
.sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 20px; }
/* in Debug, four to a row and small, so they all fit (the owner) */
#sheetDebug .sliders { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 14px; }
@media (max-width: 760px) { #sheetDebug .sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.slider { min-width: 0; }
.slider label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.slider output { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.states { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; font-variant-numeric: tabular-nums; }
.states span b { color: var(--fg); font-weight: 500; }
.note { color: var(--muted); font-size: 12px; max-width: 70ch; margin: 0; }
.howto { display: grid; gap: 6px; margin: 4px 0 0; padding: 0 0 14px 18px; font-size: 14px; max-width: 75ch; }
.howto b { font-weight: 600; }

