:root {
  color-scheme: light;
  --ink: #182733;
  --navy: #182733;
  --navy-dark: #101b25;
  --paper: #f6f4ed;
  --white: #fdfbf6;
  --cream: #efe7d7;
  --muted: #4b575e;
  --line: #c9c4b8;
  --bronze: #785f38;
  --serif: Georgia, "Times New Roman", serif;
  --ui: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--ui); }
a { color: inherit; text-underline-offset: .18em; }
a, button { -webkit-tap-highlight-color: transparent; }
button {
  min-height: 46px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white);
  color: inherit;
  font: 680 .91rem/1.35 var(--ui);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--ink); background: #ece9e0; }
button:disabled { cursor: default; opacity: .62; }
:focus-visible { outline: 2px solid #927449; outline-offset: 3px; }
.shell { width: min(100%, 1320px); margin-inline: auto; padding: 0 36px max(14px, env(safe-area-inset-bottom)); }
.topbar { min-height: 73px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.wordmark { display: inline-flex; gap: 11px; align-items: center; text-decoration: none; font: 700 1.17rem/1 var(--serif); white-space: nowrap; }
.wordmark img { flex: none; }
.wordmark-title::before { content: ". "; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.top-link { background: transparent; border-color: transparent; font-weight: 620; }
.top-link:hover:not(:disabled) { border-color: var(--line); }
.eyebrow { margin: 0; font-size: .73rem; letter-spacing: .13em; font-weight: 750; text-transform: uppercase; color: var(--bronze); }

.cover {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  grid-template-areas: "copy portrait" "facts facts";
  border: 1px solid var(--line);
  min-height: min(690px, 82svh);
}
.cover-copy {
  grid-area: copy;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: 560px;
  padding: clamp(28px, 5.6vw, 80px);
  color: #f6f2e7;
  background: var(--navy);
}
.cover-copy .eyebrow { color: #dbcbac; }
.cover h1 { margin: 17px 0 14px; font: 500 clamp(66px, 7.65vw, 111px)/.98 var(--serif); letter-spacing: -.045em; text-transform: uppercase; }
.title-line { display: block; margin-top: 10px; font-size: .36em; letter-spacing: .015em; }
.cover h1:focus, .scene-panel h2:focus { outline: 0; }
.subtitle { margin: 2px 0 16px; color: #e7d7b9; font: 400 clamp(1.23rem,2.25vw,1.85rem)/1.2 var(--serif); }
.summary { max-width: 35ch; margin: 0 0 25px; color: #e0e4e3; font-size: 1rem; }
.cover-actions { display: grid; gap: 8px; width: min(100%, 272px); }
.cover-actions .primary { text-align: left; min-height: 48px; }
.primary { background: var(--cream); color: #172430; border-color: #cabb9e; }
.primary:hover:not(:disabled) { background: #f8efda; border-color: #f8efda; }
.cover-actions #continue:not([hidden]) + #begin { background: transparent; color: #f5efe0; border-color: #8d9799; }
.cover-actions #continue:not([hidden]) + #begin:hover { background: #283b49; border-color: #d9d0bd; }
.menu-link { display: flex; align-items: center; min-height: 44px; width: fit-content; padding: 3px 0; color: #e4ddd0; font-size: .88rem; text-decoration-color: #947e5c; }
.menu-link:hover { color: white; }
.portrait {
  grid-area: portrait;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 13px;
  background: #e0dbcf;
  padding: 25px clamp(20px,4vw,58px) 20px;
}
.portrait img, .scene-portrait img { display: block; width: 100%; object-fit: cover; mix-blend-mode: multiply; }
.portrait img { width: min(100%, 345px); height: clamp(375px, 55svh, 468px); object-fit: contain; object-position: center; }
.portrait figcaption { width: min(100%, 345px); padding-top: 9px; border-top: 1px solid #a9a191; display: grid; gap: 2px; }
.portrait figcaption span { font: 700 1.03rem var(--serif); }
.portrait figcaption small { color: #4c554f; font-size: .74rem; }
.cover-facts { grid-area: facts; display: grid; grid-template-columns: repeat(3,1fr); margin: 0; border-top: 1px solid var(--line); background: var(--white); }
.cover-facts div { padding: 13px clamp(12px,3vw,35px); }
.cover-facts div + div { border-left: 1px solid var(--line); }
.cover-facts dt { color: var(--muted); font-size: .72rem; }
.cover-facts dd { margin: 3px 0 0; font: 700 clamp(.91rem,2vw,1.12rem)/1.25 var(--serif); }
.footer { padding: 13px 0 0; color: var(--muted); font-size: .77rem; }

.play { display: grid; grid-template-columns: 1.02fr 1fr; min-height: 570px; border: 1px solid var(--line); background: var(--white); }
.scene-art {
  position: relative;
  min-height: 365px;
  overflow: hidden;
  background: linear-gradient(0deg,#101b2599,transparent 45%,#101b2577), var(--scene-image,url("assets/irtysh.webp")) var(--image-position,center) / cover, #52604d;
}
.scene-art[data-art="office"] { --scene-image: url("assets/tobolsk.webp"); --image-position: 41% center; }
.scene-art[data-art="lake"] { --scene-image: url("assets/irtysh.webp"); --image-position: 35% center; }
.scene-art[data-art="dark"] { --scene-image: url("assets/irtysh.webp"); --image-position: 72% center; box-shadow: inset 0 0 150px 35px #23324485; }
.scene-art[data-art="fort"] { --scene-image: url("assets/ulba.webp"); --image-position: 55% center; }
.chapter-nav { position: relative; z-index: 2; display: flex; gap: 5px; list-style: none; padding: 0; margin: 18px; }
.chapter-nav li { height: 3px; flex: 1; background: #e7e1d778; }
.chapter-nav li[data-state="done"] { background: #bfab80; }
.chapter-nav li[aria-current] { background: #fff3cd; }
.scene-location {
  position: absolute;
  z-index: 1;
  left: 18px;
  bottom: 18px;
  max-width: calc(100% - 36px);
  padding: 6px 10px;
  background: #182733ed;
  color: #fffaf0;
  font-size: .85rem;
  font-weight: 600;
}
.scene-portrait {
  position: absolute;
  right: 7%;
  bottom: 14%;
  width: min(39%,226px);
  margin: 0;
  padding: 6px;
  background: #e3dbca;
  border: 1px solid #a99e89;
  box-shadow: 0 5px 19px #0f171746;
}
.scene-portrait img { aspect-ratio: 3 / 4; object-position: top; }
.scene-panel { min-width: 0; padding: clamp(21px,4vw,58px); }
.scene-panel h2 { margin: 9px 0 18px; font: 500 clamp(34px,4.6vw,65px)/1.02 var(--serif); letter-spacing: -.038em; }
.passages { color: #273540; font-size: clamp(.98rem,1.3vw,1.07rem); }
.passages p { margin: 0 0 14px; }
.passages .speech { padding-left: 12px; border-left: 2px solid #a99772; }
.speaker { display: block; margin-bottom: 2px; color: var(--bronze); font-weight: 760; letter-spacing: .07em; text-transform: uppercase; font-size: .72rem; }
.outcome { font-size: .87rem; color: #394447; border-left: 2px solid #a99772; background: var(--paper); padding: 7px 10px; margin: 0 0 13px; }
.choices { display: grid; gap: 7px; margin-top: 19px; }
.choices button { text-align: left; }
.choices button.gold { justify-self: start; }
.gold { background: var(--navy); color: var(--white); border-color: var(--navy); }
.gold:hover:not(:disabled) { background: #314454; border-color: #314454; }
.choice-effect { display: block; margin-top: 3px; color: var(--bronze); font-size: .74rem; font-weight: 570; }
.scene-sources { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted); font-size: .83rem; }
.scene-sources summary { width: fit-content; cursor: pointer; }
.scene-sources ul { padding-left: 18px; }
.scene-sources li { margin: 5px 0; }

.exercise { margin: 18px 0 8px; padding: 12px; border: 1px solid var(--line); background: var(--paper); border-radius: 2px; }
.exercise h3 { margin: 0 0 9px; font: 700 1.12rem/1.3 var(--serif); }
.card-list { display: grid; gap: 6px; }
.card-list button { padding: 9px 10px; text-align: left; }
.card-list button[aria-pressed="true"] { border-color: #60766e; background: #e1e8e1; }
.card-list button:disabled[aria-pressed="true"] { opacity: 1; }
.card-list strong, .card-list span { display: block; }
.card-list span { margin-top: 3px; font-weight: 400; color: var(--muted); font-size: .83rem; }
.exercise-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.exercise-message { color: #513c24; margin: 9px 0 0; font-size: .89rem; }
.exercise-message:empty { display: none; }
.crossing-frame { display: block; width: 100%; height: clamp(510px,70svh,680px); margin-top: 9px; border: 1px solid var(--line); background: var(--navy); }

dialog { width: min(calc(100% - 24px), 600px); max-height: 86svh; padding: clamp(15px,4vw,28px); overscroll-behavior: contain; border: 1px solid #9a907c; border-radius: 3px; background: var(--white); color: var(--ink); }
dialog::backdrop { background: #0c1721b8; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 2px 0; font: 500 clamp(25px,7vw,41px)/1.05 var(--serif); }
dialog h3 { margin: 17px 0 5px; color: var(--bronze); font: 700 1.12rem var(--serif); }
dialog p, dialog li { font-size: .92rem; }
dialog p { margin: 7px 0 11px; }
dialog ul { margin: 7px 0; padding-left: 20px; }
dialog li { margin-bottom: 6px; }
.chapter-directory { margin: 4px 0 0; padding-left: 24px; }
.chapter-directory li { padding: 10px 5px; border-bottom: 1px solid var(--line); margin: 0; font-weight: 650; }
.chapter-directory li small { margin-left: 8px; color: var(--bronze); font-size: .72rem; font-weight: 650; }
.journal-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.journal-stats span { border: 1px solid var(--line); border-radius: 2px; padding: 3px 7px; font-size: .83rem; }
.restart-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 761px) {
  .play { overflow: clip; }
  .scene-art { position: sticky; top: 0; align-self: start; height: min(80svh,760px); }
}
@media (max-width: 760px) {
  .shell { padding-inline: max(12px,env(safe-area-inset-left)) max(12px,env(safe-area-inset-right)); padding-top: env(safe-area-inset-top); }
  .topbar { min-height: 57px; margin-bottom: 12px; }
  .wordmark { gap: 7px; font-size: .96rem; white-space: normal; }
  .wordmark img { width: 29px; height: 29px; }
  .wordmark-title { display: block; font-size: .8em; margin-top: 3px; }
  .wordmark-title::before { content: none; }
  .top-link { padding-inline: 8px; font-size: .82rem; }
  .cover { grid-template-columns: 1fr; grid-template-areas: "copy" "portrait" "facts"; }
  .cover-copy { padding: 26px 20px 20px; min-height: auto; }
  .cover h1 { font-size: clamp(49px, 12.8vw, 78px); margin: 11px 0 8px; }
  .title-line { font-size: .47em; margin-top: 6px; }
  .summary { margin-bottom: 15px; }
  .subtitle { margin-bottom: 9px; }
  .cover-actions { width: 100%; }
  .portrait { padding: 15px 20px 12px; gap: 8px; }
  .portrait img { height: clamp(190px,33svh,317px); }
  .portrait figcaption { max-width: 240px; }
  .cover-facts div { padding-inline: 8px; }
  .play { display: block; min-height: 0; }
  .scene-art { min-height: clamp(195px,32svh,345px); }
  .scene-portrait { width: min(28%,138px); bottom: 13%; }
  .scene-location { left: 10px; bottom: 10px; font-size: .78rem; padding: 4px 7px; }
  .scene-panel { padding: 18px 14px 22px; }
  .scene-panel h2 { margin-bottom: 12px; }
  .choices { margin-top: 13px; }
}

.install-link { border: 0; border-radius: 0; background: transparent; text-decoration: underline; text-underline-offset: .18em; text-decoration-color: #947e5c; }
.install-link:hover:not(:disabled) { background: transparent; }
.offline-status { border: 1px solid var(--line); padding: 9px 11px; background: var(--paper); }
.save-transfer { margin-top: 12px; }
.save-transfer summary { font-weight: 650; cursor: pointer; }
.save-transfer label { display: block; margin-bottom: 3px; font-size: .85rem; }
.save-transfer textarea {
  display: block; width: 100%; margin-bottom: 8px; padding: 8px; resize: vertical;
  border: 1px solid var(--line); border-radius: 2px; background: var(--white); color: var(--ink); font: .875rem/1.4 monospace;
}
#save-status:empty { display: none; }
