:root {
  --bg: #f7f3ec; --ink: #2a2420; --muted: #7a6f66; --rule: #ddd3c6; --accent: #7b2d26; --card: #fffdf9; --chosen: #efe6da;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16130f; --ink: #e9e1d6; --muted: #a2968a; --rule: #3a322b; --accent: #d98a6c; --card: #201b16; --chosen: #2a231d; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1.125rem/1.7 Georgia, 'Iowan Old Style', 'Palatino Linotype', serif; }
button { font: inherit; cursor: pointer; }

.bar { position: sticky; top: 0; z-index: 2; display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 1rem 0.6rem; background: var(--bg); border-bottom: 1px solid var(--rule);
  font: 0.9rem/1.3 system-ui, sans-serif; }
.bar .title { font-weight: 600; letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .tools { display: flex; gap: 0.5rem; flex-shrink: 0; }
.bar button { background: none; border: 1px solid var(--rule); color: var(--ink); border-radius: 999px; padding: 0.3rem 0.9rem; font-size: 0.85rem; }
.bar button:disabled { opacity: 0.4; cursor: default; }

#story { max-width: 40rem; margin: 0 auto; padding: 1.5rem 1.25rem 6rem; }
.chapter { font: 600 0.85rem/1.3 system-ui, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
  margin: 3rem 0 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.chapter:first-child { margin-top: 0.5rem; border-top: none; }
.scene { scroll-margin-top: 4rem; }
.scene p { margin: 0 0 1.1em; }

.choices { display: grid; gap: 0.6rem; margin: 2rem 0 1rem; }
.choice { text-align: left; background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 0.8rem 1rem; line-height: 1.45; }
.choice:hover, .choice:focus-visible { border-color: var(--accent); outline: none; }
.speech { display: block; margin-top: 0.35rem; font-style: italic; color: var(--muted); }

.chosen { margin: 1.5rem 0 2rem; padding: 0.7rem 1rem; background: var(--chosen); border-radius: 6px; font: 0.95rem/1.45 system-ui, sans-serif; }
.chosen .you::before { content: 'You chose: '; color: var(--muted); }
.chosen .speech { font-family: Georgia, serif; }
.rewind { display: block; margin-top: 0.4rem; padding: 0; background: none; border: none; color: var(--accent); font-size: 0.85rem; text-decoration: underline; }

.fin { font-style: italic; text-align: center; margin-top: 2.5rem; }
.fin-sub { text-align: center; color: var(--muted); font: 0.9rem/1.4 system-ui, sans-serif; }
.error { color: #b3261e; }

.login { max-width: 26rem; margin: 0 auto; padding: calc(3rem + env(safe-area-inset-top, 0px)) 1.25rem 3rem; }
.login h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 0.3rem; }
.login .sub { color: var(--muted); margin: 0 0 1.5rem; font: 0.95rem/1.4 system-ui, sans-serif; }
.login .note { font: 0.9rem/1.45 system-ui, sans-serif; border-left: 3px solid var(--accent); padding: 0.4rem 0.8rem; background: var(--card); }
.login form { display: grid; gap: 1rem; margin-top: 1.5rem; font-family: system-ui, sans-serif; font-size: 0.95rem; }
.login label { display: grid; gap: 0.35rem; }
.login .hint { color: var(--muted); font-size: 0.85rem; }
.login input { font: inherit; padding: 0.6rem 0.7rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink); }
.login button { padding: 0.7rem; border: none; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; }
