html:has(.bwm-shell),
body:has(.bwm-shell) {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d0a09;
}

body:has(.bwm-shell) > .noise-layer,
body:has(.bwm-shell) > .bg-image-layer,
body:has(.bwm-shell) .support-widget {
  display: none !important;
}

.bwm-shell {
  --bwm-bg: #0d0a09;
  --bwm-panel: rgba(13, 10, 9, 0.94);
  --bwm-panel-soft: rgba(25, 19, 16, 0.84);
  --bwm-text: #eee7db;
  --bwm-muted: #b9ad9e;
  --bwm-brass: #ad8a58;
  --bwm-rule: rgba(213, 194, 165, 0.25);
  --bwm-panel-height: clamp(220px, 31dvh, 256px);
  --bwm-action-row-height: 60px;
  position: relative;
  z-index: 5;
  display: grid;
  width: 100%;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--bwm-text);
  background: var(--bwm-bg);
}

.bwm-header {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  min-height: 48px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 22px max(18px, env(safe-area-inset-left));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(7, 5, 5, 0.92), rgba(7, 5, 5, 0.56) 58%, transparent);
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  letter-spacing: 0.035em;
}

.bwm-location,
.bwm-time {
  max-width: min(48vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bwm-location {
  margin-inline-start: 52px;
}

.bwm-time {
  color: var(--bwm-muted);
  text-align: right;
}

.bwm-shell .bwm-back-overlay {
  position: absolute;
  top: max(2px, env(safe-area-inset-top));
  left: max(2px, env(safe-area-inset-left));
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  pointer-events: auto;
  appearance: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--bwm-muted);
  opacity: 0.84;
  cursor: pointer;
  transition: opacity 160ms ease;
}

.bwm-shell .bwm-back-overlay svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bwm-shell .bwm-back-overlay:hover {
  opacity: 1;
}

.bwm-shell .bwm-back-overlay:active {
  opacity: 0.68;
}

.bwm-shell .bwm-back-overlay:focus-visible {
  outline: 2px solid rgba(226, 211, 188, 0.82);
  outline-offset: -7px;
}

.bwm-stage {
  position: absolute;
  z-index: 0;
  inset: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #171214;
}

.bwm-scene-image,
.bwm-scene-image-backdrop,
.bwm-neutral-visual {
  display: block;
  width: 100%;
  height: 100%;
}

.bwm-scene-image-backdrop {
  display: none;
}

.bwm-scene-image {
  object-fit: cover;
  object-position: center;
}

.bwm-character-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}

.bwm-character-presentation-slot {
  position: absolute;
  inset: 0;
}

.bwm-character-portrait {
  position: absolute;
  right: clamp(1%, 4vw, 6%);
  bottom: max(0px, calc(var(--bwm-panel-height) - 52px));
  display: block;
  width: min(62vw, 820px);
  height: min(76vh, 720px);
  max-width: 78%;
  max-height: calc(100% - 44px);
  object-fit: contain;
  object-position: center bottom;
  opacity: 0;
  filter: saturate(0.88) contrast(1.04);
  transform: translateY(0);
  transition:
    opacity 200ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0,
    rgba(0, 0, 0, 0.92) 16%,
    #000 50%,
    rgba(0, 0, 0, 0.92) 84%,
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0,
    rgba(0, 0, 0, 0.92) 16%,
    #000 50%,
    rgba(0, 0, 0, 0.92) 84%,
    transparent 100%
  );
}

.bwm-character-presentation-slot.is-visible .bwm-character-portrait {
  opacity: 0.96;
}

.bwm-character-presentation-slot.is-first-appearance .bwm-character-portrait {
  transform: translateY(8px);
  transition:
    opacity 220ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bwm-character-presentation-slot.is-first-appearance.is-visible .bwm-character-portrait {
  transform: translateY(0);
}

.bwm-character-nameplate {
  position: absolute;
  z-index: 3;
  right: clamp(24px, 7vw, 126px);
  bottom: calc(var(--bwm-panel-height) + 18px);
  display: grid;
  min-width: 154px;
  max-width: min(280px, 36vw);
  box-sizing: border-box;
  gap: 2px;
  padding: 9px 14px 8px;
  border: 1px solid rgba(197, 162, 109, 0.52);
  border-left: 2px solid var(--bwm-brass);
  background: rgba(13, 10, 9, 0.91);
  color: var(--bwm-text);
  font-family: ui-serif, Georgia, serif;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 160ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(5px);
}

.bwm-character-nameplate strong {
  color: var(--bwm-brass);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
}

.bwm-character-nameplate span {
  color: var(--bwm-muted);
  font-size: 0.72rem;
}

.bwm-character-presentation-slot.is-visible.is-nameplate-visible .bwm-character-nameplate {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 30ms;
}

.bwm-character-presentation-slot.is-immediate .bwm-character-portrait,
.bwm-character-presentation-slot.is-immediate .bwm-character-nameplate {
  transition: none;
}

.bwm-neutral-visual {
  background:
    radial-gradient(circle at 70% 28%, rgba(173, 138, 88, 0.16), transparent 30%),
    linear-gradient(120deg, rgba(84, 56, 45, 0.35), transparent 48%),
    linear-gradient(180deg, #241b1b, #0d0a09);
}

.bwm-tool-rail {
  position: absolute;
  z-index: 25;
  top: auto;
  bottom: calc(var(--bwm-panel-height) + 12px);
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  gap: 8px;
  transform: none;
}

.bwm-shell button {
  min-height: 44px;
  border: 1px solid rgba(197, 162, 109, 0.48);
  border-radius: 7px;
  background: rgba(31, 23, 20, 0.94);
  color: var(--bwm-text);
  font: inherit;
  cursor: pointer;
}

.bwm-tool-rail button {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.bwm-utility-button img {
  position: absolute;
  top: -26%;
  left: -13%;
  display: block;
  width: 126%;
  height: auto;
  max-width: none;
  pointer-events: none;
}

.bwm-utility-button:hover img {
  filter: brightness(1.04);
}

.bwm-utility-button:active {
  transform: scale(0.98);
}

.bwm-shell button:focus-visible {
  outline: 2px solid #dfbd82;
  outline-offset: 2px;
}

.bwm-shell button:disabled {
  cursor: default;
  opacity: 0.5;
}

.bwm-panel {
  position: relative;
  z-index: 15;
  grid-row: 2;
  display: flex;
  width: 100%;
  height: var(--bwm-panel-height);
  min-height: 0;
  box-sizing: border-box;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--bwm-rule);
  background: linear-gradient(180deg, rgba(13, 10, 9, 0.72), var(--bwm-panel) 26%);
  backdrop-filter: blur(5px);
}

.bwm-shell[data-mode="choice"],
.bwm-shell[data-mode="final-start"],
.bwm-shell[data-mode="final-question"] {
  --bwm-panel-height: clamp(228px, 31dvh, 330px);
}

.bwm-context-line {
  position: absolute;
  z-index: 3;
  top: -34px;
  right: clamp(26px, 8vw, 170px);
  max-width: min(44vw, 560px);
  margin: 0;
  padding: 8px 14px;
  overflow: hidden;
  color: var(--bwm-muted);
  background: rgba(13, 10, 9, 0.88);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bwm-panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px clamp(26px, 8vw, 170px) 8px;
}

.bwm-narrative-panel {
  height: var(--bwm-panel-height);
  min-height: var(--bwm-panel-height);
  max-height: var(--bwm-panel-height);
}

.bwm-narrative-panel .bwm-panel-scroll {
  flex: 1 1 auto;
  overflow: visible !important;
  overscroll-behavior: auto;
}

.bwm-panel-meta {
  display: contents;
}

.bwm-copy-wrap,
.bwm-final-feedback {
  width: min(100%, 920px);
  margin: 0 auto;
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.65;
  white-space: pre-line;
}

.bwm-copy-wrap {
  display: grid;
  align-content: start;
}

.bwm-screen-reader-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.bwm-text-speaker-header {
  display: flex;
  width: min(100%, 920px);
  margin: 0 auto 9px;
  align-items: baseline;
  gap: 9px;
  color: #ead9bd;
  line-height: 1.2;
  animation: bwm-text-speaker-fade 140ms ease-out both;
}

.bwm-text-speaker-header strong {
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(0.92rem, 1.5vw, 1.04rem);
  font-weight: 650;
}

.bwm-text-speaker-header span {
  color: var(--bwm-muted);
  font-size: 0.76rem;
}

.bwm-text-speaker-header--npc-fallback {
  color: #dbc5a2;
}

.bwm-text-speaker-header--player {
  display: grid;
  width: max-content;
  min-width: 112px;
  max-width: min(100%, 920px);
  margin: 0 auto 13px max(0px, calc((100% - 920px) / 2));
  padding: 7px 14px 8px 12px;
  box-sizing: border-box;
  align-items: start;
  gap: 3px;
  overflow: hidden;
  border: 1px solid rgba(174, 137, 78, 0.48);
  border-left: 3px solid rgba(202, 163, 96, 0.76);
  border-radius: 2px;
  color: #f0dfc1;
  background: linear-gradient(100deg, rgba(39, 29, 23, 0.97), rgba(20, 16, 14, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 238, 204, 0.035),
    0 4px 12px rgba(0, 0, 0, 0.16);
}

.bwm-text-speaker-header--player strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.025em;
}

.bwm-text-speaker-header--player span {
  color: #bda888;
  font-size: 0.7rem;
  letter-spacing: 0.09em;
}

@keyframes bwm-text-speaker-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bwm-action-row {
  display: flex;
  height: var(--bwm-action-row-height);
  min-height: var(--bwm-action-row-height);
  max-height: var(--bwm-action-row-height);
  flex: 0 0 var(--bwm-action-row-height);
  box-sizing: border-box;
  justify-content: flex-end;
  padding: 6px clamp(26px, 8vw, 170px) max(8px, env(safe-area-inset-bottom));
}

.bwm-action-row button {
  min-width: 150px;
  padding: 8px 24px;
}

.bwm-mobile-navigation {
  display: none;
}

.bwm-choice-panel {
  height: var(--bwm-panel-height);
}

.bwm-choice-panel h2 {
  margin: 0 0 12px;
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.bwm-choice-list {
  display: grid;
  width: min(100%, 1120px);
  margin: 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bwm-choice-list button {
  display: grid;
  min-height: 60px;
  place-content: center;
  gap: 4px;
  padding: 10px 18px;
  text-align: center;
}

.bwm-choice-list small,
.bwm-question-progress {
  color: var(--bwm-muted);
}

.bwm-question-progress {
  margin: 0 0 6px;
}

.bwm-overlay {
  position: absolute;
  z-index: 50;
  inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--bwm-rule);
  background: rgba(13, 10, 9, 0.985);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
}

.bwm-overlay > header {
  display: flex;
  min-height: 56px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--bwm-rule);
}

.bwm-overlay h2 {
  margin: 0;
  font-size: 1.05rem;
}

.bwm-overlay header button {
  min-width: 84px;
}

.bwm-overlay-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  padding: 18px;
}

.bwm-overlay article {
  padding: 12px 0;
  border-bottom: 1px solid var(--bwm-rule);
}

.bwm-overlay article h3,
.bwm-overlay article p {
  margin: 4px 0;
}

.bwm-overlay article small,
.bwm-overlay article p {
  color: var(--bwm-muted);
}

.bwm-notebook-document-link {
  width: 100%;
  min-height: 44px;
  margin: 0 0 12px;
  border: 1px solid var(--bwm-rule);
  border-radius: 2px;
  background: rgba(63, 46, 37, 0.62);
  color: var(--bwm-text);
  font: inherit;
  cursor: pointer;
}

.bwm-notebook-document-link:hover,
.bwm-notebook-document-link:focus-visible {
  border-color: var(--bwm-accent);
  outline: 2px solid rgba(190, 154, 105, 0.34);
  outline-offset: 2px;
}

.bwm-map-host .bem-shell {
  position: relative;
  inset: auto;
  z-index: auto;
  height: 100%;
  min-height: 100%;
}

.bwm-map-host [data-map-close] {
  display: none;
}

.bwm-shell.is-ending {
  display: block;
}

.bwm-ending {
  box-sizing: border-box;
  display: grid;
  width: min(100%, 900px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
  padding: max(28px, env(safe-area-inset-top)) clamp(22px, 7vw, 78px) max(22px, env(safe-area-inset-bottom));
}

.bwm-ending-scroll {
  min-height: 0;
  align-self: center;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: ui-serif, Georgia, serif;
  line-height: 1.65;
  text-align: center;
}

.bwm-ending-scroll h1 {
  font-size: clamp(1.7rem, 5vw, 3.4rem);
}

.bwm-ending-kicker {
  color: var(--bwm-brass);
  letter-spacing: 0.12em;
}

.bwm-ending-actions {
  display: grid;
  min-height: 44px;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 700px) {
  .bwm-shell {
    display: flex;
    height: auto;
    flex-direction: column;
  }

  .bwm-shell.is-ending {
    height: 100svh;
    height: 100dvh;
  }

  .bwm-header {
    position: relative;
    min-height: 44px;
    flex: 0 0 auto;
    padding: max(9px, env(safe-area-inset-top)) 12px 8px;
    background: #0d0a09;
  }

  .bwm-location,
  .bwm-time {
    max-width: 48%;
    font-size: 0.72rem;
  }

  .bwm-stage {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
  }

  .bwm-scene-image {
    object-fit: contain;
  }

  .bwm-character-portrait {
    right: 0;
    bottom: 0;
    width: min(74vw, 430px);
    height: 100%;
    max-width: 82%;
    max-height: 100%;
  }

  .bwm-character-nameplate {
    right: 10px;
    bottom: 10px;
    min-width: 132px;
    max-width: 48%;
    padding: 7px 10px 6px;
  }

  .bwm-tool-rail {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    display: flex;
    min-height: 54px;
    flex: 0 0 auto;
    justify-content: center;
    gap: 8px;
    padding: 5px 10px;
    transform: none;
    background: transparent;
  }

  .bwm-tool-rail button {
    width: 56px;
    height: 56px;
  }

  .bwm-panel {
    position: relative;
    height: clamp(174px, 26dvh, 208px);
    flex: 0 0 auto;
    background: var(--bwm-panel);
  }

  .bwm-narrative-panel {
    height: clamp(174px, 26dvh, 208px);
    min-height: clamp(174px, 26dvh, 208px);
    max-height: clamp(174px, 26dvh, 208px);
  }

  .bwm-context-line {
    position: relative;
    top: auto;
    right: auto;
    max-width: none;
    flex: 0 0 auto;
    padding: 6px 16px;
    border-bottom: 1px solid var(--bwm-rule);
    background: transparent;
  }

  .bwm-panel-scroll {
    padding: 22px 18px 8px;
  }

  .bwm-copy-wrap,
  .bwm-final-feedback {
    font-size: 0.96rem;
    line-height: 1.55;
  }

  .bwm-action-row {
    --bwm-action-row-height: 64px;
    padding: 5px 12px max(6px, env(safe-area-inset-bottom));
  }

  .bwm-action-row button {
    width: 100%;
    min-width: 0;
  }

  .bwm-choice-panel {
    --bwm-panel-height: min(290px, 39dvh);
    height: min(290px, 39dvh);
  }

  .bwm-choice-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bwm-choice-list button {
    min-height: 50px;
  }

  .bwm-overlay {
    position: fixed;
  }
}

@media (max-width: 500px) and (orientation: portrait) {
  html:has(.bwm-shell),
  body:has(.bwm-shell) {
    height: var(--reader-visual-height, 100svh);
    height: var(--reader-visual-height, 100dvh);
    min-height: 0;
    overflow-x: hidden;
    overflow-y: hidden;
  }

  body:has(.bwm-shell) #app {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .bwm-shell {
    --bwm-mobile-header-height: max(56px, calc(48px + env(safe-area-inset-top)));
    --bwm-mobile-utility-height: 64px;
    --bwm-safe-bottom: env(safe-area-inset-bottom);
    --bwm-mobile-action-height: max(64px, calc(54px + var(--bwm-safe-bottom)));
    display: grid;
    height: var(--reader-visual-height, 100svh);
    height: var(--reader-visual-height, 100dvh);
    min-height: 0;
    grid-template-rows:
      var(--bwm-mobile-header-height)
      auto
      var(--bwm-mobile-utility-height)
      minmax(0, 1fr);
    overflow: hidden;
  }

  .bwm-header {
    position: relative;
    z-index: 30;
    display: grid;
    width: 100%;
    height: var(--bwm-mobile-header-height);
    min-height: var(--bwm-mobile-header-height);
    max-height: var(--bwm-mobile-header-height);
    box-sizing: border-box;
    grid-row: 1;
    grid-template-columns: 44px minmax(0, 1fr) minmax(96px, 44%);
    align-items: center;
    gap: 8px;
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
    background: #0d0a09;
  }

  .bwm-shell .bwm-back-overlay {
    position: static;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    pointer-events: auto;
  }

  .bwm-location,
  .bwm-time {
    max-width: none;
    min-width: 0;
    font-size: 0.7rem;
  }

  .bwm-location {
    margin-inline-start: 0;
  }

  .bwm-stage {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
    grid-row: 2;
    overflow: hidden;
    background: #171214;
  }

  .bwm-scene-image-backdrop {
    display: none;
  }

  .bwm-scene-image {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .bwm-character-portrait {
    right: 2px;
    bottom: 0;
    width: min(72vw, 310px);
    height: 100%;
    max-width: 78%;
    max-height: 100%;
  }

  .bwm-neutral-visual {
    position: relative;
    z-index: 1;
  }

  .bwm-tool-rail {
    position: relative;
    z-index: 32;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    height: var(--bwm-mobile-utility-height);
    min-height: var(--bwm-mobile-utility-height);
    max-height: var(--bwm-mobile-utility-height);
    box-sizing: border-box;
    grid-row: 3;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-top: 1px solid rgba(213, 194, 165, 0.12);
    border-bottom: 1px solid var(--bwm-rule);
    background: #120e0d;
  }

  .bwm-tool-rail.is-empty {
    pointer-events: none;
  }

  .bwm-panel,
  .bwm-choice-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    grid-row: 4;
    overflow: hidden;
    background: var(--bwm-panel);
  }

  .bwm-narrative-panel {
    height: 100%;
    min-height: 0;
    max-height: none;
  }

  .bwm-choice-panel,
  .bwm-shell[data-mode="final-start"] .bwm-panel,
  .bwm-shell[data-mode="final-question"] .bwm-panel {
    height: 100%;
    max-height: none;
  }

  .bwm-panel-scroll {
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px 18px 8px;
  }

  .bwm-panel-meta {
    display: grid;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: 0 0 auto;
    align-content: start;
    overflow: hidden;
  }

  .bwm-panel-meta:empty {
    display: none;
  }

  .bwm-panel-meta .bwm-context-line {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    width: auto;
    max-width: none;
    min-height: 0;
    box-sizing: border-box;
    margin: 0;
  }

  .bwm-panel-meta .bwm-context-line {
    padding: 5px 16px;
  }

  .bwm-narrative-panel .bwm-panel-scroll {
    flex: 1 1 auto;
    overflow: visible !important;
  }

  .bwm-action-row {
    --bwm-action-row-height: var(--bwm-mobile-action-height);
    margin-top: 0;
    padding: 5px 12px max(16px, var(--bwm-safe-bottom));
  }

  .bwm-mobile-navigation {
    display: none !important;
  }
}

@media (max-width: 700px) and (orientation: landscape) and (max-height: 420px) {
  .bwm-shell {
    display: grid;
    height: 100svh;
    height: 100dvh;
    grid-template-columns: minmax(0, 48%) minmax(0, 52%);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .bwm-header {
    grid-column: 1 / -1;
  }

  .bwm-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    grid-column: 1;
    grid-row: 2;
  }

  .bwm-scene-image {
    object-fit: contain;
  }

  .bwm-character-portrait {
    right: 0;
    bottom: 0;
    width: 76%;
    height: 100%;
    max-width: 76%;
    max-height: 100%;
  }

  .bwm-character-nameplate {
    right: 6px;
    bottom: 6px;
    min-width: 118px;
    max-width: 54%;
    padding: 5px 8px 4px;
  }

  .bwm-character-nameplate strong {
    font-size: 0.74rem;
  }

  .bwm-character-nameplate span {
    font-size: 0.62rem;
  }

  .bwm-tool-rail {
    position: absolute;
    z-index: 28;
    right: 52%;
    bottom: max(6px, env(safe-area-inset-bottom));
    left: 6px;
    min-height: 44px;
    justify-content: start;
    padding: 0;
    background: transparent;
  }

  .bwm-tool-rail button {
    width: 44px;
    height: 44px;
  }

  .bwm-panel {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    grid-column: 2;
    grid-row: 2;
    border-top: 0;
    border-left: 1px solid var(--bwm-rule);
  }

  .bwm-context-line {
    padding: 3px 10px;
    font-size: 0.68rem;
  }

  .bwm-panel-scroll {
    padding: 12px 12px 4px;
  }

  .bwm-copy-wrap,
  .bwm-final-feedback {
    font-size: 0.82rem;
    line-height: 1.4;
  }

  .bwm-action-row {
    min-height: 48px;
    padding: 2px 8px max(2px, env(safe-area-inset-bottom));
  }

  .bwm-choice-panel {
    height: 100%;
  }

  .bwm-choice-list button {
    min-height: 44px;
    padding: 5px 8px;
    font-size: 0.78rem;
  }

  .bwm-shell.is-ending {
    display: block;
    height: 100svh;
    height: 100dvh;
    max-height: 100dvh;
  }

  .bwm-ending {
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 6px;
    padding: 8px 16px max(8px, env(safe-area-inset-bottom));
  }

  .bwm-ending-scroll {
    min-height: 0;
    overflow-y: auto;
  }

  .bwm-ending-scroll h1 {
    margin: 4px 0;
    font-size: 1.3rem;
  }

  .bwm-ending-scroll p {
    margin: 4px 0;
    font-size: 0.8rem;
  }

  .bwm-ending-actions,
  .bwm-ending-actions button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bwm-visible-copy,
  .bwm-text-speaker-header {
    animation: none;
  }

  .bwm-character-portrait,
  .bwm-character-nameplate,
  .bwm-character-presentation-slot.is-first-appearance .bwm-character-portrait {
    transform: none;
    transition: opacity 80ms linear;
    transition-delay: 0ms;
  }
}
