:root {
  --bg: #f4efe6;
  --surface: #fbf8f2;
  --ink: #2a241d;
  --muted: #7a6f62;
  --accent: #8a3b1e;
  --accent-ink: #fff;
  --line: #ddd3c4;
  --speech: #4a3a26;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110e;
    --surface: #1d1915;
    --ink: #e9e1d4;
    --muted: #9a8f80;
    --accent: #d07a4a;
    --accent-ink: #1a120c;
    --line: #3a322a;
    --speech: #f0d9b5;
  }
}
:root[data-theme="dark"] {
  --bg: #14110e; --surface: #1d1915; --ink: #e9e1d4; --muted: #9a8f80;
  --accent: #d07a4a; --accent-ink: #1a120c; --line: #3a322a; --speech: #f0d9b5;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 19px/1.55 "EB Garamond", Georgia, serif;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 640px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }

.screen#start {
  min-height: 100svh; display: flex; flex-direction: column; justify-content: center; gap: 14px;
}
.eyebrow { letter-spacing: .25em; text-transform: uppercase; font-size: 13px; color: var(--muted); margin: 0; }
h1 { font-weight: 600; font-size: 38px; line-height: 1.1; margin: 0 0 6px; }
.hint { color: var(--muted); margin: 0 0 18px; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker button.selected { border-color: var(--accent); color: var(--accent); }

button {
  font: inherit; color: inherit; background: none; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.secondary { background: var(--surface); }
button.icon { border: none; padding: 8px 10px; font-size: 18px; color: var(--muted); }
.toggle { color: var(--muted); font-size: 16px; display: flex; gap: 8px; align-items: center; margin-top: 8px; }

.bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); padding: calc(8px + env(safe-area-inset-top)) 0 8px; border-bottom: 1px solid var(--line);
}
#scene-title { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; flex: 1; }

#log { padding: 12px 0 8px; }
#log h2 {
  font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  font-weight: 400; margin: 28px 0 10px; text-align: center;
}
#log p { margin: 0 0 14px; transition: opacity .4s; }
#log p.past { opacity: .62; }
#log p.speech { color: var(--speech); padding-left: 14px; border-left: 2px solid var(--accent); }
#log p.speech .who {
  display: block; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
#log p.chosen { color: var(--muted); font-style: italic; font-size: 17px; margin: 18px 0; }
#log p.chosen::before { content: "› "; }
#log p.current { opacity: 1; }
#log p.end { text-align: center; color: var(--muted); margin-top: 28px; }

#controls { display: flex; justify-content: center; min-height: 8px; }
#choices { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
#choices button {
  width: 100%; text-align: left; background: var(--surface); padding: 14px 16px; line-height: 1.35;
}
#choices button:active { border-color: var(--accent); }

/* debug */
button.link { border: none; background: none; color: var(--muted); font-size: 15px; text-decoration: underline; padding: 6px 0; align-self: flex-start; }
.debug-body { display: flex; flex-direction: column; gap: 14px; padding: 16px 0; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 15px; }
.field select, .code-row input {
  font: inherit; font-size: 17px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; font-family: ui-monospace, Menlo, monospace; }
.var-row { display: flex; flex-direction: column; gap: 4px; }
.var-row .name { font-family: ui-monospace, Menlo, monospace; font-size: 14px; color: var(--muted); }
.var-row input[type=range] { width: 100%; accent-color: var(--accent); }
.mono, #log pre.debug { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
#log pre.debug {
  white-space: pre-wrap; color: var(--muted); background: var(--surface); border: 1px dashed var(--line);
  border-radius: 10px; padding: 10px 12px; margin: 16px 0;
}
#log p.code { text-align: center; color: var(--muted); font-size: 16px; margin: 18px 0 6px; }
#log p.code strong { font-family: ui-monospace, Menlo, monospace; color: var(--accent); font-size: 18px; letter-spacing: .05em; }
#log p.code .hint-small { display: block; font-size: 13px; margin-top: 2px; }
#log .summary { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 16px; margin: 12px 0 20px; }
#log .summary h3 { margin: 0 0 6px; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
#log .summary p { margin: 0; font-size: 17px; min-height: 1em; }
