:root {
  --bg: #f4f1ea; --fg: #1d1b18; --muted: #6b655b; --line: #d8d1c4; --accent: #7a4b16; --bad: #a31d1d; --ok: #2f6b2f;
  --panel: #fffdf8; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16140f; --fg: #ebe5d9; --muted: #9a927f; --line: #3a352c; --accent: #d9a35b; --bad: #ff7b6b; --ok: #8fcf8f; --panel: #1f1c16; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, sans-serif; }
header { display: flex; align-items: baseline; gap: 1em; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
h1 { margin: 0; font-size: 20px; }
h1 small { font-weight: normal; color: var(--muted); font-size: 14px; }
h2 { margin: 0 0 8px; font-size: 17px; }
main { max-width: 1320px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.muted { color: var(--muted); }
code, pre { font-family: var(--mono); font-size: 12.5px; }
#checks td { padding: 2px 12px 2px 0; vertical-align: top; }
#checks td.ok { color: var(--ok); } #checks td.bad { color: var(--bad); }
button { font: inherit; padding: 6px 16px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--panel); cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
#stage { display: flex; align-items: center; gap: 12px; font-weight: 600; }
#stage progress { flex: 1; max-width: 400px; }
#status { font-family: var(--mono); font-size: 12.5px; min-height: 1.4em; overflow-wrap: anywhere; }
#milestones { margin: 6px 0 0; padding-left: 20px; font-family: var(--mono); font-size: 12.5px; }
#error { border-color: var(--bad); }
#error h2 { color: var(--bad); }
#errorText { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; margin: 0 0 8px; }
#screen { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; width: 100%; }
#screen:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }
#screenStatus { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px; background: rgba(0, 0, 0, .65); color: #eee; font: 15px/1.4 system-ui, sans-serif; }
#screenStatus small { color: #bbb; }
#canvas { display: block; width: 100%; height: 100%; }
#logBox pre { max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }
summary { cursor: pointer; }
#saveList { border-collapse: collapse; margin: 4px 0 8px; font-size: 14px; }
#saveList th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 14px 2px 0; }
#saveList td { padding: 3px 14px 3px 0; overflow-wrap: anywhere; }
#saves .buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button.small { padding: 2px 10px; font-size: 13px; }
.filebtn { display: inline-block; padding: 6px 16px; border-radius: 6px; border: 1px solid var(--accent); color: var(--accent); cursor: pointer; }
.filebtn input { display: none; }
.filebtn.disabled { opacity: .5; cursor: default; pointer-events: none; }
#saveStatus.bad { color: var(--bad); }
button.secondary { background: transparent; color: var(--accent); }
#saveEditor { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
#saveEditor h3 { margin: 4px 0; font-size: 16px; }
#saveEditor h4 { margin: 12px 0 4px; font-size: 14px; }
#saveEditor .fields { display: flex; flex-wrap: wrap; gap: 8px 16px; }
#saveEditor .field { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
#saveEditor input { font: inherit; padding: 2px 4px; }
table.edit { border-collapse: collapse; font-size: 14px; }
table.edit th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 12px 2px 0; }
table.edit td { padding: 1px 12px 1px 0; }
#saveEditor .invwrap { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
#saveEditor .adds { margin: 4px 0; padding-left: 20px; }
.bad { color: var(--bad); }
#perfHud { position: absolute; left: 8px; top: 8px; margin: 0; padding: 6px 10px; max-width: calc(100% - 16px); background: rgba(0, 0, 0, .62);
  color: #e8e8e8; font: 11.5px/1.35 var(--mono); white-space: pre; overflow: hidden; pointer-events: none; border-radius: 4px; z-index: 2; }
