:root {
  color-scheme: dark;
  --ink-0: #080b0a;
  --ink-1: #101513;
  --ink-2: #17201d;
  --paper: #ebe5d7;
  --paper-dim: #b9b4a8;
  --jade: #83b2a7;
  --jade-bright: #b8ddd3;
  --cinnabar: #b64f3d;
  --amber: #d6a75f;
  --danger: #d77562;
  --glass: rgba(14, 19, 17, 0.76);
  --glass-deep: rgba(8, 12, 11, 0.91);
  --line: rgba(220, 226, 213, 0.15);
  --soft-line: rgba(220, 226, 213, 0.08);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --ui-scale: 1;
  --keyboard-lift: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink-0);
}

body {
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input,
select {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--jade-bright);
  outline-offset: 3px;
}

.is-hidden {
  display: none !important;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 20px;
  background:
    radial-gradient(circle at center, rgba(75, 103, 94, 0.15), transparent 42%),
    #090c0b;
  transition: opacity 280ms ease, visibility 280ms ease;
}

.boot-screen.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-mark {
  width: 88px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(232, 227, 214, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 80px rgba(103, 153, 139, 0.18);
  animation: ink-breathe 1.8s ease-in-out infinite alternate;
}

.boot-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.boot-screen p {
  margin: 0;
  color: var(--paper-dim);
  font-family: var(--serif);
  letter-spacing: 0.28em;
}

.game-shell {
  --parallax-x: 0%;
  --parallax-y: 0%;
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  transform: scale(var(--ui-scale));
  transform-origin: center;
}

.world-art,
.world-mist,
.spirit-current,
.distant-lightning,
.world-vignette,
.weather-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-art {
  z-index: -6;
  background:
    linear-gradient(180deg, rgba(3, 5, 4, 0.08), rgba(3, 5, 4, 0.56)),
    url("assets/qiyuwu-dusk.jpg") center 46% / cover no-repeat;
  transform: scale(1.025);
  animation: world-drift 24s ease-in-out infinite alternate;
  transition: filter 900ms ease, opacity 900ms ease;
  will-change: transform, filter;
}

.game-shell[data-biome="ember_desert"] .world-art,
.game-shell[data-biome="thunder_plain"] .world-art {
  filter: sepia(0.24) saturate(1.12) hue-rotate(338deg);
}

.game-shell[data-biome="frost_sea"] .world-art,
.game-shell[data-biome="void_isles"] .world-art {
  filter: saturate(0.76) hue-rotate(34deg) brightness(0.9);
}

.game-shell[data-biome="ancient_forest"] .world-art,
.game-shell[data-biome="spirit_river"] .world-art {
  filter: saturate(1.08) hue-rotate(8deg);
}

.game-shell[data-biome="abyss_rift"] .world-art,
.game-shell[data-biome="ruin_belt"] .world-art {
  filter: grayscale(0.28) contrast(1.08) brightness(0.78);
}

.world-mist {
  z-index: -5;
  overflow: hidden;
  opacity: 0.42;
  mix-blend-mode: screen;
}

.world-mist i {
  position: absolute;
  width: 78vw;
  height: 24vh;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(194, 215, 206, 0.2), rgba(120, 155, 145, 0.08) 42%, transparent 72%);
  filter: blur(28px);
  animation: mist-sail 30s linear infinite;
  will-change: transform;
}

.world-mist i:first-child {
  top: 24%;
  left: -30%;
}

.world-mist i:last-child {
  right: -34%;
  bottom: 17%;
  opacity: 0.55;
  animation-duration: 42s;
  animation-direction: reverse;
}

.spirit-current {
  z-index: -4;
  overflow: hidden;
  opacity: 0.34;
  filter: blur(0.4px);
}

.spirit-current i {
  position: absolute;
  right: -12%;
  bottom: 8%;
  width: 86%;
  height: 22%;
  border-top: 1px solid rgba(111, 209, 186, 0.38);
  border-radius: 50%;
  box-shadow: 0 -8px 26px rgba(85, 179, 158, 0.08);
  transform: rotate(-7deg);
  animation: spirit-river 9s ease-in-out infinite;
  will-change: transform, opacity;
}

.spirit-current i:nth-child(2) {
  right: -4%;
  bottom: 3%;
  width: 68%;
  opacity: 0.5;
  animation-delay: -3s;
  animation-duration: 12s;
}

.spirit-current i:nth-child(3) {
  right: 14%;
  bottom: 14%;
  width: 45%;
  opacity: 0.32;
  animation-delay: -7s;
  animation-duration: 15s;
}

.distant-lightning {
  z-index: -3;
  background: radial-gradient(circle at 72% 13%, rgba(191, 218, 214, 0.26), transparent 22%);
  opacity: 0;
  animation: distant-flash 17s linear infinite;
}

.world-vignette {
  z-index: -2;
  background:
    radial-gradient(ellipse at 50% 47%, transparent 20%, rgba(4, 7, 6, 0.18) 57%, rgba(4, 7, 6, 0.78) 100%),
    linear-gradient(180deg, rgba(4, 7, 6, 0.63), transparent 20%, transparent 68%, rgba(4, 7, 6, 0.8));
}

.weather-layer {
  z-index: -1;
  opacity: 0.4;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.weather-layer i {
  position: absolute;
  inset: -30% 0 0;
  background-image: repeating-linear-gradient(102deg, transparent 0 18px, rgba(210, 228, 224, 0.13) 19px, transparent 20px 38px);
  animation: rain-fall 1.4s linear infinite;
  will-change: transform;
}

.weather-layer i:nth-child(2) {
  opacity: 0.45;
  transform: translateX(24%);
  animation-duration: 1.9s;
}

.weather-layer i:nth-child(3) {
  opacity: 0.25;
  transform: translateX(-31%);
  animation-duration: 2.6s;
}

.glass-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 32%),
    var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(0.85);
  -webkit-backdrop-filter: blur(18px) saturate(0.85);
}

.top-hud {
  position: absolute;
  z-index: 20;
  top: max(18px, env(safe-area-inset-top));
  left: max(22px, env(safe-area-inset-left));
  right: max(22px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.player-card,
.location-card {
  pointer-events: auto;
}

.player-card {
  display: flex;
  width: min(330px, 34vw);
  min-width: 270px;
  gap: 13px;
  padding: 10px 14px 10px 10px;
  border-radius: 8px 20px 8px 20px;
}

.portrait-button {
  position: relative;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(211, 223, 214, 0.32);
  border-radius: 50% 42% 50% 42%;
  background:
    radial-gradient(circle at 38% 30%, rgba(183, 217, 205, 0.36), transparent 22%),
    linear-gradient(145deg, #3e5b53, #121917 68%);
  box-shadow: 0 0 0 4px rgba(126, 162, 151, 0.08), inset 0 0 25px rgba(0, 0, 0, 0.35);
}

.portrait-button::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(235, 229, 216, 0.16);
  border-radius: inherit;
}

#portrait-glyph {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  opacity: 0.9;
}

.portrait-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 26%;
  transform: scale(1.03);
}

.player-overview {
  flex: 1;
  min-width: 0;
}

.player-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.player-title-row strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.realm-label {
  color: var(--jade-bright);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.vital-row {
  display: grid;
  grid-template-columns: 30px minmax(62px, 1fr) 28px;
  align-items: center;
  gap: 7px;
  height: 13px;
  color: var(--paper-dim);
  font-size: 9px;
}

.vital-track {
  height: 3px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.vital-track b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 700ms cubic-bezier(.2, .8, .2, 1);
}

[data-vital="body"] .vital-track b {
  background: linear-gradient(90deg, #8f493f, #d67862);
  box-shadow: 0 0 8px rgba(214, 120, 98, 0.5);
}

[data-vital="spirit"] .vital-track b {
  background: linear-gradient(90deg, #3d7469, #86c4b4);
  box-shadow: 0 0 8px rgba(113, 190, 171, 0.45);
}

[data-vital="mana"] .vital-track b {
  background: linear-gradient(90deg, #586a96, #9bace1);
  box-shadow: 0 0 8px rgba(138, 155, 216, 0.4);
}

.location-card {
  display: flex;
  align-items: center;
  min-width: 225px;
  gap: 13px;
  padding: 11px 15px 11px 11px;
  border-radius: 20px 8px 20px 8px;
  text-align: right;
}

.location-card > div:last-child {
  display: grid;
  justify-items: end;
}

.location-card small {
  color: var(--amber);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.location-card strong {
  margin-top: 2px;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.14em;
}

.location-card span {
  margin-top: 1px;
  color: var(--paper-dim);
  font-size: 9px;
}

.compass {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-content: center;
  border: 1px solid rgba(216, 220, 208, 0.23);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(107, 139, 130, 0.16), transparent 67%);
}

.compass > span:last-child {
  position: absolute;
  top: -6px;
  left: 50%;
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 8px;
  transform: translateX(-50%);
}

.compass-needle {
  width: 2px;
  height: 25px;
  margin: auto;
  border-radius: 50%;
  background: linear-gradient(var(--cinnabar) 0 45%, var(--paper-dim) 45%);
  box-shadow: 0 0 7px rgba(175, 69, 52, 0.35);
  transform: rotate(35deg);
  transition: transform 600ms ease;
}

.story-stage {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(880px, calc(100vw - 70px));
  max-height: calc(100vh - 202px);
  gap: 9px;
  transform: translate(-50%, -48%);
}

.chapter-ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(235, 229, 215, 0.72);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8);
}

.chapter-ribbon::before,
.chapter-ribbon::after {
  content: "";
  width: min(90px, 10vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 222, 210, 0.36));
}

.chapter-ribbon::after {
  background: linear-gradient(90deg, rgba(224, 222, 210, 0.36), transparent);
}

.chapter-ribbon b {
  color: var(--paper);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.3em;
}

.story-panel {
  position: relative;
  min-height: 192px;
  max-height: 42vh;
  padding: 22px 28px 20px 116px;
  overflow: auto;
  border-radius: 8px 28px 8px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 173, 161, 0.35) transparent;
}

.story-panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(236, 231, 216, 0.055);
  border-radius: 5px 23px 5px 23px;
  pointer-events: none;
}

.speaker-strip {
  position: absolute;
  top: 23px;
  left: 22px;
  display: grid;
  width: 77px;
  justify-items: center;
  text-align: center;
}

.speaker-strip img {
  width: 70px;
  height: 86px;
  object-fit: cover;
  object-position: 55% 28%;
  border: 1px solid rgba(227, 225, 211, 0.2);
  border-radius: 24px 6px 24px 6px;
  filter: saturate(0.75) contrast(1.04);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}

.speaker-strip > div {
  display: grid;
  width: 100px;
  justify-items: center;
  margin-top: 7px;
}

.speaker-strip small {
  color: var(--paper-dim);
  font-size: 8px;
}

.speaker-strip strong {
  margin: 2px 0;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.12em;
}

.speaker-strip span {
  color: var(--jade);
  font-size: 8px;
}

.story-copy {
  color: #e9e4d7;
  font-family: var(--serif);
  font-size: clamp(14px, 1.45vw, 16px);
  line-height: 1.92;
  letter-spacing: 0.055em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.story-copy p {
  margin: 0 0 0.82em;
}

.story-copy p:last-child {
  margin-bottom: 0;
}

.story-copy q {
  color: #f1dfbc;
  quotes: none;
}

.story-copy q::before,
.story-copy q::after {
  content: none;
}

.story-copy .impact {
  color: var(--jade-bright);
}

.decision-prompt {
  margin: 15px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--soft-line);
  color: var(--amber);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.choice-card {
  position: relative;
  display: grid;
  grid-template-columns: 31px 1fr;
  gap: 9px;
  min-height: 62px;
  padding: 10px 13px;
  overflow: hidden;
  border: 1px solid rgba(218, 221, 209, 0.14);
  border-radius: 6px 16px 6px 16px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.035), transparent 42%),
    rgba(9, 14, 12, 0.81);
  text-align: left;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.23);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.choice-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 35%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(151, 194, 182, 0.65));
  opacity: 0;
  transition: opacity 180ms ease;
}

.choice-card:hover,
.choice-card:focus-visible {
  border-color: rgba(139, 190, 177, 0.52);
  background:
    linear-gradient(120deg, rgba(130, 178, 164, 0.1), transparent 46%),
    rgba(12, 19, 16, 0.92);
  transform: translateY(-2px);
}

.choice-card:hover::after {
  opacity: 1;
}

.choice-number {
  display: grid;
  width: 27px;
  height: 27px;
  place-content: center;
  border: 1px solid rgba(227, 226, 213, 0.19);
  border-radius: 50%;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 11px;
}

.choice-main {
  display: block;
  margin: 0 0 5px;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.035em;
}

.choice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  color: var(--paper-dim);
  font-size: 8px;
}

.choice-meta .risk::before,
.choice-meta .chance::before {
  margin-right: 4px;
}

.choice-meta .risk::before {
  content: "險";
  color: var(--danger);
}

.choice-meta .chance::before {
  content: "機";
  color: var(--jade-bright);
}

.free-action {
  padding: 9px 12px 8px;
  border-radius: 7px 18px 7px 18px;
  transition: transform 220ms ease;
}

.free-action label {
  display: block;
  margin-bottom: 5px;
  color: var(--jade-bright);
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.free-input-row {
  display: flex;
  gap: 8px;
}

.free-action textarea {
  flex: 1;
  min-height: 31px;
  max-height: 86px;
  padding: 6px 8px;
  resize: none;
  border: 0;
  border-bottom: 1px solid rgba(228, 224, 212, 0.18);
  background: transparent;
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.55;
}

.free-action textarea::placeholder {
  color: rgba(196, 193, 182, 0.44);
}

.free-action button {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid rgba(129, 177, 163, 0.32);
  border-radius: 5px 12px 5px 12px;
  background: rgba(75, 116, 104, 0.17);
  color: var(--jade-bright);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.free-action kbd {
  padding: 2px 5px;
  border: 1px solid rgba(225, 225, 212, 0.14);
  border-radius: 3px;
  color: var(--paper-dim);
  font-family: var(--sans);
  font-size: 7px;
}

.intent-hint {
  height: 0;
  overflow: hidden;
  color: var(--paper-dim);
  font-size: 8px;
  opacity: 0;
  transition: height 180ms ease, opacity 180ms ease, padding 180ms ease;
}

.free-action:focus-within .intent-hint {
  height: 18px;
  padding-top: 7px;
  opacity: 0.75;
}

.free-action.is-thinking button {
  pointer-events: none;
}

.free-action.is-thinking button span::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 7px 0 currentColor, 14px 0 currentColor;
  animation: dots 900ms infinite;
}

.pulse-stack {
  position: absolute;
  z-index: 15;
  right: max(22px, env(safe-area-inset-right));
  bottom: calc(86px + env(safe-area-inset-bottom));
  display: grid;
  width: min(270px, 28vw);
  gap: 7px;
  pointer-events: none;
}

.pulse {
  padding: 9px 11px;
  border-left: 2px solid var(--jade);
  border-radius: 2px 9px 2px 9px;
  background: rgba(7, 11, 9, 0.75);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  animation: pulse-in 420ms ease both;
}

.pulse small {
  display: block;
  margin-bottom: 2px;
  color: var(--jade-bright);
  font-size: 8px;
  letter-spacing: 0.13em;
}

.pulse span {
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 10px;
  line-height: 1.5;
}

.bottom-nav {
  position: absolute;
  z-index: 30;
  bottom: max(13px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  gap: 3px;
  padding: 6px;
  border: 1px solid rgba(220, 223, 211, 0.14);
  border-radius: 24px 8px 24px 8px;
  background: rgba(8, 12, 10, 0.85);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.bottom-nav button {
  position: relative;
  display: grid;
  width: 67px;
  height: 52px;
  place-content: center;
  justify-items: center;
  gap: 2px;
  border-radius: 16px 5px 16px 5px;
  background: transparent;
  color: rgba(225, 222, 210, 0.62);
  transition: color 150ms ease, background 150ms ease;
}

.bottom-nav button:hover,
.bottom-nav button.active {
  background: rgba(105, 151, 138, 0.12);
  color: var(--jade-bright);
}

.bottom-nav svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.bottom-nav span {
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.bottom-nav em {
  position: absolute;
  top: 4px;
  right: 8px;
  display: none;
  min-width: 14px;
  height: 14px;
  place-content: center;
  border-radius: 8px;
  background: var(--cinnabar);
  color: #fff;
  font-size: 7px;
  font-style: normal;
}

.bottom-nav em.has-items {
  display: grid;
}

.drawer {
  position: absolute;
  z-index: 60;
  right: 20px;
  bottom: 83px;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(470px, calc(100vw - 40px));
  max-height: min(670px, calc(100vh - 130px));
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(218, 222, 209, 0.18);
  border-radius: 9px 32px 9px 32px;
  background:
    linear-gradient(145deg, rgba(146, 180, 168, 0.06), transparent 30%),
    rgba(8, 12, 10, 0.94);
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(24px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 200ms ease, transform 200ms ease;
}

.drawer.open {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.drawer-handle {
  display: none;
}

.drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--soft-line);
}

.drawer header small {
  color: var(--jade);
  font-size: 8px;
  letter-spacing: 0.18em;
}

.drawer h2 {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.2em;
}

.drawer header button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--soft-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.025);
  color: var(--paper-dim);
  font-size: 22px;
}

.drawer-content {
  padding: 18px 22px 26px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.panel-lead {
  margin: 0 0 16px;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.7;
}

.panel-section-title {
  margin: 22px 0 9px;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.data-card,
.item-card,
.relation-card,
.art-card {
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 5px 15px 5px 15px;
  background: rgba(255, 255, 255, 0.025);
  content-visibility: auto;
  contain-intrinsic-size: 112px;
}

.story-copy,
.choices,
.drawer-content {
  contain: layout paint style;
}

.data-card small,
.item-card small,
.relation-card small,
.art-card small {
  display: block;
  margin-bottom: 4px;
  color: var(--jade);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.data-card strong,
.item-card strong,
.relation-card strong,
.art-card strong {
  font-family: var(--serif);
  font-size: 12px;
}

.data-card p,
.item-card p,
.relation-card p,
.art-card p {
  margin: 6px 0 0;
  color: var(--paper-dim);
  font-size: 9px;
  line-height: 1.6;
}

.data-card.locked-lore {
  border-style: dashed;
  opacity: 0.58;
}

.lamp-card {
  position: relative;
  min-height: 125px;
  overflow: hidden;
}

.lamp-card::after {
  position: absolute;
  right: 10px;
  bottom: -17px;
  color: rgba(238, 221, 182, 0.04);
  content: "燈";
  font-family: var(--serif);
  font-size: 68px;
  line-height: 1;
  pointer-events: none;
}

.lamp-active {
  border-color: rgba(206, 171, 96, 0.38);
  background: radial-gradient(circle at 100% 0%, rgba(211, 168, 78, 0.13), transparent 52%), rgba(255, 255, 255, 0.025);
}

.lamp-active small {
  color: var(--gold);
}

.lamp-sealed {
  background: radial-gradient(circle at 100% 0%, rgba(117, 93, 128, 0.1), transparent 52%), rgba(255, 255, 255, 0.018);
}

.lamp-source {
  border-color: rgba(119, 194, 173, 0.55);
  box-shadow: inset 0 0 28px rgba(104, 172, 153, 0.08);
}

.lamp-source small {
  color: var(--jade-bright);
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.item-card {
  position: relative;
  min-height: 104px;
}

.item-icon {
  display: grid;
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  place-content: center;
  border: 1px solid rgba(134, 179, 166, 0.22);
  border-radius: 50%;
  color: var(--jade-bright);
  font-family: var(--serif);
}

.item-quantity {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--paper-dim);
  font-size: 9px;
}

.relation-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
}

.relation-avatar {
  display: grid;
  width: 42px;
  height: 50px;
  place-content: center;
  overflow: hidden;
  border-radius: 14px 4px 14px 4px;
  background: #1b2521;
  color: var(--jade-bright);
  font-family: var(--serif);
}

.relation-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.relation-meter {
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.relation-meter b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cinnabar), var(--jade));
}

.map-canvas {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 9px 24px 9px 24px;
  background:
    radial-gradient(circle at 35% 48%, rgba(99, 143, 131, 0.18), transparent 15%),
    repeating-radial-gradient(ellipse at 50% 50%, transparent 0 28px, rgba(222, 221, 205, 0.035) 29px 30px),
    #0d1210;
}

.map-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(22deg, transparent 47%, rgba(161, 179, 170, 0.1) 48% 49%, transparent 50%),
    linear-gradient(-18deg, transparent 51%, rgba(161, 179, 170, 0.08) 52% 53%, transparent 54%);
  opacity: 0.7;
}

.map-node {
  position: absolute;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 4px;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 9px;
}

.map-node::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #111a17;
  box-shadow: 0 0 0 5px rgba(121, 164, 152, 0.06);
}

.map-node.current {
  color: var(--jade-bright);
}

.map-node.current::before {
  background: var(--jade);
  box-shadow: 0 0 18px rgba(126, 190, 172, 0.5);
}

.map-node.locked {
  filter: blur(1px);
  opacity: 0.28;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 50px;
  padding: 9px 0;
  border-bottom: 1px solid var(--soft-line);
}

.setting-row > span {
  display: grid;
  gap: 3px;
}

.setting-row strong {
  font-family: var(--serif);
  font-size: 11px;
}

.setting-row small {
  color: var(--paper-dim);
  font-size: 8px;
}

.setting-row button,
.settings-actions button {
  padding: 8px 12px;
  border: 1px solid rgba(129, 176, 162, 0.23);
  border-radius: 5px 11px 5px 11px;
  background: rgba(107, 153, 140, 0.09);
  color: var(--jade-bright);
  font-size: 9px;
}

.setting-row > b {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid rgba(129, 176, 162, 0.2);
  border-radius: 12px;
  color: var(--jade-bright);
  font-size: 8px;
  font-weight: 500;
}

.settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 17px;
}

.settings-actions button.danger {
  border-color: rgba(204, 105, 84, 0.26);
  color: #e29280;
}

.modal-layer {
  position: absolute;
  z-index: 90;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 45%, rgba(8, 13, 11, 0.28), rgba(5, 8, 7, 0.74) 70%),
    linear-gradient(90deg, rgba(5, 8, 7, 0.8), rgba(5, 8, 7, 0.38) 50%, rgba(5, 8, 7, 0.8));
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 300ms ease;
}

.modal-layer.open {
  opacity: 1;
  visibility: visible;
}

.title-screen {
  display: grid;
  width: min(520px, 90vw);
  justify-items: center;
  padding: 34px 44px 28px;
  border: 1px solid rgba(226, 224, 210, 0.15);
  border-radius: 9px 34px 9px 34px;
  background: rgba(8, 12, 10, 0.82);
  box-shadow: 0 35px 130px rgba(0, 0, 0, 0.62);
  text-align: center;
  backdrop-filter: blur(22px);
}

.title-emblem {
  width: 92px;
  height: 92px;
  overflow: hidden;
  border: 1px solid rgba(233, 227, 211, 0.17);
  border-radius: 50%;
  box-shadow: 0 0 55px rgba(102, 150, 137, 0.2);
}

.title-emblem img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eyebrow {
  margin: 18px 0 4px;
  color: var(--jade);
  font-size: 8px;
  letter-spacing: 0.34em;
}

.title-screen h1 {
  margin: 4px 0;
  font-family: var(--serif);
  font-size: clamp(34px, 7vw, 52px);
  font-weight: 500;
  letter-spacing: 0.22em;
}

.title-subtitle {
  margin: 4px 0 24px;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.16em;
}

.title-actions {
  display: grid;
  width: min(310px, 100%);
  gap: 8px;
}

.title-actions button,
.creator-footer button,
.creator-header button,
.manifest-actions button {
  min-height: 42px;
  padding: 9px 17px;
  border: 1px solid rgba(222, 224, 211, 0.15);
  border-radius: 5px 14px 5px 14px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.title-actions .primary-action,
.creator-footer .primary-action,
.manifest-actions .primary-action {
  border-color: rgba(129, 178, 164, 0.42);
  background: linear-gradient(100deg, rgba(88, 139, 124, 0.31), rgba(55, 92, 82, 0.12));
  color: var(--jade-bright);
}

.title-actions button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.offline-note {
  margin: 19px 0 0;
  color: rgba(206, 202, 191, 0.48);
  font-size: 8px;
}

.offline-note span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 8px var(--jade);
}

.offline-note.legacy-save-note {
  max-width: 42rem;
  color: #d8b98b;
  line-height: 1.55;
}

.offline-note.legacy-save-note span {
  background: #c98d58;
  box-shadow: 0 0 12px rgba(201, 141, 88, 0.58);
}

.creator {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: min(830px, 94vw);
  max-height: min(790px, 94vh);
  overflow: hidden;
  border: 1px solid rgba(222, 224, 211, 0.16);
  border-radius: 8px 30px 8px 30px;
  background: rgba(8, 12, 10, 0.92);
  box-shadow: 0 35px 130px rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(25px);
}

.creator-header,
.creator-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 21px;
}

.creator-header {
  border-bottom: 1px solid var(--soft-line);
}

.creator-header > button {
  min-height: 32px;
  padding: 6px 10px;
  background: transparent;
}

.creator-header > div {
  text-align: center;
}

.creator-header small {
  color: var(--jade);
  font-size: 7px;
  letter-spacing: 0.2em;
}

.creator-header h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.2em;
}

#creator-progress {
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 10px;
}

.creator-stepper {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 0 21px;
  transform: translateY(-1px);
}

.creator-stepper b {
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.creator-stepper b.active {
  background: linear-gradient(90deg, var(--jade), rgba(130, 180, 166, 0.3));
}

.creator-body {
  padding: 24px 28px;
  overflow: auto;
}

.creator-intro {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 28px;
  margin-bottom: 22px;
}

.creator-intro h3 {
  margin: 0 0 7px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.creator-intro p {
  margin: 0;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.8;
}

.creator-quote {
  align-self: center;
  padding: 12px 14px;
  border-left: 2px solid var(--cinnabar);
  background: rgba(181, 77, 58, 0.055);
  color: #d9cdb9;
  font-family: var(--serif);
  font-size: 10px;
  line-height: 1.7;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 17px;
}

.field-grid.identity {
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--jade-bright);
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.13em;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  resize: vertical;
  border: 1px solid var(--soft-line);
  border-radius: 5px 13px 5px 13px;
  background: rgba(255, 255, 255, 0.025);
  font-family: var(--serif);
  font-size: 11px;
}

.destiny-difficulty-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.destiny-difficulty {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  min-height: 210px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid rgba(128, 171, 159, 0.17);
  border-radius: 6px 18px 6px 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(117, 173, 157, 0.09), transparent 42%),
    rgba(255, 255, 255, 0.022);
  color: var(--paper);
  text-align: left;
}

.destiny-difficulty::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid transparent;
  border-radius: 4px 14px 4px 14px;
  pointer-events: none;
}

.destiny-difficulty:hover,
.destiny-difficulty:focus-visible {
  border-color: rgba(184, 221, 211, 0.48);
  transform: translateY(-1px);
}

.destiny-difficulty.selected {
  border-color: var(--jade-bright);
  background:
    radial-gradient(circle at 100% 0%, rgba(117, 173, 157, 0.18), transparent 48%),
    linear-gradient(135deg, rgba(69, 114, 101, 0.12), rgba(179, 139, 70, 0.05));
  box-shadow: 0 0 0 2px rgba(115, 183, 165, 0.12), 0 18px 42px rgba(0, 0, 0, 0.22);
}

.destiny-difficulty.selected::after {
  border-color: rgba(174, 215, 203, 0.12);
}

.destiny-rank {
  color: #efdcb7;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1;
}

.destiny-tagline {
  align-self: center;
  color: var(--jade);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.destiny-difficulty > strong,
.destiny-difficulty > p,
.destiny-difficulty > dl,
.destiny-difficulty > em {
  grid-column: 1 / -1;
}

.destiny-difficulty > strong {
  color: var(--paper);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.destiny-difficulty > p {
  min-height: 34px;
  margin: 0;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 9px;
  line-height: 1.7;
}

.destiny-difficulty dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 9px;
  margin: 0;
}

.destiny-difficulty dl div {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 4px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.destiny-difficulty dt,
.destiny-difficulty dd {
  margin: 0;
  font-size: 8px;
  line-height: 1.5;
}

.destiny-difficulty dt {
  color: var(--jade);
}

.destiny-difficulty dd {
  color: #c9c6bc;
}

.destiny-difficulty > em {
  justify-self: start;
  padding: 4px 8px;
  border: 1px solid rgba(203, 167, 93, 0.28);
  border-radius: 12px;
  color: var(--gold);
  font-size: 8px;
  font-style: normal;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.suggestions button {
  padding: 5px 8px;
  border: 1px solid rgba(128, 171, 159, 0.17);
  border-radius: 12px;
  background: rgba(91, 133, 121, 0.07);
  color: var(--paper-dim);
  font-size: 8px;
}

.suggestions button:hover {
  color: var(--jade-bright);
}

.portrait-selector {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--soft-line);
}

.portrait-selector > header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.portrait-selector > header div {
  display: grid;
  gap: 4px;
}

.portrait-selector > header small {
  color: var(--jade);
  font-size: 8px;
  letter-spacing: 0.13em;
}

.portrait-selector > header strong {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
}

.portrait-selector > header button {
  padding: 7px 10px;
  border: 1px solid rgba(128, 171, 159, 0.22);
  border-radius: 12px;
  background: rgba(91, 133, 121, 0.09);
  color: var(--jade-bright);
  font-size: 8px;
}

.portrait-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(74px, 1fr));
  gap: 8px;
  max-height: 260px;
  padding: 2px 3px 5px;
  overflow: auto;
}

.portrait-option {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 5px 13px 5px 13px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--paper-dim);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.portrait-option img {
  width: 100%;
  aspect-ratio: 6 / 7;
  object-fit: cover;
}

.portrait-option span {
  padding: 5px 3px;
  overflow: hidden;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portrait-option:hover {
  z-index: 1;
  border-color: rgba(184, 221, 211, 0.48);
  transform: translateY(-2px);
}

.portrait-option.selected {
  border-color: var(--jade-bright);
  box-shadow: 0 0 0 2px rgba(115, 183, 165, 0.16), 0 12px 30px rgba(0, 0, 0, 0.32);
}

.portrait-option.recommended::after {
  content: "薦";
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: rgba(153, 69, 50, 0.9);
  color: #f0e8d9;
  font-family: var(--serif);
  font-size: 8px;
}

.portrait-selector > p {
  margin: 0;
  color: #8f928a;
  font-size: 8px;
  line-height: 1.6;
}

.creator-footer {
  position: relative;
  z-index: 4;
  border-top: 1px solid var(--soft-line);
  background: rgba(8, 12, 10, 0.97);
  gap: 9px;
  flex-wrap: wrap;
}

.creator-footer button {
  position: relative;
  z-index: 1;
  min-width: 126px;
  flex: 1 1 126px;
  touch-action: manipulation;
  pointer-events: auto;
}

.creator-footer .test-preset-action {
  border-color: rgba(195, 159, 92, 0.32);
  color: var(--gold);
}

.manifest-view {
  display: grid;
  gap: 18px;
}

.manifest-portrait {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 10px;
}

.manifest-portrait img {
  width: 74px;
  height: 86px;
  border: 1px solid rgba(184, 221, 211, 0.25);
  border-radius: 5px 16px 5px 16px;
  object-fit: cover;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.34);
}

.manifest-prose {
  padding: 18px 20px;
  border: 1px solid rgba(129, 177, 163, 0.17);
  border-radius: 7px 20px 7px 20px;
  background: rgba(101, 148, 134, 0.05);
}

.manifest-prose small {
  color: var(--jade);
  font-size: 8px;
  letter-spacing: 0.18em;
}

.manifest-prose h3 {
  margin: 7px 0 8px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

.manifest-vow {
  color: #efdcb7;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.7;
}

.manifest-prose p:last-child {
  margin-bottom: 0;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.8;
}

.manifest-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--soft-line);
  border-left: 1px solid var(--soft-line);
}

.manifest-cell {
  display: grid;
  grid-template-columns: 82px 1fr;
  min-height: 43px;
  border-right: 1px solid var(--soft-line);
  border-bottom: 1px solid var(--soft-line);
}

.manifest-cell span,
.manifest-cell strong {
  padding: 10px;
  font-size: 9px;
  line-height: 1.55;
}

.manifest-cell span {
  border-right: 1px solid var(--soft-line);
  color: var(--jade);
}

.manifest-cell strong {
  font-family: var(--serif);
  font-weight: 400;
}

.manifest-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast-layer {
  position: absolute;
  z-index: 120;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  width: min(400px, calc(100vw - 32px));
  gap: 7px;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  padding: 10px 14px;
  border: 1px solid rgba(128, 177, 163, 0.24);
  border-radius: 6px 15px 6px 15px;
  background: rgba(9, 14, 12, 0.93);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  color: var(--paper-dim);
  font-size: 10px;
  text-align: center;
  animation: toast-in 250ms ease both;
  backdrop-filter: blur(12px);
}

.toast.error {
  border-color: rgba(215, 112, 91, 0.38);
  color: #e3a093;
}

@keyframes world-drift {
  from { transform: scale(1.035) translate3d(calc(-0.32% + var(--parallax-x)), calc(-0.22% + var(--parallax-y)), 0); }
  to { transform: scale(1.065) translate3d(calc(0.32% + var(--parallax-x)), calc(0.28% + var(--parallax-y)), 0); }
}

@keyframes mist-sail {
  from { transform: translate3d(-8%, 0, 0) scaleX(0.9); }
  50% { transform: translate3d(58vw, -4vh, 0) scaleX(1.15); }
  to { transform: translate3d(116vw, 1vh, 0) scaleX(0.94); }
}

@keyframes spirit-river {
  0%, 100% { opacity: 0.18; transform: translate3d(-2%, 3px, 0) rotate(-7deg) scaleX(0.96); }
  50% { opacity: 0.76; transform: translate3d(3%, -5px, 0) rotate(-5deg) scaleX(1.04); }
}

@keyframes distant-flash {
  0%, 72%, 74%, 76%, 100% { opacity: 0; }
  73% { opacity: 0.22; }
  75% { opacity: 0.09; }
}

@keyframes rain-fall {
  from { transform: translate3d(0, -16%, 0); }
  to { transform: translate3d(-6%, 16%, 0); }
}

@keyframes ink-breathe {
  from { transform: scale(0.98); opacity: 0.7; }
  to { transform: scale(1.03); opacity: 1; }
}

@keyframes pulse-in {
  from { opacity: 0; transform: translateX(14px); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
}

@keyframes dots {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@media (max-width: 760px) {
  .game-shell {
    transform: none;
  }

  .world-art {
    background-position: 58% center;
  }

  .world-vignette {
    background:
      linear-gradient(180deg, rgba(5, 8, 7, 0.62), rgba(5, 8, 7, 0.12) 25%, rgba(5, 8, 7, 0.38) 58%, rgba(5, 8, 7, 0.9) 100%);
  }

  .top-hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }

  .player-card {
    width: min(250px, 67vw);
    min-width: 0;
    gap: 8px;
    padding: 7px 9px 7px 7px;
    border-radius: 6px 15px 6px 15px;
  }

  .portrait-button {
    flex-basis: 45px;
    width: 45px;
    height: 45px;
  }

  #portrait-glyph {
    font-size: 18px;
  }

  .player-title-row {
    margin-bottom: 3px;
  }

  .player-title-row strong {
    font-size: 12px;
  }

  .realm-label {
    font-size: 7px;
  }

  .vital-row {
    grid-template-columns: 24px 1fr 23px;
    height: 10px;
    gap: 4px;
    font-size: 7px;
  }

  .location-card {
    min-width: 0;
    max-width: 30vw;
    gap: 6px;
    padding: 8px;
    border-radius: 15px 6px 15px 6px;
  }

  .compass {
    display: none;
  }

  .location-card strong {
    max-width: 23vw;
    overflow: hidden;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .location-card small {
    font-size: 7px;
  }

  .location-card span {
    max-width: 24vw;
    overflow: hidden;
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .story-stage {
    top: 66px;
    bottom: calc(72px + env(safe-area-inset-bottom) + var(--keyboard-lift));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
    max-height: none;
    gap: 6px;
    transform: none;
  }

  .chapter-ribbon {
    gap: 8px;
    font-size: 8px;
  }

  .chapter-ribbon b {
    font-size: 13px;
  }

  .story-panel {
    min-height: 154px;
    max-height: min(33vh, 260px);
    padding: 14px 15px;
    border-radius: 6px 18px 6px 18px;
  }

  .speaker-strip {
    position: static;
    display: flex;
    width: 100%;
    justify-items: start;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
    text-align: left;
  }

  .speaker-strip img {
    width: 38px;
    height: 43px;
    border-radius: 12px 3px 12px 3px;
  }

  .speaker-strip > div {
    display: grid;
    width: auto;
    justify-items: start;
    margin: 0;
  }

  .speaker-strip strong {
    font-size: 11px;
  }

  .story-copy {
    font-size: 12px;
    line-height: 1.75;
  }

  .decision-prompt {
    margin-top: 10px;
    padding-top: 8px;
    font-size: 9px;
  }

  .choices {
    gap: 5px;
  }

  .choice-card {
    grid-template-columns: 22px 1fr;
    gap: 5px;
    min-height: 54px;
    padding: 7px 8px;
    border-radius: 4px 12px 4px 12px;
  }

  .choice-number {
    width: 20px;
    height: 20px;
    font-size: 8px;
  }

  .choice-main {
    margin-bottom: 3px;
    font-size: 9px;
    line-height: 1.35;
  }

  .choice-meta {
    display: grid;
    gap: 1px;
    font-size: 6.5px;
  }

  .free-action {
    padding: 7px 8px 6px;
  }

  .free-action label {
    margin-bottom: 3px;
    font-size: 7px;
  }

  .free-action textarea {
    min-height: 26px;
    padding: 4px;
    font-size: 9px;
  }

  .free-action button {
    padding: 0 10px;
    font-size: 8px;
  }

  .free-action kbd,
  .intent-hint {
    display: none;
  }

  .pulse-stack {
    right: 8px;
    bottom: calc(73px + env(safe-area-inset-bottom));
    width: auto;
    max-width: 70vw;
  }

  .pulse-stack .pulse:not(:first-child) {
    display: none;
  }

  .pulse {
    padding: 6px 9px;
  }

  .pulse small {
    margin: 0;
    font-size: 7px;
    white-space: nowrap;
  }

  .pulse span {
    display: none;
  }

  .bottom-nav {
    bottom: max(5px, env(safe-area-inset-bottom));
    width: calc(100vw - 10px - env(safe-area-inset-left) - env(safe-area-inset-right));
    justify-content: space-around;
    gap: 0;
    padding: 4px;
    border-radius: 18px 6px 18px 6px;
  }

  .bottom-nav button {
    width: 16.4%;
    height: 50px;
  }

  .bottom-nav svg {
    width: 18px;
    height: 18px;
  }

  .bottom-nav span {
    font-size: 8px;
  }

  .drawer {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 83vh;
    min-height: 55vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
  }

  .drawer.open {
    transform: none;
  }

  .drawer-handle {
    position: absolute;
    top: 7px;
    left: 50%;
    display: block;
    width: 42px;
    height: 3px;
    border-radius: 3px;
    background: rgba(230, 229, 218, 0.17);
    transform: translateX(-50%);
  }

  .drawer header {
    padding: 20px 18px 11px;
  }

  .drawer-content {
    padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
  }

  .item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .creator {
    width: 100%;
    max-height: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .creator-body {
    padding: 18px;
  }

  .creator-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 11px max(12px, env(safe-area-inset-right)) calc(11px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 8px;
  }

  .creator-footer button {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding-inline: 8px;
  }

  .creator-footer .primary-action {
    grid-column: 1 / -1;
  }

  .creator-intro {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .field-grid,
  .field-grid.identity {
    grid-template-columns: 1fr;
  }

  .destiny-difficulty-grid {
    grid-template-columns: 1fr;
  }

  .destiny-difficulty {
    min-height: 190px;
  }

  .portrait-selector > header {
    align-items: stretch;
    flex-direction: column;
  }

  .portrait-grid {
    grid-template-columns: repeat(4, minmax(70px, 1fr));
    max-height: 390px;
  }

  .manifest-table {
    grid-template-columns: 1fr;
  }

  .manifest-actions {
    flex-direction: column-reverse;
  }
}

@media (max-width: 440px), (max-height: 720px) {
  .story-panel {
    max-height: 25vh;
  }

  .story-copy {
    font-size: 10.5px;
    line-height: 1.62;
  }

  .speaker-strip {
    margin-bottom: 5px;
  }

  .speaker-strip img {
    width: 31px;
    height: 35px;
  }

  .choices {
    gap: 4px;
  }

  .choice-card {
    min-height: 48px;
    padding: 6px;
  }

  .choice-main {
    font-size: 8px;
  }

  .free-action {
    padding-top: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation: none !important;
  transition-duration: 0.01ms !important;
}

body.performance-lite .glass-panel,
body.performance-lite .drawer,
body.performance-lite .title-screen,
body.performance-lite .creator {
  backdrop-filter: blur(8px) saturate(0.9);
  -webkit-backdrop-filter: blur(8px) saturate(0.9);
}

body.performance-lite .world-mist i:last-child,
body.performance-lite .spirit-current i:nth-child(3),
body.performance-lite .weather-layer i:nth-child(n + 2) {
  display: none;
}

body.performance-lite .world-mist i {
  filter: blur(16px);
  animation-duration: 42s;
}

body.performance-lite .world-art {
  animation-duration: 38s;
}

body.performance-lite .distant-lightning {
  animation-duration: 26s;
}
