:root {
  color-scheme: dark;
  --ink: #211c19;
  --paper: #f8ebd7;
  --previous: #cbbfaf;
  --amber: #f7c686;
  --rule: rgb(248 235 215 / 26%);
  font: 16px/1.55 "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--paper); background: var(--ink); }
button { font: inherit; color: inherit; }
:where(button, summary, input, .log):focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 3px;
}
.game {
  --pane-width: clamp(375px, 36vw, 595px);
  --name-size: clamp(42px, min(8.5vh, 5.4vw), 82px);
  --name-gap: calc(var(--name-size) + 26px);
  isolation: isolate;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--pane-width);
  height: 100vh;
  height: 100dvh;
  min-height: 425px;
  /* Keep choice transitions inside the game viewport. The dialogue log scrolls separately. */
  overflow: clip;
}
.stage { position: absolute; inset: 0; overflow: hidden; }
.landscape, .landscape-layer, .bloom { position: absolute; inset: 0; }
.landscape { z-index: -1; }
:is(.landscape, .landscape-layer) {
  background: #242b24 var(--scene-image, url('./assets/station-jiuqi.webp')) 35% center / cover no-repeat;
}
.landscape-layer { pointer-events: none; }
:is(.landscape, .landscape-layer):is([data-scene="dock"], [data-scene="pump"]) { background-position: 38% center; }
:is(.landscape, .landscape-layer):is([data-scene="flight"], [data-scene="axis"]) { background-position: 42% center; }
.game[data-light="blackout"] .portrait {
  filter: brightness(.58) saturate(.56) drop-shadow(-7px 3px 15px rgb(6 11 16 / 68%));
}
.location {
  position: absolute;
  z-index: 2;
  top: clamp(24px, 5vh, 62px);
  left: clamp(23px, 4.5vw, 76px);
  text-shadow: 0 2px 12px #211c19;
}
.location h1 {
  margin: 0;
  font-family: "Songti SC", SimSun, "Noto Serif CJK SC", serif;
  font-size: clamp(32px, 3.8vw, 56px);
  letter-spacing: .18em;
  line-height: 1.15;
}
.location p {
  color: #f6e3c5;
  margin: 9px 0 0;
  font-size: 13px;
  letter-spacing: .2em;
}
.character {
  position: absolute;
  right: var(--pane-width);
  bottom: 0;
  height: 86%;
  width: min(49vw, calc(58vh + var(--name-gap)));
  transition: opacity .35s ease;
}
.game[data-art-focus] .character { opacity: 0; }
:is(.landscape, .landscape-layer)[data-scene^="departure_"] {
  background-color: #080b0b;
  background-position: center;
  background-size: 100% auto;
}
@media (min-width: 761px) {
  :is(.landscape, .landscape-layer)[data-scene^="departure_"] {
    background-position: left center;
    background-size: min(100%, calc((100% - var(--pane-width)) * 1.18)) auto;
  }
}
.portrait {
  position: absolute;
  width: calc(100% - var(--name-gap));
  height: 100%;
  inset: 0 auto auto 0;
  object-fit: contain;
  object-position: right bottom;
  opacity: 0;
  filter: drop-shadow(-7px 3px 15px rgb(17 12 9 / 36%));
  transition: filter .36s ease-out;
}
.portrait.active { opacity: 1; }
.nameplate {
  position: absolute;
  right: 13px;
  bottom: 13%;
  color: #f3e4cb;
  writing-mode: vertical-rl;
  font-family: "Songti SC", SimSun, "Noto Serif CJK SC", serif;
  font-size: var(--name-size);
  letter-spacing: .12em;
  line-height: 1.05;
  text-shadow: 0 2px 15px rgb(12 13 10 / 44%);
}
.nameplate:empty { display: none; }
.bloom { pointer-events: none; opacity: 0; }
.bloom.impact { background: #ffdda6; animation: shutter-blink .55s ease-out; }
.bloom.power-cut { background: #040809; animation: blackout-blink .7s ease-out; }
@keyframes shutter-blink {
  0%, 100% { opacity: 0; }
  15% { opacity: .45; }
}
@keyframes blackout-blink {
  0%, 100% { opacity: 0; }
  24% { opacity: .78; }
}
.pane {
  position: relative;
  grid-column: 2;
  align-self: stretch;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  padding-inline: clamp(24px, 3vw, 48px);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border-inline-start: 1px solid var(--rule);
}
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
}
.pane-header h2 { margin: 0; font-size: 13px; font-weight: 500; letter-spacing: .25em; color: #e4c4a4; }
.audio-controls { display: flex; align-items: center; gap: 14px; }
.sound {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  padding: 6px 0 6px 6px;
  cursor: pointer;
  color: var(--paper);
  font-size: 12px;
}
.sound:hover { color: var(--amber); }
.music-volume {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.music-volume summary { display: block; }
.music-volume summary::-webkit-details-marker { display: none; }
.music-volume[open] summary { color: var(--amber); }
.volume-panel {
  position: absolute;
  inset: calc(100% + 5px) 0 auto auto;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px 12px;
  width: 160px;
  padding: 10px 12px;
  background: #25231d;
  border: 1px solid var(--rule);
  color: var(--paper);
  cursor: default;
  font-size: 12px;
}
.volume-value { color: var(--amber); font-variant-numeric: tabular-nums; }
.volume-panel input {
  grid-column: 1 / -1;
  width: 100%;
  height: 26px;
  margin: 0;
  accent-color: var(--amber);
  cursor: pointer;
}
:is(.sound, .choice, .title-entry) {
  transition: background-color 150ms ease, color 150ms ease, scale 150ms cubic-bezier(.22, .7, .28, 1), translate 150ms ease;
  transform-origin: left center;
}
:is(.sound, .choice, .title-entry):enabled:active {
  scale: .97;
  translate: 0 1px;
}
.log {
  position: relative;
  overflow-y: auto;
  padding: clamp(10px, 4vh, 38px) 14px 20px 0;
  scrollbar-width: none;
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  font-size: clamp(17px, 1.38vw, 21px);
  font-weight: 400;
  line-height: 1.9;
}
.log::-webkit-scrollbar { display: none; }
.log[aria-busy="true"] { cursor: pointer; }
.beat { color: var(--previous); transition: color .22s ease-out; }
.beat + .beat { margin-top: clamp(19px, 4.7vh, 54px); }
.beat:last-child { color: var(--paper); }
.beat p { margin: 0; }
.beat p + p { margin-top: 0.9em; }
.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 6px;
  min-height: calc(112px + clamp(14px, 3vh, 30px));
  border-top: 1px solid var(--rule);
  padding: 12px 0 clamp(14px, 3vh, 30px);
}
.actions[inert]:not([data-leaving]) { visibility: hidden; }
.choice {
  position: relative;
  cursor: pointer;
  padding: 10px 14px 10px 30px;
  text-align: left;
  min-height: 46px;
  border: 0;
  background: transparent;
  line-height: 1.5;
  color: var(--paper);
}
.multiple .choice::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 12px;
  width: 6px;
  height: 6px;
  border: 1px solid var(--amber);
  border-radius: 50%;
  transform: translateY(-50%);
}
.multiple .choice:is(:hover, :focus-visible) {
  background: rgb(236 169 106 / 13%);
  color: var(--amber);
}
.multiple .choice:is(:hover, :focus-visible)::before { background: var(--amber); }
.actions:not(.multiple) .choice {
  padding-inline-start: 21px;
  color: var(--amber);
}
.actions:not(.multiple) .choice::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 8px;
  border-bottom: 1px solid var(--amber);
}
.actions:not(.multiple) .choice:is(:hover, :focus-visible) {
  background: rgb(236 169 106 / 13%);
}
.choice[data-selected] {
  background: rgb(236 169 106 / 21%);
  color: var(--amber);
}
.actions[data-decision] { gap: 8px; }
.actions[data-decision] .choice { border: 1px solid rgb(247 198 134 / 55%); }
@media (max-width: 760px) {
  .game {
    --name-size: clamp(27px, 7vw, 47px);
    --name-gap: calc(var(--name-size) + 14px);
    min-height: 395px;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(130px, 36fr) minmax(244px, 64fr);
  }
  .stage { grid-row: 1; position: relative; }
  :is(.landscape, .landscape-layer) { background-position: 26% center; }
  :is(.landscape, .landscape-layer)[data-detail]:not([data-scene^="departure_"]) {
    background-image: var(--scene-image), var(--scene-image);
    background-position: 26% top, 26% center;
    background-size: max(100vw, 64dvh) auto, cover;
  }
  :is(.landscape, .landscape-layer)[data-scene^="departure_"] {
    background-position: center max(0px, calc(18dvh - 28.15vw));
  }
  .pane { grid-column: 1; grid-row: 2; padding-inline: 22px; border-inline-start: 0; border-block-start: 1px solid var(--rule); }
  .pane-header { padding: 6px 0; }
  .location { top: 20px; left: 24px; }
  .location p { margin-top: 5px; }
  .character { right: 0; height: 98%; width: min(54%, 39vh); }
  .log { line-height: 1.75; padding-top: 7px; }
  .actions { min-height: 109px; padding: 6px 0 10px; }
  .choice { min-height: 43px; }
}
@media (prefers-reduced-motion: reduce) {
  .bloom:is(.impact, .power-cut) { animation: none; }
  .portrait, .beat, .character { transition: none; }
}

.title-screen[hidden], .game[hidden], .title-controls [hidden] { display: none; }
.title-screen {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  background: #111817;
}
.title-viewport {
  position: absolute;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 77% 49%, rgb(103 107 72 / 19%), transparent 65%),
    radial-gradient(ellipse at 22% 78%, #1f2b28, transparent 68%),
    #111817;
}
.title-stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.title-webgl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
}
.title-screen[data-webgl] .title-webgl { visibility: visible; }
.title-screen[data-journey] :is(.title-content, .title-audio) { opacity: 0; transition: opacity .47s ease; }
.title-audio {
  position: absolute;
  top: clamp(15px, 3vh, 31px);
  right: clamp(18px, 3vw, 48px);
}
.title-screen:has(#title-prompt:not([hidden])) .title-audio { display: none; }
.title-screen::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(90deg, rgb(12 17 16 / 47%), rgb(12 17 16 / 22%) 35%, transparent 63%);
  pointer-events: none;
}
.title-content {
  justify-self: start;
  margin-left: clamp(32px, 9vw, 160px);
  padding: 48px 0;
  color: #f5e8cf;
}
.title-content h1 {
  margin: 0 0 clamp(26px, 4.5vh, 56px);
  font-family: "Songti SC", SimSun, "Noto Serif CJK SC", serif;
  font-size: clamp(78px, 10vw, 180px);
  line-height: .98;
  font-weight: 700;
  letter-spacing: .13em;
  text-shadow: 0 6px 24px rgb(12 17 16 / 45%);
}
.title-controls {
  min-height: 195px;
  width: min(250px, 74vw);
}
.title-entry {
  display: flex;
  width: 100%;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  background: rgb(19 24 22 / 32%);
  color: #fae1b6;
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid rgb(239 195 136 / 29%);
  border-inline-start: 2px solid rgb(239 195 136 / 57%);
  font-size: 17px;
  letter-spacing: .1em;
  text-align: left;
  cursor: pointer;
}
#title-prompt {
  min-height: 55px;
  border-color: rgb(239 195 136 / 48%);
  border-inline-start-color: #efc388;
}
.title-entry span { font-size: 20px; line-height: 1; letter-spacing: 0; }
.title-entry:enabled:is(:hover, :focus-visible) {
  background: #f1d0a1;
  color: #241d16;
}
.title-entry:disabled {
  color: #c0af98;
  border-color: rgb(239 195 136 / 19%);
  cursor: default;
}
.title-entry[data-confirmed] {
  background: #f1d0a1;
  color: #241d16;
}
.title-menu {
  display: grid;
  gap: 6px;
}
#chapter-menu { max-height: 54svh; overflow-y: auto; overscroll-behavior: contain; }
#chapter-menu h2 { padding-bottom: 4px; }
.title-menu h2 { margin: 0; font-size: 15px; font-weight: 500; }
.title-menu p {
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid rgb(239 195 136 / 32%);
}
.title-menu p span { font-size: 13px; color: #d0b79a; }
@media (hover: hover) {
  .title-entry:enabled:hover { translate: 3px 0; }
  .title-entry:enabled:active { translate: 0 1px; }
}
@media (max-width: 640px) and (orientation: portrait) {
  .title-screen { align-items: end; }
  .title-screen::after { background: linear-gradient(180deg, transparent 44%, rgb(12 17 16 / 80%)); }
  .title-content { margin-left: 28px; padding: 0 16px clamp(33px, 6svh, 70px) 0; }
  .title-content h1 { font-size: clamp(68px, 18vw, 110px); margin-bottom: 27px; }
}
@media (prefers-reduced-motion: reduce) {
  :is(.sound, .choice, .title-entry) { transition: none; scale: none; translate: none; }
}

.game[data-atlas] { background: #101719; }
.game[data-atlas] .stage { position: absolute; inset: 0; }
.game[data-atlas] .pane, .game[data-atlas] .stage > :is(.location, .character, .bloom) {
  opacity: 0;
  visibility: hidden;
}
.atlas-art { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: #0a0c0b; }
.atlas-art img { width: 100%; height: 100%; display: block; object-fit: contain; }
.station-atlas { position: absolute; inset: 0; z-index: 5; color: #f5e8cd; }
.station-atlas[hidden] { display: none; }
.atlas-heading { position: absolute; top: 7vh; left: 6vw; pointer-events: none; }
.atlas-heading h1 {
  margin: .04em 0 .12em;
  font: 600 clamp(48px, 6vw, 91px)/1.05 "Songti SC", SimSun, serif;
  letter-spacing: .13em;
}
.atlas-heading p { margin: 0; color: #d4bd98; font-size: 12px; letter-spacing: .12em; }
.atlas-menu { position: absolute; z-index: 3; right: clamp(16px, 4vw, 74px); top: 7vh; }
.station-nodes { position: absolute; inset: 0; pointer-events: none; }
.station-pin {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #f8d79f;
  pointer-events: none;
}
.station-pin svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.station-pin line { stroke: currentColor; stroke-width: 1; opacity: .62; }
.station-pin i {
  position: absolute;
  top: var(--pin-y,50%);
  left: var(--pin-x,50%);
  width: 10px;
  height: 10px;
  background: #3f3523;
  border: 1px solid currentColor;
  transform: translate(-50%,-50%) rotate(45deg);
}
.station-pin span {
  position: absolute;
  display: grid;
  place-items: center;
  top: var(--label-y,50%);
  left: var(--label-x,50%);
  min-width: 112px;
  min-height: 37px;
  padding: 4px 10px;
  border: 1px solid currentColor;
  background: rgb(18 23 21 / 93%);
  transform: translate(-50%,-50%);
  transition: color .17s ease, background .17s ease, transform .17s ease;
  white-space: nowrap;
}
.station-pin:enabled { z-index: 1; }
.station-pin:enabled :is(span,i) { pointer-events: auto; cursor: pointer; }
.station-pin:enabled i::after { content: ''; position: absolute; inset: -9px; }
.station-pin:enabled:is(:hover,:focus-visible) span {
  color: #292017;
  background: #ebc48d;
}
.station-pin:enabled:active span { transform: translate(-50%,-50%) scale(.96); }
.station-pin:focus-visible { outline: none; }
.station-pin:focus-visible span { outline: 1px solid #f8d79f; outline-offset: 4px; }
.station-pin:disabled { color: #a4aaa0; }
.station-pin:disabled span { border-color: #68746b; }
@media (max-width: 760px) {
  .atlas-heading { top: 5vh; }
  .atlas-menu { top: 5vh; }
  .station-pin span { min-width: 96px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .station-pin span { transition: none; }
}
