:root {
  --bg: #07060a;
  --panel: #0d0b11;
  --panel-soft: #141019;
  --line: rgba(218, 198, 157, 0.22);
  --line-bright: rgba(236, 214, 168, 0.52);
  --ivory: #eee7da;
  --muted: #a59b91;
  --gold: #c8a86a;
  --gold-bright: #f1d497;
  --blood: #9c3e44;
  --pink: #d668a0;
  --pink-dark: #5f2748;
  --green: #7ea78e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-vh, 100dvh);
  max-height: 100%;
  max-height: var(--app-vh, 100dvh);
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  color: var(--ivory);
  background:
    radial-gradient(circle at 52% -15%, rgba(90, 65, 77, 0.3), transparent 38%),
    #050407;
  font-family: "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

html.lang-ja, html.lang-ja body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Noto Sans JP", "Meiryo", "Microsoft YaHei", system-ui, sans-serif;
}
html.lang-ko, html.lang-ko body {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Microsoft YaHei", system-ui, sans-serif;
}
html.lang-ja .brand-button strong,
html.lang-ja .title-screen h1,
html.lang-ja .panel-heading h2,
html.lang-ja .character-card-copy strong,
html.lang-ja .scene-header h2 {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", "STSong", Georgia, serif;
  letter-spacing: 0.06em;
}
html.lang-ko .brand-button strong,
html.lang-ko .title-screen h1,
html.lang-ko .panel-heading h2,
html.lang-ko .character-card-copy strong,
html.lang-ko .scene-header h2 {
  font-family: "Noto Serif KR", "Apple SD Gothic Neo", "Malgun Gothic", "STSong", Georgia, serif;
  letter-spacing: 0.04em;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: 0.42; }

.app-shell {
  position: relative;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
}

.ambient-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  z-index: 20;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.33'/%3E%3C/svg%3E");
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  padding: 0 34px;
  border-bottom: 1px solid rgba(221, 202, 168, 0.14);
  background: linear-gradient(180deg, rgba(8, 7, 10, 0.98), rgba(8, 7, 10, 0.82));
  backdrop-filter: blur(14px);
}

.topbar-lead {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  flex-shrink: 1;
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  color: var(--ivory);
  border: 0;
  background: transparent;
  cursor: default;
  text-align: left;
}

.brand-button strong { display: block; font-family: Georgia, "Songti SC", serif; letter-spacing: 0.2em; }
.brand-button small { display: block; margin-top: 2px; color: #82786f; font-size: calc(8px * var(--fs, 1)); letter-spacing: 0.18em; }
.brand-mark { color: var(--gold); font-size: calc(28px * var(--fs, 1)); transform: rotate(45deg); }

.run-summary { display: flex; height: 72px; margin-left: auto; }
.summary-item {
  min-width: 100px;
  display: grid;
  place-content: center;
  padding: 0 20px;
  border-left: 1px solid rgba(221, 202, 168, 0.1);
  text-align: center;
}
.summary-item:last-child { border-right: 1px solid rgba(221, 202, 168, 0.1); }
.summary-item small { color: #756e68; font-size: calc(10px * var(--fs, 1)); letter-spacing: 0.22em; }
.summary-item b { margin-top: 2px; color: #ddd2c1; font-family: Georgia, serif; font-size: calc(14px * var(--fs, 1)); font-weight: 500; }
.summary-item.fog-summary { min-width: 132px; }
/* Hide the unused top-bar run-turn widget (state.turn). Keep 身后腐化迷雾. */
.summary-item:has(#turnLabel),
#turnLabel { display: none !important; }
.fog-summary b { color: #e1b0ca; }
.top-fog-track { display: block; width: 88px; height: 3px; margin: 5px auto 0; overflow: hidden; background: rgba(215, 106, 163, .13); }
.top-fog-track > i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #8c3c68, #e883b8); box-shadow: 0 0 10px #d66aa3; transition: width .35s ease; }

.top-actions { display: flex; gap: 8px; margin-left: 18px; }
.icon-button, .text-button {
  color: #b9aea2;
  border: 1px solid rgba(220, 198, 160, 0.2);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}
.icon-button { min-width: 56px; padding: 9px 13px; font-size: calc(12px * var(--fs, 1)); letter-spacing: 0.12em; }
.return-title-button { min-width: 106px; color: #d2c5b7; border-color: rgba(220, 198, 160, .3); }
.icon-button:not(:disabled):hover, .text-button:not(:disabled):hover { color: var(--gold-bright); border-color: rgba(220, 188, 130, 0.48); }
.text-button { padding: 8px 15px; }

.screen-stack { height: 100%; max-height: 100%; min-height: 0; overflow: hidden; }
.screen { display: none; min-height: 0; padding-top: 72px; }
.screen.is-active {
  display: flex;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.title-screen {
  position: relative;
  align-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(4, 4, 6, 0.99) 0%, rgba(7, 6, 9, 0.89) 42%, rgba(9, 6, 10, 0.38) 75%, rgba(5, 4, 7, 0.7) 100%),
    radial-gradient(ellipse at 76% 40%, rgba(205, 106, 160, 0.24), transparent 22%),
    linear-gradient(145deg, #0b0a0e, #17111a 45%, #08070b 46%);
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 0 0 0 43%;
  opacity: 0.66;
  background:
    linear-gradient(90deg, transparent, rgba(10, 8, 12, 0.12)),
    repeating-linear-gradient(90deg, transparent 0 90px, rgba(195, 173, 139, 0.08) 91px 93px),
    repeating-linear-gradient(0deg, transparent 0 110px, rgba(195, 173, 139, 0.06) 111px 113px);
  clip-path: polygon(20% 0, 100% 0, 100% 100%, 0 100%, 13% 78%, 3% 58%, 18% 34%);
}

.title-screen::after {
  content: "";
  position: absolute;
  right: 10%;
  bottom: -10%;
  width: min(38vw, 560px);
  aspect-ratio: .62;
  border-radius: 50% 50% 0 0;
  opacity: 0.25;
  filter: blur(2px);
  background: linear-gradient(90deg, transparent, #000 22% 78%, transparent);
  box-shadow: 0 -130px 130px rgba(0, 0, 0, 0.85);
}

.title-content {
  width: min(620px, 50vw);
  margin-left: clamp(7vw, 10vw, 150px);
  position: relative;
  z-index: 3;
}

.eyebrow { margin: 0 0 12px; color: var(--gold); font-size: calc(11px * var(--fs, 1)); letter-spacing: 0.32em; text-transform: uppercase; }
.title-content h1 {
  margin: 0;
  font-family: Georgia, "STSong", serif;
  font-size: calc(clamp(62px, 7.6vw, 116px) * var(--fs, 1));
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 0.96;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}
.title-content h1 span { color: var(--gold-bright); }
.title-subtitle { margin: 30px 0 38px; color: #b4aaa0; font-family: "STSong", serif; font-size: calc(17px * var(--fs, 1)); line-height: 1.9; letter-spacing: 0.08em; }
.title-menu { width: min(390px, 100%); display: grid; gap: 10px; }

.dev-shortcuts {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px dashed rgba(218, 198, 157, 0.16);
  display: grid;
  gap: 6px;
}
.dev-shortcuts-label {
  color: #6a625a;
  font-size: calc(10px * var(--fs, 1));
  letter-spacing: 0.22em;
}
.dev-shortcut-button {
  min-height: 40px;
  padding: 8px 14px;
  color: #9a9084;
  border: 1px solid rgba(218, 198, 157, 0.16);
  background: rgba(8, 7, 10, 0.55);
  cursor: pointer;
  text-align: left;
  font-size: calc(12px * var(--fs, 1));
  letter-spacing: 0.08em;
}
.dev-shortcut-button:hover {
  color: var(--gold-bright);
  border-color: rgba(220, 188, 130, 0.4);
}
.icon-button.dev-header-debug {
  min-width: 48px;
  color: #8a8176;
  border-color: rgba(218, 198, 157, 0.18);
}


.primary-button, .secondary-button {
  min-height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px 14px 24px;
  cursor: pointer;
  text-align: left;
}
.primary-button {
  color: #17110a;
  border: 1px solid #e3c989;
  background: linear-gradient(110deg, #d8bc7e, #a7854b);
  box-shadow: 0 12px 30px rgba(160, 120, 61, 0.18);
}
.secondary-button { color: #c9bba9; border: 1px solid var(--line); background: rgba(12, 10, 14, 0.72); }
.primary-button span, .secondary-button span { font-family: "STSong", serif; font-size: calc(18px * var(--fs, 1)); letter-spacing: 0.16em; }
.primary-button small, .secondary-button small { max-width: 140px; opacity: 0.68; font-size: calc(10px * var(--fs, 1)); text-align: right; }
.primary-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.secondary-button:not(:disabled):hover { border-color: var(--gold); color: var(--gold-bright); }
.secondary-button.is-coming-soon { opacity: 0.72; }
.secondary-button.is-coming-soon:hover { opacity: 1; border-color: var(--gold); color: var(--gold-bright); }
.version-stamp { position: absolute; right: 28px; bottom: 24px; z-index: 3; color: #5e5651; font-size: calc(9px * var(--fs, 1)); letter-spacing: 0.18em; }

.title-mist { position: absolute; border-radius: 50%; filter: blur(60px); background: rgba(201, 92, 151, 0.22); animation: breathe 8s ease-in-out infinite alternate; }
.title-mist-a { width: 480px; height: 170px; right: -80px; bottom: 15%; }
.title-mist-b { width: 300px; height: 110px; right: 25%; top: 30%; animation-delay: -3s; }
@keyframes breathe { to { transform: translate(-42px, 18px) scale(1.13); opacity: .54; } }

.slot-screen, .character-screen {
  flex-direction: column;
  padding: 118px clamp(28px, 8vw, 120px) 46px;
  overflow: auto;
  background:
    radial-gradient(circle at 80% 20%, rgba(125, 69, 103, 0.13), transparent 30%),
    linear-gradient(130deg, #09080c, #110d14 55%, #070609);
}

/* itch iframe: overflow:auto alone does not scroll if the screen grows with content
   past min-height: 100vh; bind the active title screens to the viewport. */
.slot-screen.is-active,
.character-screen.is-active {
  height: 100vh;
  height: 100dvh;
  max-height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.character-screen {
  background:
    radial-gradient(circle at 50% 24%, rgba(159, 124, 91, .12), transparent 30%),
    radial-gradient(circle at 82% 60%, rgba(126, 55, 94, .12), transparent 34%),
    linear-gradient(130deg, #09080c, #100d13 55%, #070609);
}

.character-select-grid {
  flex: 1;
  min-height: 470px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.character-card {
  min-width: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a090c;
  box-shadow: var(--shadow);
  color: var(--ivory);
  text-align: left;
}

button.character-card { padding: 0; cursor: pointer; }
.character-card.available:hover { border-color: var(--gold); transform: translateY(-3px); }
.character-card.available::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 45%, rgba(255,255,255,.09) 50%, transparent 55%);
  transform: translateX(-120%);
  transition: transform .7s ease;
}
.character-card.available:hover::after { transform: translateX(120%); }
.character-card img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 50% 20%; filter: saturate(.82) contrast(1.08); }
.character-card-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(4,3,5,.96) 96%); }
.character-number { position: absolute; left: 18px; top: 18px; z-index: 3; color: var(--gold); font-family: Georgia, serif; font-size: calc(10px * var(--fs, 1)); letter-spacing: .2em; }
.character-card-copy { position: absolute; z-index: 3; left: 22px; right: 22px; bottom: 25px; border-left: 2px solid var(--gold); padding-left: 12px; }
.character-card-copy small, .character-card-copy strong, .character-card-copy em { display: block; }
.character-card-copy small { color: #9d9185; font-size: calc(9px * var(--fs, 1)); letter-spacing: .13em; }
.character-card-copy strong { margin: 5px 0 8px; font-family: Georgia, "STSong", serif; font-size: calc(clamp(24px, 2.6vw, 38px) * var(--fs, 1)); font-weight: 400; letter-spacing: .1em; }
.character-card-copy em { color: #9f9388; font-size: calc(10px * var(--fs, 1)); font-style: normal; }
.select-callout { position: absolute; z-index: 4; right: 20px; top: 17px; color: #e5c98d; font-size: calc(10px * var(--fs, 1)); letter-spacing: .12em; }
.character-card.locked { filter: saturate(.4); }
.character-card.locked::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.2), rgba(0,0,0,.8)); }
.character-card.locked.knight-coming {
  filter: none;
  background:
    radial-gradient(circle at 50% 36%, #2c272f 0 34%, #0a090c 68%);
}
.character-card.locked.knight-coming img.character-silhouette {
  object-fit: contain;
  object-position: 50% 36%;
  filter: none;
  padding: 8% 6% 22%;
}
.character-card.locked.knight-coming::after {
  background: linear-gradient(180deg, rgba(0,0,0,.1), rgba(0,0,0,.78) 86%);
}
.character-card.locked.knight-coming .lock-seal { letter-spacing: .16em; }
.character-card.locked.nidhogg-coming {
  filter: none;
}
.character-card.locked.nidhogg-coming img {
  object-fit: cover;
  object-position: 50% 18%;
  filter: saturate(.82) contrast(1.08);
}
.character-card.locked.nidhogg-coming::after {
  background: linear-gradient(180deg, rgba(0,0,0,.12), rgba(0,0,0,.76) 86%);
}
.character-card.locked.nidhogg-coming .lock-seal { letter-spacing: .16em; }
.character-card.available.nidhogg-available img {
  object-fit: cover;
  object-position: 50% 18%;
  filter: saturate(.82) contrast(1.08);
}
.locked-silhouette { position: absolute; left: 50%; bottom: 0; width: 74%; height: 88%; transform: translateX(-50%); background: radial-gradient(circle at 50% 15%, #17151a 0 10%, transparent 10.5%), linear-gradient(90deg, transparent 8%, #111014 24% 76%, transparent 92%); clip-path: polygon(30% 0, 70% 0, 78% 14%, 72% 22%, 94% 42%, 100% 100%, 0 100%, 6% 42%, 28% 22%, 22% 14%); filter: blur(1px); }
.locked-silhouette.alternate { width: 62%; height: 82%; clip-path: polygon(37% 0, 63% 0, 70% 18%, 91% 41%, 78% 100%, 22% 100%, 9% 41%, 30% 18%); }
.chain { position: absolute; z-index: 5; left: -18%; top: 44%; width: 140%; height: 15px; opacity: .72; transform: rotate(28deg); background: repeating-linear-gradient(90deg, #2a272c 0 8px, #797077 8px 10px, #18171a 10px 20px); border: 1px solid #0b0a0d; box-shadow: 0 4px 8px #000; }
.chain-b { top: 58%; transform: rotate(-24deg); }
.lock-seal { position: absolute; z-index: 7; left: 50%; top: 49%; transform: translate(-50%, -50%) rotate(-3deg); padding: 9px 18px; color: #8f8580; border: 1px solid #5c5555; background: #151316; font-size: calc(10px * var(--fs, 1)); letter-spacing: .24em; white-space: nowrap; }
.character-card.locked .character-card-copy { z-index: 7; border-color: #5f5754; }
.character-select-note { padding-top: 20px; color: #756d67; font-size: calc(10px * var(--fs, 1)); letter-spacing: .1em; text-align: center; }
.character-select-note span { margin-right: 8px; color: var(--gold); }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.panel-heading-actions { display: flex; gap: 8px; }
.panel-heading h2 { margin: 0; font-family: Georgia, "STSong", serif; font-size: calc(34px * var(--fs, 1)); font-weight: 400; letter-spacing: 0.12em; }
.panel-intro { margin: 18px 0 30px; color: var(--muted); font-size: calc(13px * var(--fs, 1)); }
.save-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.save-card {
  position: relative;
  min-height: 236px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(150deg, rgba(29, 24, 32, .88), rgba(10, 9, 12, .96));
  box-shadow: var(--shadow);
}
.save-card::after { content: ""; position: absolute; width: 140px; height: 140px; top: -70px; right: -70px; transform: rotate(45deg); border: 1px solid rgba(213, 183, 126, 0.12); }
.save-card:hover { border-color: rgba(221, 191, 134, 0.5); transform: translateY(-2px); }
.save-index { color: var(--gold); font-family: Georgia, serif; font-size: calc(11px * var(--fs, 1)); letter-spacing: 0.2em; }
.save-card h3 { margin: 36px 0 8px; font-family: Georgia, "STSong", serif; font-size: calc(24px * var(--fs, 1)); font-weight: 400; }
.save-card p { min-height: 42px; margin: 0; color: #8e8379; font-size: calc(12px * var(--fs, 1)); line-height: 1.7; }
.save-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 22px 0; background: rgba(230, 205, 163, 0.12); }
.save-stats div { padding: 10px; background: #0d0b10; text-align: center; }
.save-stats small { display: block; color: #706861; font-size: calc(9px * var(--fs, 1)); }
.save-stats b { display: block; margin-top: 4px; color: #cbbfb0; font-size: calc(12px * var(--fs, 1)); font-weight: 500; }
.save-actions { display: flex; gap: 8px; }
.save-actions button { flex: 1; padding: 10px; cursor: pointer; }
.load-slot { color: #16110a; border: 1px solid #c3a15f; background: #c3a15f; }
.export-slot { color: #c7b79e; border: 1px solid var(--line); background: transparent; }
.export-slot:hover { color: var(--gold-bright); border-color: var(--gold); }
.delete-slot { flex: 0 0 42px !important; color: #9f8d82; border: 1px solid var(--line); background: transparent; }
.empty-slot-note { padding: 11px; color: #5f5853; border: 1px dashed rgba(220,197,157,.13); font-size: calc(9px * var(--fs, 1)); letter-spacing: .16em; text-align: center; }
.archive-footer { display: flex; justify-content: flex-end; gap: 50px; margin-top: auto; padding-top: 32px; color: #746b65; font-size: calc(11px * var(--fs, 1)); }
.archive-footer span, .archive-footer b { display: block; }
.archive-footer b { margin-top: 5px; color: #bbb0a5; font-size: calc(13px * var(--fs, 1)); font-weight: 500; }

.game-screen { flex-direction: column; height: 100%; max-height: 100%; min-height: 0; overflow: hidden; background: #07060a; }
/* display is controlled by .screen / .screen.is-active only.
   A later .game-screen { display:flex } would keep the dungeon in document
   flow under 文集/画廊, so scrolling the page revealed combat UI. */
.dungeon-stage { position: relative; flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: 92px minmax(0, 1fr) 310px; overflow: hidden; background: linear-gradient(180deg, #17131a 0%, #0b090d 100%); }
.dungeon-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.92;
  background:
    linear-gradient(180deg, rgba(6, 5, 8, .2), rgba(6, 5, 8, .78)),
    radial-gradient(ellipse at 50% 100%, rgba(112, 86, 69, .24), transparent 55%),
    repeating-linear-gradient(90deg, transparent 0 138px, rgba(167, 145, 116, .04) 139px 141px),
    repeating-linear-gradient(0deg, transparent 0 92px, rgba(167, 145, 116, .035) 93px 95px);
}
.dungeon-stage[data-room="safe"] { background: linear-gradient(180deg, #1e1a18, #0b0a0b); }
.dungeon-stage[data-room="altar"] { background: radial-gradient(circle at 50% 42%, rgba(92,24,43,.18), transparent 34%), linear-gradient(180deg, #181219, #08070a); }
.dungeon-stage[data-room="event"] { background: linear-gradient(180deg, #151927, #09090c); }
.dungeon-stage[data-room="battle"] { background: linear-gradient(180deg, #1b1115, #08070a); }
.stage-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 7; box-shadow: inset 0 0 160px rgba(0, 0, 0, .92); }

.route-rail { position: relative; z-index: 9; display: flex; flex-direction: column; align-items: center; padding-top: 24px; border-right: 1px solid rgba(218, 198, 157, .14); background: rgba(8, 7, 10, .76); }
.floor-emblem { width: 55px; height: 64px; display: grid; place-content: center; border: 1px solid rgba(215, 185, 127, .28); clip-path: polygon(50% 0, 100% 22%, 90% 83%, 50% 100%, 10% 83%, 0 22%); text-align: center; }
.floor-emblem span { color: var(--gold-bright); font-family: Georgia, serif; font-size: calc(18px * var(--fs, 1)); }
.floor-emblem small { color: #776d63; font-size: calc(8px * var(--fs, 1)); letter-spacing: .18em; }
.route-track { position: relative; flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 3px; padding: 12px 0 18px; }
.route-track::before { content: ""; position: absolute; top: 13%; bottom: 13%; left: 50%; width: 1px; background: rgba(204, 174, 117, .24); }
.route-dot { position: relative; z-index: 1; width: 11px; height: 11px; transform: rotate(45deg); border: 1px solid #62584e; background: #0c0a0e; }
.route-dot.passed { border-color: #a68957; background: #7e633a; }
.route-dot.current { width: 15px; height: 15px; border-color: var(--gold-bright); background: var(--gold); box-shadow: 0 0 18px rgba(235, 202, 130, .45); }

.scene-area { position: relative; z-index: 8; min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; padding: 24px clamp(26px, 4vw, 66px) 22px; }
.dungeon-stage.intro-chamber .scene-area {
  background-color: #08070b;
  background-image:
    linear-gradient(180deg, rgba(4, 4, 7, .16), rgba(4, 3, 6, .08) 44%, rgba(4, 3, 6, .58)),
    url("场景/初始房间-召唤大厅.png");
  background-origin: border-box;
  background-clip: border-box;
  background-position: center center;
  background-repeat: no-repeat;
  /* cover: fill the mid frame proportionally (crop OK, no black gutters, no stretch) */
  background-size: auto, cover;
}
.dungeon-stage:not(.intro-chamber) .scene-area {
  background-color: #0b090d;
  background-image:
    linear-gradient(180deg, rgba(4, 4, 7, .28), rgba(4, 3, 6, .12) 44%, rgba(4, 3, 6, .66)),
    var(--room-bg, none);
  background-origin: border-box;
  background-clip: border-box;
  background-position: center center;
  background-repeat: no-repeat;
  /* cover tracks mid-frame size, including D20 rail collapse/expand */
  background-size: auto, cover;
}

.scene-area.has-bg-video { isolation: isolate; }
.scene-bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
  pointer-events: none;
  background: #0b090d;
}
.scene-bg-video-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 4, 7, .28), rgba(4, 3, 6, .12) 44%, rgba(4, 3, 6, .66));
}
.scene-area.has-bg-video > .scene-header,
.scene-area.has-bg-video > .choice-layer,
.scene-area.has-bg-video > .scene-object,
.scene-area.has-bg-video > .combat-layer {
  position: relative;
  z-index: 4;
}

.dungeon-stage:not(.intro-chamber)[data-room="battle"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="event"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="altar"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="safe"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="threshold"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="rustCasket"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="mistSpring"] .scene-header,
.dungeon-stage:not(.intro-chamber)[data-room="darkReedPassage"] .scene-header { position: relative; z-index: 5; text-shadow: 0 2px 16px #000; }
.dungeon-stage.intro-chamber::before { opacity: .18; }
.dungeon-stage.intro-chamber .scene-header { position: relative; z-index: 5; text-shadow: 0 2px 16px #000; }
.scene-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.scene-kicker { margin: 0 0 6px; color: var(--gold); font-size: calc(9px * var(--fs, 1)); letter-spacing: .25em; }
.scene-header h2 { margin: 0; font-family: Georgia, "STSong", serif; font-size: clamp(16px, 1.9vw, 26px); font-weight: 400; letter-spacing: .08em; }
.dice-history-rail { position: relative; z-index: 9; min-width: 0; display: flex; flex-direction: column; overflow: hidden; border-left: 1px solid rgba(218, 198, 157, .14); background: linear-gradient(180deg, rgba(8, 7, 10, .92), rgba(8, 6, 10, .78)); }
.dice-history-heading { flex: 0 0 auto; padding: 18px 18px 14px; border-bottom: 1px solid rgba(218, 198, 157, .12); }
.dice-history-heading span, .dice-history-heading small { display: block; }
.dice-history-heading span { color: #d8cbbd; font: 500 calc(12px * var(--fs, 1)) Georgia, "Songti SC", serif; letter-spacing: .12em; }
.dice-history-heading small { margin-top: 4px; color: #665d58; font-size: calc(8px * var(--fs, 1)); letter-spacing: .2em; }
.dice-readout { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 12px; scrollbar-width: thin; scrollbar-color: #5f4452 rgba(255,255,255,.03); }
.dice-readout:empty::before { content: attr(data-empty-text); display: block; padding: 24px 10px; color: #615954; font-size: calc(9px * var(--fs, 1)); line-height: 1.8; white-space: pre-line; text-align: center; }
.dice-action-group { position: relative; margin-bottom: 12px; padding: 0 0 12px; border-bottom: 1px solid rgba(218, 190, 138, .18); min-width: 0; max-width: 100%; }
.dice-action-group:last-child { margin-bottom: 0; }
.dice-action-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin: 1px 2px 8px; color: #9b8e82; font-size: calc(8px * var(--fs, 1)); letter-spacing: .12em; min-width: 0; }
.dice-action-heading b { flex: 1 1 auto; min-width: 0; color: #c8b9aa; font-size: calc(9px * var(--fs, 1)); font-weight: 500; line-height: 1.4; overflow-wrap: break-word; word-break: normal; white-space: normal; }
.dice-action-heading span { flex: 0 0 auto; color: #625956; white-space: nowrap; line-height: 1.4; }
.dice-entry { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; margin-top: 6px; padding: 8px 8px; border: 1px solid rgba(218, 190, 138, .2); background: rgba(12, 9, 13, .78); box-shadow: 0 8px 22px rgba(0,0,0,.25); }
.dice-face { flex: 0 0 29px; width: 29px; height: 29px; display: grid; place-items: center; transform: rotate(45deg); border: 1px solid var(--gold); color: var(--gold-bright); background: #171117; font: 700 calc(12px * var(--fs, 1)) Georgia, serif; }
.dice-face b { transform: rotate(-45deg); }
.dice-face.enemy { border-color: #9a5969; color: #e0a1af; }
.dice-versus { flex: 0 0 auto; color: #5f5753; font: calc(8px * var(--fs, 1)) Georgia, serif; }
.dice-copy { flex: 1 1 auto; min-width: 0; }
.dice-copy b, .dice-copy small { display: block; overflow: visible; max-width: 100%; overflow-wrap: break-word; word-break: normal; white-space: normal; }
.dice-copy b { color: #d9cdc0; font-size: calc(9px * var(--fs, 1)); font-weight: 500; letter-spacing: .06em; line-height: 1.4; }
.dice-copy small { margin-top: 3px; color: #827871; font-size: calc(8px * var(--fs, 1)); line-height: 1.45; }
.dice-entry.success .dice-face { border-color: #87b696; color: #b5d8bf; box-shadow: 0 0 14px rgba(100,180,127,.2); }
.dice-entry.failure .dice-face { border-color: #b05a67; color: #e49aa6; box-shadow: 0 0 14px rgba(190,74,94,.22); }
.dice-entry.critical .dice-face { border-color: #f0d18a; color: #fff1bf; box-shadow: 0 0 18px rgba(238,195,101,.38); }

.fog-wall { position: absolute; z-index: 6; left: -26%; top: 0; bottom: 0; width: 42%; pointer-events: none; opacity: .13; filter: blur(18px); transition: left .55s ease, opacity .55s ease; }
.fog-wall i { position: absolute; border-radius: 50%; background: rgba(218, 88, 158, .88); animation: fogFloat 5s ease-in-out infinite alternate; }
.fog-wall i:nth-child(1) { width: 88%; height: 40%; left: 0; top: 4%; }
.fog-wall i:nth-child(2) { width: 70%; height: 48%; left: 12%; top: 30%; animation-delay: -1.5s; }
.fog-wall i:nth-child(3) { width: 92%; height: 44%; left: -8%; bottom: -6%; animation-delay: -3s; }
.fog-wall i:nth-child(4) { width: 52%; height: 30%; right: -8%; top: 20%; animation-delay: -2s; }
@keyframes fogFloat { to { transform: translate(22px, 15px) scale(1.1); } }

.scene-object { flex: 1 1 0; min-height: 0; min-width: 0; position: relative; display: grid; place-items: center; overflow: hidden; padding: 8px 0 12px; }
.intro-hotspots { position: absolute; z-index: 6; inset: 0; }
.scene-hotspot { position: absolute; min-width: 120px; padding: 12px 14px; color: #d9c8b2; border: 1px solid rgba(220, 187, 129, .25); background: rgba(5, 4, 7, .72); box-shadow: 0 12px 32px rgba(0,0,0,.48), inset 0 0 20px rgba(120,83,55,.08); cursor: pointer; backdrop-filter: blur(4px); transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.scene-hotspot:hover, .scene-hotspot:focus-visible { transform: translateY(-3px); color: #f0dba7; border-color: rgba(238, 205, 142, .72); background: rgba(20, 12, 17, .88); outline: none; }
.scene-hotspot span, .scene-hotspot small { display: block; }
.scene-hotspot span { font: 500 calc(13px * var(--fs, 1)) Georgia, "Songti SC", serif; letter-spacing: .12em; }
.scene-hotspot small { margin-top: 5px; color: #8f7f73; font-size: calc(8px * var(--fs, 1)); letter-spacing: .08em; }
.altar-hotspot { left: 21%; top: 42%; }
.door-hotspot { right: 13%; top: 35%; }
.door-hotspot.unlocked { border-color: rgba(186, 120, 144, .58); box-shadow: 0 0 26px rgba(172, 72, 119, .2); }

.breeding-hotspots { position: absolute; z-index: 3; inset: 0; pointer-events: none; }
.breeding-hotspots .scene-hotspot { pointer-events: auto; }
.breeding-cavity-hotspot {
  left: 70%;
  top: 57%;
  transform: translate(-50%, -50%);
  text-align: center;
  border-color: rgba(186, 120, 144, .52);
  box-shadow: 0 12px 32px rgba(0,0,0,.48), 0 0 24px rgba(172, 72, 119, .22), inset 0 0 20px rgba(120,83,55,.08);
}
.breeding-cavity-hotspot:hover, .breeding-cavity-hotspot:focus-visible {
  transform: translate(-50%, calc(-50% - 3px));
  border-color: rgba(238, 180, 200, .8);
  background: rgba(28, 12, 20, .9);
}
.door-silhouette { position: relative; width: 120px; height: 190px; border: 1px solid rgba(203, 177, 132, .15); border-bottom: 0; border-radius: 60px 60px 0 0; background: linear-gradient(90deg, #08070a, #161119 50%, #08070a); box-shadow: 0 0 70px rgba(0, 0, 0, .9), inset 0 0 40px #000; }
.door-rune { position: absolute; left: 50%; top: 38%; width: 26px; height: 26px; transform: translateX(-50%) rotate(45deg); border: 1px solid rgba(218, 189, 132, .35); box-shadow: inset 0 0 12px rgba(219, 188, 125, .13); }

.enemy-figure { position: relative; width: 200px; height: 245px; overflow: visible; animation: enemyIdle 2.8s ease-in-out infinite alternate; }
.enemy-figure:not(.has-portrait) .enemy-head,
.enemy-figure:not(.has-portrait) .enemy-body,
.enemy-figure:not(.has-portrait) .enemy-weapon { filter: drop-shadow(0 25px 22px rgba(0, 0, 0, .75)); }
@keyframes enemyIdle { to { transform: translateY(-4px); } }
.enemy-aura { position: absolute; inset: 5% 5% 12%; border-radius: 50%; background: radial-gradient(circle, rgba(166, 59, 91, .2), transparent 65%); filter: blur(10px); }
.enemy-head { position: absolute; z-index: 2; left: 69px; top: 12px; width: 62px; height: 70px; clip-path: polygon(50% 0, 95% 28%, 80% 100%, 20% 100%, 5% 28%); background: linear-gradient(135deg, #2f2a31, #09080a 60%); border: 1px solid #5c4c4f; }
.enemy-head i { position: absolute; top: 35px; width: 12px; height: 3px; background: #dc4a6c; box-shadow: 0 0 10px #ec416c; }
.enemy-head i:first-child { left: 13px; transform: rotate(8deg); }
.enemy-head i:last-child { right: 13px; transform: rotate(-8deg); }
.enemy-body { position: absolute; z-index: 1; left: 39px; top: 70px; width: 122px; height: 142px; clip-path: polygon(21% 0, 79% 0, 100% 28%, 84% 100%, 16% 100%, 0 28%); background: linear-gradient(110deg, #0b090c 0 28%, #30292f 48%, #0b090c 77%); border: 1px solid #51444a; }
.enemy-weapon { position: absolute; z-index: 3; right: 13px; top: 66px; width: 5px; height: 170px; transform: rotate(16deg); transform-origin: bottom; background: linear-gradient(90deg, #3b3437, #a18a75, #332c31); box-shadow: 0 0 0 1px #1a171a; }
.enemy-nameplate { position: absolute; z-index: 4; left: 50%; bottom: -9px; width: 220px; transform: translateX(-50%); text-align: center; }
.enemy-nameplate span { display: block; margin-bottom: 5px; font-family: "STSong", serif; letter-spacing: .16em; }
.enemy-hp { height: 5px; background: #251015; border: 1px solid rgba(189, 90, 104, .35); }
.enemy-hp i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #7d2737, #c8495b); transition: width .25s ease; }
.enemy-nameplate small { color: #9f8585; font-size: calc(9px * var(--fs, 1)); }
.enemy-portrait { display: none; }
.enemy-figure.has-portrait { position: absolute; z-index: 3; left: 50%; top: 8px; bottom: 20px; width: clamp(180px, 24vw, 310px); max-width: 92%; margin-left: calc(clamp(180px, 24vw, 310px) / -2); height: auto; max-height: calc(100% - 28px); }
.enemy-figure.has-portrait.boss-portrait { width: clamp(210px, 29vw, 360px); margin-left: calc(clamp(210px, 29vw, 360px) / -2); }
.enemy-figure.has-portrait .enemy-head,
.enemy-figure.has-portrait .enemy-body,
.enemy-figure.has-portrait .enemy-weapon { display: none; }
.enemy-figure.has-portrait .enemy-portrait { display: block; position: absolute; z-index: 2; left: 0; top: 0; width: 100%; height: calc(100% - 42px); object-fit: contain; object-position: center bottom; pointer-events: none; user-select: none; filter: drop-shadow(0 25px 22px rgba(0, 0, 0, .75)); }
/* 失落英雄二阶段立绘暂为 怪物/失落英雄_PLACEHOLDER.svg；正式图替换该文件或改 MONSTER_PORTRAITS */
.enemy-figure.has-portrait .enemy-aura { inset: 8% 8% 14%; }
.enemy-figure.acting-attack:not(.hit):not(.dying):not(.dead),
.enemy-figure.acting-melee:not(.hit):not(.dying):not(.dead),
.enemy-figure.acting-status:not(.hit):not(.dying):not(.dead),
.enemy-figure.acting-grapple:not(.hit):not(.dying):not(.dead) {
  animation-iteration-count: 1;
  animation-fill-mode: both;
}
.enemy-figure.acting-attack:not(.hit):not(.dying):not(.dead) {
  animation-name: enemyActAttack;
  animation-duration: .6s;
  animation-timing-function: cubic-bezier(.2, .7, .2, 1);
}
@keyframes enemyActAttack {
  0% { transform: translate(0, 0); filter: brightness(1); }
  16% { transform: translate(-10px, 2px) rotate(-2deg); filter: brightness(1.06); }
  36% { transform: translate(-26px, 5px) rotate(-5deg); filter: brightness(1.12); }
  52% { transform: translate(-14px, 3px) rotate(-2deg); }
  72% { transform: translate(6px, -1px) rotate(1deg); filter: brightness(1.04); }
  100% { transform: translate(0, 0); filter: brightness(1); }
}
.enemy-figure.acting-melee:not(.hit):not(.dying):not(.dead) {
  animation-name: enemyActMelee;
  animation-duration: .7s;
  animation-timing-function: ease-in-out;
}
@keyframes enemyActMelee {
  0% { transform: translate(0, 0); }
  18% { transform: translate(-18px, 7px) rotate(-3deg); }
  30% { transform: translate(-8px, 5px) rotate(-1deg); }
  48% { transform: translate(-24px, 9px) rotate(-4deg); }
  64% { transform: translate(-10px, 6px) rotate(-1deg); }
  100% { transform: translate(0, 0); }
}
.enemy-figure.acting-status:not(.hit):not(.dying):not(.dead) {
  animation-name: enemyActStatus;
  animation-duration: .65s;
  animation-timing-function: ease-in-out;
}
@keyframes enemyActStatus {
  0% { transform: translateY(0) scale(1); filter: brightness(1); }
  24% { transform: translateY(-7px) scale(1.025); filter: brightness(1.22); }
  50% { transform: translateY(-3px) scale(1.01); filter: brightness(1.38); }
  74% { transform: translateY(-6px) scale(1.015); filter: brightness(1.14); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}
.enemy-figure.acting-grapple:not(.hit):not(.dying):not(.dead) {
  animation-name: enemyActGrapple;
  animation-duration: .75s;
  animation-timing-function: ease-in-out;
}
@keyframes enemyActGrapple {
  0% { transform: translate(0, 0) scale(1); }
  28% { transform: translate(-30px, 9px) rotate(-5deg) scale(1.035); }
  50% { transform: translate(-28px, 11px) rotate(-4deg) scale(1.04); }
  72% { transform: translate(-16px, 5px) rotate(-2deg) scale(1.015); }
  100% { transform: translate(0, 0) scale(1); }
}
.enemy-figure.hit { animation: enemyHit .5s ease-in-out; }
@keyframes enemyHit {
  0%, 100% { transform: translate(0, 0); opacity: 1; filter: brightness(1); }
  10% { transform: translate(-12px, 2px); opacity: .28; filter: brightness(1.65); }
  22% { transform: translate(11px, -2px); opacity: 1; filter: brightness(1.25); }
  34% { transform: translate(-9px, 3px); opacity: .38; filter: brightness(1.5); }
  48% { transform: translate(8px, -1px); opacity: 1; filter: brightness(1.2); }
  62% { transform: translate(-6px, 2px); opacity: .45; }
  76% { transform: translate(4px, 0); opacity: 1; }
}
.enemy-figure.dying {
  pointer-events: none;
  animation: enemyDeath .92s ease-out forwards;
}
@keyframes enemyDeath {
  0% { opacity: 1; transform: translate(0, 0); filter: none; }
  10% { opacity: .12; }
  18% { opacity: 1; }
  28% { opacity: .08; }
  36% { opacity: 1; }
  46% { opacity: .1; }
  54% { opacity: .85; }
  64% { opacity: .06; }
  74% { opacity: .45; }
  100% { opacity: 0; transform: translate(0, 8px); filter: grayscale(1) brightness(.55); }
}
.enemy-figure.dead {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
  animation: none;
  filter: none;
}

.enemy-party { position: absolute; z-index: 4; inset: 6px 0 18px; display: flex; align-items: stretch; justify-content: center; gap: clamp(4px, 1vw, 14px); overflow: visible; }
.enemy-party[hidden] { display: none; }
.enemy-party .enemy-figure { position: relative; inset: auto; flex: 0 1 clamp(150px, 22vw, 260px); width: clamp(150px, 22vw, 260px); max-width: 31%; height: 100%; max-height: 100%; margin: 0; padding: 0; color: inherit; border: 1px solid transparent; background: transparent; cursor: pointer; overflow: visible; }
.enemy-party .enemy-figure:hover,
.enemy-party .enemy-figure.targeted { border-color: rgba(224, 187, 115, .6); background: radial-gradient(circle at 50% 60%, rgba(104, 70, 38, .18), transparent 64%); }
.enemy-party .enemy-figure.acting,
.enemy-figure.acting { border-color: rgba(218, 83, 112, .82); box-shadow: inset 0 0 26px rgba(174, 42, 76, .2), 0 0 20px rgba(174, 42, 76, .22); }
.enemy-party .enemy-figure.defeated:not(.dying):not(.dead) { opacity: .28; filter: grayscale(1); pointer-events: none; }
.enemy-party .enemy-figure .enemy-nameplate { bottom: 2px; width: min(210px, 96%); }
.enemy-party .enemy-figure .enemy-nameplate span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(10px * var(--fs, 1)); letter-spacing: .06em; }
.enemy-party .enemy-figure .enemy-nameplate em { display: block; margin-bottom: 3px; color: #b99a69; font-size: calc(8px * var(--fs, 1)); font-style: normal; }
.enemy-party .enemy-figure .enemy-portrait { height: calc(100% - 58px); }
/* t454u: speaking bubble must paint above sibling portrait frames */
.enemy-figure.is-speaking,
.enemy-figure:has(> .enemy-speech.is-visible),
.enemy-party .enemy-figure.is-speaking,
.enemy-party .enemy-figure:has(> .enemy-speech.is-visible) { z-index: 8; }
.enemy-party .enemy-speech { max-width: min(360px, 280%); overflow: visible; }

.event-story { display: grid; gap: 10px; max-height: min(46vh, 420px); overflow-y: auto; padding-right: 6px; }
.event-story p { margin: 0; color: #c8bdb2; line-height: 1.8; }
.event-adult-note { padding: 8px 10px; color: #d3a5b9; border-left: 2px solid var(--pink); background: rgba(117,42,79,.14); font-size: calc(9px * var(--fs, 1)); }

.object-card { position: relative; z-index: 2; width: min(560px, 94%); max-width: 100%; max-height: min(46vh, 340px); overflow-x: hidden; overflow-y: auto; padding: 18px 20px; border: 1px solid var(--line-bright); background: rgba(13, 11, 16, .86); box-shadow: var(--shadow); text-align: center; box-sizing: border-box; scrollbar-width: thin; scrollbar-color: rgba(220,190,138,.34) rgba(255,255,255,.025); }
.object-glyph { display: block; color: var(--gold-bright); font-size: calc(28px * var(--fs, 1)); }
.object-card h3 { margin: 8px 0 6px; font-family: "STSong", serif; font-size: clamp(15px, 2.1vw, 19px); font-weight: 400; letter-spacing: .06em; line-height: 1.45; overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
.object-card p { margin: 0; color: var(--muted); font-size: calc(12px * var(--fs, 1)); line-height: 1.7; overflow-wrap: anywhere; word-break: break-word; white-space: normal; }

.choice-layer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: min(820px, 100%); margin: 0 auto; position: relative; z-index: 12; flex: 0 1 auto; max-height: min(42%, 420px); overflow-x: hidden; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(220,190,138,.34) rgba(255,255,255,.025); }
.choice-card {
  position: relative;
  min-width: 0;
  width: 100%;
  min-height: 78px;
  height: auto;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: start;
  gap: 13px;
  padding: 13px 16px;
  overflow: hidden;
  color: var(--ivory);
  border: 1px solid var(--line);
  background: rgba(10, 9, 12, .86);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}
.choice-card:hover { border-color: var(--gold); background: rgba(26, 21, 26, .94); transform: translateY(-1px); }
.choice-card::after { content: ""; position: absolute; inset: auto 0 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: 0; }
.choice-card:hover::after { opacity: .72; }
.choice-index { width: 34px; height: 34px; margin-top: 2px; display: grid; place-items: center; transform: rotate(45deg); border: 1px solid rgba(214, 183, 127, .3); color: var(--gold-bright); font-family: Georgia, serif; flex-shrink: 0; }
.choice-index i { transform: rotate(-45deg); font-style: normal; }
.choice-copy { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.choice-copy b, .choice-copy small { display: block; overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
.choice-copy b { margin-bottom: 5px; font-family: "STSong", serif; font-size: calc(15px * var(--fs, 1)); font-weight: 400; letter-spacing: .06em; line-height: 1.4; }
.choice-copy small { color: #8f847b; font-size: calc(10px * var(--fs, 1)); line-height: 1.55; }
.route-reveal { display: block; margin-top: 5px; color: #d8bd83; font-style: normal; letter-spacing: .08em; }
.choice-arrow { align-self: center; color: #6f635b; font-size: calc(18px * var(--fs, 1)); }

.combat-layer { width: min(820px, 100%); margin: 0 auto; position: relative; z-index: 12; flex: 0 1 auto; max-height: min(48%, 280px); overflow: visible; display: flex; flex-direction: column; min-height: 0; }
.combat-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; overflow: visible; }
.combat-skill-bar { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; position: relative; overflow: visible; }
.combat-menu-slot { position: relative; overflow: visible; min-width: 0; }
.combat-button { min-height: 64px; width: 100%; padding: 11px; color: #d8cec2; border: 1px solid var(--line); background: rgba(10, 9, 12, .9); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.combat-button:hover { border-color: #b89255; color: var(--gold-bright); }
.combat-button.energy { border-color: rgba(207,171,92,.3); background: rgba(58,43,17,.32); }
.combat-button.status { border-color: rgba(118,112,165,.3); background: rgba(31,28,55,.32); }
.combat-button.bag { border-color: rgba(180,160,120,.28); background: rgba(28,24,18,.4); }
.combat-button.ejaculate { border-color: rgba(232,120,170,.6); background: linear-gradient(145deg, rgba(140,36,88,.62), rgba(72,18,52,.78)); color: #f6c6da; }
.combat-button.ejaculate:hover { border-color: #f0a8c4; color: #ffe4f0; }
.combat-button.ejaculate small { color: #d090ae; }
.combat-button.counter { border-color: rgba(111,157,137,.3); }
.combat-button.is-open { border-color: #b89255; color: var(--gold-bright); }
.combat-button:disabled { filter: grayscale(.7); }
.combat-button b, .combat-button small { display: block; }
.combat-button b { margin-bottom: 0; font-family: "STSong", serif; font-weight: 400; }
.combat-button small { margin-top: 5px; color: #7e746d; font-size: calc(9px * var(--fs, 1)); }
.combat-flyout { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 24; display: grid; gap: 6px; min-width: 100%; width: max(100%, min(260px, 72vw)); max-height: min(42vh, 280px); overflow-x: hidden; overflow-y: auto; padding: 6px; border: 1px solid var(--line); background: rgba(10, 9, 12, .96); box-shadow: 0 14px 32px rgba(0, 0, 0, .55); }
.combat-flyout.is-bag { left: auto; right: 0; width: min(320px, 78vw); }
.combat-flyout .combat-button { min-height: 54px; }
.combat-bag-section { display: grid; gap: 4px; }
.combat-bag-section + .combat-bag-section { margin-top: 4px; padding-top: 6px; border-top: 1px solid rgba(223, 199, 154, .16); }
.combat-bag-label { margin: 0 2px 2px; color: #8f847b; font-size: calc(9px * var(--fs, 1)); letter-spacing: .08em; }
.combat-bag-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; color: #d8cec2; border: 1px solid var(--line); background: rgba(10, 9, 12, .9); }
.combat-bag-copy { min-width: 0; }
.combat-bag-copy b, .combat-bag-copy small { display: block; overflow-wrap: anywhere; word-break: break-word; }
.combat-bag-copy b { margin-bottom: 3px; font-family: "STSong", serif; font-size: calc(12px * var(--fs, 1)); font-weight: 400; }
.combat-bag-copy small { color: #7e746d; font-size: calc(9px * var(--fs, 1)); line-height: 1.45; }
.combat-bag-row .equipment-action { min-width: 64px; text-align: center; }
.combat-bag-empty { margin: 0; padding: 8px 6px; color: #7e746d; font-size: calc(10px * var(--fs, 1)); line-height: 1.55; }

.hud-panel { --hud-scale: 0.84; flex: 0 0 calc(350px * var(--hud-scale)); min-height: calc(350px * var(--hud-scale)); height: calc(350px * var(--hud-scale)); position: relative; z-index: 15; overflow: visible; border-top: 1px solid rgba(223, 199, 154, .25); background: linear-gradient(180deg, #0e0c11, #09080b); box-shadow: 0 -20px 50px rgba(0, 0, 0, .48); }
.hud-panel-inner { position: absolute; left: 0; top: 0; width: calc(100% / var(--hud-scale)); height: 350px; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: 270px 202px minmax(0, 1fr) 170px 170px; transform: scale(var(--hud-scale)); transform-origin: top left; }
.portrait-frame { position: relative; overflow: hidden; width: 100%; height: 100%; min-width: 0; min-height: 0; align-self: stretch; justify-self: stretch; padding: 0; color: inherit; border: 0; border-right: 1px solid rgba(220, 197, 157, .2); background: #17141a; cursor: pointer; text-align: left; }
.portrait-frame img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; display: block; object-fit: cover; object-position: 50% 18%; filter: saturate(.78) contrast(1.06); transition: filter .2s ease; }
/* If a text-scroll wrap is still present, pin it so the img can fill the frame. */
.portrait-frame > .btn-scroll-surface { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; max-height: none; min-width: 0; min-height: 0; overflow: hidden; }
.portrait-frame:hover img { filter: saturate(.9) contrast(1.04) brightness(1.08); }
.portrait-frame.is-hit img { animation: portraitHit .32s ease; }
@keyframes portraitHit { 45% { transform: translateX(-7px); filter: saturate(.65) contrast(1.3) sepia(.25); } }
.portrait-frame.is-attack img { animation: portraitAttack .4s ease; }
@keyframes portraitAttack { 35% { transform: scale(1.07) translateY(-5px); filter: saturate(.95) contrast(1.08) brightness(1.06); } }
.portrait-frame.fog-engulfed { box-shadow: inset 0 0 28px rgba(239,74,159,.72), 0 0 24px rgba(216,54,137,.3); }
.portrait-frame.fog-engulfed::before { content: ""; position: absolute; z-index: 2; inset: -15% -35%; pointer-events: none; background: radial-gradient(ellipse at 8% 20%, rgba(244,94,174,.64), transparent 27%), radial-gradient(ellipse at 92% 46%, rgba(220,61,151,.56), transparent 31%), radial-gradient(ellipse at 25% 92%, rgba(246,128,191,.5), transparent 30%); filter: blur(11px); animation: portraitFogDrift 3.8s ease-in-out infinite alternate; }
.portrait-frame.fog-engulfed::after { content: ""; position: absolute; z-index: 3; inset: 0; pointer-events: none; border: 1px solid rgba(255,111,189,.64); box-shadow: inset 0 0 20px rgba(232,70,157,.7); animation: portraitFogPulse 2.2s ease-in-out infinite alternate; }
@keyframes portraitFogDrift { to { transform: translateX(12%) translateY(-4%) scale(1.08); opacity: .72; } }
@keyframes portraitFogPulse { to { border-color: rgba(255,164,211,.86); box-shadow: inset 0 0 34px rgba(232,70,157,.88); } }
.portrait-fade { position: absolute; z-index: 4; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(7, 6, 9, .97)); }
.portrait-open-hint { position: absolute; z-index: 5; left: 0; right: 0; top: 0; padding: 8px 10px; color: #e0c58b; background: linear-gradient(180deg, rgba(5,4,6,.88), transparent); opacity: 0; font-size: calc(8px * var(--fs, 1)); letter-spacing: .12em; text-align: center; transition: opacity .2s ease; }
.portrait-frame:hover .portrait-open-hint, .portrait-frame:focus-visible .portrait-open-hint { opacity: 1; }
.portrait-name { position: absolute; z-index: 5; left: 14px; right: 14px; bottom: 14px; border-left: 2px solid var(--gold); padding-left: 9px; }
.portrait-name small, .portrait-name b { display: block; }
.portrait-name small { color: #8f8378; font-size: calc(8px * var(--fs, 1)); letter-spacing: .14em; }
.portrait-name b { margin-top: 0; font-family: "STSong", serif; font-weight: 400; letter-spacing: .12em; }
.portrait-name small + b { margin-top: 2px; }

.status-column { display: grid; grid-template-rows: auto minmax(0, 1fr); border-right: 1px solid rgba(220, 197, 157, .18); }
.data-slot { padding: 12px 17px; }
.data-slot { border-bottom: 1px solid rgba(220, 197, 157, .13); }
.vital-row { display: flex; justify-content: space-between; align-items: baseline; color: #8f857c; font-size: calc(10px * var(--fs, 1)); }
.vital-row b { color: #d8cbc0; font-family: Georgia, serif; font-size: calc(13px * var(--fs, 1)); font-weight: 500; }
.vital-row.compact { margin-top: 13px; }
.vital-row.compact span { display: flex; align-items: center; gap: 6px; }
.bar { height: 5px; margin-top: 8px; background: #261015; }
.bar i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #7d2b36, #bd4e58); transition: width .3s ease; }
.resource-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; color: #817872; font-size: calc(8px * var(--fs, 1)); }
.resource-row b { color: #cfc4b8; font: 500 calc(9px * var(--fs, 1)) Georgia, serif; }
.resource-row + .bar { height: 4px; margin-top: 4px; position: relative; overflow: hidden; }
.desire-bar { background: #21101b; }
.desire-bar i { background: linear-gradient(90deg, #7e2e5c, #d467a5); }
.sanity-bar { background: #111728; }
.sanity-bar i { background: linear-gradient(90deg, #516d9f, #9bb2d9); }
.energy-bar { background: #1c180e; }
.energy-bar i { position: relative; z-index: 1; background: linear-gradient(90deg, #a67d31, #f1d497); }
.energy-bar em { position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: 0; background: repeating-linear-gradient(135deg, rgba(38,20,27,.96) 0 4px, rgba(117,43,76,.88) 4px 7px); border-left: 1px solid #e073aa; transition: width .3s ease; }
.attribute-slot { min-width: 0; min-height: 0; padding: 12px 15px 10px; overflow: visible; }
.attribute-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.attribute-heading span { color: #8e8378; font-size: calc(9px * var(--fs, 1)); letter-spacing: .18em; }
.attribute-heading small { color: #554e4a; font-size: calc(7px * var(--fs, 1)); }
.attribute-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 5px; }
.attribute-chip { position: relative; display: flex; justify-content: space-between; gap: 5px; padding: 5px 6px; color: #817873; border: 1px solid rgba(220,197,157,.1); background: rgba(255,255,255,.018); font-size: calc(9px * var(--fs, 1)); cursor: help; }
.attribute-chip:first-child { grid-column: 1 / -1; }
.attribute-level-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}
.attribute-level-split .attribute-chip-half {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 5px;
  padding: 5px 6px;
  color: #817873;
  border: 1px solid rgba(220,197,157,.1);
  background: rgba(255,255,255,.018);
  font-size: calc(9px * var(--fs, 1));
  cursor: help;
  min-width: 0;
}
.attribute-level-split .attribute-chip-half b {
  color: #eee7da;
  font: 500 calc(10px * var(--fs, 1)) Georgia, serif;
}
.attribute-level-split .attribute-chip-half.is-hybrid {
  color: #e0c8f0;
  border-color: rgba(158, 92, 196, .4);
  background: rgba(72, 28, 96, .22);
}
.attribute-level-split .attribute-chip-half.is-hybrid b { color: #e8d6f6; }
.attribute-level-split .attribute-chip-half:hover .attribute-tooltip,
.attribute-level-split .attribute-chip-half:focus-visible .attribute-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.attribute-chip b { color: #eee7da; font: 500 calc(10px * var(--fs, 1)) Georgia, serif; }
.attribute-chip.increased b { color: #84c79a; }
.attribute-chip.decreased b { color: #db747c; }
.attribute-tooltip, .equipment-tooltip { position: absolute; z-index: 60; left: 50%; bottom: calc(100% + 9px); width: 220px; transform: translate(-50%, 6px); padding: 10px 12px; color: #e8ddd3; border: 1px solid #cbb58a; background: #0c0a0e; box-shadow: 0 16px 40px rgba(0,0,0,.88), 0 0 0 1px #000; opacity: 0; visibility: hidden; pointer-events: none; font-size: calc(9px * var(--fs, 1)); line-height: 1.6; transition: .18s ease; }
.attribute-tooltip::after, .equipment-tooltip::after { content: ""; position: absolute; left: 50%; top: 100%; width: 8px; height: 8px; transform: translate(-50%,-4px) rotate(45deg); border-right: 1px solid rgba(220,190,138,.34); border-bottom: 1px solid rgba(220,190,138,.34); background: #0c0a0e; }
.attribute-chip:hover .attribute-tooltip, .attribute-chip:focus-visible .attribute-tooltip, .equipment-card:hover .equipment-tooltip, .equipment-card:focus-within .equipment-tooltip { opacity: 1; visibility: visible; transform: translate(-50%,0); }
.attribute-chip:nth-child(even) .attribute-tooltip { left: 0; transform: translate(0,6px); }
.attribute-chip:nth-child(odd):not(:first-child) .attribute-tooltip { left: auto; right: 0; transform: translate(0,6px); }
.attribute-chip:nth-child(even):hover .attribute-tooltip, .attribute-chip:nth-child(even):focus-visible .attribute-tooltip,
.attribute-chip:nth-child(odd):not(:first-child):hover .attribute-tooltip, .attribute-chip:nth-child(odd):not(:first-child):focus-visible .attribute-tooltip { transform: translate(0,0); }
.status-list { display: flex; flex-wrap: wrap; gap: 6px; }
.status-chip { width: 100%; padding: 6px 7px; color: #cdbbc2; border: 1px solid rgba(208, 107, 160, .28); background: rgba(107, 40, 76, .16); font-size: calc(8px * var(--fs, 1)); line-height: 1.35; }
.status-chip[title] { cursor: help; }
.status-chip.positive { color: #b8ccb9; border-color: rgba(122, 170, 138, .3); background: rgba(48, 92, 64, .14); }
.status-chip.has-durability { position: relative; display: flex; flex-direction: column; box-sizing: border-box; padding-bottom: 8px; overflow: hidden; }
.status-chip .status-dura-bar { display: block; width: 100%; height: 3px; margin-top: 5px; background: rgba(0, 0, 0, .45); overflow: hidden; pointer-events: none; }
.status-chip .status-dura-fill { display: block; height: 100%; width: 0; }
.status-chip .status-dura-fill.high { background: #f2f2f2; }
.status-chip .status-dura-fill.mid { background: #e6c84a; }
.status-chip .status-dura-fill.low { background: #d4554a; }
.empty-status { color: #5f5854; font-size: calc(10px * var(--fs, 1)); }

.dialogue-box { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 26px 30px 18px; background: linear-gradient(110deg, rgba(19, 16, 22, .96), rgba(9, 8, 11, .96)); }
.dialogue-box::before { content: ""; position: absolute; left: 0; top: 26px; bottom: 26px; width: 1px; background: linear-gradient(transparent, var(--gold), transparent); }
.speaker-line { display: flex; align-items: center; gap: 12px; color: var(--gold-bright); font-family: "STSong", serif; font-size: calc(13px * var(--fs, 1)); letter-spacing: .15em; }
.speaker-line i { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(204, 171, 110, .34), transparent); }
.dialogue-box > p { white-space: normal; min-height: 70px; flex: 1 1 auto; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(204,171,110,.4) transparent; margin: 19px 0 16px; color: #d3c9bf; font-family: "STSong", serif; font-size: calc(clamp(14px, 1.25vw, 17px) * var(--fs, 1)); line-height: 1.8; letter-spacing: .04em; }
.dialogue-line { display: block; color: #d3c9bf; }
.dialogue-line + .dialogue-line { margin-top: .22em; }
.dialogue-line.dialogue-enemy { color: #9fd1df; text-shadow: 0 0 10px rgba(76, 153, 180, .13); }
.dialogue-line.dialogue-intimate { color: #efa0d5; font-family: "STKaiti", "KaiTi", "FangSong", serif; font-style: italic; font-weight: 500; letter-spacing: .065em; text-shadow: 0 0 12px rgba(222, 83, 170, .22); }
.dialogue-line.dialogue-relic-obtain,
.dialogue-box.is-relic-obtain > p .dialogue-line.dialogue-relic-obtain {
  color: #f0a3cc;
  font-weight: 650;
  letter-spacing: .05em;
  text-shadow: 0 0 14px rgba(214, 104, 160, .42), 0 0 1px rgba(242, 170, 210, .7);
}
.dialogue-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.dialogue-footer > span { color: #665f5a; font-size: calc(9px * var(--fs, 1)); letter-spacing: .08em; }
#contextHint.dialogue-relic-obtain,
.dialogue-footer > span.dialogue-relic-obtain {
  color: #e389b8;
  font-weight: 650;
  letter-spacing: .1em;
  text-shadow: 0 0 10px rgba(214, 104, 160, .35);
}
.advance-button { min-width: 92px; padding: 9px 14px; color: #cfbd9e; border: 1px solid rgba(214, 183, 127, .3); background: rgba(203, 165, 95, .05); cursor: pointer; }
.advance-button:hover { color: #16110a; background: var(--gold); }
.advance-button[hidden] { display: none; }

.quick-status-rail, .body-monitor-rail { min-width: 0; min-height: 0; overflow: hidden; padding: 13px 10px 10px; display: flex; flex-direction: column; border-left: 1px solid rgba(220,197,157,.16); background: rgba(7,6,9,.48); }
.quick-status-heading, .body-monitor-heading { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 9px; margin-bottom: 9px; border-bottom: 1px solid rgba(220,197,157,.12); }
.quick-status-heading span, .body-monitor-heading span { color: #a99b8d; font-family: "STSong", serif; font-size: calc(12px * var(--fs, 1)); letter-spacing: .16em; }
.quick-status-heading small, .body-monitor-heading small { color: #514b47; font-size: calc(7px * var(--fs, 1)); letter-spacing: .12em; }
.quick-status-rail > .status-list { flex: 1 1 0; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; align-content: flex-start; align-items: flex-start; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(196, 164, 110, .55) rgba(255,255,255,.04); }
.quick-status-rail > .status-list::-webkit-scrollbar { width: 6px; }
.quick-status-rail > .status-list::-webkit-scrollbar-thumb { background: rgba(196, 164, 110, .45); border-radius: 99px; }
.quick-status-rail .status-chip { flex: 0 0 auto; }

.body-monitor { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; border: 1px solid rgba(101, 210, 132, .22); background: radial-gradient(circle at 50% 34%, rgba(39, 96, 59, .16), rgba(5, 13, 9, .7) 67%, rgba(2, 6, 4, .9)); box-shadow: inset 0 0 24px rgba(43, 117, 65, .11); }
.body-monitor::before, .body-monitor::after { content: ""; position: absolute; z-index: 0; pointer-events: none; }
.body-monitor::before { inset: 7px; border: 1px solid rgba(109, 209, 137, .08); }
.body-monitor::after { left: 12%; right: 12%; top: 12px; height: 1px; background: linear-gradient(90deg, transparent, rgba(123, 230, 151, .42), transparent); animation: bodyScan 4.8s linear infinite; }
@keyframes bodyScan { 0% { transform: translateY(0); opacity: .2; } 45% { opacity: .75; } 100% { transform: translateY(160px); opacity: .12; } }
.body-monitor-svg { position: relative; z-index: 1; display: block; width: 100%; height: calc(100% - 20px); }
.body-grid path { fill: none; stroke: rgba(108, 192, 130, .065); stroke-width: 4; }
.body-lineart-raster { opacity: .9; filter: url(#bodyLineGreen); }
.body-eye-glow { display: none; fill: #ff76bd; opacity: var(--eye-glow-intensity, .45); filter: url(#bodyPinkGlow) drop-shadow(0 0 18px rgba(255, 92, 184, .98)); transform-box: fill-box; transform-origin: center; animation: bodyEyePulse 3.4s ease-in-out infinite; }
.body-monitor.sanity-low .body-eye-glow { display: inline; }
.body-mouth-mist { display: none; fill: none; stroke: #f778bb; stroke-width: 12; stroke-linecap: round; opacity: .22; filter: url(#bodyPinkGlow); transform-box: fill-box; transform-origin: left center; animation: bodyBreathMist 4.2s ease-in-out infinite; }
.body-monitor.desire-high .body-mouth-mist { display: inline; }
.body-mouth-mist path:nth-child(2) { opacity: .64; }
.body-mouth-mist path:nth-child(3) { opacity: .32; }
.body-negative-accessory { display: none; fill: none; stroke: #ff78bd; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 6px rgba(246, 67, 165, .9)); animation: invasiveEquipmentPulse 2.8s ease-in-out infinite; }
.body-negative-accessory.is-visible { display: inline; }
.body-invasion { display: none; fill: #df3e8b; opacity: .32; filter: url(#bodyInvasionGlow); transform-box: fill-box; transform-origin: center; }
.body-invasion.is-visible { display: inline; animation: bodyInvasionPulse 3.3s ease-in-out infinite; }
.body-curse-glow { display: none; fill: #209553; opacity: .42; filter: url(#bodyCurseGlow); transform-box: fill-box; transform-origin: center; }
.body-curse-glow.is-visible { display: inline; animation: bodyCursePulse 3.8s ease-in-out infinite; }
.body-parasite { display: none; fill: rgba(255, 140, 40, .14); stroke: #ff9a2e; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transform-box: fill-box; }
.body-parasite * { vector-effect: non-scaling-stroke; }
.body-parasite path:not([class]), .body-parasite circle:not([class]), .body-parasite ellipse:not([class]) { fill: rgba(255, 140, 40, .16); }
.body-parasite .body-parasite-thin { stroke-width: 1.1; fill: none; opacity: .85; }
.body-parasite .body-parasite-dot { fill: #ffb25c; stroke: none; }
.body-parasite.is-visible { display: inline; animation: bodyParasiteGlow 5.2s ease-in-out infinite; }
@keyframes bodyParasiteGlow { 0%, 100% { opacity: .55; filter: drop-shadow(0 0 3px rgba(255, 140, 40, .55)); } 50% { opacity: 1; filter: drop-shadow(0 0 11px rgba(255, 150, 50, .98)); } }
@keyframes bodyInvasionPulse { 0%, 100% { opacity: .2; transform: scale(.82); } 50% { opacity: .62; transform: scale(1.12); } }
@keyframes bodyCursePulse { 0%, 100% { opacity: .26; transform: scale(.86); } 50% { opacity: .78; transform: scale(1.1); } }
@keyframes invasiveEquipmentPulse { 0%, 100% { opacity: .72; } 50% { opacity: 1; } }
@keyframes bodyEyePulse { 0%, 100% { transform: scale(.92); } 50% { transform: scale(1.08); } }
@keyframes bodyBreathMist { 0%, 100% { opacity: 0; transform: translateX(-12px) scale(.72); } 24% { opacity: .2; } 58% { opacity: .58; transform: translateX(20px) scale(1.04); } 82% { opacity: 0; transform: translateX(46px) scale(1.22); } }

.modal.character-sheet-modal {
  display: flex;
  flex-direction: column;
  width: min(930px, 94vw);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  min-height: 0;
  overflow: hidden;
  padding: 26px;
}
.character-sheet-head { display: grid; grid-template-columns: 72px 1fr auto; gap: 15px; align-items: center; padding: 12px 0 20px; border-bottom: 1px solid var(--line); }
.sheet-level { width: 62px; height: 62px; display: grid; place-content: center; border: 1px solid var(--gold); transform: rotate(45deg); text-align: center; }
.sheet-level span { transform: rotate(-45deg); color: var(--gold-bright); font: calc(18px * var(--fs, 1)) Georgia, serif; }
.sheet-level small { display: block; font-size: calc(7px * var(--fs, 1)); }
.sheet-title small, .sheet-title strong { display: block; }
.sheet-title small { color: #8c8177; font-size: calc(9px * var(--fs, 1)); letter-spacing: .14em; }
.sheet-title strong { margin-top: 5px; font-family: Georgia,"STSong",serif; font-size: calc(27px * var(--fs, 1)); font-weight: 400; letter-spacing: .12em; }
.sheet-identity { display: flex; align-items: center; gap: 18px; min-width: 0; }
.sheet-hybrid-level { border-color: rgba(196, 140, 220, .85); flex: 0 0 auto; }
.sheet-hybrid-level span { color: #e8d6f6; }
.sheet-hybrid-level small.sheet-cap-note {
  display: block;
  margin-top: 2px;
  color: #c4a0d8;
  font-size: calc(7px * var(--fs, 1));
  letter-spacing: .04em;
}
.sheet-summary { color: #8f857d; font-size: calc(10px * var(--fs, 1)); text-align: right; line-height: 1.7; }
.sheet-tabs { display: flex; gap: 4px; margin: 18px 0 14px; }
.sheet-tab { padding: 8px 14px; color: #8e8379; border: 1px solid rgba(220,197,157,.13); background: transparent; cursor: pointer; font-size: calc(10px * var(--fs, 1)); }
.sheet-tab.active { color: #1a130b; border-color: var(--gold); background: var(--gold); }
.sheet-body { min-height: 300px; max-height: 48vh; overflow-y: auto; padding: 4px 2px 10px; }
.sheet-tabs { flex-wrap: wrap; }
.character-sheet-modal.is-skill-tree {
  display: flex;
  flex-direction: column;
  width: min(1080px, 96vw);
  height: min(92vh, calc(100vh - 48px));
  max-height: min(92vh, calc(100vh - 48px));
  min-height: 0;
  overflow: hidden;
}
.character-sheet-modal.is-skill-tree > #modalContent {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.character-sheet-modal.is-skill-tree > .eyebrow,
.character-sheet-modal.is-skill-tree > h2 {
  flex: 0 0 auto;
}
.character-sheet-modal.is-skill-tree .character-sheet-head { padding: 8px 0 12px; flex: 0 0 auto; }
.character-sheet-modal.is-skill-tree .sheet-tabs { margin: 10px 0 8px; flex: 0 0 auto; }
.character-sheet-modal.is-skill-tree .modal-actions { margin-top: 12px; flex: 0 0 auto; }
.character-sheet-modal.is-skill-tree .sheet-body,
.sheet-body.is-skill-tree {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 2px 8px;
}
.platinum-skill-tree-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.platinum-skill-tree-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  container-type: size;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 14px 16px;
  box-sizing: border-box;
  overflow: visible;
}
.platinum-skill-tree {
  position: relative;
  box-sizing: border-box;
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  overflow: visible;
  background-color: #07060b;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  border: 1px solid rgba(220, 197, 157, .22);
  box-shadow: inset 0 0 40px rgba(12, 9, 6, .45), 0 0 28px rgba(200, 168, 106, .08);
}
.skill-tree-node {
  position: absolute;
  z-index: 2;
  width: 132px;
  min-height: 36px;
  padding: 6px 8px;
  color: var(--gold-bright);
  border: 1px solid rgba(241, 212, 151, .72);
  background: radial-gradient(circle at 50% 30%, rgba(48, 38, 18, .92), rgba(14, 11, 8, .92));
  box-shadow: 0 0 12px rgba(200, 168, 106, .22);
  transform: translate(-50%, -50%);
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
}
.skill-tree-node-label {
  display: block;
  text-align: center;
  font-size: calc(11px * var(--fs, 1));
  letter-spacing: .04em;
  text-shadow: 0 0 8px rgba(0, 0, 0, .85);
}
.skill-tree-node-label b,
.skill-tree-node-label small {
  display: block;
}
.skill-tree-node-label small {
  margin-top: 2px;
  font-size: calc(10px * var(--fs, 1));
  letter-spacing: .02em;
}
.skill-tree-node-popup {
  position: fixed;
  z-index: 9999;
  width: min(280px, 72vw);
  padding: 10px 12px;
  color: #efe6d8;
  text-align: left;
  border: 1px solid rgba(241, 212, 151, .45);
  background: rgba(10, 8, 12, .88);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
  pointer-events: auto;
}
.skill-tree-node-popup b {
  display: block;
  color: var(--gold-bright);
  font-size: calc(14px * var(--fs, 1));
  font-weight: 500;
  letter-spacing: .08em;
}
.skill-tree-node-popup small {
  display: block;
  margin-top: 4px;
  color: #9a8f82;
  font-size: calc(10px * var(--fs, 1));
}
.skill-tree-node-popup p {
  margin: 8px 0 0;
  color: #d3c9bf;
  font-size: calc(12px * var(--fs, 1));
  line-height: 1.7;
}
.skill-tree-node.is-learned {
  color: #fff4d4;
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(241, 212, 151, .42), inset 0 0 10px rgba(200, 168, 106, .2);
}
.skill-tree-node.is-locked {
  color: #8a837b;
  border-color: rgba(138, 131, 123, .45);
  background: radial-gradient(circle at 50% 30%, rgba(30, 28, 26, .9), rgba(10, 9, 9, .92));
  box-shadow: none;
  opacity: .78;
}
.skill-tree-node.is-selected {
  z-index: 5;
  outline: 1px solid var(--gold-bright);
  outline-offset: 2px;
}
.skill-tree-node.is-learned.is-selected {
  box-shadow: 0 0 20px rgba(241, 212, 151, .62), inset 0 0 12px rgba(200, 168, 106, .28);
}
@media (max-width: 720px) {
  .character-sheet-modal.is-skill-tree { width: min(1000px, 96vw); padding: 16px; }
  .character-sheet-modal.is-skill-tree .sheet-body,
  .sheet-body.is-skill-tree {
    max-height: none;
    min-height: 0;
    overflow: hidden;
  }
  .platinum-skill-tree-stage { padding: 14px 14px; }
  .skill-tree-node { width: 116px; min-height: 32px; padding: 5px 6px; }
  .skill-tree-node-label { font-size: calc(10px * var(--fs, 1)); }
}
.portrait-charge-badge {
  position: absolute;
  z-index: 6;
  top: 12px;
  left: 50%;
  padding: 4px 10px;
  color: #1a130b;
  border: 1px solid var(--gold-bright);
  background: linear-gradient(180deg, #f4e0a8, var(--gold));
  box-shadow: 0 0 16px rgba(241, 212, 151, .55);
  transform: translateX(-50%);
  font-size: calc(10px * var(--fs, 1));
  letter-spacing: .18em;
  pointer-events: none;
}
.portrait-frame.is-charging {
  box-shadow: inset 0 0 28px rgba(241, 212, 151, .28), 0 0 18px rgba(200, 168, 106, .2);
}
.portrait-frame.is-charging img {
  filter: saturate(.9) contrast(1.08) brightness(1.06);
}

.sheet-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sheet-stat-card { padding: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.018); }
.sheet-stat-card span, .sheet-stat-card b, .sheet-stat-card small { display: block; }
.sheet-stat-card span { color: #8e837b; font-size: calc(9px * var(--fs, 1)); letter-spacing: .12em; }
.sheet-stat-card b { margin: 7px 0 5px; color: #eee6d9; font: calc(24px * var(--fs, 1)) Georgia, serif; }
.sheet-stat-card b.increased { color: #84c79a; }
.sheet-stat-card b.decreased { color: #db747c; }
.sheet-stat-card small { color: #665f5a; font-size: calc(8px * var(--fs, 1)); line-height: 1.55; }
.resource-detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.resource-detail-grid article { padding: 12px; border: 1px solid rgba(220,197,157,.16); background: rgba(255,255,255,.02); }
.resource-detail-grid span, .resource-detail-grid b, .resource-detail-grid small { display: block; }
.resource-detail-grid span { color: #8c8178; font-size: calc(8px * var(--fs, 1)); letter-spacing: .12em; }
.resource-detail-grid b { margin: 6px 0; color: var(--gold-bright); font: calc(18px * var(--fs, 1)) Georgia,serif; }
.resource-detail-grid small { color: #6f6660; font-size: calc(8px * var(--fs, 1)); line-height: 1.5; }
.equipment-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.equipment-card.is-broken { opacity: .64; filter: grayscale(.25); }
.equipment-card { position: relative; display: grid; grid-template-columns: 45px 1fr auto; gap: 12px; align-items: center; min-height: 88px; padding: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.018); }
.equipment-icon { width: 42px; height: 42px; display: grid; place-items: center; transform: rotate(45deg); border: 1px solid rgba(220,190,138,.35); color: var(--gold-bright); }
.equipment-icon span { transform: rotate(-45deg); font-size: calc(19px * var(--fs, 1)); }
.equipment-copy small, .equipment-copy b { display: block; }
.equipment-copy small { color: #766d66; font-size: calc(8px * var(--fs, 1)); letter-spacing: .12em; }
.equipment-copy b { margin-top: 5px; font-family: "STSong",serif; font-size: calc(14px * var(--fs, 1)); font-weight: 400; }
.equipment-action { padding: 7px 10px; color: #b9aa99; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: calc(9px * var(--fs, 1)); }
.equipment-action:hover { color: #16110a; border-color: var(--gold); background: var(--gold); }
.equipment-action.locked, .equipment-action.locked:hover { color: #bc758e; border-color: rgba(190,73,104,.34); background: rgba(100,31,54,.14); cursor: not-allowed; }
.equipment-card.empty { border-style: dashed; opacity: .75; }
.equipment-tooltip { left: auto; right: 10px; width: min(320px,80vw); transform: translate(0,6px); }
.equipment-card:hover .equipment-tooltip, .equipment-card:focus-within .equipment-tooltip { transform: translate(0,0); }
.character-sheet-modal .equipment-card:hover .equipment-tooltip,
.character-sheet-modal .equipment-card:focus-within .equipment-tooltip { opacity: 0; visibility: hidden; }
.floating-equipment-tooltip { position: fixed; z-index: 200; left: 0; top: 0; width: min(320px,80vw); padding: 10px 12px; color: #e8ddd3; border: 1px solid #cbb58a; background: #0c0a0e; box-shadow: 0 16px 40px rgba(0,0,0,.88), 0 0 0 1px #000; font-size: calc(9px * var(--fs, 1)); line-height: 1.6; pointer-events: none; opacity: 0; visibility: hidden; }
.floating-equipment-tooltip.is-visible { opacity: 1; visibility: visible; }
.floating-equipment-tooltip::after { content: ""; position: absolute; left: var(--arrow-left, 78%); top: 100%; width: 8px; height: 8px; transform: translate(-50%,-4px) rotate(45deg); border-right: 1px solid rgba(220,190,138,.34); border-bottom: 1px solid rgba(220,190,138,.34); background: #0c0a0e; }
.floating-equipment-tooltip.is-below::after { top: 0; transform: translate(-50%,-4px) rotate(45deg); border-right: 0; border-bottom: 0; border-left: 1px solid rgba(220,190,138,.34); border-top: 1px solid rgba(220,190,138,.34); }
.equipment-tooltip::after { left: 78%; }
.inventory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.inventory-item { min-height: 92px; padding: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.018); display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.inventory-item-main { display: flex; align-items: flex-start; gap: 10px; }
.inventory-item-icon { flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center; transform: rotate(45deg); border: 1px solid rgba(220,190,138,.35); color: var(--gold-bright); }
.inventory-item-icon span { transform: rotate(-45deg); font-size: calc(16px * var(--fs, 1)); line-height: 1; }
.inventory-item-copy { min-width: 0; flex: 1; }
.inventory-item b, .inventory-item small { display: block; }
.inventory-item b { margin-bottom: 7px; color: #d8cbbb; font-size: calc(12px * var(--fs, 1)); font-weight: 500; }
.inventory-item small { color: #716962; font-size: calc(8px * var(--fs, 1)); line-height: 1.55; }
.inventory-item-action { min-height: 32px; display: flex; justify-content: flex-end; align-items: flex-end; }
.inventory-item-action .equipment-action { min-width: 64px; text-align: center; }
.inventory-item.is-equipped { border-color: rgba(220,190,138,.34); background: rgba(220,190,138,.05); }
.sheet-status-list { display: grid; gap: 8px; }
.sheet-status-row { display: grid; grid-template-columns: 150px 1fr; gap: 15px; padding: 12px 14px; border: 1px solid var(--line); background: rgba(255,255,255,.018); }
.sheet-status-row b { color: #d1bec5; font-size: calc(11px * var(--fs, 1)); font-weight: 500; }
.sheet-status-row span { color: #817670; font-size: calc(9px * var(--fs, 1)); line-height: 1.6; }
.sheet-status-row.positive { border-color: rgba(111,167,126,.27); background: rgba(43,84,56,.1); }
.sheet-status-row.positive b { color: #a9d2b2; }
.sheet-status-row.negative { border-color: rgba(190,73,104,.29); background: rgba(100,31,54,.12); }
.sheet-status-row.negative b { color: #dda0b1; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(3, 3, 5, .78); backdrop-filter: blur(7px); }
.modal-backdrop[hidden] { display: none; }
.modal { position: relative; width: min(560px, 100%); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 30px; border: 1px solid var(--line-bright); background: linear-gradient(145deg, #17131a, #0b090d); box-shadow: 0 35px 100px #000; scrollbar-width: thin; scrollbar-color: rgba(220,190,138,.34) rgba(255,255,255,.025); }
.modal h2 { margin: 0 0 18px; font-family: Georgia, "STSong", serif; font-size: calc(28px * var(--fs, 1)); font-weight: 400; }
.modal-close { position: absolute; right: 14px; top: 12px; color: #80756e; border: 0; background: transparent; font-size: calc(25px * var(--fs, 1)); cursor: pointer; }
.modal-copy { color: #aaa097; font-size: calc(13px * var(--fs, 1)); line-height: 1.8; }
.modal-copy strong { color: #dfd1bf; }
.modal-warning { padding: 12px 14px; color: #cda9b9; border-left: 2px solid var(--pink); background: rgba(117, 42, 79, .14); font-size: calc(11px * var(--fs, 1)); line-height: 1.6; }
.offering-grid { display: grid; gap: 8px; margin-top: 16px; }
.offering-card { padding: 13px 14px; border: 1px solid rgba(190,73,104,.24); background: linear-gradient(90deg, rgba(104,31,55,.13), rgba(255,255,255,.012)); }
.offering-card small, .offering-card b, .offering-card p, .offering-card em { display: block; }
.offering-card small { color: #9c6679; font-size: calc(8px * var(--fs, 1)); letter-spacing: .16em; }
.offering-card b { margin-top: 4px; color: #dfc1cb; font: 500 calc(13px * var(--fs, 1)) Georgia, "Songti SC", serif; }
.offering-card p { margin: 6px 0 3px; color: #9b8f88; font-size: calc(10px * var(--fs, 1)); }
.offering-card em { color: #766b66; font-size: calc(9px * var(--fs, 1)); font-style: normal; line-height: 1.55; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.modal-actions button { padding: 10px 17px; cursor: pointer; }
.modal-primary { color: #1a130a; border: 1px solid var(--gold); background: var(--gold); }
.modal-secondary { color: #b8aca0; border: 1px solid var(--line); background: transparent; }

.modal.platinum-intro-modal,
.modal.nidhogg-intro-modal { width: min(640px, 100%); }
.platinum-intro-modal .platinum-intro-story,
.nidhogg-intro-modal .platinum-intro-story,
.nidhogg-intro-modal .nidhogg-intro-story {
  max-height: min(58vh, 58dvh, 520px);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  gap: 12px;
}
.platinum-intro-modal .platinum-intro-bio-title,
.nidhogg-intro-modal .platinum-intro-bio-title {
  margin: 8px 0 0;
  color: #dfd1bf;
  font-family: "STSong", Georgia, serif;
  font-size: calc(16px * var(--fs, 1));
  font-weight: 400;
  letter-spacing: .08em;
}
.platinum-intro-modal .platinum-intro-bio,
.nidhogg-intro-modal .platinum-intro-bio { display: grid; gap: 4px; margin-top: 4px; }
.platinum-intro-modal .platinum-intro-bio-line,
.nidhogg-intro-modal .platinum-intro-bio-line {
  margin: 0;
  color: #aaa097;
  font-size: calc(12px * var(--fs, 1));
  line-height: 1.7;
}
.modal.difficulty-modal { overflow: visible; }
.difficulty-modal .difficulty-mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}
.difficulty-modal .difficulty-mode-btn {
  position: relative;
  min-width: 132px;
  padding: 12px 20px;
  cursor: pointer;
  font-size: calc(13px * var(--fs, 1));
  letter-spacing: .04em;
}
.difficulty-modal .difficulty-mode-btn-simple {
  color: #b8aca0;
  border: 1px solid var(--line);
  background: transparent;
}
.difficulty-modal .difficulty-mode-btn-simple:hover,
.difficulty-modal .difficulty-mode-btn-simple:focus-visible {
  color: #dfd1bf;
  border-color: rgba(220,190,138,.45);
}
.difficulty-modal .difficulty-mode-btn-hard {
  color: #1a130a;
  border: 1px solid var(--gold);
  background: var(--gold);
}
.difficulty-modal .difficulty-mode-btn-hard:hover,
.difficulty-modal .difficulty-mode-btn-hard:focus-visible {
  filter: brightness(1.05);
}
.difficulty-modal .difficulty-hard-tooltip {
  position: absolute;
  z-index: 80;
  left: 50%;
  top: calc(100% + 10px);
  bottom: auto;
  width: max(220px, 100%);
  transform: translate(-50%, -6px);
  padding: 10px 12px;
  color: #f8d7e6;
  border: 1px solid #e4a8c4;
  background: #2a0c1c;
  box-shadow: 0 16px 40px rgba(0,0,0,.9), 0 0 0 1px #14060c;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  font-size: calc(11px * var(--fs, 1));
  line-height: 1.65;
  letter-spacing: .02em;
  transition: .18s ease;
  text-align: left;
  white-space: normal;
}
.difficulty-modal .difficulty-hard-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -4px) rotate(45deg);
  border-left: 1px solid #e4a8c4;
  border-top: 1px solid #e4a8c4;
  border-right: 0;
  border-bottom: 0;
  background: #2a0c1c;
}
.difficulty-modal .difficulty-mode-btn-hard:hover .difficulty-hard-tooltip,
.difficulty-modal .difficulty-mode-btn-hard:focus-visible .difficulty-hard-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast { position: fixed; z-index: 120; left: 50%; bottom: 28px; transform: translate(-50%, 24px); padding: 11px 18px; color: #e4d7c7; border: 1px solid rgba(218, 188, 132, .35); background: #0c0a0e; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s ease; font-size: calc(11px * var(--fs, 1)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .topbar { padding: 0 18px; }
  .run-summary { margin-left: auto; }
  .summary-item { min-width: 74px; padding: 0 10px; }
  .summary-item.fog-summary { min-width: 98px; }
  .top-fog-track { width: 62px; }
  .top-actions { margin-left: 8px; gap: 5px; }
  .return-title-button { min-width: 88px; padding-inline: 9px; }
  .title-content { width: 76vw; margin-left: 9vw; }
  .save-grid { grid-template-columns: 1fr; }
  .character-select-grid { min-height: 420px; }
  .save-card { min-height: 240px; }
  .save-card h3 { margin-top: 22px; }
  .slot-screen, .character-screen { overflow: auto; }
  .hud-panel { flex-basis: calc(350px * var(--hud-scale)); }
  .hud-panel-inner { grid-template-columns: 230px 150px minmax(0, 1fr) 145px 145px; }
  .dialogue-box { padding: 20px 22px 14px; }
  .portrait-name b { font-size: calc(13px * var(--fs, 1)); }
  .quick-status-rail, .body-monitor-rail { padding: 11px 7px 8px; }
  .dungeon-stage { grid-template-columns: 72px minmax(0, 1fr) 250px; }
  .dice-history-heading { padding-inline: 13px; }
  .dice-readout { padding: 9px; }
}

@media (max-width: 680px) and (orientation: portrait) {
  body { overflow: hidden; }
  .topbar { height: 60px; }
  .screen { padding-top: 60px; }
  .brand-button small { display: none; }
  .brand-button strong { font-size: calc(13px * var(--fs, 1)); }
  .soul-core-chip { height: 60px; min-width: 72px; padding: 0 10px; }
  .soul-core-chip small { display: none; }
  .run-summary { height: 60px; }
  .summary-item { min-width: 60px; padding: 0 6px; }
  .summary-item.fog-summary { min-width: 72px; }
  .summary-item small { display: none; }
  .top-fog-track { width: 50px; }
  .top-actions .icon-button { min-width: 44px; padding: 7px; }
  .return-title-button { font-size: calc(10px * var(--fs, 1)); }
  .panel-heading { align-items: flex-start; gap: 12px; }
  .panel-heading-actions { flex-direction: column; }
  .character-screen { padding: 90px 18px 30px; }
  .character-select-grid { grid-template-columns: 1fr; min-height: 1180px; }
  .character-card { min-height: 360px; }
  .game-screen {
    height: 100vh;
    height: 100dvh;
    max-height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .slot-screen { padding: 90px 18px 30px; }
  .dungeon-stage { min-height: 1040px; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: 800px 240px; }
  .route-rail { grid-column: 1; grid-row: 1; }
  .scene-area { grid-column: 2; grid-row: 1; }
  .dice-history-rail { grid-column: 1 / -1; grid-row: 2; border-left: 0; border-top: 1px solid rgba(218, 198, 157, .14); }
  .dice-history-heading { padding: 11px 14px 9px; }
  .dice-readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; overflow-x: hidden; }
  .dice-action-group { margin: 0; padding: 0 8px 0 0; border-bottom: 0; border-right: 1px solid rgba(218,190,138,.18); min-width: 0; max-width: 100%; overflow-x: hidden; }
  .scene-area { padding: 18px 14px; }
  .scene-header { gap: 10px; }
  .altar-hotspot { left: 9%; }
  .door-hotspot { right: 5%; }
  .breeding-cavity-hotspot { left: 76%; top: 56%; min-width: 108px; padding: 10px 12px; }
  .choice-layer { grid-template-columns: 1fr; }
  .scene-object { min-height: 200px; }
  .combat-actions { grid-template-columns: repeat(2, 1fr); }
  .combat-skill-bar { grid-template-columns: repeat(3, 1fr); }
  .combat-button { min-height: 50px; }
  .hud-panel { height: calc(790px * var(--hud-scale)); min-height: calc(790px * var(--hud-scale)); flex-basis: calc(790px * var(--hud-scale)); }
  .hud-panel-inner { height: 790px; grid-template-columns: 185px 1fr; grid-template-rows: 340px auto 240px; }
  .status-column { grid-row: 1; grid-column: 1; }
  .portrait-frame { grid-row: 1; grid-column: 2; }
  .dialogue-box { grid-column: 1 / -1; grid-row: 2; min-height: 170px; border-top: 1px solid var(--line); }
  .body-monitor-rail { grid-column: 1; grid-row: 3; min-height: 230px; border-left: 0; border-top: 1px solid var(--line); }
  .quick-status-rail { grid-column: 2; grid-row: 3; min-height: 230px; border-top: 1px solid var(--line); }
  .quick-status-rail .status-list { display: grid; grid-template-columns: 1fr; align-content: start; }
  .dialogue-box > p { min-height: 52px; }
  .sheet-stat-grid, .equipment-grid { grid-template-columns: 1fr; }
  .resource-detail-grid { grid-template-columns: repeat(2,1fr); }
  .inventory-grid { grid-template-columns: repeat(2,1fr); }
  .character-sheet-head { grid-template-columns: 58px 1fr; }
  .sheet-summary { grid-column: 1 / -1; text-align: left; }
  .archive-footer { justify-content: flex-start; }
}

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

.choice-copy small .curse-flavor, .choice-copy small .curse-effect, .choice-copy small .curse-hint { display: block; overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
.choice-copy small .curse-flavor { color: #a89c92; line-height: 1.6; }
.choice-copy small .curse-effect { margin-top: 6px; color: #d8bd83; }
.choice-copy small .curse-hint { margin-top: 4px; color: #8f847b; }

/* 祭坛三选一诅咒：单列完整展示 flavor/effect，避免卡片内裁切 */
.choice-layer.altar-curse-picks {
  grid-template-columns: 1fr;
  max-height: min(42vh, 360px);
  align-content: start;
}
.choice-layer.altar-curse-picks .choice-card {
  min-height: 0;
  padding: 10px 12px;
}
.choice-layer.altar-curse-picks .choice-copy small {
  font-size: calc(10.5px * var(--fs, 1));
  line-height: 1.55;
}

.story-overlay { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; box-sizing: border-box; width: auto; height: auto; max-height: none; min-height: 0; overflow: hidden; padding: 56px clamp(24px, 8vw, 140px) 28px; background: radial-gradient(ellipse at 50% 30%, #1d1219 0%, #0a070b 70%, #050305 100%); animation: storyFade .6s ease; touch-action: pan-y; }
.scene-fade-overlay { position: fixed; inset: 0; z-index: 400; background: #000; opacity: 0; pointer-events: none; transition: opacity .48s ease; }
.scene-fade-overlay.is-visible { opacity: 1; pointer-events: auto; }
@keyframes storyFade { from { opacity: 0; } to { opacity: 1; } }
.story-close { position: absolute; right: 22px; top: 16px; color: #8d8179; border: 0; background: transparent; font-size: calc(34px * var(--fs, 1)); line-height: 1; cursor: pointer; }
.story-close:hover { color: var(--gold-bright, #e6c98c); }
.story-page { flex: 1; min-height: 0; max-height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; max-width: 860px; width: 100%; margin: 0 auto; padding-right: 10px; cursor: pointer; scrollbar-width: thin; }
.story-kicker { margin: 0 0 6px; color: #8a6b78; font-size: calc(11px * var(--fs, 1)); letter-spacing: .3em; }
.story-title { margin: 0 0 26px; color: #d8bd83; font-family: "STSong", Georgia, serif; font-size: calc(30px * var(--fs, 1)); font-weight: 400; letter-spacing: .14em; }
.story-body p { margin: 0 0 20px; color: #cfc4b8; font-family: "STSong", "Songti SC", Georgia, serif; font-size: calc(17px * var(--fs, 1)); line-height: 2; text-indent: 2em; text-align: justify; min-height: 2em; }
.story-body p.story-quote { color: #e6d3c0; text-indent: 0; }
.story-foot { display: flex; align-items: center; justify-content: space-between; max-width: 860px; width: 100%; margin: 14px auto 0; }
.story-hint { color: #6f635b; font-size: calc(11px * var(--fs, 1)); }
.story-continue { margin-left: auto; padding: 10px 26px; color: #1a130a; border: 1px solid var(--gold, #cfab5c); background: var(--gold, #cfab5c); cursor: pointer; }


/* —— 暗精灵祭司战败：视频剧情弹窗（仅 .story-overlay--video；纯文字弹窗样式不变） —— */
.story-overlay.story-overlay--video {
  flex-direction: row;
  padding: 56px 56px 0 0; /* 右侧留出关闭按钮安全带，避免压视频 */
}
.story-overlay.story-overlay--video .story-main {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.story-overlay.story-overlay--video .story-page {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 24px 28px 20px;
  cursor: default;
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 190, 138, .35) transparent;
}
.story-overlay.story-overlay--video .story-kicker {
  margin: 0 0 6px;
  font-size: calc(11px * var(--fs, 1)); /* 与纯文字战败弹窗一致 */
  letter-spacing: .3em;
}
.story-overlay.story-overlay--video .story-title {
  margin: 0 0 26px;
  font-size: calc(30px * var(--fs, 1));
}
.story-overlay.story-overlay--video .story-body p {
  margin: 0 0 20px;
  font-size: calc(17px * var(--fs, 1));
  line-height: 2;
}
.story-overlay.story-overlay--video .story-video-anchor {
  display: block;
  width: 100%;
  height: 2px;
  margin: 1.2em 0 1.6em;
  padding: 0;
  border: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}
.story-overlay.story-overlay--video .story-video-col {
  flex: 0 0 auto;
  --stage-h: calc(var(--app-vh, 100dvh) - 80px);
  width: min(42vw, calc(var(--stage-h) * 9 / 16));
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 8px 20px 4px;
  position: sticky;
  top: 0;
  align-self: stretch;
}
.story-overlay.story-overlay--video .story-video-stage {
  position: relative;
  width: 100%;
  height: var(--stage-h);
  max-height: var(--stage-h);
  aspect-ratio: 9 / 16;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}
.story-overlay.story-overlay--video .story-video-stage video {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.story-overlay.story-overlay--video .story-video-stage video.is-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
.story-overlay.story-overlay--video .story-video-stage.is-playing {
  box-shadow: 0 0 0 1px rgba(216, 189, 131, .28);
}
.story-overlay.story-overlay--video .story-video-mute-tip {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(10, 7, 9, .78);
  color: #c9b8a4;
  font-size: 11px;
  letter-spacing: .04em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.story-overlay.story-overlay--video .story-video-stage.is-muted-fallback .story-video-mute-tip {
  opacity: 1;
}
.story-overlay.story-overlay--video .story-foot--inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: none;
  width: auto;
  margin: 32px 0 0;
  padding-top: 16px;
  padding-bottom: 8px;
  border-top: 1px solid rgba(180, 140, 100, .12);
}
.story-overlay.story-overlay--video .story-foot--inline .story-hint {
  font-size: calc(11px * var(--fs, 1));
}
.story-overlay.story-overlay--video .story-foot--inline .story-continue {
  margin-left: auto;
  flex-shrink: 0;
}
.story-overlay.story-overlay--video .story-close {
  z-index: 30;
  right: 10px;
  top: 8px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(8, 6, 10, .78);
  border: 1px solid rgba(220, 190, 138, .22);
  font-size: calc(28px * var(--fs, 1)); /* 略小于纯文字 34，避免抢画面 */
  line-height: 1;
}
@media (max-width: 820px) and (orientation: portrait) {
  .story-overlay.story-overlay--video { flex-direction: column; padding-top: 44px; }
  .story-overlay.story-overlay--video .story-main { flex-direction: column; }
  .story-overlay.story-overlay--video .story-page {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    height: 55%;
    padding-left: 16px;
    padding-right: 16px;
  }
  .story-overlay.story-overlay--video .story-video-col {
    flex: 0 0 42%;
    width: 100%;
    max-width: 100%;
    height: 42%;
    padding: 4px 16px 16px;
  }
  .story-overlay.story-overlay--video .story-video-stage {
    max-height: none;
    height: 100%;
  }
}

.hero-speech { position: absolute; z-index: 6; padding: 7px 10px; color: #1b1418; border-radius: 9px; background: rgba(244, 236, 226, .96); box-shadow: 0 4px 14px rgba(0,0,0,.55); font-size: calc(12px * var(--fs, 1)); font-weight: 700; line-height: 1.45; letter-spacing: .02em; pointer-events: none; opacity: 0; transform: translateY(6px) scale(.92); transition: opacity .18s ease, transform .18s ease; width: max-content; }
.hero-speech.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.hero-speech::before { content: ""; position: absolute; top: -7px; left: var(--tail-x, 50%); margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom: 8px solid rgba(244, 236, 226, .96); }
.hero-speech[data-mood="anger"] { color: #3a0d0d; background: rgba(255, 226, 214, .97); }
.hero-speech[data-mood="anger"]::before { border-bottom-color: rgba(255, 226, 214, .97); }
.hero-speech[data-mood="lost"] { color: #4a1230; background: rgba(255, 214, 234, .97); }
.hero-speech[data-mood="lost"]::before { border-bottom-color: rgba(255, 214, 234, .97); }

/* 安全房间的“自慰”选项：粉色诱惑框 */
.choice-card.choice-lust { border-color: rgba(255, 105, 180, .65); background: linear-gradient(90deg, rgba(150, 30, 90, .45), rgba(60, 14, 44, .88)); box-shadow: 0 0 14px rgba(255, 105, 180, .25), inset 0 0 18px rgba(255, 105, 180, .1); }
.choice-card.choice-lust:hover { border-color: #ff8fc7; background: linear-gradient(90deg, rgba(180, 40, 110, .55), rgba(76, 18, 56, .92)); }
.choice-card.choice-lust .choice-copy b { color: #ffb3d9; }
.choice-card.choice-lust .choice-copy small { color: #e7a6c8; }
.choice-card.choice-lust .choice-index { border-color: rgba(255, 140, 200, .6); color: #ff9ed0; }
.choice-card.is-disabled { opacity: .5; filter: grayscale(.5); cursor: not-allowed; }

/* 放大字号后场景区内容变高时，允许场景区自己上下滚动，避免选项被截断 */
.dungeon-stage { grid-template-rows: minmax(0, 1fr); }
.scene-area { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(220, 190, 138, .35) transparent; }

/* 左侧状态栏：顶部生命/欲望/理智/精能区更紧凑，被动属性栏整体上移，避免 125% 字号下超出显示 */
.status-column .data-slot:first-child { padding: 8px 17px 6px; }
.status-column .vital-row.compact { margin-top: 8px; }
.attribute-slot { padding: 7px 12px 6px; overflow: visible; }
.attribute-heading { margin-bottom: 5px; }
.attribute-list { gap: 4px; width: 100%; }
.attribute-chip { min-width: 0; padding: 4px 6px; }

/* 选人界面：桌面窗口下整页一屏显示，卡片高度随窗口自适应，不再需要滚动 */
@media (min-width: 901px) {
  .character-screen.is-active {
    height: 100vh;
    height: 100dvh;
    max-height: 100%;
    min-height: 0;
    padding-top: 84px;
    padding-bottom: 20px;
    overflow: hidden; /* keep heading fixed; grid below can scroll if cards overflow */
  }
  .character-screen .panel-heading { padding-bottom: 12px; }
  .character-screen .panel-intro { margin: 12px 0 16px; }
  .character-screen .character-select-grid {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .character-screen .character-select-note { padding-top: 12px; }
}

.enemy-speech { position: absolute; z-index: 12; left: 50%; top: 36%; width: max-content; max-width: min(360px, 180%); padding: 7px 11px; color: #f1dede; border: 1px solid rgba(200, 73, 91, .65); border-radius: 9px; background: rgba(38, 10, 18, .94); box-shadow: 0 4px 14px rgba(0,0,0,.6); font-size: calc(12px * var(--fs, 1)); font-weight: 700; line-height: 1.5; letter-spacing: .02em; pointer-events: none; opacity: 0; overflow: visible; transform: translate(-50%, 6px) scale(.94); transition: opacity .2s ease, transform .2s ease; }
.enemy-speech.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.enemy-speech::after { content: ""; position: absolute; top: -8px; left: var(--tail-x, 50%); margin-left: -6px; border: 6px solid transparent; border-top: 0; border-bottom: 8px solid rgba(38, 10, 18, .94); }
/* 缠茎藤图标较小，描边相应变细 */
.body-parasite[data-parasite-id="stemVine"] { stroke-width: .9; }
.body-parasite[data-parasite-id="stemVine"] .body-parasite-thin { stroke-width: .6; }
.body-parasite[data-parasite-id="urethralParasite"] { stroke: #f0a0b8; fill: rgba(232, 120, 150, .22); stroke-width: 1; }
.body-parasite[data-parasite-id="urethralParasite"] .body-parasite-thin { stroke-width: .7; }
.body-parasite[data-parasite-id="urethralParasite"] .body-parasite-dot { fill: #ffc0d0; }
.body-parasite[data-parasite-id="urethralParasite"].is-visible { animation: bodyUrethralGlow 3.8s ease-in-out infinite; }
@keyframes bodyUrethralGlow { 0%, 100% { opacity: .6; filter: drop-shadow(0 0 3px rgba(232, 120, 150, .5)); } 50% { opacity: 1; filter: drop-shadow(0 0 10px rgba(255, 160, 184, .95)); } }
/* 第一次屈服献祭后出现的另一侧（左胸）欲根蛭图标：以画布原点为变换基准，便于左右对称。 */
.body-parasite[data-parasite-id="desireLeech"] { transform-box: view-box; transform-origin: 0 0; stroke-width: 1.2; }
.body-parasite[data-parasite-id="desireLeech"] .body-parasite-thin { stroke-width: .8; }

/* 回响之虫：魅惑低语的回答气泡（粉紫色） */
.hero-speech[data-mood="echo"] { color: #3c0f55; background: rgba(228, 186, 255, .97); box-shadow: 0 0 16px rgba(214, 120, 255, .65), 0 4px 14px rgba(0,0,0,.55); }
.hero-speech[data-mood="echo"]::before { border-bottom-color: rgba(228, 186, 255, .97); }
.body-parasite[data-parasite-id="echoWorm"] { stroke: #e08cff; fill: rgba(214, 120, 255, .16); stroke-width: 1; }
.body-parasite[data-parasite-id="echoWorm"] .body-parasite-dot { fill: #f0b8ff; }
.body-parasite[data-parasite-id="echoWorm"].is-visible { animation: bodyEchoGlow 3.6s ease-in-out infinite; }
@keyframes bodyEchoGlow { 0%, 100% { opacity: .55; filter: drop-shadow(0 0 3px rgba(214, 120, 255, .55)); } 50% { opacity: 1; filter: drop-shadow(0 0 11px rgba(226, 140, 255, .98)); } }

/* 释放完毕界面：粉色羞辱文字；有剧情弹窗时，卡片等弹窗关闭后才淡入 */
.object-card p.lust-mockery { color: #ff8fc4; font-size: calc(14px * var(--fs, 1)); line-height: 1.9; text-shadow: 0 0 10px rgba(255, 105, 180, .35); }
.object-card.release-await { opacity: 0; pointer-events: none; }
.object-card:not(.release-await) { transition: opacity .7s ease; }

/* 释放完毕 / 屈服献祭界面上方的爱心：粉色 */
.object-glyph.glyph-pink { color: #ff8fc4; text-shadow: 0 0 12px rgba(255, 105, 180, .55); }

/* 闪避成功的粗口气泡：淡金（自信）/ 白（动摇）/ 淡粉（渴望被打） */
.hero-speech[data-mood="dodge-gold"] { color: #4a3406; background: rgba(252, 237, 183, .97); box-shadow: 0 0 14px rgba(240, 200, 100, .55), 0 4px 14px rgba(0,0,0,.55); }
.hero-speech[data-mood="dodge-gold"]::before { border-bottom-color: rgba(252, 237, 183, .97); }
.hero-speech[data-mood="dodge-white"] { color: #1c1c22; background: rgba(255, 255, 255, .98); }
.hero-speech[data-mood="dodge-white"]::before { border-bottom-color: rgba(255, 255, 255, .98); }
.hero-speech[data-mood="dodge-pink"] { color: #5a1033; background: rgba(255, 205, 226, .97); box-shadow: 0 0 14px rgba(255, 120, 180, .5), 0 4px 14px rgba(0,0,0,.55); }
.hero-speech[data-mood="dodge-pink"]::before { border-bottom-color: rgba(255, 205, 226, .97); }

.mist-spring-thought {
  position: absolute;
  z-index: 12;
  max-width: min(340px, 48%);
  padding: 10px 14px 12px;
  border-radius: 18px 18px 18px 6px;
  font-size: calc(13px * var(--fs, 1));
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: .02em;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  width: max-content;
}
.mist-spring-thought.is-visible {
  opacity: 1;
  animation: mist-spring-thought-float 2.8s ease-in-out infinite;
}
.mist-spring-thought::before {
  content: "";
  position: absolute;
  left: -8px;
  top: var(--tail-y, 40%);
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: inherit;
  box-shadow: inherit;
}
.mist-spring-thought::after {
  content: "";
  position: absolute;
  left: -18px;
  top: var(--tail-y, 40%);
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: inherit;
}
.mist-spring-thought[data-tone="platinum"] {
  color: #3d2d0a;
  background: linear-gradient(180deg, rgba(255, 244, 214, .97), rgba(232, 208, 150, .96));
  box-shadow: 0 0 16px rgba(230, 198, 120, .55), 0 4px 14px rgba(0,0,0,.55);
  border: 1px solid rgba(236, 214, 160, .85);
}
.mist-spring-thought[data-tone="pink"] {
  color: #5a1033;
  background: rgba(255, 214, 228, .97);
  box-shadow: 0 0 16px rgba(255, 140, 190, .5), 0 4px 14px rgba(0,0,0,.55);
  border: 1px solid rgba(255, 180, 210, .8);
}
.mist-spring-thought[data-tone="violet"] {
  color: #4a1458;
  background: linear-gradient(180deg, rgba(255, 210, 236, .97), rgba(228, 186, 255, .97));
  box-shadow: 0 0 16px rgba(200, 120, 255, .5), 0 4px 14px rgba(0,0,0,.55);
  border: 1px solid rgba(210, 170, 240, .85);
}
.mist-spring-thought[data-tone="deep"] {
  color: #f3e6ff;
  background: linear-gradient(180deg, rgba(88, 30, 110, .96), rgba(42, 14, 58, .97));
  box-shadow: 0 0 18px rgba(160, 60, 220, .55), 0 4px 14px rgba(0,0,0,.55);
  border: 1px solid rgba(150, 80, 190, .7);
}
.mist-spring-thought-text { display: block; }
.mist-spring-thought-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.mist-spring-thought-actions button {
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-weight: 700;
  color: inherit;
  background: rgba(255,255,255,.46);
}
.mist-spring-thought[data-tone="deep"] .mist-spring-thought-actions button {
  border-color: rgba(255,255,255,.28);
  background: rgba(255,255,255,.12);
  color: #f3e6ff;
}
.mist-spring-thought[data-tone="ghost"] {
  color: #eef6ff;
  background: linear-gradient(180deg, rgba(186, 206, 230, .94), rgba(84, 104, 132, .96));
  box-shadow: 0 0 18px rgba(200, 220, 255, .45), 0 4px 14px rgba(0,0,0,.55);
  border: 1px solid rgba(220, 232, 255, .7);
}
.mist-spring-thought[data-tone="ghost"] .mist-spring-thought-actions button {
  border-color: rgba(255,255,255,.35);
  background: rgba(255,255,255,.18);
  color: #f4f8ff;
}
.mist-spring-thought-actions button:hover,
.mist-spring-thought-actions button:focus-visible {
  background: rgba(255,255,255,.7);
}
@keyframes mist-spring-thought-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}


/* 颅内菌丝：脑部的青白色菌丝，随阶数扩大 */
.body-parasite[data-parasite-id="mycelium"] { stroke: #8fe8d0; fill: rgba(143, 232, 208, .14); stroke-width: 1; transform-box: view-box; transform-origin: 0 0; }
.body-parasite[data-parasite-id="mycelium"] .body-parasite-dot { fill: #c9fff0; }
.body-parasite[data-parasite-id="mycelium"].is-visible { animation: bodyMyceliumGlow 4.2s ease-in-out infinite; }
@keyframes bodyMyceliumGlow { 0%, 100% { opacity: .6; filter: drop-shadow(0 0 3px rgba(143, 232, 208, .5)); } 50% { opacity: 1; filter: drop-shadow(0 0 10px rgba(160, 255, 225, .95)); } }

/* 互动自慰：粉色射精槽 */
.jerk-gauge { margin: 14px 0 0; padding: 6px 12px; text-align: left; border: 1px solid rgba(255, 105, 180, .6); border-radius: 8px; background: linear-gradient(90deg, rgba(110, 22, 70, .55), rgba(40, 10, 32, .9)); box-shadow: 0 0 14px rgba(255, 105, 180, .22); }
.jerk-gauge-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; color: #ffb3d9; font-size: 14px; }
.jerk-gauge-head span { color: #ffd2e8; font-variant-numeric: tabular-nums; }
.jerk-gauge-track { position: relative; height: 12px; border-radius: 6px; background: rgba(20, 4, 14, .85); border: 1px solid rgba(255, 140, 200, .35); overflow: hidden; }
.jerk-gauge-track i { display: block; height: 100%; background: linear-gradient(90deg, #ff6fb5, #ff9ed0); box-shadow: 0 0 10px rgba(255, 120, 190, .8); transition: width .3s ease; }
.jerk-gauge-track em { position: absolute; top: 0; bottom: 0; left: 90%; width: 2px; background: rgba(255, 255, 255, .7); }
/* 互动自慰：射精槽放在“释放中”卡片内，卡片压缩以免被下方按钮盖住 */
.object-card:has(.jerk-gauge) { padding: 14px 28px 16px; }
.object-card:has(.jerk-gauge) .object-glyph { display: none; }
.object-card:has(.jerk-gauge) h3 { margin: 0; }
.object-card:has(.jerk-gauge) h3:empty { display: none; }
.object-card:has(.jerk-gauge) p { display: none; }
.object-card .jerk-gauge { margin-top: 12px; }

/* 互动自慰：“释放中”右侧粉色闪动爱心 */
.jerk-heart { display: inline-block; margin-left: 12px; color: #ff5fae; text-shadow: 0 0 10px rgba(255, 95, 174, .9), 0 0 20px rgba(255, 95, 174, .5); animation: jerkHeartBeat 1s ease-in-out infinite; }
@keyframes jerkHeartBeat { 0%, 100% { opacity: .45; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.25); } }


/* 门扉之主·阿刻戎：二/三阶段时间之轮蓝色闪烁 */
@keyframes acheronTimeWheelPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(80, 170, 255, .35)) drop-shadow(0 0 14px rgba(40, 120, 255, .25)); }
  50% { filter: drop-shadow(0 0 16px rgba(120, 200, 255, .95)) drop-shadow(0 0 28px rgba(60, 140, 255, .7)); }
}
.enemy-figure.time-wheel-glow,
.enemy-figure.time-wheel-glow .enemy-portrait,
body.acheron-time-wheel-glow .enemy-figure.has-portrait.boss-portrait .enemy-portrait {
  animation: acheronTimeWheelPulse 1.35s ease-in-out infinite;
}
.enemy-figure.spectating {
  opacity: .92;
}
.enemy-figure.spectating .enemy-nameplate small::after {
  content: attr(data-spectating-suffix);
  color: #7ec8ff;
}
body.acheron-time-wheel-glow .combat-layer {
  box-shadow: inset 0 0 48px rgba(40, 120, 255, .18);
}


/* ===== 祭坛 · 阿刻戎 NPC / 小对话 / 左右分栏（防溢出、一屏看完） ===== */
/* scene-area：header 跨列；左 scene-object=立绘(+旁侧对话)；右 choice-layer=祭坛按钮 */
.dungeon-stage[data-room="altar"] .scene-area {
  display: grid;
  grid-template-columns: minmax(300px, 0.58fr) minmax(210px, 0.42fr);
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: clamp(12px, 1.8vw, 24px);
  row-gap: 8px;
  align-content: stretch;
  min-height: 0;
  overflow: hidden;
  position: relative;
  padding: 18px clamp(16px, 2.2vw, 36px) 14px;
}
.dungeon-stage[data-room="altar"] .scene-header {
  grid-column: 1 / -1;
  grid-row: 1;
  position: relative;
  z-index: 5;
}
/* 左区：立绘 | 对话窗（对话打开时并排；关闭时立绘占满） */
.dungeon-stage[data-room="altar"] .scene-object {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  justify-items: stretch;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
  gap: 8px;
}
.dungeon-stage[data-room="altar"] .scene-object:has(.altar-talk:not([hidden])) {
  grid-template-columns: minmax(118px, 0.42fr) minmax(150px, 0.58fr);
}
/* 有卡且无选项（如诅咒烙成 roomResult）：主区单列，卡片正中 */
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):not(:has(.choice-layer > .choice-card)) {
  grid-template-columns: minmax(0, 1fr);
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):not(:has(.choice-layer > .choice-card)) .scene-object {
  grid-column: 1;
  grid-row: 2;
  z-index: 4;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):not(:has(.choice-layer > .choice-card)) .choice-layer {
  display: none;
}
/* 有卡且有选项：三栏 —— 立绘 | 居中卡 | 选项，避免 choice 挤偏/盖住卡 */
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) {
  grid-template-columns: minmax(120px, 0.28fr) minmax(240px, 0.44fr) minmax(190px, 0.28fr);
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .scene-object {
  grid-column: 1 / 3;
  grid-row: 2;
  z-index: 4;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .choice-layer,
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .choice-layer.altar-curse-picks {
  grid-column: 3;
  grid-row: 2;
  z-index: 6;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: clamp(120px, 34%, 260px);
  height: auto;
  max-height: 100%;
  z-index: 5;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc-hit {
  pointer-events: auto;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-talk:not([hidden]) {
  position: absolute;
  left: clamp(120px, 34%, 260px);
  top: 50%;
  transform: translateY(-50%);
  width: min(280px, 36%);
  max-width: 36%;
  z-index: 9;
  pointer-events: auto;
  grid-column: auto;
  grid-row: auto;
}
.dungeon-stage[data-room="altar"] .object-card {
  position: absolute;
  z-index: 8;
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 52%);
  max-width: min(480px, 62%);
  max-height: min(68%, 260px);
  margin: 0;
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: auto;
}
/* 有右侧选项时，卡片在「立绘+卡」两列区域内居中，略偏右以躲开立绘 */
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .object-card {
  left: 56%;
  width: min(380px, 58%);
  max-width: min(420px, 66%);
}
/* 献祭成功后：把「离开祭坛」放在居中对话卡正下方，而不是右侧选项列 */
.dungeon-stage[data-room="altar"] .altar-object-stack {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(420px, 52%);
  max-width: min(480px, 62%);
  box-sizing: border-box;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .altar-object-stack {
  left: 56%;
  width: min(380px, 58%);
  max-width: min(420px, 66%);
}
.dungeon-stage[data-room="altar"] .altar-object-stack .object-card {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  transform: none;
  width: 100%;
  max-width: 100%;
  margin: 0;
  max-height: min(58%, 220px);
  pointer-events: auto;
}
.dungeon-stage[data-room="altar"] .altar-leave-button {
  pointer-events: auto;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 10em;
  max-width: 100%;
  margin: 0;
  padding: 6px 16px 7px;
  border: 1px solid rgba(214, 183, 127, .48);
  background: rgba(18, 14, 12, .92);
  box-shadow: 0 0 0 1px rgba(40, 28, 16, .45), 0 6px 14px rgba(0, 0, 0, .32);
  color: var(--ivory, #e8d5aa);
  cursor: pointer;
  font: inherit;
  text-align: center;
  box-sizing: border-box;
}
.dungeon-stage[data-room="altar"] .altar-leave-button:hover,
.dungeon-stage[data-room="altar"] .altar-leave-button:focus-visible {
  border-color: var(--gold, #d6b77f);
  background: rgba(26, 21, 18, .96);
  color: var(--gold-bright, #f4e6c0);
}
.dungeon-stage[data-room="altar"] .altar-leave-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.dungeon-stage[data-room="altar"] .altar-leave-copy b {
  display: block;
  font-family: "STSong", serif;
  font-size: calc(12px * var(--fs, 1));
  font-weight: 400;
  letter-spacing: .12em;
  line-height: 1.3;
}
.dungeon-stage[data-room="altar"] .altar-leave-copy small {
  display: block;
  color: #8f847b;
  font-size: calc(9px * var(--fs, 1));
  letter-spacing: .06em;
  line-height: 1.3;
}
.dungeon-stage[data-room="altar"] .object-card h3 {
  font-size: clamp(12px, 1.5vw, 15px);
  line-height: 1.35;
}
.dungeon-stage[data-room="altar"] .object-card p {
  font-size: calc(10.5px * var(--fs, 1));
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}
.dungeon-stage[data-room="altar"] .object-glyph {
  font-size: calc(20px * var(--fs, 1));
}

/* 右列：整栏只给祭坛交互按钮；献祭后功能菜单在面板内滚动，不靠背后整页去够下面的按钮 */
.dungeon-stage[data-room="altar"] .choice-layer {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 100%;
  z-index: 6;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  align-content: start;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(220,190,138,.34) rgba(255,255,255,.025);
}
.dungeon-stage[data-room="altar"] .choice-layer .choice-card {
  min-height: 0;
  height: auto;
  max-height: none;
  padding: 7px 10px;
  gap: 8px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: start;
  overflow: hidden;
}
.dungeon-stage[data-room="altar"] .choice-layer .choice-index {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  font-size: calc(10px * var(--fs, 1));
}
.dungeon-stage[data-room="altar"] .choice-layer .choice-copy {
  min-width: 0;
  overflow: hidden;
}
.dungeon-stage[data-room="altar"] .choice-layer .choice-copy b {
  margin-bottom: 2px;
  font-size: calc(12px * var(--fs, 1));
  line-height: 1.3;
  letter-spacing: .04em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dungeon-stage[data-room="altar"] .choice-layer .choice-copy small {
  font-size: calc(9px * var(--fs, 1));
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.dungeon-stage[data-room="altar"] .choice-layer .choice-arrow {
  font-size: calc(13px * var(--fs, 1));
  align-self: center;
}
.dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks {
  width: 100%;
  max-height: 100%;
  gap: 5px;
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
}
.dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks .choice-card {
  padding: 6px 9px;
}
.dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks .choice-copy small {
  -webkit-line-clamp: 4;
  font-size: calc(8.5px * var(--fs, 1));
  line-height: 1.32;
}
.dungeon-stage[data-room="altar"] .combat-layer {
  grid-column: 1 / -1;
  grid-row: 2;
  z-index: 7;
}
.dungeon-stage[data-room="altar"] .combat-layer[hidden] {
  display: none !important;
}

.dungeon-stage[data-room="altar"].altar-bare-object .scene-object {
  min-height: 0;
  max-height: none;
}
.dungeon-stage[data-room="altar"].altar-bare-object .choice-layer,
.dungeon-stage[data-room="altar"].altar-bare-object .choice-layer.altar-curse-picks {
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 左侧阿刻戎立绘：占左区第一子列，可点 */
.dungeon-stage[data-room="altar"] .altar-npc,
.altar-npc {
  position: relative;
  z-index: 5;
  inset: auto;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
  box-sizing: border-box;
  grid-column: 1;
  grid-row: 1;
}
.dungeon-stage[data-room="altar"] .scene-object:has(.altar-talk:not([hidden])) .altar-npc {
  width: 100%;
}
.altar-npc[hidden] { display: none !important; }
.altar-npc-hit {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 0 0 26px;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 14px 16px rgba(0,0,0,.65));
  box-sizing: border-box;
}
.altar-npc-hit:hover .altar-npc-portrait,
.altar-npc-hit:focus-visible .altar-npc-portrait {
  filter: brightness(1.08) drop-shadow(0 0 12px rgba(220, 180, 110, .45));
  outline: none;
}
.altar-npc-portrait {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  user-select: none;
  transition: filter .18s ease;
}
.altar-npc-tag {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  max-width: calc(100% - 4px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  color: #e6d3b0;
  border: 1px solid rgba(220, 187, 129, .35);
  border-radius: 999px;
  background: rgba(8, 6, 10, .82);
  font-size: calc(9px * var(--fs, 1));
  letter-spacing: .1em;
  pointer-events: none;
  box-sizing: border-box;
}

/* 立绘交谈按钮含全身大图，不能套用通用按钮文本滚动包裹层。
   包裹后 .btn-scroll-surface 没有 height:100%，立绘 height:100% 失效，
   图按容器宽度按比例放大并被裁成巨大半身像，「点击交谈」标签也跟着贴在裁切底边。 */
.altar-npc-hit.btn-text-scroll {
  overflow: hidden;
}
.altar-npc-hit > .btn-scroll-surface {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  flex: none;
  align-self: stretch;
  overflow: hidden;
}

/* 立绘气泡：贴在立绘上，尽量一屏不滚 */
.altar-npc-speech {
  position: absolute;
  z-index: 6;
  left: 4px;
  right: 4px;
  top: 4%;
  width: auto;
  max-width: calc(100% - 8px);
  max-height: min(36%, 110px);
  overflow: hidden;
  padding: 5px 7px;
  color: #f3e7d4;
  border: 1px solid rgba(200, 170, 110, .55);
  border-radius: 9px;
  background: rgba(28, 18, 12, .94);
  box-shadow: 0 4px 14px rgba(0,0,0,.55);
  font-size: calc(10px * var(--fs, 1));
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .02em;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px) scale(.94);
  transition: opacity .2s ease, transform .2s ease;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}
.altar-npc-speech.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.altar-npc-speech::after {
  content: "";
  position: absolute;
  left: 16px;
  bottom: -7px;
  border: 6px solid transparent;
  border-bottom: 0;
  border-top: 8px solid rgba(28, 18, 12, .94);
}

/* 对话窗：立绘旁（左区第二子列），绝不盖住右侧祭坛按钮；一屏看完 */
.dungeon-stage[data-room="altar"] .altar-talk,
.altar-talk {
  position: relative;
  z-index: 14;
  left: auto;
  right: auto;
  top: auto;
  bottom: auto;
  transform: none;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 11px 8px;
  border: 1px solid rgba(218, 190, 138, .28);
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(22, 16, 20, .97), rgba(10, 8, 12, .98));
  box-shadow: 0 12px 28px rgba(0,0,0,.5);
  overflow: hidden;
  box-sizing: border-box;
}
.altar-talk[hidden] { display: none !important; }
.altar-talk-close {
  position: absolute;
  right: 6px;
  top: 2px;
  color: #8d8179;
  border: 0;
  background: transparent;
  font-size: calc(20px * var(--fs, 1));
  line-height: 1;
  cursor: pointer;
}
.altar-talk-close:hover { color: var(--gold-bright, #e6c98c); }
.altar-talk-kicker {
  margin: 0 0 2px;
  padding-right: 22px;
  color: #8a6b78;
  font-size: calc(8.5px * var(--fs, 1));
  letter-spacing: .2em;
}
.altar-talk-name {
  flex: 0 0 auto;
  margin: 0 0 6px;
  padding-right: 22px;
  color: #d8bd83;
  font-family: "STSong", Georgia, serif;
  font-size: calc(14px * var(--fs, 1));
  font-weight: 400;
  letter-spacing: .06em;
}
.altar-talk-body {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 34%;
  overflow: hidden;
  margin-bottom: 6px;
  color: #d3c9bf;
  font-family: "STSong", serif;
  font-size: calc(11.5px * var(--fs, 1));
  line-height: 1.45;
  letter-spacing: .02em;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}
.altar-talk-choices {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}
.altar-talk-choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  color: #e8dcc8;
  border: 1px solid rgba(218, 190, 138, .28);
  border-radius: 6px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  font-size: calc(11px * var(--fs, 1));
  letter-spacing: .03em;
  line-height: 1.3;
  transition: border-color .15s ease, background .15s ease;
  box-sizing: border-box;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.altar-talk-choice:hover,
.altar-talk-choice:focus-visible {
  border-color: rgba(238, 205, 142, .7);
  background: rgba(80, 55, 30, .35);
  outline: none;
}
.altar-talk-choice.is-pink {
  color: #ffb3d9;
  border-color: rgba(255, 105, 180, .65);
  background: linear-gradient(90deg, rgba(150, 30, 90, .4), rgba(60, 14, 44, .85));
  box-shadow: 0 0 12px rgba(255, 105, 180, .2);
}
.altar-talk-choice.is-pink:hover {
  border-color: #ff8fc7;
  background: linear-gradient(90deg, rgba(180, 40, 110, .5), rgba(76, 18, 56, .9));
}
.altar-talk-choice.is-muted {
  color: #9a9086;
  border-style: dashed;
}

@media (max-width: 900px) {
  .dungeon-stage[data-room="altar"] .scene-area {
    grid-template-columns: minmax(240px, 0.52fr) minmax(0, 0.48fr);
    padding: 14px 12px 10px;
    column-gap: 10px;
  }
  .dungeon-stage[data-room="altar"] .scene-object:has(.altar-talk:not([hidden])) {
    grid-template-columns: minmax(96px, 0.4fr) minmax(120px, 0.6fr);
  }
  .dungeon-stage[data-room="altar"] .object-card {
    width: min(360px, 70%);
    max-width: min(400px, 78%);
    max-height: min(58%, 200px);
  }
  .dungeon-stage[data-room="altar"] .altar-object-stack {
    width: min(360px, 70%);
    max-width: min(400px, 78%);
  }
  .dungeon-stage[data-room="altar"] .altar-object-stack .object-card {
    max-height: min(50%, 170px);
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc {
    width: clamp(96px, 30%, 180px);
  }
  .altar-talk-body { -webkit-line-clamp: 5; font-size: calc(11px * var(--fs, 1)); }
  .altar-talk-choice { font-size: calc(10.5px * var(--fs, 1)); padding: 4px 7px; }
}
@media (max-width: 680px) and (orientation: portrait) {
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])),
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(200px, 46vh) minmax(0, 1fr);
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .scene-object {
    grid-column: 1;
    grid-row: 2;
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .choice-layer,
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .choice-layer.altar-curse-picks {
    grid-column: 1;
    grid-row: 3;
  }
  .dungeon-stage[data-room="altar"] .scene-area {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(200px, 46vh) minmax(0, 1fr);
  }
  .dungeon-stage[data-room="altar"] .scene-object {
    grid-column: 1;
    grid-row: 2;
    min-height: 180px;
  }
  .dungeon-stage[data-room="altar"] .scene-object:has(.altar-talk:not([hidden])) {
    grid-template-columns: minmax(90px, 0.38fr) minmax(0, 0.62fr);
  }
  .dungeon-stage[data-room="altar"] .choice-layer,
  .dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks {
    grid-column: 1;
    grid-row: 3;
    align-self: stretch;
    width: 100%;
    max-height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .altar-npc-speech {
    font-size: calc(9.5px * var(--fs, 1));
    max-height: min(32%, 90px);
    -webkit-line-clamp: 4;
  }
}


/* 灵魂核心顶栏入口 / 商店（主界面与选角顶栏可配置；研发版局内可开关战斗效果） */
.soul-core-chip {
  min-width: 108px;
  height: 72px;
  padding: 0 16px;
  color: inherit;
  border: 0;
  border-left: 1px solid rgba(221, 202, 168, 0.1);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-content: center;
  text-align: center;
  flex-shrink: 0;
}
.soul-core-chip:hover b { color: var(--gold-bright); }
.soul-core-chip b { color: #e7c48a; }
.soul-core-chip.is-locked-run { opacity: 0.92; }
.soul-core-chip.is-locked-run:hover b { color: #c9b089; }
.soul-core-shop-modal { width: min(720px, 94vw); }
.soul-shop-lock-banner {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(220, 170, 120, 0.28);
  background: rgba(180, 120, 60, 0.08);
  color: #e2c8a0;
}
.soul-shop-toggle.is-disabled { opacity: 0.55; cursor: not-allowed; }
.soul-shop-toggle input:disabled { cursor: not-allowed; }
.modal.return-home-modal { width: min(620px, 94vw); }
.modal.settlement-modal { width: min(760px, 94vw); }
.modal.settlement-modal .settlement-lead { margin: 0 0 14px; }
.modal.settlement-modal .settlement-grid { margin-top: 0; }
.return-home-story { max-height: min(52vh, 460px); }
.return-home-story p + p { margin-top: 2px; }
.return-home-story p:last-child { color: #dfd1bf; }
.soul-shop-grid { display: grid; gap: 12px; margin-top: 14px; }
.soul-shop-card {
  padding: 14px 16px;
  border: 1px solid rgba(220, 198, 160, 0.18);
  background: rgba(255, 255, 255, 0.03);
}
.soul-shop-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.soul-shop-head b { color: #eadcc6; font-size: calc(15px * var(--fs, 1)); }
.soul-shop-head small { color: #9a8f82; letter-spacing: 0.08em; }
.soul-shop-price-was {
  color: #7d746c;
  text-decoration: line-through;
  margin-right: 0.2em;
}
.soul-shop-discount-tag {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0 0.42em;
  border-radius: 999px;
  border: 1px solid rgba(212, 176, 106, 0.55);
  background: rgba(212, 140, 160, 0.18);
  color: #e8c48a;
  font-size: 0.9em;
  letter-spacing: 0.06em;
  vertical-align: baseline;
  line-height: 1.35;
  white-space: nowrap;
}
.soul-shop-desc { margin: 8px 0 12px; color: #aea297; font-size: calc(12px * var(--fs, 1)); line-height: 1.7; }
.soul-shop-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.soul-shop-buy:disabled { opacity: .45; cursor: not-allowed; }
.soul-shop-buy.is-pink {
  color: #1a0b12;
  border-color: #e38bb6;
  background: #e58bb8;
}
.soul-shop-buy.is-pink:hover { filter: brightness(1.06); }
.soul-shop-buy.is-gray,
.soul-shop-buy.is-gray:disabled {
  color: #cfc6bc;
  border-color: #6f675f;
  background: #4a453f;
  opacity: .55;
  cursor: not-allowed;
}
.soul-shop-run-banner {
  padding: 10px 12px;
  color: #d8c4a3;
  border-left: 2px solid #c9a36a;
  background: rgba(80, 58, 28, .28);
}
.soul-shop-card.is-hidden-item .soul-shop-head b { letter-spacing: 0.28em; color: #9a8f82; }
.soul-core-convert {
  margin: 10px 0 16px;
  padding: 10px 12px;
  border: 1px solid rgba(201, 163, 106, .35);
  background: rgba(40, 30, 18, .45);
}
.soul-core-convert .modal-copy { margin: 0 0 6px; }
.soul-shop-toggle span { white-space: nowrap; }
.soul-shop-toggle { display: inline-flex; align-items: center; gap: 8px; color: #cbbba7; font-size: calc(12px * var(--fs, 1)); cursor: pointer; }
.soul-shop-toggle input { accent-color: #d4b06a; width: 16px; height: 16px; }
.soul-shop-locked { color: #7d746c; font-size: calc(11px * var(--fs, 1)); }


/* ENDING_VOID_SETTLEMENT_CSS */
.ending-hotspots { position: absolute; z-index: 6; inset: 0; pointer-events: none; }
.ending-hotspots .scene-hotspot { pointer-events: auto; }
.time-wheel-hotspot {
  left: 50%; top: 58%; transform: translate(-50%, -50%);
  min-width: 168px; text-align: center;
  border-color: rgba(110, 180, 255, .45);
  box-shadow: 0 0 28px rgba(60, 140, 255, .28), inset 0 0 22px rgba(40, 100, 200, .12);
  animation: acheronTimeWheelPulse 1.6s ease-in-out infinite;
}
.time-wheel-hotspot:hover, .time-wheel-hotspot:focus-visible {
  transform: translate(-50%, calc(-50% - 3px));
  border-color: rgba(160, 210, 255, .85);
}
.dungeon-stage[data-room="acheronWheel"] {
  background:
    radial-gradient(circle at 50% 62%, rgba(70, 140, 255, .16), transparent 28%),
    linear-gradient(180deg, #12151c, #07080c);
}
.dungeon-stage[data-room="acheronWheel"]::before {
  opacity: .35;
  background-image: radial-gradient(circle at 50% 58%, rgba(120, 190, 255, .18), transparent 40%);
}
.dungeon-stage[data-room="void"] {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(220,230,255,.35), transparent),
    radial-gradient(1px 1px at 28% 72%, rgba(200,210,255,.22), transparent),
    radial-gradient(1px 1px at 63% 24%, rgba(230,240,255,.28), transparent),
    radial-gradient(1px 1px at 81% 61%, rgba(190,205,255,.2), transparent),
    radial-gradient(1.5px 1.5px at 47% 44%, rgba(255,255,255,.18), transparent),
    radial-gradient(circle at 50% 40%, rgba(40, 55, 90, .14), transparent 42%),
    linear-gradient(180deg, #05060a 0%, #020308 55%, #000 100%);
}
.dungeon-stage[data-room="void"]::before { opacity: .12; }
.dungeon-stage[data-room="void"] .scene-header,
.dungeon-stage[data-room="acheronWheel"] .scene-header,
.dungeon-stage[data-room="settlement"] .scene-header {
  position: relative; z-index: 5; text-shadow: 0 2px 16px #000;
}
.dungeon-stage[data-room="void"] .dialogue-box {
  background: linear-gradient(110deg, rgba(10, 12, 20, .92), rgba(4, 5, 10, .96));
}
.dungeon-stage[data-room="settlement"] {
  background: linear-gradient(180deg, #15131a, #08070b);
}
.choice-layer:has(.settlement-panel) {
  grid-template-columns: 1fr;
  width: min(760px, 100%);
  max-height: min(68vh, 620px);
}
.settlement-panel {
  width: 100%;
  margin: 0;
  padding: 18px 20px 16px;
  border: 1px solid rgba(214, 183, 127, .28);
  background: linear-gradient(160deg, rgba(22, 18, 24, .96), rgba(8, 7, 11, .96));
  box-shadow: 0 18px 40px rgba(0,0,0,.45), inset 0 0 24px rgba(120, 90, 55, .06);
  position: relative; z-index: 4;
}
.settlement-actions {
  margin-top: 14px;
  display: grid;
}
.settlement-panel h3 {
  margin: 0 0 6px;
  font: 400 calc(18px * var(--fs, 1)) "STSong", serif;
  letter-spacing: .12em;
  color: #efd7a4;
}
.settlement-panel .settlement-lead {
  margin: 0 0 14px;
  color: #8f847b;
  font-size: calc(11px * var(--fs, 1));
  letter-spacing: .06em;
}
.settlement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.settlement-card {
  padding: 12px 12px 10px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.025);
}
.settlement-card b {
  display: block;
  margin-bottom: 4px;
  color: #d8bd83;
  font: 500 calc(12px * var(--fs, 1)) Georgia, serif;
  letter-spacing: .08em;
}
.settlement-card span, .settlement-card small {
  display: block;
  color: #d3c9bf;
  font-size: calc(13px * var(--fs, 1));
  line-height: 1.55;
  white-space: pre-wrap;
}
.settlement-card.full { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .settlement-grid { grid-template-columns: 1fr; }
  .time-wheel-hotspot { top: 64%; }
}


/* ===== 文集 & 画廊 ===== */
.archive-screen {
  display: none;
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 96px 18px 48px; /* 顶栏 72px + 间距，避免大标题叠进 topbar */
  box-sizing: border-box;
}
.archive-screen.is-active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.archive-tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0 8px;
  flex-wrap: wrap;
}
.archive-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(16, 12, 18, 0.85);
  color: #b9aa98;
  padding: 10px 18px;
  border-radius: 999px;
  letter-spacing: 0.18em;
  cursor: pointer;
  font-family: inherit;
}
.archive-tab.is-active {
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 0 1px rgba(212, 175, 95, 0.25) inset;
}
.archive-pane { display: none; margin-top: 10px; }
.archive-pane.is-active { display: block; }

.codex-shelf { margin: 18px 0 26px; }
.codex-shelf > header,
.gallery-section > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(212, 175, 95, 0.18);
  padding-bottom: 6px;
}
.codex-shelf h3,
.gallery-section h3 {
  margin: 0;
  font-size: calc(15px * var(--fs, 1));
  letter-spacing: 0.2em;
  color: var(--gold-bright);
  font-weight: 500;
}
.codex-shelf small,
.gallery-section small {
  opacity: 0.65;
  font-size: calc(11px * var(--fs, 1));
}
.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
}
.codex-book {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 158px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.codex-spine {
  width: 10px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(180deg, #5a4632, #2a1c14 55%, #1a120e);
  box-shadow: inset -1px 0 0 rgba(255, 220, 160, 0.18);
}
.codex-cover {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 12px 12px;
  border-radius: 0 8px 8px 0;
  border: 1px solid rgba(180, 150, 110, 0.28);
  background:
    linear-gradient(145deg, rgba(58, 42, 32, 0.95), rgba(22, 16, 20, 0.96)),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0,0,0,0.08) 3px, rgba(0,0,0,0.08) 4px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  min-width: 0;
}
.codex-cover small {
  opacity: 0.55;
  letter-spacing: 0.14em;
  font-size: calc(9px * var(--fs, 1));
}
.codex-cover b {
  font-weight: 500;
  font-size: calc(13px * var(--fs, 1));
  line-height: 1.35;
  color: #e6d7c3;
  word-break: break-word;
}
.codex-book.is-locked .codex-cover {
  filter: grayscale(0.35) brightness(0.72);
  border-color: rgba(120, 100, 90, 0.25);
}
.codex-book.is-locked .codex-cover b { color: #8d8074; letter-spacing: 0.28em; }
.codex-book.is-unlocked:hover .codex-cover {
  border-color: var(--gold);
  transform: translateY(-2px);
}
.codex-lock,
.gallery-lock {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: #a8947d;
  opacity: 0.8;
  border: 1px solid rgba(168, 148, 125, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(0,0,0,0.35);
}

.gallery-section { margin: 18px 0 26px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
}
.gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(180, 150, 110, 0.22);
  background: rgba(14, 10, 14, 0.78);
  color: #d8cbb8;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.gallery-card.is-unlocked:hover { border-color: var(--gold); }
.gallery-frame {
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, rgba(80, 60, 50, 0.35), rgba(8, 6, 10, 0.95));
  display: grid;
  place-items: center;
}
.gallery-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.gallery-silhouette {
  width: 58%;
  height: 72%;
  border-radius: 40% 40% 28% 28%;
  background: linear-gradient(180deg, #2a2228, #0c0a0e);
  box-shadow: inset 0 0 24px rgba(0,0,0,0.8);
  filter: blur(0.2px);
}
.gallery-card b {
  font-size: calc(12px * var(--fs, 1));
  font-weight: 500;
  line-height: 1.35;
}
.gallery-card.is-locked { filter: saturate(0.7); opacity: 0.88; }
.gallery-preview-body {
  display: grid;
  place-items: center;
  min-height: 280px;
  max-height: min(70vh, 560px);
  background: radial-gradient(circle at 50% 20%, rgba(70,50,40,0.35), rgba(8,6,10,0.95));
  border-radius: 12px;
  overflow: auto;
}
.gallery-preview-body img {
  max-width: 100%;
  max-height: min(68vh, 520px);
  object-fit: contain;
}
.gallery-frame video,
.gallery-frame .gallery-thumb-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a080c;
  pointer-events: none;
}
.gallery-card.is-video .gallery-frame {
  aspect-ratio: 9 / 16;
  background: radial-gradient(circle at 50% 35%, rgba(60, 40, 70, 0.4), rgba(8, 6, 10, 0.96));
}
.gallery-preview-body--video {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-height: min(78vh, 720px);
}
.gallery-preview-body--video video {
  width: min(100%, 360px);
  max-height: min(68vh, 620px);
  object-fit: contain;
  background: #050408;
  border-radius: 8px;
}
.gallery-video-tip {
  margin: 0;
  opacity: 0.65;
  font-size: calc(12px * var(--fs, 1));
  letter-spacing: 0.08em;
}

@media (max-width: 640px) {
  .codex-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
  .codex-book { min-height: 142px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
}


/* 文集&画廊 · 调试锁 */
.archive-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.archive-debug-lock {
  appearance: none;
  border: 1px solid rgba(180, 150, 110, 0.35);
  background: rgba(20, 14, 18, 0.72);
  color: #d4b86a;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset;
}
.archive-debug-lock:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  transform: translateY(-1px);
}

.archive-screen .panel-heading {
  align-items: flex-start;
  gap: 12px;
  margin-top: 0;
  padding-top: 4px;
}
.archive-screen .panel-heading h2 {
  line-height: 1.25;
}

/* ===== 育种腔室 · 插入后的射精条与插图位 ===== */
.breeding-rig { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.breeding-rig[hidden] { display: none; }
.breeding-illust { position: absolute; left: 4%; top: 22%; height: 50%; aspect-ratio: 2 / 3; margin: 0; display: grid; place-items: center; overflow: hidden; border: 1px dashed rgba(255, 140, 200, .6); border-radius: 6px; background: linear-gradient(180deg, rgba(40, 8, 28, .72), rgba(14, 3, 10, .82)); box-shadow: 0 0 22px rgba(255, 105, 180, .18), inset 0 0 30px rgba(255, 105, 180, .08); pointer-events: auto; }
.breeding-illust img,
.breeding-illust video,
.breeding-illust .breeding-illust-videos { position: absolute; inset: 0; width: 100%; height: 100%; }
.breeding-illust img,
.breeding-illust video { object-fit: contain; object-position: center center; }
.breeding-illust video { opacity: 0; pointer-events: none; }
.breeding-illust video.is-active { opacity: 1; }
.breeding-illust.has-image,
.breeding-illust.has-video { border-style: solid; border-color: rgba(255, 140, 200, .45); }
.breeding-illust.has-image .breeding-illust-placeholder,
.breeding-illust.has-video .breeding-illust-placeholder { display: none; }
.breeding-illust-placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; text-align: center; color: #e7a6c8; }
.breeding-illust-placeholder b { color: #ffb3d9; font: 500 calc(14px * var(--fs, 1)) Georgia, "Songti SC", serif; letter-spacing: .2em; }
.breeding-illust-placeholder span { font-size: calc(11px * var(--fs, 1)); line-height: 1.6; }
.breeding-illust-placeholder em { font-style: normal; color: #ffd2e8; font-size: calc(11px * var(--fs, 1)); font-variant-numeric: tabular-nums; }
.breeding-illust-placeholder small { color: rgba(231, 166, 200, .6); font-size: calc(9px * var(--fs, 1)); word-break: break-all; }
.breeding-illust:not([data-seq="idle"]) { border-color: rgba(255, 160, 210, .9); box-shadow: 0 0 26px rgba(255, 105, 180, .4), inset 0 0 30px rgba(255, 105, 180, .14); }
.breeding-illust.frame-tick:not(.has-image) .breeding-illust-placeholder em { animation: breeding-frame-tick .12s ease-out; }
@keyframes breeding-frame-tick { from { transform: scale(1.12); color: #fff; } to { transform: scale(1); } }
.breeding-control { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(600px, 70%); pointer-events: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(170px, 1.3fr) minmax(0, 1fr); grid-template-areas: ". finish ." "thrust gauge pull"; gap: 6px 10px; align-items: center; }
.breeding-buttons { display: contents; }
.breeding-gauge { grid-area: gauge; margin: 0; }
.breeding-gauge .jerk-gauge-track em.mark-pull { left: 60%; background: rgba(210, 200, 210, .55); }
.breeding-gauge .jerk-gauge-track em.mark-finish { left: 90%; }
.breeding-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 46px; padding: 6px 10px; color: #ffd2e8; cursor: pointer; border: 1px solid rgba(255, 105, 180, .65); border-radius: 8px; background: linear-gradient(90deg, rgba(150, 30, 90, .55), rgba(60, 14, 44, .9)); box-shadow: 0 0 14px rgba(255, 105, 180, .25), inset 0 0 18px rgba(255, 105, 180, .1); transition: transform .15s ease, opacity .2s ease, filter .2s ease; }
.breeding-btn b { color: #ffb3d9; font: 500 calc(13px * var(--fs, 1)) Georgia, "Songti SC", serif; letter-spacing: .12em; }
.breeding-btn small { color: #e7a6c8; font-size: calc(9px * var(--fs, 1)); line-height: 1.35; }
.breeding-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: #ff8fc7; }
.breeding-btn:disabled { cursor: default; opacity: .55; }
.breeding-btn.is-greyed { filter: grayscale(1); opacity: .38; border-color: rgba(180, 170, 175, .4); }
.breeding-btn-thrust { grid-area: thrust; }
.breeding-btn-pull { grid-area: pull; }
.breeding-btn-finish { grid-area: finish; min-height: 38px; border-color: #ff8fc7; animation: breeding-finish-glow 1.4s ease-in-out infinite; }
@keyframes breeding-finish-glow { 0%, 100% { box-shadow: 0 0 12px rgba(255, 105, 180, .35); } 50% { box-shadow: 0 0 26px rgba(255, 140, 200, .85); } }
.breeding-rig.is-finished .breeding-control { opacity: .7; }

/* 虚空之眼 · 精神气泡（虫族之母的精神低语，区别于普通对话气泡） */
.void-psy { position: absolute; z-index: 7; left: 57%; top: 5%; width: min(470px, 40%); max-height: 90%; display: flex; flex-direction: column; pointer-events: auto; filter: drop-shadow(0 0 18px rgba(255, 80, 190, .35)); }
.void-psy[hidden] { display: none; }
.void-psy-cloud { position: relative; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 18px 20px 14px; border-radius: 42px 46px 40px 44px / 34px 38px 34px 40px; border: 1px solid rgba(255, 150, 225, .55); background: radial-gradient(ellipse at 28% 18%, rgba(132, 30, 116, .9), rgba(46, 8, 46, .93) 58%, rgba(18, 4, 22, .95)); box-shadow: 0 0 26px rgba(255, 90, 200, .5), 0 0 70px rgba(150, 60, 255, .28), inset 0 0 34px rgba(255, 120, 220, .2); animation: void-psy-pulse 2.8s ease-in-out infinite; }
.void-psy-cloud::before, .void-psy-cloud::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255, 150, 225, .45); border-bottom-color: transparent; background: radial-gradient(circle at 40% 40%, rgba(132, 30, 116, .92), rgba(60, 10, 58, .94)); z-index: -1; }
.void-psy-cloud::before { width: 34%; height: 46px; left: 12%; top: -16px; }
.void-psy-cloud::after { width: 26%; height: 38px; right: 16%; top: -12px; }
.void-psy-text { flex: 1 1 auto; min-height: 48px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(255, 150, 225, .4) transparent; }
.void-psy-text p { margin: 0 0 8px; color: #ffdcf3; font: 500 calc(13.5px * var(--fs, 1))/1.75 Georgia, "Songti SC", "STSong", serif; letter-spacing: .04em; text-shadow: 0 0 7px rgba(255, 110, 215, .75), 1px 0 0 rgba(120, 200, 255, .32), -1px 0 0 rgba(255, 60, 130, .32); opacity: 0; animation: void-psy-in .9s ease-out forwards, void-psy-shimmer 4.6s ease-in-out infinite; animation-delay: var(--d, 0s), calc(var(--d, 0s) + .9s); }
.void-psy-text p:last-child { margin-bottom: 0; }
.void-psy-text p.is-glyph { color: #d4b2ff; letter-spacing: .14em; font-style: italic; word-break: break-all; text-shadow: 0 0 9px rgba(190, 120, 255, .9), 2px 0 0 rgba(255, 60, 160, .4), -2px 0 0 rgba(80, 220, 255, .35); animation: void-psy-in .9s ease-out forwards, void-psy-jitter .32s steps(2) infinite; animation-delay: var(--d, 0s), var(--d, 0s); }
.void-psy-text p.is-laugh { color: #ff9fd6; font-size: calc(16px * var(--fs, 1)); letter-spacing: .1em; animation: void-psy-in .6s ease-out forwards, void-psy-shake .18s linear infinite; animation-delay: var(--d, 0s), var(--d, 0s); }
.void-psy-text p.is-boon { padding-left: 10px; border-left: 2px solid rgba(255, 150, 225, .55); }
.void-psy-choices { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.void-psy-choices[hidden] { display: none; }
.void-psy-btn { padding: 7px 14px; color: #ffe2f5; cursor: pointer; border: 1px solid rgba(255, 150, 225, .7); border-radius: 999px; background: linear-gradient(90deg, rgba(126, 22, 104, .78), rgba(44, 8, 54, .92)); box-shadow: 0 0 12px rgba(255, 105, 200, .3), inset 0 0 14px rgba(255, 120, 220, .12); font: 500 calc(13px * var(--fs, 1)) Georgia, "Songti SC", serif; letter-spacing: .08em; text-align: center; transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease; }
.void-psy-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: #ffb3e6; box-shadow: 0 0 20px rgba(255, 120, 210, .65), inset 0 0 16px rgba(255, 140, 225, .2); }
.void-psy-btn:disabled { opacity: .5; cursor: default; }
.void-psy-btn-refuse { border-color: rgba(255, 110, 130, .75); background: linear-gradient(90deg, rgba(130, 16, 44, .8), rgba(50, 6, 24, .92)); }
.void-psy-trail { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.void-psy-trail i { position: absolute; border-radius: 50%; border: 1px solid rgba(255, 190, 240, .85); background: radial-gradient(circle at 35% 35%, rgba(255, 190, 240, .95), rgba(170, 50, 150, .95) 55%, rgba(70, 10, 70, .95)); box-shadow: 0 0 14px rgba(255, 120, 220, .85), 0 0 4px rgba(255, 255, 255, .5); animation: void-psy-dot 2.8s ease-in-out infinite; }
.void-psy-trail i:nth-child(1) { width: 20px; height: 20px; left: -18px; top: 30px; }
.void-psy-trail i:nth-child(2) { width: 13px; height: 13px; left: -40px; top: 16px; animation-delay: .25s; }
.void-psy-trail i:nth-child(3) { width: 8px; height: 8px; left: -58px; top: 6px; animation-delay: .5s; }
.void-psy.is-pulse .void-psy-cloud { animation: void-psy-arrive .7s ease-out, void-psy-pulse 2.8s ease-in-out .7s infinite; }
@keyframes void-psy-pulse { 0%, 100% { box-shadow: 0 0 22px rgba(255, 90, 200, .45), 0 0 60px rgba(150, 60, 255, .22), inset 0 0 30px rgba(255, 120, 220, .16); } 50% { box-shadow: 0 0 36px rgba(255, 110, 215, .75), 0 0 96px rgba(170, 70, 255, .38), inset 0 0 40px rgba(255, 140, 230, .28); } }
@keyframes void-psy-arrive { from { opacity: 0; transform: scale(.94); filter: blur(6px); } to { opacity: 1; transform: scale(1); filter: blur(0); } }
@keyframes void-psy-in { from { opacity: 0; filter: blur(5px); transform: translateY(3px); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes void-psy-shimmer { 0%, 100% { transform: none; filter: blur(0); } 46% { transform: skewX(0); filter: blur(0); } 50% { transform: skewX(-4deg) translateX(1px); filter: blur(.6px); } 54% { transform: skewX(2deg); filter: blur(0); } }
@keyframes void-psy-jitter { 0% { transform: translate(0, 0); } 50% { transform: translate(1px, -1px) skewX(-6deg); } 100% { transform: translate(-1px, 0); } }
@keyframes void-psy-shake { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(1px, -1px); } 75% { transform: translate(-1px, 1px); } }
@keyframes void-psy-dot { 0%, 100% { opacity: .65; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.12); } }
@media (max-width: 900px) {
  .void-psy { left: 3%; right: 3%; width: auto; top: 26%; }
  .void-psy-trail { left: 50%; }
  .void-psy-trail i:nth-child(1) { left: -9px; top: -26px; }
  .void-psy-trail i:nth-child(2) { left: -6px; top: -46px; }
  .void-psy-trail i:nth-child(3) { left: -4px; top: -62px; }
  .void-psy { max-height: 70%; }
}
@media (max-width: 900px) {
  .breeding-illust { left: 3%; top: 12%; height: 40%; }
  .breeding-control { width: 96%; grid-template-columns: 1fr 1fr; grid-template-areas: "finish finish" "gauge gauge" "thrust pull"; }
}
/* 第二轮：拒绝气泡叠在榨精装置上方时，不遮挡下方按钮、也不挡点击 */
.void-psy.is-over-rig { pointer-events: none; max-height: 70%; }
.void-psy.is-over-rig .void-psy-text { pointer-events: auto; }

/* ── 混合体技能树 / 紫黑色战斗技能 ── */
.combat-button.hybrid {
  color: #e4d4f4;
  border-color: rgba(158, 92, 196, .62);
  background: linear-gradient(145deg, rgba(42, 14, 48, .92), rgba(10, 6, 14, .94));
  box-shadow: 0 0 12px rgba(132, 64, 168, .28), inset 0 0 10px rgba(88, 28, 110, .35);
}
.combat-button.hybrid:hover {
  border-color: #c89be8;
  color: #f6e8ff;
  box-shadow: 0 0 16px rgba(168, 92, 214, .45);
}
.combat-button.hybrid small { color: #a888c0; }
.combat-button.hybrid:disabled {
  filter: grayscale(.55) brightness(.72);
  box-shadow: none;
  color: #8a7a96;
  border-color: rgba(90, 70, 104, .45);
}
.hybrid-skill-tree {
  border-color: rgba(150, 96, 196, .32);
  box-shadow: inset 0 0 46px rgba(28, 8, 40, .55), 0 0 28px rgba(120, 60, 160, .14);
}
.hybrid-skill-tree .skill-tree-node {
  color: #e8d6f6;
  border-color: rgba(176, 112, 210, .7);
  background: radial-gradient(circle at 50% 30%, rgba(52, 22, 64, .94), rgba(10, 6, 14, .94));
  box-shadow: 0 0 12px rgba(132, 64, 168, .28);
}
.hybrid-skill-tree .skill-tree-node.is-learned {
  color: #f8e9ff;
  border-color: #d8b0f0;
  box-shadow: 0 0 16px rgba(176, 96, 214, .48), inset 0 0 10px rgba(120, 48, 150, .28);
}
.hybrid-skill-tree .skill-tree-node.is-locked {
  color: #8a7d96;
  border-color: rgba(110, 90, 126, .45);
  background: radial-gradient(circle at 50% 30%, rgba(28, 22, 32, .9), rgba(8, 6, 10, .92));
  box-shadow: none;
  opacity: .78;
  cursor: default;
}
.hybrid-skill-tree .skill-tree-node.is-locked .skill-tree-node-label small {
  display: none;
}
.hybrid-skill-tree .skill-tree-node.is-selected {
  outline-color: #d8b0f0;
}
.hybrid-skill-tree .skill-tree-node.is-learned.is-selected {
  box-shadow: 0 0 20px rgba(196, 120, 230, .62), inset 0 0 12px rgba(140, 64, 180, .3);
}
.skill-tree-node-popup.is-hybrid {
  border-color: rgba(176, 112, 210, .5);
  background: rgba(12, 8, 18, .9);
}
.skill-tree-node-popup.is-hybrid b { color: #e8d6f6; }
.sheet-level.is-capped small.sheet-cap-note {
  display: block;
  margin-top: 2px;
  color: #c4a0d8;
  font-size: calc(7px * var(--fs, 1));
  letter-spacing: .04em;
}
.hybrid-hud-chip,
.status-chip.hybrid-chip {
  color: #e0c8f0;
  border-color: rgba(158, 92, 196, .4);
  background: rgba(72, 28, 96, .22);
}
.combat-actions.essence-offering-actions,
.combat-actions:has(.essence-offering-panel) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  grid-template-columns: none;
}
.essence-offering-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}
.essence-offering-panel .jerk-gauge {
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}
.essence-offering-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 10px;
  width: 100%;
}
.essence-offering-buttons .combat-button {
  min-height: 56px;
  padding: 12px 16px;
}
.essence-offering-buttons .combat-button b {
  line-height: 1.45;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}
.void-psy.is-over-rig .void-psy-choices { pointer-events: auto; }

/* 种源骑士跳场：从场景后方/上方冲入前景 */
@keyframes seedKnightLeapIn {
  0% {
    opacity: 0;
    transform: translate(-18%, -46%) scale(.62);
    filter: blur(10px) brightness(1.55) drop-shadow(0 0 18px rgba(232, 196, 122, .0));
  }
  42% {
    opacity: 1;
    transform: translate(6%, 8%) scale(1.12);
    filter: blur(0) brightness(1.2) drop-shadow(0 0 28px rgba(232, 196, 122, .55));
  }
  70% {
    transform: translate(-2%, -2%) scale(1.03);
    filter: brightness(1.06) drop-shadow(0 0 16px rgba(201, 92, 151, .35));
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
    filter: none;
  }
}
.enemy-figure.seed-knight-leap,
.enemy-figure.has-portrait.seed-knight-leap {
  animation: seedKnightLeapIn .9s cubic-bezier(.14, .86, .28, 1) both;
  z-index: 8;
}
.enemy-figure.seed-knight-leap .enemy-portrait {
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .7));
}


/* —— Language switch + English typography —————————————— */

.topbar-trailing {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 18px;
  flex-shrink: 0;
}
.topbar-trailing .top-actions { margin-left: 0; }

html[data-edition="test"] #langSwitch {
  display: none !important;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  align-self: center;
  height: 36px;
  padding: 0 4px;
  border: 1px solid rgba(220, 198, 160, 0.2);
  background: rgba(255, 255, 255, 0.025);
  flex-shrink: 0;
}
.lang-switch-btn {
  margin: 0;
  padding: 7px 7px;
  color: #8a8078;
  border: 0;
  background: transparent;
  font-size: calc(11px * var(--fs, 1));
  letter-spacing: 0.08em;
  font-family: inherit;
  cursor: pointer;
  line-height: 1;
}
.lang-switch-btn.is-active {
  color: var(--gold-bright);
}
.lang-switch-btn:hover { color: var(--gold-bright); }
.lang-switch-divider {
  color: #6a635c;
  padding: 0 1px;
  letter-spacing: 0;
  font-size: calc(11px * var(--fs, 1));
  pointer-events: none;
}

html.lang-en .brand-button strong { letter-spacing: 0.04em; }
html.lang-en .brand-button small { letter-spacing: 0.08em; }
html.lang-en .summary-item small { letter-spacing: 0.04em; }
html.lang-en .icon-button,
html.lang-en .text-button,
html.lang-en .primary-button,
html.lang-en .secondary-button { letter-spacing: 0.04em; }
html.lang-en .return-title-button {
  min-width: 118px;
  white-space: nowrap;
}
html.lang-en .lock-seal {
  white-space: normal;
  letter-spacing: 0.06em;
  max-width: 90%;
  text-align: center;
  line-height: 1.4;
}
html.lang-en .enemy-party .enemy-figure .enemy-nameplate span,
html.lang-en .enemy-nameplate span {
  white-space: normal;
  line-height: 1.25;
}
html.lang-en .combat-button {
  min-height: 68px;
}
html.lang-en .combat-button b,
html.lang-en .essence-offering-buttons .combat-button b {
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  letter-spacing: 0.02em;
  line-height: 1.3;
}
html.lang-en .combat-actions {
  gap: 8px;
}
html.lang-en .skill-tree-node {
  width: 148px;
  min-height: 42px;
  padding: 7px 8px;
}
html.lang-en .skill-tree-node-label {
  letter-spacing: 0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: normal;
}
html.lang-en .skill-tree-node-popup b { letter-spacing: 0.03em; }
html.lang-en .sheet-tab {
  white-space: normal;
  line-height: 1.3;
  letter-spacing: 0.04em;
}
html.lang-en .modal-copy,
html.lang-en .story-overlay .story-body,
html.lang-en .story-page,
html.lang-en .dialogue-box,
html.lang-en #dialogueText {
  line-height: 1.7;
  letter-spacing: 0.01em;
}
html.lang-en .title-subtitle,
html.lang-en .panel-intro,
html.lang-en .character-card-copy,
html.lang-en .choice-copy,
html.lang-en .object-card p,
html.lang-en .object-card h3 {
  letter-spacing: 0.01em;
  line-height: 1.65;
}
html.lang-en .primary-button small,
html.lang-en .secondary-button small {
  letter-spacing: 0.03em;
  white-space: normal;
  line-height: 1.35;
}

html.lang-en .dungeon-stage { grid-template-columns: 92px minmax(0, 1fr) minmax(20rem, 26rem); }
html.lang-en .dice-history-heading span { letter-spacing: 0.04em; }
html.lang-en .dice-history-rail {
  min-width: 20rem;
  overflow-x: auto;
}
html.lang-en .dice-readout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-x: auto;
  overflow-y: auto;
  min-width: 0;
}
html.lang-en .dice-action-group {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}
/* Do not let a nowrap Turn/Round label squeeze the title into a ~1ch column.
   Previous min-width:0 + overflow-wrap:break-word did exactly that. */
html.lang-en .dice-action-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  letter-spacing: 0.03em;
  min-width: 0;
}
html.lang-en .dice-action-heading b {
  flex: 1 1 12rem;
  min-width: min(12rem, 100%);
  color: #c8b9aa;
  font-size: calc(9px * var(--fs, 1));
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.45;
  overflow-wrap: break-word;
  word-break: normal;
  word-wrap: break-word;
  hyphens: none;
  white-space: normal;
  overflow: visible;
}
html.lang-en .dice-action-heading span {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}
html.lang-en .dice-entry {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 12px;
  padding: 8px 10px;
}
html.lang-en .dice-face { margin: 0; }
html.lang-en .dice-copy {
  flex: 1 1 14rem;
  min-width: min(14rem, 100%);
}
html.lang-en .dice-copy b,
html.lang-en .dice-copy small {
  letter-spacing: 0.03em;
  line-height: 1.45;
  overflow-wrap: break-word;
  word-break: normal;
  word-wrap: break-word;
  hyphens: none;
  overflow: visible;
}
html.lang-en .dice-copy b { letter-spacing: 0.03em; }
html.lang-en .dice-copy small {
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  scrollbar-width: thin;
}


@media (max-width: 900px) {
  .topbar-trailing { margin-left: 8px; gap: 6px; }
  html.lang-en .return-title-button { min-width: 96px; }
  html.lang-en .skill-tree-node { width: 132px; }
  html.lang-en .dungeon-stage { grid-template-columns: 72px minmax(0, 1fr) minmax(18rem, 22rem); }
  html.lang-en .dice-history-rail { min-width: 18rem; }
}
@media (max-width: 680px) and (orientation: portrait) {
  .topbar-trailing { margin-left: 6px; gap: 4px; }
  .lang-switch { height: 30px; padding: 0 2px; }
  .lang-switch-btn { padding: 5px 7px; letter-spacing: 0.08em; }
  html.lang-en .return-title-button {
    min-width: 72px;
    font-size: calc(10px * var(--fs, 1));
    letter-spacing: 0.02em;
  }
  html.lang-en .summary-item { min-width: 52px; }
  html.lang-en .dungeon-stage {
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-rows: 760px 300px;
    min-height: 1060px;
  }
  html.lang-en .dice-history-rail { min-width: 0; }
  html.lang-en .dice-readout {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    gap: 12px;
  }
  html.lang-en .dice-action-group {
    margin: 0;
    padding: 0 0 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(218, 190, 138, .18);
    overflow: visible;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}


/* 锈锁石匣 · 宝箱怪挣扎 / 射精条 */
.rust-casket-gauges {
  position: relative;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, 100%);
  margin: 0 0 10px;
  flex-shrink: 0;
  pointer-events: none;
}
.dungeon-stage[data-room="rustCasket"] .scene-area {
  position: relative;
  z-index: 12;
}
/* 宝箱怪射精条、挣扎条整体上移 64px，不改未出现宝箱怪时的选项位置。
   抓住后三条挣扎按钮用 transform 提到两条条的上方；两条条仍留在原文档流位置，不被挤下去。 */
.dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) .choice-layer.rust-casket-actions {
  margin-bottom: 64px;
  z-index: 41;
  transform: translateY(calc(-100% - var(--rust-casket-gauge-stack, 114px) - 18px));
}
.dungeon-stage[data-room="rustCasket"] .choice-layer.rust-casket-actions {
  z-index: 12;
  width: min(420px, 100%);
  gap: 8px;
  max-height: none;
  overflow: visible;
  flex-shrink: 0;
  margin-left: 0;
  margin-right: auto;
  padding-right: 0;
}
.dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) .scene-object {
  min-height: 0;
}
.dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) {
  overflow: hidden;
}
.dungeon-stage[data-room="rustCasket"] .choice-layer.rust-casket-actions .choice-card {
  min-height: 44px;
  padding: 7px 12px;
  gap: 8px;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
}
.dungeon-stage[data-room="rustCasket"] .choice-layer.rust-casket-actions .choice-index {
  width: 24px;
  height: 24px;
  margin-top: 0;
}
.dungeon-stage[data-room="rustCasket"] .choice-layer.rust-casket-actions .choice-copy b {
  margin-bottom: 0;
  font-size: calc(14px * var(--fs, 1));
}

.rust-casket-gauge {
  padding: 7px 12px 8px;
  text-align: left;
  border-radius: 10px;
  box-shadow: 0 0 14px rgba(0, 0, 0, .28);
  transition: box-shadow .45s ease, border-color .45s ease, transform .35s ease;
}
.rust-casket-gauge-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 14px;
}
.rust-casket-gauge-head span {
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.rust-casket-gauge-track {
  position: relative;
  height: 14px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
}
.rust-casket-gauge-track i {
  position: relative;
  display: block;
  height: 100%;
  width: 0;
  overflow: hidden;
  border-radius: 8px;
  transform-origin: left center;
  transition: width .55s cubic-bezier(.22, .7, .28, 1);
}
.rust-casket-gauge-track i::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 45%;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.rust-casket-gauge-track i::after {
  content: "";
  position: absolute;
  inset: -20% -40%;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, .0) 40%, rgba(255, 255, 255, .55) 50%, rgba(255, 255, 255, 0) 60%, transparent 80%);
  animation: rust-casket-sheen 2.6s ease-in-out infinite;
  pointer-events: none;
}
.rust-casket-gauge.is-ejac {
  border: 1px solid rgba(255, 105, 180, .6);
  background: linear-gradient(90deg, rgba(110, 22, 70, .55), rgba(40, 10, 32, .9));
}
.rust-casket-gauge.is-ejac .rust-casket-gauge-head { color: #ffb3d9; }
.rust-casket-gauge.is-ejac .rust-casket-gauge-head span { color: #ffd2e8; }
.rust-casket-gauge.is-ejac .rust-casket-gauge-track {
  background: rgba(20, 4, 14, .85);
  border: 1px solid rgba(255, 140, 200, .35);
}
.rust-casket-gauge.is-ejac .rust-casket-gauge-track i {
  background: linear-gradient(90deg, #ff4e9d, #ff6fb5 35%, #ffb3dc 70%, #ffd0ea);
  box-shadow: 0 0 12px rgba(255, 120, 190, .85), 0 0 18px rgba(255, 80, 160, .35);
}
.rust-casket-gauge.is-ejac .rust-casket-gauge-track em {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 90%;
  width: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .15), rgba(255, 255, 255, .95), rgba(255, 255, 255, .15));
  box-shadow: 0 0 8px rgba(255, 255, 255, .65);
  z-index: 2;
}
.rust-casket-gauge.is-ejac.is-warming {
  box-shadow: 0 0 16px rgba(255, 90, 170, .32), 0 0 14px rgba(0, 0, 0, .28);
}
.rust-casket-gauge.is-ejac.is-hot {
  border-color: rgba(255, 170, 210, .95);
  box-shadow: 0 0 22px rgba(255, 80, 170, .55), 0 0 14px rgba(0, 0, 0, .28);
  animation: rust-casket-hot-glow 1.15s ease-in-out infinite;
}
.rust-casket-gauge.is-ejac.is-hot .rust-casket-gauge-track i {
  box-shadow: 0 0 16px rgba(255, 150, 210, 1), 0 0 24px rgba(255, 70, 160, .6);
}
.rust-casket-gauge.is-struggle {
  border: 1px solid rgba(230, 230, 235, .55);
  background: linear-gradient(90deg, rgba(52, 52, 60, .62), rgba(18, 18, 22, .92));
}
.rust-casket-gauge.is-struggle .rust-casket-gauge-head { color: #f2f2f6; }
.rust-casket-gauge.is-struggle .rust-casket-gauge-head span { color: #d8d8e0; }
.rust-casket-gauge.is-struggle .rust-casket-gauge-track {
  background: rgba(10, 10, 14, .85);
  border: 1px solid rgba(220, 220, 230, .3);
}
.rust-casket-gauge.is-struggle .rust-casket-gauge-track i {
  background: linear-gradient(90deg, #d8d8e4, #f7f7fb 45%, #ffffff 75%, #ececf4);
  box-shadow: 0 0 12px rgba(240, 240, 245, .5), 0 0 16px rgba(200, 200, 220, .25);
}
.rust-casket-gauge.is-rising.is-flash {
  transform: translateY(-1px);
}
.rust-casket-gauge.is-falling.is-flash .rust-casket-gauge-track i {
  filter: brightness(1.15);
}
@keyframes rust-casket-sheen {
  0% { transform: translateX(-55%); opacity: .15; }
  45% { opacity: .85; }
  100% { transform: translateX(55%); opacity: .2; }
}
@keyframes rust-casket-hot-glow {
  0%, 100% { box-shadow: 0 0 16px rgba(255, 80, 170, .4), 0 0 14px rgba(0, 0, 0, .28); }
  50% { box-shadow: 0 0 26px rgba(255, 120, 200, .7), 0 0 14px rgba(0, 0, 0, .28); }
}


/* 育种房 · 插入后左侧动画栏与底部进度（复用育种腔室栏位布局，无抽离键） */
.breeding-hall-rig .breeding-control,
.breeding-hall-control {
  grid-template-columns: minmax(0, 1.15fr) minmax(170px, 1.3fr) minmax(0, 1.15fr);
  grid-template-areas: "thrust gauge finish";
}
.breeding-hall-rig .breeding-btn-finish {
  grid-area: finish;
  min-height: 46px;
}
.dungeon-stage[data-room="breedingHall"] .scene-area {
  position: relative;
  z-index: 12;
}


/* ===== 尼德霍格独有资源条 / 技能树 ===== */
.nidhogg-mp-row,
.nidhogg-qi-row,
.nidhogg-hormone-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nidhogg-mp-bar { background: #0c1c28; }
.nidhogg-mp-bar i { background: linear-gradient(90deg, #1a6a8a, #6fd0e6); }
.nidhogg-qi-ticks { display: flex; gap: 4px; flex: 1; justify-content: flex-end; min-height: 12px; }
.nidhogg-qi-ticks i { width: 12px; height: 12px; border-radius: 1px; border: 1px solid #d8d8d8; box-sizing: border-box; }
.nidhogg-qi-ticks i.is-filled { background: #f5f5f5; border-color: #ffffff; }
.nidhogg-qi-ticks i.is-empty { background: #050505; border-color: #2a2a2a; }
.nidhogg-heartbeat { display: inline-flex; width: 88px; height: 18px; margin-left: 8px; overflow: hidden; }
.nidhogg-heartbeat svg { width: 100%; height: 100%; }
.nidhogg-heartbeat polyline { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nidhogg-heartbeat.is-calm polyline { stroke: #f2f2f2; animation: nidhoggBeatCalm 1.4s ease-in-out infinite; }
.nidhogg-heartbeat.is-wave polyline { stroke: #e6c84a; animation: nidhoggBeatWave 1.05s ease-in-out infinite; }
.nidhogg-heartbeat.is-heat polyline { stroke: #d88ad8; animation: nidhoggBeatHeat .72s ease-in-out infinite; }
.nidhogg-heartbeat.is-rut polyline { stroke: #8a1a1a; animation: nidhoggBeatRut .52s ease-in-out infinite; }
@keyframes nidhoggBeatCalm { 0%,100% { transform: scaleY(0.7); } 50% { transform: scaleY(1); } }
@keyframes nidhoggBeatWave { 0%,100% { transform: scaleY(0.85); } 50% { transform: scaleY(1.25); } }
@keyframes nidhoggBeatHeat { 0%,100% { transform: scaleY(0.9); } 40% { transform: scaleY(1.55); } }
@keyframes nidhoggBeatRut { 0%,100% { transform: scaleY(1); } 30% { transform: scaleY(1.85); } }
.bar.nidhogg-sanity-bar { position: relative; }
.nidhogg-gold-line { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: linear-gradient(180deg, #f6e27a, #c9a227); box-shadow: 0 0 4px rgba(240, 210, 110, .8); pointer-events: none; z-index: 3; }
.nidhogg-gold-line.is-shattered { background: linear-gradient(180deg, #8a7a3a, #3a320f); box-shadow: none; opacity: .45; clip-path: polygon(0 0, 100% 0, 80% 35%, 100% 55%, 70% 100%, 0 100%, 20% 60%, 0 40%); }
.nidhogg-armor-chip { display: flex; flex-direction: column; gap: 4px; }
.nidhogg-armor-chip .armor-dura-bar { display: block; height: 6px; background: #1a1a1a; border: 1px solid #6a6a6a; }
.nidhogg-armor-chip .armor-dura-bar i { display: block; height: 100%; background: #f4f4f4; }
.nidhogg-armor-dismiss { margin-top: 2px; font-size: 11px; padding: 1px 6px; background: transparent; color: #d8d8d8; border: 1px solid #888; cursor: pointer; }
.nidhogg-skill-points { margin: 0 0 8px; font-size: 13px; color: #d7c9b0; }
.nidhogg-blood-tree .skill-tree-node.is-learned,
.nidhogg-skill-tree.is-blood .skill-tree-node.is-learned,
.skill-tree-node.is-blood.is-learned {
  background: linear-gradient(180deg, #5a1518, #3a0b0d);
  border-color: #8a2a2e;
  color: #f3d6d4;
}
.nidhogg-spear-tree .skill-tree-node.is-learned,
.skill-tree-node.is-spear.is-learned {
  background: linear-gradient(180deg, #0f4c5c, #08323d);
  border-color: #3eb7d0;
  color: #d7f6ff;
}
.nidhogg-blood-tree .skill-tree-node.is-locked { background: rgba(40, 10, 12, .72); border-color: #5a2a2c; }
.nidhogg-spear-tree .skill-tree-node.is-locked { background: rgba(8, 28, 36, .72); border-color: #1c4a58; }
.nidhogg-learn-skill { margin-top: 8px; }

/* In-game load modal (next to Save) */
.in-game-load-modal .in-game-load-slot-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: min(52vh, 52dvh, 420px);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.in-game-load-slot {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  color: #dfd1bf;
  border: 1px solid rgba(220, 188, 130, 0.28);
  background: rgba(20, 16, 14, 0.72);
  border-radius: 6px;
  font: inherit;
}
.in-game-load-slot:hover {
  border-color: rgba(220, 188, 130, 0.55);
  color: var(--gold-bright);
}
.in-game-load-slot-label {
  font-size: calc(12px * var(--fs, 1));
  letter-spacing: 0.14em;
  color: var(--gold);
}
.in-game-load-slot-summary {
  font-size: calc(12px * var(--fs, 1));
  line-height: 1.55;
  color: #aaa097;
}


/* =============================================================================
 * ITCH PUBLIC EDITION: altar success layout (merged from 研发版, layout only)
 * - 「祭坛已经回应」与祭坛居中
 * - 「离开祭坛」在该弹窗正下方
 * - 点击阿刻戎出现对话时，立绘保持原位，不位移到弹窗下方
 * ============================================================================= */
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .scene-object:has(.altar-talk:not([hidden])) {
  grid-template-columns: minmax(0, 1fr);
}
.dungeon-stage[data-room="altar"] .scene-object:has(.altar-object-stack) {
  overflow: visible;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):not(:has(.choice-layer > .choice-card)) {
  grid-template-columns: minmax(0, 1fr);
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):not(:has(.choice-layer > .choice-card)) .scene-object {
  grid-column: 1;
  grid-row: 2;
  z-index: 4;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) {
  grid-template-columns: minmax(120px, 0.28fr) minmax(240px, 0.44fr) minmax(190px, 0.28fr);
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .scene-object {
  grid-column: 1 / 3;
  grid-row: 2;
  z-index: 4;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .choice-layer,
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .choice-layer.altar-curse-picks {
  grid-column: 3;
  grid-row: 2;
  z-index: 6;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc,
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-talk,
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-object-stack {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: clamp(120px, 34%, 260px);
  height: auto;
  max-height: 100%;
  z-index: 5;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.altar-talk:not([hidden])) .altar-npc {
  width: clamp(96px, 22%, 170px);
  left: 0;
  top: 0;
  bottom: 0;
  transform: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc-hit {
  pointer-events: auto;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-talk:not([hidden]) {
  position: absolute;
  left: clamp(120px, 34%, 260px);
  top: 50%;
  transform: translateY(-50%);
  width: min(240px, 26%);
  max-width: 28%;
  max-height: calc(100% - 16px);
  z-index: 9;
  pointer-events: auto;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.altar-talk:not([hidden])) .altar-talk:not([hidden]) {
  left: clamp(96px, 22%, 170px);
}
.dungeon-stage[data-room="altar"] .object-card {
  position: absolute;
  z-index: 8;
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 52%);
  max-width: min(480px, 62%);
  max-height: min(68%, 260px);
  margin: 0;
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: auto;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .altar-object-stack .object-card {
  left: auto;
  width: 100%;
  max-width: 100%;
}
.dungeon-stage[data-room="altar"] .altar-object-stack {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(420px, 52%);
  max-width: min(480px, 62%);
  max-height: 100%;
  box-sizing: border-box;
  overflow: visible;
  pointer-events: none;
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card) .altar-object-stack {
  left: 56%;
  width: min(380px, 58%);
  max-width: min(420px, 66%);
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.altar-talk:not([hidden])) .altar-object-stack {
  left: 72%;
  width: min(360px, 44%);
  max-width: min(380px, 50%);
}
.dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card):has(.altar-talk:not([hidden])) .altar-object-stack {
  left: 74%;
  width: min(340px, 44%);
  max-width: min(380px, 50%);
}
.dungeon-stage[data-room="altar"] .altar-object-stack .object-card {
  position: relative;
  left: auto;
  right: auto;
  top: auto;
  transform: none;
  width: 100%;
  max-width: 100%;
  margin: 0;
  max-height: min(200px, calc(100% - 52px));
  flex: 0 1 auto;
  pointer-events: auto;
}
.dungeon-stage[data-room="altar"] .altar-leave-button {
  pointer-events: auto;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  align-self: center;
  width: auto;
  min-width: 10em;
  max-width: 100%;
  margin: 0;
  padding: 6px 16px 7px;
  border: 1px solid rgba(214, 183, 127, .48);
  background: rgba(18, 14, 12, .92);
  box-shadow: 0 0 0 1px rgba(40, 28, 16, .45), 0 6px 14px rgba(0, 0, 0, .32);
  color: var(--ivory, #e8d5aa);
  cursor: pointer;
  font: inherit;
  text-align: center;
  box-sizing: border-box;
}

.difficulty-mode-btn.is-locked,
.difficulty-mode-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

@media (max-width: 900px) {
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .scene-object:has(.altar-talk:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])) .altar-npc {
    width: clamp(96px, 30%, 180px);
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.altar-talk:not([hidden])) .altar-npc {
    width: clamp(80px, 22%, 140px);
    left: 0;
    top: 0;
    bottom: 0;
    transform: none;
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.altar-talk:not([hidden])) .altar-talk:not([hidden]) {
    left: clamp(80px, 22%, 140px);
    width: min(200px, 28%);
    max-width: 30%;
  }
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.altar-talk:not([hidden])) .altar-object-stack,
  .dungeon-stage[data-room="altar"] .scene-area:has(.object-card:not([hidden])):has(.choice-layer > .choice-card):has(.altar-talk:not([hidden])) .altar-object-stack {
    left: 74%;
    width: min(280px, 44%);
    max-width: min(320px, 50%);
  }
}

html.lang-ja .brand-button small,
html.lang-ko .brand-button small,
html.lang-ja .summary-item small,
html.lang-ko .summary-item small,
html.lang-ja .icon-button,
html.lang-ko .icon-button,
html.lang-ja .text-button,
html.lang-ko .text-button,
html.lang-ja .primary-button,
html.lang-ko .primary-button,
html.lang-ja .secondary-button,
html.lang-ko .secondary-button {
  letter-spacing: 0.04em;
}
html.lang-ja .return-title-button,
html.lang-ko .return-title-button {
  min-width: 118px;
  white-space: nowrap;
}
html.lang-ja .lock-seal,
html.lang-ko .lock-seal {
  white-space: normal;
  letter-spacing: 0.04em;
  max-width: 90%;
  text-align: center;
  line-height: 1.4;
}
html.lang-ja .enemy-party .enemy-figure .enemy-nameplate span,
html.lang-ja .enemy-nameplate span,
html.lang-ko .enemy-party .enemy-figure .enemy-nameplate span,
html.lang-ko .enemy-nameplate span {
  white-space: normal;
  line-height: 1.25;
  letter-spacing: 0.04em;
}
html.lang-ja .combat-button,
html.lang-ko .combat-button {
  min-height: 68px;
}
html.lang-ja .combat-button b,
html.lang-ja .essence-offering-buttons .combat-button b,
html.lang-ko .combat-button b,
html.lang-ko .essence-offering-buttons .combat-button b {
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  letter-spacing: 0.02em;
  line-height: 1.3;
}
html.lang-ja .skill-tree-node,
html.lang-ko .skill-tree-node {
  width: 148px;
  min-height: 42px;
  padding: 7px 8px;
}
html.lang-ja .skill-tree-node-label,
html.lang-ko .skill-tree-node-label {
  letter-spacing: 0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: normal;
}
html.lang-ja .sheet-tab,
html.lang-ko .sheet-tab {
  white-space: normal;
  line-height: 1.3;
  letter-spacing: 0.04em;
}
html.lang-ja .modal-copy,
html.lang-ja .story-overlay .story-body,
html.lang-ja .story-page,
html.lang-ja .dialogue-box,
html.lang-ja #dialogueText,
html.lang-ko .modal-copy,
html.lang-ko .story-overlay .story-body,
html.lang-ko .story-page,
html.lang-ko .dialogue-box,
html.lang-ko #dialogueText {
  line-height: 1.75;
  letter-spacing: 0.02em;
}
html.lang-ja .dungeon-stage,
html.lang-ko .dungeon-stage { grid-template-columns: 92px minmax(0, 1fr) minmax(20rem, 26rem); }
html.lang-ja .dice-history-rail,
html.lang-ko .dice-history-rail {
  min-width: 20rem;
  overflow-x: auto;
}

/* t342-content-type */

/* Short viewports (phones/tablets, itch iframe): tighten modal/story chrome so
   inner scrollers with 100dvh / max-height bounds can actually move. */
@media (max-height: 700px) {
  .modal-backdrop { padding: 12px; }
  .modal {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .story-overlay {
    padding: 44px 16px 16px;
  }
  .platinum-intro-modal .platinum-intro-story,
  .nidhogg-intro-modal .platinum-intro-story,
  .nidhogg-intro-modal .nidhogg-intro-story {
    max-height: min(48vh, 48dvh, 420px);
  }
}


/* =============================================================================
   Phone landscape: desktop-like structure, compact short viewports.

   Width-only breakpoints are not enough:
   - 667px landscape still hit the stacked max-width: 680px portrait layout.
   - 844–932px landscape already trips tablet/desktop width queries, but
     375–430px of height cannot fit the 72px topbar + ~294px HUD chrome.

   Strategy:
   - Stacked mobile rules above are portrait-only.
   - Landscape + min-width 560px restores the side-by-side desktop structure
     (stage | scene | dice rail, HUD as a bottom bar).
   - Landscape + min-width 560px + max-height 560px tightens vertical chrome
     with flex + dvh (no page-level transform: scale; no scrollbar hiding).
   - Typical desktop/laptop (1280×800, 1366×768, 1920×1080) and iPad-class
     landscape heights (>=768px) do not match the compact query.
   ============================================================================= */

/* Hide D20 collapse control except in the landscape 3-column layout below. */
.dice-rail-toggle { display: none; }

/* Restore desktop structure in landscape, including widths ≤680px / ≤900px. */
@media (orientation: landscape) and (min-width: 560px) {
  .save-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settlement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .character-select-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-height: 0;
  }

  .game-screen {
    height: 100vh;
    height: 100dvh;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .dungeon-stage {
    min-height: 0;
    flex: 1 1 auto;
    grid-template-rows: none;
  }

  html.lang-en .dungeon-stage {
    min-height: 0;
    grid-template-rows: none;
  }

  /* Keep HUD as a bottom bar (not the 790px stacked portrait HUD). */
  .hud-panel {
    height: calc(350px * var(--hud-scale));
    min-height: calc(350px * var(--hud-scale));
    flex-basis: calc(350px * var(--hud-scale));
  }

  .route-rail,
  .scene-area,
  .dice-history-rail {
    grid-column: auto;
    grid-row: auto;
  }

  .dice-history-rail { border-left: 1px solid rgba(218, 198, 157, .14); border-top: 0; }

  .story-overlay.story-overlay--video { flex-direction: row; }
  .story-overlay.story-overlay--video .story-main { flex-direction: row; }

  /* D20 rail collapse: show toggle only in this desktop-like landscape layout. */
  .dice-history-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 8px;
  }
  .dice-history-heading span,
  .dice-history-heading small { display: block; flex: 1 1 100%; }
  .dice-rail-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 32px;
    padding: 5px 8px;
    color: #cbbfb0;
    border: 1px solid rgba(220, 198, 160, 0.2);
    background: rgba(255, 255, 255, 0.025);
    cursor: pointer;
    letter-spacing: 0.12em;
    font-size: calc(11px * var(--fs, 1));
  }
  .dice-rail-toggle:hover,
  .dice-rail-toggle:focus-visible {
    color: var(--gold-bright);
    border-color: rgba(220, 188, 130, 0.48);
  }
  .dice-rail-toggle-expand { display: none; }
  .dice-history-rail.is-collapsed .dice-rail-toggle-collapse { display: none; }
  .dice-history-rail.is-collapsed .dice-rail-toggle-expand { display: inline; }

  .dungeon-stage.is-dice-rail-collapsed,
  html.lang-en .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ja .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ko .dungeon-stage.is-dice-rail-collapsed {
    grid-template-columns: 92px minmax(0, 1fr) 44px;
  }
  .dice-history-rail.is-collapsed {
    min-width: 0;
    overflow: hidden;
  }
  .dice-history-rail.is-collapsed .dice-readout { display: none; }
  .dice-history-rail.is-collapsed .dice-history-heading {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    padding: 10px 4px;
    border-bottom: 0;
    gap: 10px;
  }
  .dice-history-rail.is-collapsed .dice-history-heading span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.16em;
    flex: 0 0 auto;
    font-size: calc(11px * var(--fs, 1));
  }
  .dice-history-rail.is-collapsed .dice-history-heading small { display: none; }
  .dice-history-rail.is-collapsed .dice-rail-toggle {
    margin: 0;
    min-width: 0;
    width: 100%;
    writing-mode: horizontal-tb;
    padding: 8px 2px;
    font-size: calc(10px * var(--fs, 1));
  }
}

/* Slightly tighter 3-column stage for narrow landscape (e.g. 667px). */
@media (orientation: landscape) and (min-width: 560px) and (max-width: 900px) {
  .dungeon-stage { grid-template-columns: 64px minmax(0, 1fr) 220px; }
  html.lang-en .dungeon-stage { grid-template-columns: 64px minmax(0, 1fr) minmax(12rem, 16rem); }
  html.lang-ja .dungeon-stage,
  html.lang-ko .dungeon-stage { grid-template-columns: 64px minmax(0, 1fr) minmax(12rem, 16rem); }
  html.lang-ja .dice-history-rail,
  html.lang-ko .dice-history-rail { min-width: 0; }
  .dungeon-stage.is-dice-rail-collapsed,
  html.lang-en .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ja .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ko .dungeon-stage.is-dice-rail-collapsed {
    grid-template-columns: 64px minmax(0, 1fr) 40px;
  }
}

/* Compact vertical chrome for short landscape phones; leave taller desktops alone.
   No-overlap flex: topbar + reserved mid-stage actions + compact HUD.
   Scene flexes into leftover height. Action buttons / gauges stay above the HUD.
   100dvh so hiding the mobile toolbar actually lengthens the stage. */
@media (orientation: landscape) and (min-width: 560px) and (max-height: 560px) {
  .app-shell,
  .screen-stack,
  .game-screen {
    min-height: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .topbar,
  .run-summary,
  .soul-core-chip { height: 40px; }
  .screen { padding-top: 40px; min-height: 0; }
  .topbar { padding: 0 14px; }
  .brand-button small { display: none; }
  .brand-button strong { font-size: calc(13px * var(--fs, 1)); }
  .summary-item { min-width: 64px; padding: 0 8px; }
  .summary-item.fog-summary { min-width: 84px; }
  .summary-item small { display: none; }
  .top-fog-track { width: 56px; margin-top: 3px; }
  .top-actions { margin-left: 8px; gap: 5px; }
  .icon-button { min-width: 44px; padding: 6px 10px; }
  .return-title-button { min-width: 84px; padding-inline: 8px; font-size: calc(11px * var(--fs, 1)); }

  /* Title */
  .title-content h1 { font-size: calc(clamp(36px, 12vh, 72px) * var(--fs, 1)); }
  .title-subtitle { margin: 10px 0 14px; font-size: calc(14px * var(--fs, 1)); line-height: 1.45; }
  .title-menu { gap: 6px; width: min(390px, 100%); }
  .primary-button,
  .secondary-button { min-height: 44px; padding: 8px 16px; }
  .primary-button span,
  .secondary-button span { font-size: calc(16px * var(--fs, 1)); }
  .version-stamp { right: 16px; bottom: 10px; }

  /* Character select / load-save */
  .slot-screen,
  .character-screen { padding: 56px 20px 14px; }
  .panel-heading h2 { font-size: calc(24px * var(--fs, 1)); }
  .panel-intro { margin: 8px 0 12px; }
  .save-card { min-height: 0; padding: 12px; }
  .save-card h3 { margin: 10px 0 6px; font-size: calc(18px * var(--fs, 1)); }
  .save-stats { margin: 10px 0; }
  .character-select-grid { min-height: 0; gap: 10px; }
  .character-card { min-height: 0; }

  /* Column: stage (flex leftover) then compact HUD. Buttons live in the stage, not under the HUD.
     Do not set display:flex here — that would un-hide an inactive game screen. */
  .game-screen.is-active {
    flex-direction: column;
    overflow: hidden;
  }
  .dungeon-stage {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }
  .route-rail { padding-top: 10px; }
  .floor-emblem { width: 42px; height: 50px; }

  .scene-area {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 6px clamp(12px, 2vw, 28px) 6px;
  }
  .dungeon-stage:not([data-room="altar"]) .scene-area {
    display: flex;
    flex-direction: column;
  }
  .scene-header { flex: 0 0 auto; }
  .scene-header h2 { font-size: calc(20px * var(--fs, 1)); }

  /* Scene art shrinks; mid-stage actions stay in a reserved row above the HUD. */
  .dungeon-stage:not([data-room="altar"]) .scene-object {
    flex: 1 1 0;
    min-height: 0;
    padding: 4px 0 6px;
    overflow: hidden;
  }
  .dungeon-stage:not([data-room="altar"]) .choice-layer,
  .dungeon-stage:not([data-room="altar"]) .combat-layer {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    position: relative;
    z-index: 18;
  }
  /* Many exploration choices: scroll the list inside the stage, never under the HUD. */
  .dungeon-stage:not([data-room="altar"]) .choice-layer:has(.choice-card:nth-child(5)) {
    max-height: min(38%, 150px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .choice-card { min-height: 44px; padding: 7px 10px; gap: 8px; }

  .combat-layer {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(48%, 200px);
    overflow: hidden;
  }
  .combat-actions { flex: 0 0 auto; overflow: visible; }
  .combat-skill-bar {
    flex: 0 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .combat-button { min-height: 44px; padding: 6px; }
  .combat-flyout { max-height: min(36vh, 180px); z-index: 24; }

  /* 射精条 + offering / breeding / rust-casket controls stay in the stage, above the HUD. */
  .object-card { max-height: 100%; padding: 10px 12px; }
  .object-card:has(.jerk-gauge) {
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .object-card:has(.jerk-gauge) .jerk-gauge { flex: 0 0 auto; margin-top: 8px; }

  .combat-actions.essence-offering-actions,
  .combat-actions:has(.essence-offering-panel) {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .essence-offering-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .essence-offering-buttons { flex: 0 0 auto; }
  .essence-offering-buttons .combat-button { min-height: 44px; padding: 8px 12px; }

  .jerk-gauge { z-index: 18; }
  .breeding-control {
    bottom: 6px;
    width: min(600px, 92%);
    z-index: 18;
  }
  .breeding-btn { min-height: 40px; }

  .dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) .choice-layer.rust-casket-actions {
    margin-bottom: 0;
    transform: none;
    max-height: min(42%, 140px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 18;
  }
  .rust-casket-gauges { z-index: 18; flex-shrink: 0; }
  .void-psy { max-height: 62%; z-index: 18; }

  /* Shorter HUD so the stage + action row actually get height. Do not let the HUD paint over the stage. */
  .hud-panel {
    --hud-scale: 0.34;
    flex: 0 0 calc(350px * var(--hud-scale));
    height: calc(350px * var(--hud-scale));
    min-height: calc(350px * var(--hud-scale));
    flex-basis: calc(350px * var(--hud-scale));
    overflow: hidden;
    z-index: 15;
  }

  .dice-history-heading { padding: 8px 10px 6px; }
  .dice-readout {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
  }

  .modal-backdrop { padding: 10px; }
  .modal {
    padding: 16px 18px;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .modal h2 { margin: 0 0 10px; font-size: calc(22px * var(--fs, 1)); }
  .modal-actions { margin-top: 12px; }
  .platinum-intro-modal .platinum-intro-story,
  .nidhogg-intro-modal .platinum-intro-story,
  .nidhogg-intro-modal .nidhogg-intro-story {
    max-height: min(42vh, 42dvh, 280px);
  }

  .story-overlay {
    padding: 20px clamp(16px, 4vw, 48px) 12px;
    height: 100vh;
    height: 100dvh;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .story-overlay .story-body,
  .story-overlay .story-page {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .archive-screen { padding: 52px 16px 16px; }
  .archive-screen.is-active {
    height: 100vh;
    height: 100dvh;
    max-height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Altar: keep the grid; actions stay in the stage column, not under the HUD. */
  .altar-talk {
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .dungeon-stage[data-room="altar"] .scene-area {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .dungeon-stage[data-room="altar"] .altar-object-stack {
    max-height: min(88%, 100%);
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    z-index: 18;
  }
  .dungeon-stage[data-room="altar"] .altar-object-stack .object-card {
    max-height: min(46%, 140px);
  }
  .dungeon-stage[data-room="altar"] .choice-layer,
  .dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks {
    min-height: 0;
    max-height: min(48%, 160px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    z-index: 18;
  }

  .soul-shop-grid {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* Even shorter phone landscape (~375–430px), including after the toolbar hides. */
@media (orientation: landscape) and (min-width: 560px) and (max-height: 430px) {
  .topbar,
  .run-summary,
  .soul-core-chip { height: 36px; }
  .screen { padding-top: 36px; }
  .hud-panel { --hud-scale: 0.30; }
  .dungeon-stage:not([data-room="altar"]) .choice-layer:has(.choice-card:nth-child(5)),
  .dungeon-stage[data-room="altar"] .choice-layer,
  .dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks {
    max-height: min(36%, 128px);
  }
  .combat-layer { max-height: min(46%, 176px); }
  .title-content h1 { font-size: calc(clamp(32px, 11vh, 56px) * var(--fs, 1)); }
  .slot-screen,
  .character-screen { padding: 48px 16px 10px; }
  .archive-screen { padding: 48px 14px 12px; }
}


/* =============================================================================
   itch-mobile t409: mid-frame is a strict box; mid controls stay inside it.
   Phone play uses a 1280x720 design frame uniformly scaled into the viewport
   (see itch-mobile-layout.js). Desktop/laptop stays 1:1 (no rotate, no scale).
   ============================================================================= */

.hud-panel { z-index: 15; }
.jerk-gauge,
.essence-offering-panel,
.breeding-control,
.rust-casket-gauges,
.void-psy,
.altar-object-stack { z-index: 12; }
.combat-flyout { z-index: 20; }

.dungeon-stage:not([data-room="altar"]) .choice-layer,
.dungeon-stage:not([data-room="altar"]) .combat-layer {
  flex: 0 1 auto;
  position: relative;
  z-index: 12;
}
.combat-actions { flex: 0 0 auto; }
.combat-skill-bar {
  flex: 0 1 auto;
  min-height: 0;
  overflow: visible;
}
.combat-actions.essence-offering-actions,
.combat-actions:has(.essence-offering-panel) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.essence-offering-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.essence-offering-buttons { flex: 0 0 auto; }
.object-card:has(.jerk-gauge) {
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.object-card:has(.jerk-gauge) .jerk-gauge { flex: 0 0 auto; }
.breeding-control { max-width: 100%; }

.dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) .choice-layer.rust-casket-actions {
  margin-bottom: 0;
  transform: none;
  max-height: min(42%, 200px);
  overflow-x: hidden;
  overflow-y: auto;
}

.dungeon-stage[data-room="altar"] .scene-area {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.dungeon-stage[data-room="altar"] .choice-layer,
.dungeon-stage[data-room="altar"] .choice-layer.altar-curse-picks,
.dungeon-stage[data-room="altar"] .combat-layer,
.dungeon-stage[data-room="altar"] .altar-object-stack {
  max-height: min(48%, 280px);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Phone design-frame wrappers: inert on desktop (no scale, no rotation).
   Must still pass the viewport height through to .app-shell. After the
   scroll fix, html/body and screens use height: 100% / var(--app-vh)
   instead of min-height: 100vh. height: auto on these wrappers made
   that 100% chain resolve to content height, leaving a large empty
   gap under the title and combat HUD.
   width/height/max-height: 100% are for the desktop 1:1 path only.
   html.is-mobile-fit rules below must explicitly override max-height
   (and width/height/position) on the frame and inner: the inner is a
   1280x720 design box that is visually scaled into a smaller frame.
   Leaving max-height: 100% in place caps the inner to the already
   scaled frame, and transform: scale() then shrinks it a second time,
   leaving a large black region under the UI on phone landscape. */
.mobile-fit-root,
.mobile-fit-rotate,
.mobile-fit-frame,
.mobile-fit-inner {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  transform: none;
  position: static;
}

html.is-mobile-fit,
html.is-mobile-fit body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: var(--app-vh, 100dvh);
  max-height: 100dvh;
  max-height: var(--app-vh, 100dvh);
  overflow: hidden;
  background: #07060a;
  overscroll-behavior: none;
  touch-action: pan-y;
}

html.is-mobile-fit .mobile-fit-root {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #07060a;
  z-index: 1;
}

html.is-mobile-fit .mobile-fit-rotate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* t415: no CSS 90deg rotate fallback. Portrait is not forced into a
   landscape frame; is-mobile-fit is only applied in phone landscape. */

html.is-mobile-fit .mobile-fit-frame {
  display: block;
  position: relative;
  width: calc(var(--design-w) * var(--fit-scale));
  height: calc(var(--design-h) * var(--fit-scale));
  max-width: none;
  max-height: none;
  overflow: hidden;
  flex: 0 0 auto;
  background: #07060a;
}

html.is-mobile-fit .mobile-fit-inner {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: var(--design-w);
  height: var(--design-h);
  max-width: none;
  max-height: none;
  transform: scale(var(--fit-scale));
  transform-origin: top left;
  overflow: hidden;
}

/* Inside the 1280x720 frame, force the desktop shell. Viewport media queries
   still see the phone size, so compact/portrait/max-width:900 rules must not
   shrink only the HUD or stack the dungeon. */
html.is-mobile-fit .app-shell,
html.is-mobile-fit .screen-stack,
html.is-mobile-fit .screen,
html.is-mobile-fit .screen.is-active,
html.is-mobile-fit .game-screen {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
html.is-mobile-fit .app-shell { min-height: 0; isolation: isolate; }
html.is-mobile-fit .screen { padding-top: 72px; }
html.is-mobile-fit .topbar,
html.is-mobile-fit .run-summary,
html.is-mobile-fit .soul-core-chip { height: 72px; }
html.is-mobile-fit .topbar { padding: 0 34px; }

html.is-mobile-fit .dungeon-stage,
html.is-mobile-fit html.lang-en .dungeon-stage,
html.is-mobile-fit.lang-en .dungeon-stage,
html.is-mobile-fit.lang-ja .dungeon-stage,
html.is-mobile-fit.lang-ko .dungeon-stage {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: none;
  grid-template-columns: 92px minmax(0, 1fr) 310px;
}
html.is-mobile-fit.lang-en .dungeon-stage,
html.is-mobile-fit.lang-ja .dungeon-stage,
html.is-mobile-fit.lang-ko .dungeon-stage {
  grid-template-columns: 92px minmax(0, 1fr) minmax(20rem, 26rem);
}

html.is-mobile-fit .route-rail,
html.is-mobile-fit .scene-area,
html.is-mobile-fit .dice-history-rail {
  grid-column: auto;
  grid-row: auto;
}
html.is-mobile-fit .dice-history-rail {
  border-left: 1px solid rgba(218, 198, 157, .14);
  border-top: 0;
  min-width: 0;
}
html.is-mobile-fit .scene-area { padding: 24px clamp(26px, 4vw, 66px) 22px; }
html.is-mobile-fit .scene-object { min-height: 0; }
html.is-mobile-fit .choice-layer { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: min(42%, 320px); }
html.is-mobile-fit .combat-actions { grid-template-columns: repeat(4, 1fr); }
html.is-mobile-fit .combat-skill-bar { grid-template-columns: repeat(6, 1fr); }
html.is-mobile-fit .combat-button { min-height: 64px; }
html.is-mobile-fit .choice-card { min-height: 78px; }

html.is-mobile-fit .hud-panel {
  --hud-scale: 0.84;
  flex: 0 0 calc(350px * var(--hud-scale));
  height: calc(350px * var(--hud-scale));
  min-height: calc(350px * var(--hud-scale));
  flex-basis: calc(350px * var(--hud-scale));
  overflow: hidden;
  z-index: 15;
}
html.is-mobile-fit .hud-panel-inner {
  height: 350px;
  grid-template-columns: 270px 202px minmax(0, 1fr) 170px 170px;
  grid-template-rows: minmax(0, 1fr);
}

html.is-mobile-fit .story-overlay,
html.is-mobile-fit .scene-fade-overlay,
html.is-mobile-fit .modal-backdrop {
  position: absolute;
  inset: 0;
  height: 100%;
  max-height: 100%;
  width: 100%;
}
html.is-mobile-fit .story-overlay { padding: 56px clamp(24px, 8vw, 140px) 28px; }
html.is-mobile-fit .toast { position: absolute; }

/* D20 collapse stays available inside the landscape design frame
   (is-mobile-fit is on only when the phone is actually in landscape). */
html.is-mobile-fit .dice-history-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 8px;
}
html.is-mobile-fit .dice-history-heading span,
html.is-mobile-fit .dice-history-heading small { display: block; flex: 1 1 100%; }
html.is-mobile-fit .dice-rail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 32px;
  padding: 5px 8px;
  color: #cbbfb0;
  border: 1px solid rgba(220, 198, 160, 0.2);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  letter-spacing: 0.12em;
  font-size: calc(11px * var(--fs, 1));
}
html.is-mobile-fit .dice-rail-toggle-expand { display: none; }
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-toggle-collapse { display: none; }
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-toggle-expand { display: inline; }
html.is-mobile-fit .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit.lang-en .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit.lang-ja .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit.lang-ko .dungeon-stage.is-dice-rail-collapsed {
  grid-template-columns: 92px minmax(0, 1fr) 44px;
}
html.is-mobile-fit .dice-history-rail.is-collapsed { min-width: 0; overflow: hidden; }
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-readout { display: none; }
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-history-heading {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  padding: 10px 4px;
  border-bottom: 0;
  gap: 10px;
}
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-history-heading span {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.16em;
  flex: 0 0 auto;
  font-size: calc(11px * var(--fs, 1));
}
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-history-heading small { display: none; }
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-toggle {
  margin: 0;
  min-width: 0;
  width: 100%;
  writing-mode: horizontal-tb;
  padding: 8px 2px;
  font-size: calc(10px * var(--fs, 1));
}


/* =============================================================================
   itch-mobile t410: unclip combat skill flyouts; dossier header + skill tree.
   Mid-frame overflow:hidden stays on .dungeon-stage / .scene-area so flyouts
   cannot cover the top bar or HUD. Do not use vh for modal size inside the
   1280x720 scaled frame (vh is the device viewport, not the frame).
   ============================================================================= */

/* Flyouts open upward from .combat-menu-slot; any overflow:hidden between the
   slot and the mid frame was clipping them to zero. */
.combat-layer,
.dungeon-stage:not([data-room="altar"]) .combat-layer,
.dungeon-stage[data-room="altar"] .combat-layer,
.combat-actions,
.combat-skill-bar,
.combat-menu-slot {
  overflow: visible;
}
.combat-flyout {
  z-index: 20;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
}
.scene-area:has(.combat-flyout) {
  z-index: 16;
}

/* Dossier: header, tabs, and 关闭 stay in view; only the tab body scrolls. */
.modal.character-sheet-modal > .eyebrow,
.modal.character-sheet-modal > h2,
.modal.character-sheet-modal > .modal-close,
.modal.character-sheet-modal .character-sheet-head,
.modal.character-sheet-modal .sheet-tabs,
.modal.character-sheet-modal > .modal-actions {
  flex: 0 0 auto;
}
.modal.character-sheet-modal > #modalContent {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.character-sheet-modal .sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal.character-sheet-modal.is-skill-tree {
  height: min(92vh, calc(100vh - 48px));
  height: min(92dvh, calc(100dvh - 48px));
  max-height: min(92vh, calc(100vh - 48px));
  max-height: min(92dvh, calc(100dvh - 48px));
}
.modal.character-sheet-modal.is-skill-tree .sheet-body,
.sheet-body.is-skill-tree {
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.platinum-skill-tree-tab,
.platinum-skill-tree-stage {
  min-height: 0;
  width: 100%;
  height: 100%;
}

/* Inside the design frame, size modals against the 720px inner box, not 100vh. */
html.is-mobile-fit .modal-backdrop {
  padding: 16px;
  overflow: hidden;
  box-sizing: border-box;
  align-items: center;
  justify-items: center;
}
html.is-mobile-fit .modal,
html.is-mobile-fit .modal.character-sheet-modal,
html.is-mobile-fit .modal.character-sheet-modal.is-skill-tree {
  width: min(1080px, 100%);
  max-width: 100%;
  min-height: 0;
  max-height: 100%;
  height: auto;
}
html.is-mobile-fit .modal.character-sheet-modal.is-skill-tree {
  height: 100%;
}
html.is-mobile-fit .combat-layer,
html.is-mobile-fit .combat-actions,
html.is-mobile-fit .combat-skill-bar,
html.is-mobile-fit .combat-menu-slot {
  overflow: visible;
}
html.is-mobile-fit .combat-flyout {
  width: max(100%, min(260px, 28vw));
  max-height: 240px;
}

/* =============================================================================
   itch-mobile t412: unsquashed platinum/hybrid skill tree with a scrolling
   viewport. t410 used width:100% + max-height:100% + aspect-ratio:16/9, which
   breaks the aspect when the leftover pane is shorter than 16:9 and then
   background-size:100% 100% flattens the art; percent-placed node buttons
   follow the squashed box. Keep the tree at its intrinsic 16:9 (art is
   1280x720), width-fit the pane, let height follow the real aspect, and
   scroll the overflow. Header, tabs, X, and 关闭 stay put.
   ============================================================================= */

.character-sheet-modal.is-skill-tree .sheet-body,
.modal.character-sheet-modal.is-skill-tree .sheet-body,
.sheet-body.is-skill-tree {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  align-items: unset;
  justify-content: unset;
}

@media (max-width: 720px) {
  .character-sheet-modal.is-skill-tree .sheet-body,
  .sheet-body.is-skill-tree {
    overflow-x: auto;
    overflow-y: auto;
    max-height: none;
    min-height: 0;
  }
}

.character-sheet-modal.is-skill-tree .platinum-skill-tree-tab,
.character-sheet-modal.is-skill-tree .platinum-skill-tree-stage,
.sheet-body.is-skill-tree .platinum-skill-tree-tab,
.sheet-body.is-skill-tree .platinum-skill-tree-stage {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  min-height: 0;
  /* Grow with the unsquashed tree so .sheet-body can scroll it.
     Do not use height:100% here — that traps overflow and prevents scroll. */
}

.character-sheet-modal.is-skill-tree .platinum-skill-tree-stage,
.sheet-body.is-skill-tree .platinum-skill-tree-stage {
  /* Room for absolutely positioned nodes that hang past the art edges
     (translate(-50%, -50%)), so they stay visible without a horizontal gutter. */
  box-sizing: border-box;
  padding: 28px 72px;
  overflow: visible;
}

.character-sheet-modal.is-skill-tree .platinum-skill-tree,
.sheet-body.is-skill-tree .platinum-skill-tree {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none; /* never compress the 16:9 box into the leftover pane */
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  overflow: visible;
  background-position: center;
  background-repeat: no-repeat;
  /* Art and box are both 16:9; 100% 100% fills without stretch or letterbox. */
  background-size: 100% 100%;
}

html.is-mobile-fit .character-sheet-modal.is-skill-tree .sheet-body,
html.is-mobile-fit .sheet-body.is-skill-tree {
  overflow-x: auto;
  overflow-y: auto;
}

/* =============================================================================
   itch-mobile t413: phone title / load-save / preload use the same 1280x720
   uniform fit as the dungeon (layout JS enables is-mobile-fit on any phone
   screen). Do not clip the top of those UIs; allow the pane to scroll if
   content is still taller than the frame. Hybrid skill tree gets the same
   unsquashed 16:9 + vertical scroll treatment as the t412 platinum tree.
   Desktop/laptop windows stay 1:1 (no force-rotate, no auto-scale).
   ============================================================================= */

/* Preload: never clip the title/progress off the top. Panel is width-fit
   inside the overlay (100%, not 100vw, so it tracks the 1280 frame). */
.asset-preload-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  align-items: center;
  justify-content: safe center;
}
.asset-preload-panel {
  width: min(560px, calc(100% - 48px));
  max-width: 560px;
  margin-block: auto;
  box-sizing: border-box;
}

html.is-mobile-fit .asset-preload-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  z-index: 10000;
  box-sizing: border-box;
}
html.is-mobile-fit .asset-preload-panel h1 {
  font-size: clamp(52px, 6.5%, 84px);
}

/* Title / 读取存档 / 选择记忆刻印 / character / archive: scroll inside the
   720 box. Override 100vh and overflow:hidden so tops stay reachable.
   margin-block auto centers when content is short; when it overflows, the
   auto margins collapse and the pane scrolls from the top (no flex clipping). */
.title-screen {
  overflow-x: hidden;
  overflow-y: auto;
  align-items: flex-start;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.title-screen .title-content {
  margin-top: auto;
  margin-bottom: auto;
}

html.is-mobile-fit .title-screen,
html.is-mobile-fit .title-screen.is-active,
html.is-mobile-fit .slot-screen,
html.is-mobile-fit .slot-screen.is-active,
html.is-mobile-fit .character-screen,
html.is-mobile-fit .character-screen.is-active,
html.is-mobile-fit .archive-screen,
html.is-mobile-fit .archive-screen.is-active {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
html.is-mobile-fit .title-screen,
html.is-mobile-fit .title-screen.is-active {
  align-items: flex-start;
}
html.is-mobile-fit .title-content {
  width: min(620px, 50%);
  margin-left: clamp(48px, 10%, 150px);
  margin-top: auto;
  margin-bottom: auto;
}
html.is-mobile-fit .game-screen,
html.is-mobile-fit .game-screen.is-active {
  overflow: hidden;
}

/* Hybrid skill tree: same unsquashed width-fit 16:9 + body scroll as platinum.
   Markup already uses .platinum-skill-tree.hybrid-skill-tree; restate the
   rules on the hybrid classes so a later theme rule cannot re-squash it. */
.character-sheet-modal.is-skill-tree .hybrid-skill-tree-tab,
.sheet-body.is-skill-tree .hybrid-skill-tree-tab,
.character-sheet-modal.is-skill-tree .hybrid-skill-tree-tab .platinum-skill-tree-stage,
.sheet-body.is-skill-tree .hybrid-skill-tree-tab .platinum-skill-tree-stage {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  min-height: 0;
}
.character-sheet-modal.is-skill-tree .hybrid-skill-tree,
.sheet-body.is-skill-tree .hybrid-skill-tree,
.platinum-skill-tree.hybrid-skill-tree {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  overflow: visible;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}


/* =============================================================================
   itch-mobile t416: in every display mode, all mid-stage controls stay strictly
   inside the mid frame and remain fully visible (or scroll inside it). Safe-room
   buttons, 射精条, and 挣扎条 scale with the mid frame. Command buttons such as
   服从命令 stay clickable: no HUD overlap, no overflow clipping to zero, no
   stray translateY / pointer-events traps.
   ============================================================================= */

.dungeon-stage {
  overflow: hidden;
}
.dungeon-stage .scene-area {
  position: relative;
  isolation: isolate;
  min-height: 0;
  overflow: hidden;
  --mid-frame-scale: 1;
}

/* Mid-stage interactive rows live in the remaining column under the art, never
   under the top bar or the bottom HUD. */
.dungeon-stage .choice-layer,
.dungeon-stage .combat-layer,
.dungeon-stage .combat-actions,
.dungeon-stage .altar-object-stack,
.dungeon-stage .essence-offering-buttons {
  position: relative;
  z-index: 22;
  max-width: 100%;
  box-sizing: border-box;
  pointer-events: auto;
  transform: none;
}

.dungeon-stage:not([data-room="altar"]) .choice-layer,
.dungeon-stage:not([data-room="altar"]) .combat-layer {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(46%, 280px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* A visible command / status action (抵抗命令 / 服从命令 / 挣脱) must not be
   clipped to an unclickable sliver. Keep the action row in view. */
.dungeon-stage .combat-actions {
  flex: 0 0 auto;
  overflow: visible;
  pointer-events: auto;
  z-index: 23;
}
.dungeon-stage .combat-actions .combat-button {
  position: relative;
  z-index: 23;
  pointer-events: auto;
  flex-shrink: 0;
}

/* Skill flyouts may open upward, but they stay inside the mid frame, not the HUD. */
.dungeon-stage .combat-skill-bar {
  position: relative;
  z-index: 23;
  overflow: visible;
}
.dungeon-stage .combat-flyout {
  z-index: 24;
  max-height: min(240px, 42%);
  overflow-x: hidden;
  overflow-y: auto;
}

.dungeon-stage .scene-object {
  min-height: 0;
  overflow: hidden;
}

/* HUD must not intercept mid-frame clicks if a control ever paints near the seam. */
.hud-panel {
  overflow: hidden;
}

/* 射精条 / 挣扎条 / 育种控制: scale with the mid frame, stay in-flow or
   bottom-anchored inside .scene-area. */
.dungeon-stage .jerk-gauge,
.dungeon-stage .rust-casket-gauges,
.dungeon-stage .rust-casket-gauge,
.dungeon-stage .essence-offering-panel .jerk-gauge {
  max-width: 100%;
  box-sizing: border-box;
  transform-origin: left bottom;
  zoom: var(--mid-frame-scale, 1);
}
@supports not (zoom: 1) {
  .dungeon-stage .jerk-gauge,
  .dungeon-stage .rust-casket-gauges,
  .dungeon-stage .rust-casket-gauge,
  .dungeon-stage .essence-offering-panel .jerk-gauge {
    transform: scale(var(--mid-frame-scale, 1));
  }
}

.dungeon-stage .breeding-control {
  left: 50%;
  bottom: 8px;
  width: min(600px, calc(96% / var(--mid-frame-scale, 1)));
  max-width: 100%;
  transform: translateX(-50%) scale(var(--mid-frame-scale, 1));
  transform-origin: bottom center;
  z-index: 22;
  pointer-events: auto;
  box-sizing: border-box;
}

/* Rust-casket: drop the negative translateY that lifted struggle buttons
   out of the mid frame (and off the hit target). Gauges sit above the
   action row in normal flow. */
.dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) {
  overflow: hidden;
}
.dungeon-stage[data-room="rustCasket"] .scene-area:has(.rust-casket-gauges:not([hidden])) .choice-layer.rust-casket-actions,
.dungeon-stage[data-room="rustCasket"] .choice-layer.rust-casket-actions {
  margin-bottom: 0 !important;
  transform: none !important;
  max-height: min(42%, 200px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 23;
  pointer-events: auto;
}
.dungeon-stage[data-room="rustCasket"] .rust-casket-gauges {
  position: relative;
  z-index: 22;
  flex-shrink: 0;
  max-width: 100%;
  pointer-events: none;
}

/* Safe-room / exploration choices stay inside the mid frame in every mode,
   including the desktop 1:1 path and phone portrait (is-mobile-fit off). */
.dungeon-stage[data-room="safe"] .choice-layer,
.dungeon-stage[data-room="event"] .choice-layer,
.dungeon-stage[data-room="threshold"] .choice-layer,
.dungeon-stage[data-room="mistSpring"] .choice-layer,
.dungeon-stage[data-room="darkReedPassage"] .choice-layer {
  max-width: 100%;
  z-index: 22;
  pointer-events: auto;
}

/* Landscape 1280x720 fit: the whole inner shell already scales. Keep mid-frame
   overflow rules, but let --mid-frame-scale stay 1 so bars are not double-scaled. */
html.is-mobile-fit .dungeon-stage .scene-area {
  --mid-frame-scale: 1;
}
html.is-mobile-fit .dungeon-stage .choice-layer,
html.is-mobile-fit .dungeon-stage .combat-layer {
  max-height: min(46%, 280px);
}
/* Flyouts may be visible inside the scaled mid frame, not outside it. */
html.is-mobile-fit .dungeon-stage .combat-layer,
html.is-mobile-fit .dungeon-stage .combat-actions,
html.is-mobile-fit .dungeon-stage .combat-skill-bar,
html.is-mobile-fit .dungeon-stage .combat-menu-slot {
  overflow: visible;
}
html.is-mobile-fit .dungeon-stage .combat-layer {
  overflow-x: hidden;
  overflow-y: auto;
}

/* =============================================================================
   itch-mobile t417 + t418 (do not ship one without the other)

   t417: After collapse, the D20 expand button + hint were blank in EN/JA/KO.
   Catalogs and t() already had 展开/收起 and the title keys. The empty box
   came from CSS:
     - html.lang-en/ja/ko .dice-history-rail { min-width: 20rem } (and the
       max-width:900px 18rem EN rule) can outlive or visually fight the
       collapsed 44px/40px grid column. The rail stays ~20rem wide, overflow
       clips it to a gold strip, and centered vertical text sits outside the
       visible window. ZH has no 20rem min-width, so 展开 still showed.
     - .dice-history-heading span { writing-mode: vertical-rl } also applied
       to toggle labels, while the button itself was writing-mode:horizontal-tb
       with short padding, so longer EN/KO strings could clip even when the
       column width was correct.
   Fix: force collapsed rail min-width:0 for every language, slightly widen
   the collapsed column, scope title typography to .dice-rail-title, and give
   the collapsed toggle vertical writing-mode with enough height so Expand /
   展開 / 펼치기 stay readable. Title/aria still come from t().

   t418: Tapping 攻击技能 / 状态技能 did not show skill pickers. t410 set
   overflow:visible on .combat-layer / .combat-skill-bar so the upward
   .combat-flyout (position:absolute; bottom: calc(100% + 6px)) could paint.
   t416 mid-frame tightening then set .combat-layer { overflow-x:hidden;
   overflow-y:auto } (and the same again under is-mobile-fit), which re-clips
   the flyout to nothing. overflow-x:hidden also forces overflow-y to compute
   as auto. t416's max-height: min(240px, 42%) on the flyout is also relative
   to the positioned slot (~button height), so 42% is a sliver.
   Fix: restore overflow:visible on the flyout ancestors, keep .scene-area
   overflow:hidden so the picker stays inside the mid frame (not over the
   top bar or HUD), and cap flyout height in px, not a % of the slot.
   ============================================================================= */

/* --- t417: collapsed D20 rail text --- */
.dice-history-rail.is-collapsed,
html.lang-en .dice-history-rail.is-collapsed,
html.lang-ja .dice-history-rail.is-collapsed,
html.lang-ko .dice-history-rail.is-collapsed,
html.is-mobile-fit .dice-history-rail.is-collapsed,
html.is-mobile-fit.lang-en .dice-history-rail.is-collapsed,
html.is-mobile-fit.lang-ja .dice-history-rail.is-collapsed,
html.is-mobile-fit.lang-ko .dice-history-rail.is-collapsed {
  min-width: 0;
  width: auto;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  justify-content: flex-start;
  align-items: stretch;
}

.dice-history-rail.is-collapsed .dice-history-heading {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 8px 2px 10px;
  box-sizing: border-box;
}

/* Title typography only — do not restyle the toggle labels. */
.dice-history-rail.is-collapsed .dice-rail-title,
html.lang-en .dice-history-rail.is-collapsed .dice-rail-title,
html.lang-ja .dice-history-rail.is-collapsed .dice-rail-title,
html.lang-ko .dice-history-rail.is-collapsed .dice-rail-title,
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-title {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.08em;
  font-size: 11px;
  line-height: 1.15;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  width: auto;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

html.lang-en .dice-history-rail.is-collapsed .dice-rail-title,
html.is-mobile-fit.lang-en .dice-history-rail.is-collapsed .dice-rail-title {
  letter-spacing: 0.02em;
  font-size: 10px;
}

.dice-history-rail.is-collapsed .dice-rail-toggle,
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  flex-direction: row;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 5.2em;
  padding: 10px 3px;
  margin-top: auto;
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.15;
  overflow: visible;
  white-space: nowrap;
  box-sizing: border-box;
}

html.lang-en .dice-history-rail.is-collapsed .dice-rail-toggle,
html.is-mobile-fit.lang-en .dice-history-rail.is-collapsed .dice-rail-toggle {
  letter-spacing: 0.02em;
  font-size: 10px;
  min-height: 6em;
}

.dice-history-rail.is-collapsed .dice-rail-toggle-label,
.dice-history-rail.is-collapsed .dice-rail-toggle-expand,
.dice-history-rail.is-collapsed .dice-rail-toggle-collapse,
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-toggle-expand {
  writing-mode: inherit;
  text-orientation: inherit;
  letter-spacing: inherit;
  font-size: inherit;
  line-height: inherit;
  overflow: visible;
  white-space: nowrap;
  width: auto;
  height: auto;
  flex: 0 0 auto;
}

.dice-history-rail.is-collapsed .dice-rail-toggle-collapse {
  display: none;
}
.dice-history-rail.is-collapsed .dice-rail-toggle-expand,
html.is-mobile-fit .dice-history-rail.is-collapsed .dice-rail-toggle-expand {
  display: inline-block;
}

.dungeon-stage.is-dice-rail-collapsed,
html.lang-en .dungeon-stage.is-dice-rail-collapsed,
html.lang-ja .dungeon-stage.is-dice-rail-collapsed,
html.lang-ko .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit.lang-en .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit.lang-ja .dungeon-stage.is-dice-rail-collapsed,
html.is-mobile-fit.lang-ko .dungeon-stage.is-dice-rail-collapsed {
  grid-template-columns: 92px minmax(0, 1fr) 56px;
}

@media (orientation: landscape) and (min-width: 560px) {
  .dice-history-rail.is-collapsed,
  html.lang-en .dice-history-rail.is-collapsed,
  html.lang-ja .dice-history-rail.is-collapsed,
  html.lang-ko .dice-history-rail.is-collapsed {
    min-width: 0;
    overflow: hidden;
  }
  .dungeon-stage.is-dice-rail-collapsed,
  html.lang-en .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ja .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ko .dungeon-stage.is-dice-rail-collapsed {
    grid-template-columns: 92px minmax(0, 1fr) 56px;
  }
}

@media (orientation: landscape) and (min-width: 560px) and (max-width: 900px) {
  .dice-history-rail.is-collapsed,
  html.lang-en .dice-history-rail.is-collapsed,
  html.lang-ja .dice-history-rail.is-collapsed,
  html.lang-ko .dice-history-rail.is-collapsed {
    min-width: 0;
    overflow: hidden;
  }
  .dungeon-stage.is-dice-rail-collapsed,
  html.lang-en .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ja .dungeon-stage.is-dice-rail-collapsed,
  html.lang-ko .dungeon-stage.is-dice-rail-collapsed {
    grid-template-columns: 64px minmax(0, 1fr) 52px;
  }
}

/* --- t418: unclip combat skill flyouts; keep them inside the mid frame --- */
.dungeon-stage .combat-layer,
.dungeon-stage:not([data-room="altar"]) .combat-layer,
.dungeon-stage[data-room="altar"] .combat-layer,
.dungeon-stage .combat-actions,
.dungeon-stage .combat-skill-bar,
.dungeon-stage .combat-menu-slot,
html.is-mobile-fit .dungeon-stage .combat-layer,
html.is-mobile-fit .dungeon-stage:not([data-room="altar"]) .combat-layer,
html.is-mobile-fit .dungeon-stage .combat-actions,
html.is-mobile-fit .dungeon-stage .combat-skill-bar,
html.is-mobile-fit .dungeon-stage .combat-menu-slot {
  overflow: visible;
}

.dungeon-stage .combat-flyout,
html.is-mobile-fit .dungeon-stage .combat-flyout {
  z-index: 30;
  max-height: 240px;
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: auto;
}

/* Mid-frame clip stays so the flyout cannot cover the top bar or bottom HUD.
   Do not put overflow-x:auto/hidden on .combat-layer; that forces overflow-y
   to auto and clips the upward flyout to nothing. */
.dungeon-stage .scene-area,
html.is-mobile-fit .dungeon-stage .scene-area {
  overflow: hidden;
}

/* t450u: no visible button scrollbars; overflowing inner text is press-and-drag / swipe only.
   The surface inherits the button's grid/flex and spans every track so door cards keep their
   original columns (a column-flex wrapper was squeezing labels into the first 42px track). */
button.btn-text-scroll {
  overflow: hidden;
  box-sizing: border-box;
}
button.btn-text-scroll > .btn-scroll-surface {
  display: inherit;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  grid-template-columns: inherit;
  grid-template-rows: inherit;
  grid-template-areas: inherit;
  grid-auto-columns: inherit;
  grid-auto-rows: inherit;
  grid-auto-flow: inherit;
  gap: inherit;
  column-gap: inherit;
  row-gap: inherit;
  align-items: inherit;
  align-content: inherit;
  justify-items: inherit;
  justify-content: inherit;
  flex-direction: inherit;
  flex-wrap: inherit;
  place-items: inherit;
  place-content: inherit;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  flex: 1 1 auto;
  overflow: hidden;
  overscroll-behavior: contain;
  text-align: inherit;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
button.btn-text-scroll::-webkit-scrollbar,
button.btn-text-scroll > .btn-scroll-surface::-webkit-scrollbar,
button.btn-text-scroll.has-overflow > .btn-scroll-surface::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent;
}
button.btn-text-scroll.has-overflow > .btn-scroll-surface {
  overflow-x: hidden;
  overflow-y: hidden;
  touch-action: none;
}

/* =============================================================================
   itch iframe / overflowing UI panes:
   Official itch HTML5 embeds (itch.io / itch.zone iframes) often disable
   document scrolling on the iframe. 100vh can also be larger than the iframe,
   so a min-height:100vh screen grows past the visible area and never becomes
   an inner scroller. Bind the shell to the iframe/window box (--app-vh from
   JS uses visualViewport / innerHeight) and keep full-page panes scrolling
   inside the game with touch + wheel + page keys.
   ============================================================================= */
.screen.is-active:focus,
.story-page:focus,
.modal:focus {
  outline: none;
}

.title-screen.is-active,
.slot-screen.is-active,
.character-screen.is-active,
.archive-screen.is-active,
.asset-preload-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.game-screen.is-active {
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.story-overlay .story-page,
.story-overlay .story-body,
.modal,
.modal .sheet-body,
.platinum-intro-modal .platinum-intro-story,
.nidhogg-intro-modal .platinum-intro-story,
.nidhogg-intro-modal .nidhogg-intro-story,
.gallery-preview-body,
.in-game-load-modal .in-game-load-slot-list,
.archive-screen,
.archive-pane.is-active {
  touch-action: pan-y;
}

.modal {
  max-height: calc(100% - 48px);
  max-height: calc(var(--app-vh, 100dvh) - 48px);
}
@media (max-height: 700px) {
  .modal {
    max-height: calc(100% - 24px);
    max-height: calc(var(--app-vh, 100dvh) - 24px);
  }
}
.modal.character-sheet-modal.is-skill-tree {
  height: min(92vh, calc(var(--app-vh, 100dvh) - 48px));
  max-height: min(92vh, calc(var(--app-vh, 100dvh) - 48px));
}
.platinum-intro-modal .platinum-intro-story,
.nidhogg-intro-modal .platinum-intro-story,
.nidhogg-intro-modal .nidhogg-intro-story {
  max-height: min(58vh, calc(var(--app-vh, 100dvh) * 0.58), 520px);
}

/* Cards in 文集/画廊 are full tiles, not inner-text scroll buttons. Swipes on
   them must pan the archive page, not be treated as button-text drags. */
.archive-screen .codex-book,
.archive-screen .gallery-card,
.archive-screen .archive-tab {
  touch-action: pan-y;
}

html.is-mobile-fit .title-screen,
html.is-mobile-fit .title-screen.is-active,
html.is-mobile-fit .slot-screen,
html.is-mobile-fit .slot-screen.is-active,
html.is-mobile-fit .character-screen,
html.is-mobile-fit .character-screen.is-active,
html.is-mobile-fit .archive-screen,
html.is-mobile-fit .archive-screen.is-active,
html.is-mobile-fit .asset-preload-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Portrait phone dungeon is taller than the viewport; keep the game screen
   as the scroller (do not fall back to document/body scroll in an iframe). */
@media (max-width: 680px) and (orientation: portrait) {
  .game-screen.is-active {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
}

/* Inactive screens must not remain in document flow. .game-screen { display:flex }
   (same specificity as .screen { display:none }, but later in the file) used to
   keep the dungeon visible under 文集/画廊, so page scroll revealed combat UI. */
.screen:not(.is-active),
.game-screen:not(.is-active),
.title-screen:not(.is-active),
.slot-screen:not(.is-active),
.character-screen:not(.is-active),
.archive-screen:not(.is-active) {
  display: none !important;
}
.screen.game-screen.is-active,
.game-screen.is-active {
  display: flex !important;
  flex-direction: column;
}
