:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }

.theme-winter {
  --bg: #0b1020;
  --ink: #ece6d8;
  --muted: #a9b1c2;
  --accent: #e9b85a;
  --button: #e9b85a;
  --button-ink: #15192b;
  --line: rgba(236, 230, 216, .16);
  --choice-bg: #182036;
  --focus: #e9b85a;
  --warn: #e08a7a;
  color-scheme: dark;
  background: radial-gradient(95% 85% at 15% 0, #1d2742, var(--bg));
}

body { color: var(--ink); font-family: Georgia, "Times New Roman", serif; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
h1:focus { outline: none; }

.reader { display: flex; flex-direction: column; width: min(100%, 1380px); height: 100vh; height: 100svh; margin-inline: auto; padding-inline: clamp(16px, 3vw, 38px); }
.topbar { display: flex; align-items: center; gap: 20px; min-height: 64px; border-bottom: 1px solid var(--line); font: 600 .93rem/1.3 system-ui, -apple-system, sans-serif; }
.home { flex: none; color: var(--accent); text-decoration: none; }
.home:hover { text-decoration: underline; text-underline-offset: 4px; }
.book-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.progress { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.stage { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-block: 24px 32px; }
.page { display: grid; gap: clamp(26px, 3vw, 44px); animation: appear .45s ease both; }
.visual { position: relative; align-self: start; margin: 0; overflow: hidden; aspect-ratio: 3 / 2; border-radius: 18px; background: var(--choice-bg); box-shadow: 0 22px 50px -32px rgba(0, 0, 0, .8); }
.visual img { display: block; width: 100%; height: 100%; object-fit: cover; }
.copy { max-width: 40em; }
.copy h1 { margin: 0 0 .7em; color: var(--accent); font-size: clamp(1.65rem, 2.4vw, 2.45rem); font-weight: 700; line-height: 1.16; text-wrap: balance; }
.copy p { margin: 0 0 .85em; font-size: clamp(1.09rem, .94rem + .48vw, 1.29rem); line-height: 1.65; text-wrap: pretty; }

.party { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 18px; }
.party img { width: 46px; height: 46px; object-fit: cover; object-position: 50% 18%; border: 2px solid var(--accent); border-radius: 50%; }
.items { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; font: 600 .8rem/1.3 system-ui, -apple-system, sans-serif; }
.items li { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

.choice-heading { margin: 1.4em 0 12px; color: var(--accent); font: 700 .8rem/1.3 system-ui, -apple-system, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.choices { display: grid; gap: 12px; margin-bottom: 16px; }
.choice { display: block; width: 100%; min-height: 56px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--choice-bg); color: var(--ink); text-align: left; cursor: pointer; font: 600 1rem/1.4 system-ui, -apple-system, sans-serif; transition: transform .18s ease, border-color .18s ease; }
.choice:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.choice.locked { opacity: .55; cursor: default; border-style: dashed; }
.choice.locked span { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; font-style: italic; font-weight: 500; }

.next { display: inline-flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 22px; border: 0; border-radius: 999px; background: var(--button); color: var(--button-ink); cursor: pointer; font: 700 1rem/1.2 system-ui, -apple-system, sans-serif; }
.next:hover:not(:disabled) { filter: brightness(1.08); }
.next:disabled { opacity: .4; cursor: default; }
.continue { margin-top: 1.2em; }

.end { margin-block: 18px 24px; padding-top: 18px; border-top: 1px solid var(--line); font: 600 1rem/1.5 system-ui, -apple-system, sans-serif; }
.end p { font: inherit; color: var(--muted); }
.again { min-height: 48px; padding: 10px 18px; border: 1px solid var(--accent); border-radius: 999px; background: transparent; color: var(--accent); cursor: pointer; font: 700 .95rem/1.2 system-ui, -apple-system, sans-serif; }
.again:hover { background: var(--choice-bg); }

.navigation { display: flex; align-items: center; gap: 14px; min-height: 74px; padding-block: 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
.back { min-height: 46px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer; font: 600 .92rem/1.2 system-ui, -apple-system, sans-serif; }
.back:disabled { opacity: .35; cursor: default; }

.cast { max-width: 1100px; animation: appear .45s ease both; }
.cast h1 { margin: 0 0 .4em; color: var(--accent); font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; }
.cast .hint { margin-bottom: 1.6em; color: var(--muted); }
.resume { margin-bottom: 30px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--choice-bg); }
.resume p { margin-bottom: 12px; }
.characters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 26px; }
.character { display: block; width: 100%; padding: 0 0 16px; border: 2px solid var(--line); border-radius: 18px; background: var(--choice-bg); color: var(--ink); text-align: left; cursor: pointer; overflow: hidden; transition: border-color .18s ease, transform .18s ease; }
.character:hover { transform: translateY(-3px); }
.character[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233, 184, 90, .25); }
.character img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 15%; }
.character h2 { margin: 14px 16px 6px; font-size: 1.25rem; color: var(--accent); }
.character .intro { margin: 0 16px 12px; font-size: .98rem; line-height: 1.5; }
.character dl { margin: 0 16px; font: .86rem/1.45 system-ui, -apple-system, sans-serif; }
.character dt { margin-top: 8px; font-weight: 700; }
.character dt.weakness { color: var(--warn); }
.character dd { margin: 0; color: var(--muted); }

@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-width: 880px) and (orientation: landscape) {
  .page { min-height: 100%; grid-template-columns: minmax(0, 1.28fr) minmax(0, 1fr); align-items: start; }
  .visual { position: sticky; top: 24px; width: 100%; max-height: calc(100svh - 194px); }
  .copy { padding: 8px 12px 24px 0; }
}
@media (max-width: 760px) {
  .characters { grid-template-columns: 1fr; }
  .character { display: grid; grid-template-columns: 112px 1fr; column-gap: 4px; padding-bottom: 12px; }
  .character img { grid-row: 1 / span 4; aspect-ratio: auto; height: 100%; }
}
@media (max-width: 640px) {
  .topbar { min-height: 54px; }
  .book-title { display: none; }
  .stage { padding-top: 16px; }
  .page { gap: 20px; }
  .copy h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .page, .cast { animation: none; }
  .choice, .character { transition: none; }
}
