:root {
  --qsd-safe-top: env(safe-area-inset-top, 0px);
  --qsd-safe-right: env(safe-area-inset-right, 0px);
  --qsd-safe-bottom: env(safe-area-inset-bottom, 0px);
  --qsd-safe-left: env(safe-area-inset-left, 0px);
  --qsd-ui-scale: 1;
}

/* Final cursor layer: hide Chromium's native cursor everywhere and draw our own
   fixed overlay, so buttons/native controls can never swap it to a system hand. */
#qsdMouseCursor { display: none; }
@media (any-hover: hover) and (any-pointer: fine) {
  html#qsdCursorRoot#qsdCursorRoot.qsd-custom-cursor,
  html#qsdCursorRoot#qsdCursorRoot.qsd-custom-cursor body,
  html#qsdCursorRoot#qsdCursorRoot.qsd-custom-cursor body *,
  html#qsdCursorRoot#qsdCursorRoot.qsd-custom-cursor body *::before,
  html#qsdCursorRoot#qsdCursorRoot.qsd-custom-cursor body *::after {
    cursor: none !important;
  }

  #qsdMouseCursor {
    position: fixed !important;
    left: var(--qsd-cursor-x, -200px) !important;
    top: var(--qsd-cursor-y, -200px) !important;
    z-index: 2147483647 !important;
    display: block !important;
    width: 44.8px !important;
    height: 44.8px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: url("../assets/ui/cursor-normal.png") 0 0 / 44.8px 44.8px no-repeat !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
    user-select: none !important;
    transform: translate3d(-4.9px, -4.9px, 0) !important;
    transform-origin: 0 0 !important;
    transition: none !important;
    will-change: left, top, transform;
  }
  html.qsd-cursor-visible #qsdMouseCursor {
    opacity: 1;
    visibility: visible;
  }
  html.qsd-cursor-pressed #qsdMouseCursor {
    width: 44.8px !important;
    height: 39.9px !important;
    background-image: url("../assets/ui/cursor-pressed.png") !important;
    background-size: 44.8px 39.9px !important;
    transform: translate3d(-6.3px, -1.4px, 0) !important;
  }
}

/* The oversized logo is absolutely positioned; keep its version label out of the centered flex flow. */
#mainMenuOverlay .main-menu-home .main-menu-version {
  position: absolute !important;
  left: 50% !important;
  top: calc(20% + clamp(126px, 9.8vw, 150px)) !important;
  z-index: 13 !important;
  width: max-content !important;
  margin: 0 !important;
  transform: translateX(-50%) !important;
  white-space: nowrap !important;
}

@media (max-width: 760px) {
  #mainMenuOverlay .main-menu-home .main-menu-version {
    top: calc(18% + 100px) !important;
  }
}

html,
body {
  width: 100%;
  height: 100%;
  padding: 0 !important;
}

.stage {
  width: 100dvw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.run-info-hud-layer {
  position: absolute;
  inset: 0;
  z-index: 31;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
  image-rendering: auto;
}

/* The same combat pause control stays clickable above the upgrade overlay. */
#pauseButton.pause-button {
  z-index: 1250 !important;
}

.main-menu-shell.selection-mode,
.selection-panel.visible {
  width: min(100%, 1920px) !important;
  height: min(100%, 1080px) !important;
  max-width: calc(100dvw - var(--qsd-safe-left) - var(--qsd-safe-right) - 24px) !important;
  max-height: calc(100dvh - var(--qsd-safe-top) - var(--qsd-safe-bottom) - 24px) !important;
}

/* Character selection reserves the larger share for readable attributes and
   descriptions. The portrait carousel remains fully visible but no longer
   consumes most of the screen. */
#characterSelectPanel .character-selection-body {
  grid-template-rows: minmax(0, 40%) 1px minmax(0, 60%);
}

#characterSelectPanel .character-card {
  height: clamp(170px, 27vh, 290px);
}

[data-layout="ultrawide"] .main-menu-shell:not(.selection-mode),
[data-layout="super-ultrawide"] .main-menu-shell:not(.selection-mode) {
  margin-left: clamp(0px, 8vw, 180px);
}

[data-layout="compact"] .character-selection-body,
[data-layout="compact"] .map-selection-body {
  grid-template-columns: minmax(0, 1fr) !important;
}

[data-layout="compact"] .upgrade-card-row {
  gap: clamp(4px, 0.8vw, 10px) !important;
}

[data-layout="super-ultrawide"] .owned-card-hud,
[data-layout="ultrawide"] .owned-card-hud {
  max-width: min(720px, 36vw) !important;
}

/* Touch HUD: landscape phones are often wider than 760px, so width-only
   breakpoints accidentally gave them the desktop card tray. Keep the same
   supplied tray/frame artwork and shrink the complete in-combat component. */
@media (pointer: coarse) {
  #ownedCardHud.owned-card-hud {
    min-height: 43px !important;
    gap: 3px !important;
    max-width: min(420px, 52vw) !important;
    padding: 3px 6px 4px !important;
  }

  #ownedCardHud.owned-card-hud > .owned-card-chip {
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
  }

  #ownedCardHud .owned-card-chip.card-chip .owned-card-ui-tray,
  #ownedCardHud .owned-card-chip.card-chip .owned-card-art-mask {
    width: 29.6px !important;
    height: 29.6px !important;
  }

  #ownedCardHud .owned-card-chip.card-chip .owned-card-ui-frame {
    width: 32px !important;
    height: 32px !important;
  }

  #ownedCardHud .owned-card-chip.item-chip .owned-card-ui-tray,
  #ownedCardHud .owned-card-chip.item-chip .owned-card-art-mask {
    width: 29.6px !important;
    height: 32.6px !important;
  }

  #ownedCardHud .owned-card-chip.item-chip .owned-card-ui-frame {
    width: 32px !important;
    height: 34.5px !important;
  }

  #ownedCardHud .owned-card-level {
    min-width: 11px !important;
    padding: 1px 2px !important;
    right: 1px !important;
    bottom: 0 !important;
    font-size: 7.2px !important;
  }

  #ownedCardHud .owned-card-ui-tray {
    filter: drop-shadow(0 0 2px var(--icon-glow)) !important;
  }
}

/* Settlement uses its own card gallery: cards are deliberately arranged in the
   left column instead of inheriting the in-combat one-dimensional HUD strip. */
.death-run-info-overlay.visible .death-run-side.left {
  align-self: start;
  width: min(470px, 30vw);
  height: min(78vh, 720px);
  max-height: min(78vh, 720px);
  pointer-events: auto;
}

#deathRunCards.death-run-cards {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  grid-auto-rows: 62px;
  align-content: start !important;
  align-items: start;
  justify-items: start;
  gap: 12px;
  padding: 4px 0;
  overflow-y: auto;
  pointer-events: auto;
}

#deathRunCards.death-run-cards .owned-card-chip {
  pointer-events: auto !important;
}

/* Native range controls own shadow-DOM cursor states in Chromium. Explicitly
   suppress them so hovering the track/thumb never reveals the system cursor. */
@media (any-hover: hover) and (any-pointer: fine) {
  html#qsdCursorRoot.qsd-custom-cursor body input[type="range"],
  html#qsdCursorRoot.qsd-custom-cursor body input[type="range"]::-webkit-slider-runnable-track,
  html#qsdCursorRoot.qsd-custom-cursor body input[type="range"]::-webkit-slider-thumb,
  html#qsdCursorRoot.qsd-custom-cursor body input[type="range"]::-moz-range-track,
  html#qsdCursorRoot.qsd-custom-cursor body input[type="range"]::-moz-range-progress,
  html#qsdCursorRoot.qsd-custom-cursor body input[type="range"]::-moz-range-thumb {
    cursor: none !important;
  }
}

html body .stage input[type="range"]:is(:hover, :focus-visible)::-webkit-slider-thumb {
  background:
    linear-gradient(#345000,#345000) center calc(50% - 7px)/11px 3px no-repeat,
    linear-gradient(#345000,#345000) center center/11px 3px no-repeat,
    linear-gradient(#345000,#345000) center calc(50% + 7px)/11px 3px no-repeat,
    linear-gradient(180deg, #eaff54, #ccff00 54%, #8fbd00) !important;
  box-shadow: inset 0 4px 7px rgba(255,255,255,.38), 0 0 12px rgba(204,255,0,.72), 0 4px 8px rgba(0,0,0,.38) !important;
}

html body .stage input[type="range"]:is(:hover, :focus-visible)::-moz-range-thumb {
  background:
    linear-gradient(#345000,#345000) center calc(50% - 7px)/11px 3px no-repeat,
    linear-gradient(#345000,#345000) center center/11px 3px no-repeat,
    linear-gradient(#345000,#345000) center calc(50% + 7px)/11px 3px no-repeat,
    linear-gradient(180deg, #eaff54, #ccff00 54%, #8fbd00) !important;
  box-shadow: inset 0 4px 7px rgba(255,255,255,.38), 0 0 12px rgba(204,255,0,.72), 0 4px 8px rgba(0,0,0,.38) !important;
}

body.player-death-active #ownedCardFloatingTooltip.settlement-visible {
  display: block !important;
  z-index: 220 !important;
}

@media (max-width: 760px) {
  .death-run-info-overlay.visible .death-run-side.left {
    width: min(42vw, 250px);
    height: min(76vh, 560px);
  }

  #deathRunCards.death-run-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-rows: 46px;
    gap: 7px;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  [data-layout="ultrawide"] .main-menu-shell:not(.selection-mode),
  [data-layout="super-ultrawide"] .main-menu-shell:not(.selection-mode) {
    margin-left: 0;
  }
  .main-menu-shell:not(.selection-mode) {
    transform: scale(.84);
    transform-origin: center;
  }
  #mainMenuOverlay .main-menu-home .main-menu-actions {
    transform: translateY(40px) !important;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .main-menu-shell:not(.selection-mode) { transform: scale(.70); }
  #mainMenuOverlay .main-menu-home .main-menu-actions { transform: translateY(28px) !important; }
}

img,
canvas {
  object-fit: contain;
}

/* Desktop display controls share the established settings-panel visual language. */
.display-settings-block {
  margin: 10px 0 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(190, 208, 223, .13);
}

.display-settings-heading {
  margin-bottom: 3px;
  color: #8296aa;
  font: 900 10px/1.2 Inter, "Microsoft YaHei", sans-serif;
  letter-spacing: .18em;
}

.display-setting-row .game-select {
  grid-column: 2 / 4;
  position: relative;
  width: 100%;
  min-width: 0;
}

.game-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 34px;
  padding: 0 34px 0 13px;
  overflow: hidden;
  border: 1px solid rgba(209, 224, 237, .25);
  border-radius: 5px;
  background:
    linear-gradient(90deg, rgba(113, 57, 151, .18), transparent 34%),
    linear-gradient(180deg, #17121f, #0b0910);
  color: #f1f6fa;
  font: 800 12px/1 Inter, "Microsoft YaHei", sans-serif;
  text-align: left;
  text-shadow:
    -1px 0 #000,
    1px 0 #000,
    0 -1px #000,
    0 1px #000;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    inset 3px 0 0 rgba(184, 255, 0, .32),
    0 3px 8px rgba(0, 0, 0, .22);
  transition: border-color .14s ease, box-shadow .14s ease, filter .14s ease;
}

.game-select-trigger:hover,
.game-select-trigger:focus-visible,
.game-select.open .game-select-trigger {
  border-color: rgba(190, 255, 0, .67);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .07),
    inset 3px 0 0 #b8ff00,
    0 0 0 2px rgba(140, 79, 185, .25),
    0 0 12px rgba(184, 255, 0, .10);
}

html body .stage .game-select-trigger,
html body .stage .game-select-trigger.ui-text-plain:hover:not(:disabled),
html body .stage .game-select-trigger.ui-text-plain:focus-visible:not(:disabled),
html body .stage .game-select-trigger.ui-text-plain:active:not(:disabled),
html body .stage .game-select-trigger [data-display-value] {
  color: #f1f6fa !important;
}

.game-select-trigger:disabled {
  filter: grayscale(.35);
  opacity: .45;
  box-shadow: inset 3px 0 0 rgba(180, 190, 170, .22);
}

.game-select-chevron {
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #d7e3ec;
  border-bottom: 2px solid #d7e3ec;
  transform: translateY(-66%) rotate(45deg);
  transition: transform .14s ease, border-color .14s ease;
}

.game-select.open .game-select-chevron {
  border-color: #b8ff00;
  transform: translateY(-28%) rotate(225deg);
}

.game-select-options {
  position: absolute;
  z-index: 260;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  max-height: 190px;
  padding: 5px;
  overflow: auto;
  border: 1px solid rgba(190, 255, 0, .48);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(111, 51, 153, .22), transparent 44%),
    rgba(9, 7, 13, .985);
  box-shadow:
    0 15px 28px rgba(0, 0, 0, .70),
    0 0 0 2px rgba(91, 45, 123, .36),
    inset 0 1px 0 rgba(255, 255, 255, .05);
  scrollbar-width: thin;
  scrollbar-color: #79489c #0a0810;
}

.game-select.opens-up .game-select-options {
  top: auto;
  bottom: calc(100% + 5px);
}

.game-select-option {
  position: relative;
  display: block;
  width: 100%;
  min-height: 31px;
  padding: 0 11px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: #cfd9e2;
  font: 800 11px/1 Inter, "Microsoft YaHei", sans-serif;
  text-align: left;
  outline: none;
}

.game-select-option:hover,
.game-select-option:focus-visible {
  border-left-color: #a65be0;
  background: linear-gradient(90deg, rgba(141, 72, 190, .48), rgba(67, 35, 92, .20));
  color: #fff;
}

html body .stage .game-select-option:not([aria-selected="true"]),
html body .stage .game-select-option.ui-text-plain:hover:not([aria-selected="true"]),
html body .stage .game-select-option.ui-text-plain:focus-visible:not([aria-selected="true"]) {
  color: #cfd9e2 !important;
}

.game-select-option[aria-selected="true"] {
  border-left-color: #f4ffbf;
  background: linear-gradient(90deg, #c8ff18, #8fd700);
  color: #101407;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
}

html body .stage .game-select-option[aria-selected="true"] {
  color: #101407 !important;
}

.game-select-option[aria-selected="true"]::after {
  content: '';
  position: absolute;
  right: 11px;
  top: 50%;
  width: 7px;
  height: 4px;
  border-left: 2px solid #162000;
  border-bottom: 2px solid #162000;
  transform: translateY(-65%) rotate(-45deg);
}

.main-menu-settings {
  max-height: min(80dvh, 660px);
  overflow: auto;
  scrollbar-width: thin;
}

[data-platform-kind="wechat"] .display-settings-block,
[data-platform-kind="bilibili"] .display-settings-block {
  display: none;
}

@media (orientation: landscape) and (max-height: 600px) {
  .display-settings-block { margin-top: 5px; padding-top: 5px; }
  .display-setting-row { min-height: 32px !important; }
  .game-select-trigger { height: 29px; font-size: 10px; }
  .game-select-option { min-height: 28px; font-size: 9px; }
}

/* Character/map selection: persistent account resources in the same rounded tray language. */
.selection-resource-tray {
  position: absolute;
  z-index: 245;
  top: calc(var(--qsd-safe-top) + clamp(14px, 2.2vh, 28px));
  right: calc(var(--qsd-safe-right) + clamp(16px, 2.4vw, 36px));
  display: none;
  width: clamp(160px, 12.2vw, 214px);
  overflow: hidden;
  border: 3px solid #050505;
  border-radius: 17px;
  background: rgba(36, 38, 46, .94);
  box-shadow: 0 8px 0 rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .12);
  color: #fff;
  pointer-events: none;
}

#mainMenuOverlay.mode-character .selection-resource-tray,
#mainMenuOverlay.mode-map .selection-resource-tray {
  display: block;
}

.selection-resource-tray__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 31px;
  padding: 0 12px;
  border-bottom: 2px solid #050505;
  background: linear-gradient(180deg, #31343d, #252831);
  color: #f7f7fa;
  font: 900 12px/1 "Microsoft YaHei", sans-serif;
  letter-spacing: .08em;
  text-shadow: 0 2px 0 #000;
}

.selection-resource-tray__list {
  display: grid;
  gap: 2px;
  padding: 7px 10px 8px;
  background: linear-gradient(180deg, rgba(8, 8, 12, .18), rgba(0, 0, 0, .34));
}

.selection-resource-tray__row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 28px;
}

.selection-resource-tray__icon {
  display: block;
  width: 25px;
  height: 25px;
  filter: drop-shadow(0 0 5px currentColor) drop-shadow(0 2px 1px #000);
}

.selection-resource-tray__value {
  justify-self: end;
  color: #fff;
  font: 900 clamp(15px, 1.25vw, 20px)/1 "Microsoft YaHei", sans-serif;
  text-shadow: -1px 0 #000, 1px 0 #000, 0 -1px #000, 0 2px #000;
}

/* Item quantities are rasterized from the game's number-art atlas. */
.owned-card-level.owned-card-level-art {
  min-width: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.character-unlock-cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 72px;
}

.character-unlock-cost__icon {
  width: 27px;
  height: 27px;
  filter: drop-shadow(0 0 6px rgba(60, 205, 255, .75)) drop-shadow(0 2px 1px #000);
}

.character-unlock-cost__number {
  display: block;
  width: auto;
  height: 24px;
}

/* Locked portraits keep the supplied art darkened without hatch/mask layers;
   the standalone supplied lock remains readable at every carousel scale. */
.character-card.locked-character .character-lock-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  display: block;
  width: clamp(48px, 5.2vw, 82px);
  aspect-ratio: 200 / 264;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background: url("../assets/ui/lock-icon.png") center / contain no-repeat;
  filter: drop-shadow(0 3px 2px #000) drop-shadow(0 0 9px rgba(204, 255, 0, .28));
}

.character-card.locked-character .character-lock-icon::before,
.character-card.locked-character .character-lock-icon::after {
  content: none !important;
  display: none !important;
}

@media (orientation: landscape) and (max-height: 600px) {
  .selection-resource-tray { top: calc(var(--qsd-safe-top) + 8px); right: calc(var(--qsd-safe-right) + 12px); transform: scale(.82); transform-origin: top right; }
}

/* Editor text/number fields: user-supplied 143x50 capsule rendered as a true 9-slice. */
:root {
  --editor-input-9slice: url("../assets/ui/editor-input-9slice.png");
  --editor-input-core: linear-gradient(180deg, #373737 0%, #323232 48%, #292929 100%);
  --editor-input-core-focus: radial-gradient(ellipse at 38% 24%, #efff61 0%, #dfff19 38%, #ccff00 68%, #91b400 100%);
}

html body .stage #editorPanel input:is([type="text"], [type="number"]),
html body .stage #editorPanel #editorForm textarea {
  box-sizing: border-box !important;
  min-width: 0 !important;
  min-height: 40px !important;
  border: solid transparent !important;
  border-width: 10px 20px !important;
  border-radius: 0 !important;
  border-image-source: var(--editor-input-9slice) !important;
  border-image-slice: 20 28 20 28 !important;
  border-image-width: 10px 20px !important;
  border-image-outset: 0 !important;
  border-image-repeat: stretch !important;
  padding: 0 8px !important;
  outline: 0 !important;
  background-color: #323232 !important;
  background-image: var(--editor-input-core) !important;
  background-clip: padding-box !important;
  color: #fff !important;
  caret-color: #fff !important;
  box-shadow: none !important;
  font: 700 13px/20px "Microsoft YaHei", sans-serif !important;
  transition: color .12s ease, caret-color .12s ease, filter .12s ease, box-shadow .12s ease !important;
}

html body .stage #editorPanel #editorForm textarea {
  min-height: 84px !important;
  max-height: none !important;
  padding: 8px 10px !important;
  line-height: 1.45 !important;
  resize: vertical !important;
}

html body .stage #editorPanel input:is([type="text"], [type="number"])::placeholder,
html body .stage #editorPanel #editorForm textarea::placeholder {
  color: rgba(255, 255, 255, .48) !important;
  opacity: 1 !important;
}

html body .stage #editorPanel input:is([type="text"], [type="number"]):focus:not(:disabled),
html body .stage #editorPanel #editorForm textarea:focus:not(:disabled) {
  border: solid transparent !important;
  border-width: 10px 20px !important;
  border-image-source: var(--editor-input-9slice) !important;
  border-image-slice: 20 28 20 28 !important;
  border-image-width: 10px 20px !important;
  border-image-repeat: stretch !important;
  outline: 0 !important;
  background-color: #ccff00 !important;
  background-image: var(--editor-input-core-focus) !important;
  background-clip: padding-box !important;
  color: #050505 !important;
  caret-color: #050505 !important;
  box-shadow: 0 0 0 2px rgba(204, 255, 0, .18), 0 0 12px rgba(204, 255, 0, .28) !important;
}

html body .stage #editorPanel input:is([type="text"], [type="number"]):focus:not(:disabled)::placeholder,
html body .stage #editorPanel #editorForm textarea:focus:not(:disabled)::placeholder {
  color: rgba(5, 5, 5, .56) !important;
}

html body .stage #editorPanel input:is([type="text"], [type="number"]):disabled,
html body .stage #editorPanel #editorForm textarea:disabled,
html body .stage #editorPanel input:is([type="text"], [type="number"]):disabled:focus,
html body .stage #editorPanel #editorForm textarea:disabled:focus {
  background-color: #303030 !important;
  background-image: var(--editor-input-core) !important;
  color: rgba(255, 255, 255, .56) !important;
  caret-color: transparent !important;
  box-shadow: none !important;
  filter: saturate(.35) brightness(.78) !important;
  opacity: .58 !important;
}

#editorForm.character-compact-form .editor-field,
#editorForm.character-compact-form .editor-field.wide,
.editor-visual-row,
.editor-floor-pattern-row {
  min-height: 44px;
}

/* The two 72px grid-size fields need a narrower 9-slice rim so their native number steppers and values remain visible. */
html body .stage #editorPanel .editor-floor-pattern-button-row input[type="number"],
html body .stage #editorPanel .editor-floor-pattern-button-row input[type="number"]:focus:not(:disabled) {
  border-width: 9px 13px !important;
  border-image-width: 9px 13px !important;
  padding-right: 2px !important;
  padding-left: 5px !important;
}

@media (max-width: 900px), (orientation: landscape) and (max-height: 600px) {
  html body .stage #editorPanel input:is([type="text"], [type="number"]),
  html body .stage #editorPanel #editorForm textarea {
    min-height: 36px !important;
    border-width: 9px 18px !important;
    border-image-width: 9px 18px !important;
    padding-right: 7px !important;
    padding-left: 7px !important;
    font-size: 12px !important;
    line-height: 18px !important;
  }

  html body .stage #editorPanel input:is([type="text"], [type="number"]):focus:not(:disabled),
  html body .stage #editorPanel #editorForm textarea:focus:not(:disabled) {
    border-width: 9px 18px !important;
    border-image-width: 9px 18px !important;
  }

  html body .stage #editorPanel #editorForm textarea {
    min-height: 72px !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
    line-height: 1.4 !important;
  }

  #editorForm.character-compact-form .editor-field,
  #editorForm.character-compact-form .editor-field.wide,
  .editor-visual-row,
  .editor-floor-pattern-row {
    min-height: 40px;
  }


  html body .stage #editorPanel .editor-floor-pattern-button-row input[type="number"],
  html body .stage #editorPanel .editor-floor-pattern-button-row input[type="number"]:focus:not(:disabled) {
    border-width: 8px 12px !important;
    border-image-width: 8px 12px !important;
    padding-right: 1px !important;
    padding-left: 4px !important;
  }
}

/* Mobile presentation is requested automatically by the runtime; never block play behind a rotate prompt. */
.orientation-notice,
.orientation-notice[hidden] {
  display: none !important;
}

@media (orientation: portrait) and (pointer: coarse) {
  .stage { visibility: visible !important; }
}

/* Keep multiplayer private while the editor entry is temporarily available for content work. */
#mainMenuLanButton,
#mainMenuLanButton[hidden] {
  display: none !important;
}

/* Pausing over the upgrade/card screen should separate the menu from the artwork behind it. */
#pauseOverlay.pause-overlay.pause-over-upgrade {
  background: rgba(2, 3, 6, .22) !important;
  -webkit-backdrop-filter: blur(10px) saturate(.72) brightness(.72);
  backdrop-filter: blur(10px) saturate(.72) brightness(.72);
}

.mobile-control-layout-editor,
.mobile-control-layout-editor-canvas {
  touch-action: none !important;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
/* Supplied 3:2 Shiba World art fills its map card without stretching. */
.map-placeholder.map-placeholder-image::before {
  content: none;
}

.map-placeholder-image > img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

/* Map browsing states: neighbours stay fully visible in monochrome. */
.map-card:not(.active) {
  opacity: 1 !important;
  filter: grayscale(1) brightness(.72) contrast(1.04) !important;
}

.map-card {
  transform: scale(var(--map-depth-scale, .88)) !important;
  z-index: var(--map-depth-z, 1) !important;
  transform-origin: center;
}

.map-card.active {
  opacity: 1 !important;
  filter: none !important;
  transform: scale(var(--map-depth-scale, 1)) !important;
  z-index: var(--map-depth-z, 8) !important;
}

.map-card.locked:not(.active) {
  filter: grayscale(1) brightness(.62) contrast(1.08) !important;
}

.map-card.locked.active {
  filter: none !important;
}

.map-card.locked::after {
  content: '';
  background:
    url("../assets/ui/lock-icon.png") center / auto clamp(52px, 7vw, 96px) no-repeat,
    repeating-linear-gradient(
      135deg,
      rgba(0, 0, 0, .38) 0 10px,
      rgba(255, 255, 255, .10) 10px 13px,
      rgba(0, 0, 0, .08) 13px 24px
    ),
    rgba(0, 0, 0, .16) !important;
}

/* Main-menu production credits: full-screen black fade and responsive vertical roll. */
.credits-overlay {
  --credits-roll-duration: 28s;
  position: absolute;
  inset: 0;
  z-index: 1600;
  overflow: hidden;
  background: #000;
  color: #fff;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity .85s ease, visibility 0s linear .85s;
  isolation: isolate;
}
.credits-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .85s ease;
}
.credits-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.credits-roll {
  position: absolute;
  top: 100%;
  left: 50%;
  width: min(760px, calc(100vw - 48px));
  box-sizing: border-box;
  text-align: center;
  transform: translate3d(-50%, 0, 0);
  will-change: transform;
}
.credits-overlay.is-playing .credits-roll {
  animation: creditsRoll var(--credits-roll-duration) linear .55s both;
}
.credits-title-block {
  margin-bottom: clamp(72px, 12vh, 132px);
}
.credits-game-title {
  font: 950 clamp(38px, 5.4vw, 82px)/1.05 Inter, "Microsoft YaHei", sans-serif;
  letter-spacing: .13em;
  text-indent: .13em;
  color: #fff;
  -webkit-text-stroke: clamp(1px, .12vw, 2px) #090909;
  text-shadow: 0 4px 0 #000, 0 0 24px rgba(204,255,0,.2), 0 0 44px rgba(125,55,255,.18);
}
.credits-game-title-en {
  margin-top: 12px;
  color: #bfc6ce;
  font: 800 clamp(10px, 1vw, 14px)/1.2 Inter, Arial, sans-serif;
  letter-spacing: .42em;
  text-indent: .42em;
}
.credits-entry {
  margin-bottom: clamp(50px, 8vh, 88px);
}
.credits-role {
  margin-bottom: 13px;
  color: #ccff00;
  font: 900 clamp(15px, 1.65vw, 24px)/1.15 Inter, "Microsoft YaHei", sans-serif;
  letter-spacing: .28em;
  text-indent: .28em;
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(204,255,0,.2);
}
.credits-name {
  color: #fff;
  font: 900 clamp(22px, 2.65vw, 38px)/1.35 Inter, "Microsoft YaHei", sans-serif;
  letter-spacing: .06em;
  text-shadow: 0 3px 0 #000;
}
.credits-finale {
  padding: clamp(52px, 9vh, 96px) 0 clamp(90px, 14vh, 150px);
  color: #fff;
  font: 950 clamp(30px, 4vw, 58px)/1 Inter, "Microsoft YaHei", sans-serif;
  letter-spacing: .28em;
  text-indent: .28em;
  text-shadow: 0 3px 0 #000, 0 0 24px rgba(125,55,255,.36);
}
.credits-close-button {
  position: absolute !important;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 2;
  width: auto !important;
  min-width: 112px;
  min-height: 42px !important;
  padding: 0 22px !important;
  background: rgba(19,19,23,.84) !important;
}
.credits-skip-hint {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2;
  transform: translateX(-50%);
  color: rgba(255,255,255,.48);
  font: 700 clamp(9px, .85vw, 12px)/1.2 Inter, "Microsoft YaHei", sans-serif;
  letter-spacing: .14em;
  white-space: nowrap;
}
.main-menu-overlay.credits-active { pointer-events: none !important; }
@keyframes creditsRoll {
  from { transform: translate3d(-50%, 0, 0); }
  to { transform: translate3d(-50%, calc(-100% - 100vh), 0); }
}
@media (max-height: 560px), (pointer: coarse) {
  .credits-overlay { --credits-roll-duration: 25s; }
  .credits-roll { top: 100%; width: min(680px, calc(100vw - 32px)); }
  .credits-title-block { margin-bottom: 58px; }
  .credits-entry { margin-bottom: 42px; }
  .credits-role { margin-bottom: 8px; }
  .credits-finale { padding: 44px 0 80px; }
  .credits-close-button { top: max(8px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); min-width: 82px; min-height: 34px !important; padding: 0 14px !important; font-size: 10px !important; }
  .credits-skip-hint { bottom: max(7px, env(safe-area-inset-bottom)); }
  @keyframes creditsRoll {
    from { transform: translate3d(-50%, 0, 0); }
    to { transform: translate3d(-50%, calc(-100% - 100vh), 0); }
  }
}

/* Update notice reuses the established stat tray and menu-button visual system. */
.update-notes-overlay {
  position: absolute;
  inset: 0;
  z-index: 1650;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: max(18px, var(--qsd-safe-top, 0px)) max(18px, var(--qsd-safe-right, 0px)) max(18px, var(--qsd-safe-bottom, 0px)) max(18px, var(--qsd-safe-left, 0px));
  background: rgba(3, 4, 8, .78);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility 0s linear .22s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.update-notes-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.update-notes-panel {
  width: min(900px, 92vw);
  height: min(720px, 88vh);
  min-height: 320px;
  transform: translateY(18px) scale(.985);
  transition: transform .24s cubic-bezier(.18, .82, .2, 1);
}
.update-notes-overlay.visible .update-notes-panel { transform: translateY(0) scale(1); }
.update-notes-panel > .shared-stat-tray { height: 100%; }
.update-notes-header {
  min-height: 82px;
  padding: 14px 18px;
  gap: 20px;
}
.update-notes-header > div:first-child { min-width: 0; }
.update-notes-kicker {
  margin-bottom: 4px;
  color: #ccff00;
  font: 900 clamp(8px, .8vw, 12px)/1.15 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .22em;
}
#updateNotesTitle {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 38px);
}
.update-notes-close {
  width: auto !important;
  min-width: 116px !important;
  min-height: 46px !important;
  padding: 0 24px !important;
  flex: 0 0 auto;
}
.update-notes-list {
  height: calc(100% - 82px);
  box-sizing: border-box;
  display: block;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: clamp(14px, 2.2vw, 28px);
  scrollbar-gutter: stable;
}
.update-notes-entry {
  margin-bottom: 16px;
  overflow: hidden;
  border: 4px solid #050608;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(51, 54, 62, .97), rgba(28, 30, 36, .98));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .15), 0 10px 24px rgba(0, 0, 0, .28);
}
.update-notes-entry.is-latest { box-shadow: 0 0 0 2px rgba(204, 255, 0, .34), 0 0 24px rgba(204, 255, 0, .12), 0 10px 24px rgba(0, 0, 0, .3); }
.update-notes-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 2px solid #0a0b0e;
  background: rgba(20, 22, 27, .66);
}
.update-notes-date {
  display: block;
  color: #ccff00;
  font: 900 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .12em;
}
.update-notes-entry-title { margin: 5px 0 0; color: #fff; font: 950 clamp(17px, 1.55vw, 23px)/1.2 "Microsoft YaHei", sans-serif; }
.update-notes-version { flex: 0 0 auto; color: #131515; background: #ccff00; border: 3px solid #050608; border-radius: 999px; padding: 5px 11px; font: 950 10px/1 ui-monospace, Consolas, monospace; }
.update-notes-copy {
  flex: 0 0 auto;
  width: auto !important;
  min-width: 82px !important;
  min-height: 38px !important;
  padding: 0 16px !important;
  font-size: 13px !important;
}
.update-notes-copy:disabled { opacity: .82; }
.update-notes-intro { margin: 0; padding: 16px 22px 12px; color: #f2f4f6; font: 800 clamp(13px, 1.1vw, 16px)/1.65 "Microsoft YaHei", sans-serif; }
.update-notes-section { padding: 0 22px 5px; }
.update-notes-section-title { margin: 4px 0 0; padding: 8px 12px; border-left: 5px solid #ccff00; border-radius: 0 8px 8px 0; background: rgba(8, 10, 13, .42); color: #fff; font: 950 clamp(15px, 1.35vw, 20px)/1.25 "Microsoft YaHei", sans-serif; }
.update-notes-section .update-notes-items { padding: 12px 12px 14px 20px; }
.update-notes-items { margin: 0; padding: 16px 22px 18px 42px; color: #e7e9ec; font: 800 clamp(13px, 1.1vw, 16px)/1.65 "Microsoft YaHei", sans-serif; }
.update-notes-items li + li { margin-top: 7px; }
.update-notes-items li::marker { color: #ccff00; }
.update-notes-entry-footer { margin: 8px 22px 20px; padding: 15px 16px; border-top: 2px solid rgba(204, 255, 0, .42); color: #dfe3e8; font: 800 clamp(12px, 1vw, 15px)/1.6 "Microsoft YaHei", sans-serif; }
.update-notes-entry-footer p { margin: 0; }
.update-notes-entry-footer p + p { margin-top: 8px; color: #ccff00; }
.update-notes-empty {
  min-height: 100%;
  box-sizing: border-box;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
}
.update-notes-empty::before {
  content: '!';
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border: 5px solid #050608;
  border-radius: 50%;
  background: #ccff00;
  color: #111;
  font: 950 38px/1 Inter, sans-serif;
  box-shadow: 0 0 0 2px rgba(255,255,255,.18), 0 0 24px rgba(204,255,0,.2);
}
.update-notes-empty-title { color: #fff; font: 950 clamp(20px, 2vw, 30px)/1.2 "Microsoft YaHei", sans-serif; text-shadow: 0 3px 0 #000; }
.update-notes-empty-copy { max-width: 480px; margin: 10px 0 0; color: #aeb4bd; font: 750 clamp(12px, 1vw, 15px)/1.6 "Microsoft YaHei", sans-serif; }
.main-menu-overlay.update-notes-active { pointer-events: none !important; }

@media (max-height: 620px), (pointer: coarse) {
  .update-notes-overlay { padding: max(8px, var(--qsd-safe-top, 0px)) max(9px, var(--qsd-safe-right, 0px)) max(8px, var(--qsd-safe-bottom, 0px)) max(9px, var(--qsd-safe-left, 0px)); }
  .update-notes-panel { width: min(820px, 96vw); height: min(500px, 94vh); min-height: 250px; }
  .update-notes-header { min-height: 58px; padding: 8px 11px; }
  #updateNotesTitle { font-size: clamp(19px, 4.2vh, 27px); }
  .update-notes-kicker { font-size: 7px; }
  .update-notes-close { min-width: 90px !important; min-height: 38px !important; padding: 0 15px !important; font-size: 11px !important; }
  .update-notes-list { height: calc(100% - 58px); padding: 10px; }
  .update-notes-entry { margin-bottom: 10px; border-width: 3px; border-radius: 13px; }
  .update-notes-entry-header { padding: 9px 12px; }
  .update-notes-entry-title { font-size: 15px; }
  .update-notes-copy { min-width: 68px !important; min-height: 34px !important; padding: 0 11px !important; font-size: 11px !important; }
  .update-notes-intro { padding: 10px 14px 8px; font-size: 12px; line-height: 1.5; }
  .update-notes-section { padding: 0 14px 3px; }
  .update-notes-section-title { padding: 6px 9px; font-size: 13px; border-left-width: 4px; }
  .update-notes-section .update-notes-items { padding: 8px 8px 10px 18px; }
  .update-notes-items { padding: 10px 16px 12px 32px; font-size: 12px; line-height: 1.5; }
  .update-notes-entry-footer { margin: 6px 14px 12px; padding: 10px 11px; font-size: 11px; }
  .update-notes-empty::before { width: 48px; height: 48px; margin-bottom: 10px; border-width: 4px; font-size: 28px; }
}

/* Upgrade presentation: the card selection remains unchanged, but the former
   full-screen structural frame is deliberately removed.  The reusable stat tray
   keeps its own established black rounded frame. */
#upgradeOverlay .upgrade-center-panel {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Long-press skip uses the requested rose-red progress fill. */
#upgradeOverlay .hold-progress > i {
  background: linear-gradient(90deg, #a81442 0%, #e63868 52%, #ff7b9e 100%) !important;
  box-shadow: 0 0 7px rgba(226, 43, 94, .72) !important;
}

/* Mobile/short-landscape home layout.
   Keep real touch targets instead of shrinking the complete menu shell. The
   left region owns the logo and menu actions; the task panel owns the right
   region and scrolls internally when browser chrome reduces the viewport. */
@media (orientation: landscape) and (max-height: 620px) {
  #mainMenuOverlay .main-menu-shell:not(.selection-mode) {
    transform: none !important;
    transform-origin: center !important;
  }

  #mainMenuOverlay .main-menu-home {
    --qsd-mobile-task-width: clamp(250px, 43vw, 420px);
    --qsd-mobile-edge: max(10px, var(--qsd-safe-right));
    --qsd-mobile-left-center: calc((100% - var(--qsd-mobile-task-width) - var(--qsd-mobile-edge)) / 2);
    --qsd-mobile-logo-height: clamp(70px, 19dvh, 112px);
    --qsd-mobile-actions-top: calc(max(7px, var(--qsd-safe-top)) + clamp(96px, 23dvh, 134px));
    overflow: hidden !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-title {
    left: var(--qsd-mobile-left-center) !important;
    top: max(7px, var(--qsd-safe-top)) !important;
    width: min(45vw, 420px) !important;
    height: var(--qsd-mobile-logo-height) !important;
    max-width: none !important;
    transform: translateX(-50%) rotate(var(--main-menu-logo-angle)) !important;
    transform-origin: 50% 52% !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-version {
    left: var(--qsd-mobile-left-center) !important;
    top: calc(max(7px, var(--qsd-safe-top)) + var(--qsd-mobile-logo-height) + 1px) !important;
    transform: translateX(-50%) !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-actions {
    position: absolute !important;
    left: var(--qsd-mobile-left-center) !important;
    top: var(--qsd-mobile-actions-top) !important;
    width: clamp(250px, 45vw, 420px) !important;
    max-width: none !important;
    margin: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: clamp(5px, 1.2dvh, 8px) !important;
    transform: translateX(-50%) !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button,
  #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.primary,
  #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.exit {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: clamp(46px, 8.2dvh, 56px) !important;
    padding: 0 clamp(18px, 3vw, 34px) !important;
    border-width: 5px !important;
    font-size: clamp(14px, 2.1dvh, 18px) !important;
  }
}

/* Very short phone viewports use two button columns. This preserves a 46px
   minimum touch height instead of reducing every control until it fits. */
@media (orientation: landscape) and (max-height: 420px) {
  #mainMenuOverlay .main-menu-home {
    --qsd-mobile-actions-top: calc(max(6px, var(--qsd-safe-top)) + clamp(82px, 24dvh, 101px));
  }

  #mainMenuOverlay .main-menu-home .main-menu-title {
    height: clamp(66px, 20dvh, 82px) !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-version {
    top: calc(max(6px, var(--qsd-safe-top)) + clamp(66px, 20dvh, 82px) + 1px) !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button,
  #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.primary,
  #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.exit {
    min-height: 46px !important;
    padding-inline: 10px !important;
    font-size: 14px !important;
  }
}

/* Mobile readability pass.
   Toy's in-app WebView may keep a portrait viewport even after the Screen
   Orientation request is rejected. In that case use a real vertical document
   flow, rather than stacking desktop-positioned controls on top of each other. */
@media (orientation: portrait) and (pointer: coarse) {
  html.qsd-mobile-portrait-fallback #mainMenuOverlay,
  html.qsd-mobile-portrait-fallback #mainMenuOverlay .menu-camera-viewport,
  html.qsd-mobile-portrait-fallback #mainMenuOverlay .menu-camera-world,
  html.qsd-mobile-portrait-fallback #mainMenuOverlay .menu-camera-scene--home {
    touch-action: pan-y !important;
    overscroll-behavior: contain;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .menu-camera-scene--home {
    place-items: stretch center !important;
    padding: max(10px, var(--qsd-safe-top)) max(10px, var(--qsd-safe-right)) max(12px, var(--qsd-safe-bottom)) max(10px, var(--qsd-safe-left)) !important;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home {
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 7px !important;
    width: 100% !important;
    height: 100% !important;
    padding: 8px 0 max(22px, var(--qsd-safe-bottom)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-title {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    flex: 0 0 auto !important;
    width: min(90vw, 430px) !important;
    height: clamp(104px, 18dvh, 154px) !important;
    max-width: 90vw !important;
    margin: 0 auto !important;
    transform: rotate(var(--main-menu-logo-angle)) !important;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-version {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    flex: 0 0 auto !important;
    margin: -5px auto 2px !important;
    transform: none !important;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-actions {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    flex: 0 0 auto !important;
    width: min(82vw, 360px) !important;
    max-width: 360px !important;
    margin: 0 auto !important;
    gap: 6px !important;
    transform: none !important;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button,
  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.primary,
  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.exit {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    border-width: 4px !important;
    font-size: 14px !important;
  }

  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .toy-menu-toast,
  html.qsd-mobile-portrait-fallback #mainMenuOverlay .main-menu-home .main-menu-exit-note {
    position: relative !important;
    flex: 0 0 auto !important;
    width: min(86vw, 390px) !important;
    margin: 2px auto !important;
  }

  /* Portrait character selection becomes a vertically scrollable document.
     The portrait, attributes and descriptions keep readable minimum sizes. */
  #mainMenuOverlay #characterSelectPanel.visible {
    max-width: 100% !important;
    max-height: 100% !important;
  }

  #characterSelectPanel .selection-header {
    flex: 0 0 48px !important;
    min-height: 48px !important;
  }

  #characterSelectPanel .character-selection-body {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(164px, 27dvh) 0 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  #characterSelectPanel .character-stage {
    min-height: 164px !important;
    padding: 0 34px !important;
  }

  #characterSelectPanel .character-card {
    flex-basis: clamp(116px, 34vw, 160px) !important;
    height: min(23dvh, 210px) !important;
  }

  #characterSelectPanel .character-divider { display: none !important; }

  #characterSelectPanel .character-info {
    box-sizing: border-box !important;
    min-height: 0 !important;
    padding: 10px 8px 16px !important;
    overflow: visible !important;
  }

  #characterSelectPanel .character-info-grid {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: clamp(280px, 43dvh, 390px) auto !important;
    gap: 11px !important;
    width: min(94%, 520px) !important;
    margin: 0 auto !important;
  }

  #characterSelectPanel #characterStatsTrayMount {
    width: 100% !important;
    height: 100% !important;
    min-height: 280px !important;
  }

  #characterSelectPanel .shared-stat-tray__list {
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  #characterSelectPanel .shared-stat-tray__row {
    min-height: 30px !important;
    padding: 5px 2px !important;
    font-size: 10px !important;
  }

  #characterSelectPanel .character-description-panel {
    box-sizing: border-box !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    overflow: visible !important;
    border: 3px solid #050505;
    border-radius: 14px;
    background: rgba(48, 52, 58, .88);
  }

  #characterSelectPanel .character-intro-label {
    font-size: 10px !important;
  }

  #characterSelectPanel .character-weapon-detail,
  #characterSelectPanel .character-intro {
    font-size: 11px !important;
    line-height: 1.5 !important;
  }

  #characterSelectPanel .character-info .selection-actions {
    width: min(82vw, 360px) !important;
    margin: 11px auto 0 !important;
  }

  #characterSelectPanel .character-info .selection-actions .main-menu-button {
    min-height: 48px !important;
    font-size: 14px !important;
  }
}

/* On an actual landscape phone, spend the horizontal space on two readable
   columns: character preview at left, full-height stats/descriptions at right. */
@media (orientation: landscape) and (pointer: coarse) and (max-height: 700px) {
  #mainMenuOverlay #characterSelectPanel.visible {
    max-width: 100% !important;
    max-height: 100% !important;
  }

  #characterSelectPanel .selection-header {
    flex: 0 0 44px !important;
    min-height: 44px !important;
  }

  #characterSelectPanel .character-selection-body {
    display: grid !important;
    grid-template-columns: minmax(0, 34%) 0 minmax(0, 66%) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #characterSelectPanel .character-stage {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    padding: 0 32px !important;
  }

  #characterSelectPanel .character-divider { display: none !important; }

  #characterSelectPanel .character-info {
    grid-column: 3 !important;
    grid-row: 1 !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    padding: 5px 7px 4px !important;
    overflow: hidden !important;
  }

  #characterSelectPanel .character-info-grid {
    display: grid !important;
    grid-template-columns: minmax(124px, 36%) minmax(0, 64%) !important;
    gap: 8px !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
  }

  #characterSelectPanel #characterStatsTrayMount,
  #characterSelectPanel .character-description-panel {
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  #characterSelectPanel .shared-stat-tray__list,
  #characterSelectPanel .character-description-panel {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  #characterSelectPanel .shared-stat-tray__row {
    min-height: 26px !important;
    padding: 4px 1px !important;
    gap: 6px !important;
    font-size: 9.5px !important;
  }

  #characterSelectPanel .character-description-panel {
    gap: 7px !important;
    padding: 7px 9px !important;
    border: 3px solid #050505;
    border-radius: 14px;
    background: rgba(48, 52, 58, .88);
  }

  #characterSelectPanel .character-intro-label { font-size: 9px !important; }
  #characterSelectPanel .character-weapon-detail,
  #characterSelectPanel .character-intro {
    font-size: 10px !important;
    line-height: 1.42 !important;
  }

  #characterSelectPanel .character-info .selection-actions {
    width: min(330px, 76%) !important;
    margin: 5px auto 0 !important;
  }

  #characterSelectPanel .character-info .selection-actions .main-menu-button {
    min-height: 42px !important;
    font-size: 12px !important;
  }

  #characterSelectPanel .character-card {
    flex-basis: clamp(108px, 16vw, 170px) !important;
    height: min(52dvh, 235px) !important;
  }
}

/* Toy virtual-landscape fallback.
   Some Bilibili WebViews keep a portrait CSS viewport and expose no native
   orientation API. Rotate the complete game surface clockwise, but size it in
   the pre-transform coordinate system so every scene still receives a real
   landscape canvas. mobile-presentation.js removes this class immediately
   when the host actually rotates. */
@keyframes qsdVirtualLandscapeLogoSineSway {
  0% { transform: translateX(-50%) rotate(-3.8deg); }
  12.5% { transform: translateX(-50%) rotate(-2.7deg); }
  25% { transform: translateX(-50%) rotate(0deg); }
  37.5% { transform: translateX(-50%) rotate(2.7deg); }
  50% { transform: translateX(-50%) rotate(3.8deg); }
  62.5% { transform: translateX(-50%) rotate(2.7deg); }
  75% { transform: translateX(-50%) rotate(0deg); }
  87.5% { transform: translateX(-50%) rotate(-2.7deg); }
  100% { transform: translateX(-50%) rotate(-3.8deg); }
}

@media (orientation: portrait) {
  html.qsd-mobile-virtual-landscape,
  html.qsd-mobile-virtual-landscape body {
    width: 100dvw !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }

  html.qsd-mobile-virtual-landscape body {
    display: block !important;
    padding: 0 !important;
  }

  html.qsd-mobile-virtual-landscape .stage,
  html.qsd-mobile-virtual-landscape .stage.menu-open,
  html.qsd-mobile-virtual-landscape #startupSplash,
  html.qsd-mobile-virtual-landscape #bootLoadingOverlay {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    width: 100dvh !important;
    height: 100dvw !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    aspect-ratio: auto !important;
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: 50% 50% !important;
  }

  html.qsd-mobile-virtual-landscape .stage {
    --qsd-safe-top: env(safe-area-inset-right, 0px);
    --qsd-safe-right: env(safe-area-inset-bottom, 0px);
    --qsd-safe-bottom: env(safe-area-inset-left, 0px);
    --qsd-safe-left: env(safe-area-inset-top, 0px);
    contain: layout paint size !important;
  }

  html.qsd-mobile-virtual-landscape #orientationNotice {
    display: none !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay .menu-camera-scene--home {
    place-items: stretch !important;
    padding: max(6px, var(--qsd-safe-top)) max(8px, var(--qsd-safe-right)) max(6px, var(--qsd-safe-bottom)) max(8px, var(--qsd-safe-left)) !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home {
    --qsd-mobile-task-width: clamp(270px, 42%, 390px);
    --qsd-mobile-content-left-width: calc(100% - var(--qsd-mobile-task-width) - 20px);
    --qsd-mobile-left-center: calc(var(--qsd-mobile-content-left-width) / 2);
    --qsd-mobile-actions-top: clamp(100px, 29%, 116px);
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    overflow: hidden !important;
    touch-action: none !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home .main-menu-title {
    position: absolute !important;
    left: var(--qsd-mobile-left-center) !important;
    top: max(5px, var(--qsd-safe-top)) !important;
    width: min(45%, 400px) !important;
    height: clamp(68px, 23%, 90px) !important;
    max-width: var(--qsd-mobile-content-left-width) !important;
    margin: 0 !important;
    transform: translateX(-50%) rotate(var(--main-menu-logo-angle)) !important;
    transform-origin: 50% 55% !important;
    animation: qsdVirtualLandscapeLogoSineSway 5.6s linear infinite !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home .main-menu-version {
    position: absolute !important;
    left: var(--qsd-mobile-left-center) !important;
    top: clamp(78px, 24%, 96px) !important;
    margin: 0 !important;
    transform: translateX(-50%) !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home .main-menu-actions {
    position: absolute !important;
    left: var(--qsd-mobile-left-center) !important;
    top: var(--qsd-mobile-actions-top) !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: min(45%, 400px) !important;
    max-width: var(--qsd-mobile-content-left-width) !important;
    margin: 0 !important;
    transform: translateX(-50%) !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button,
  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.primary,
  html.qsd-mobile-virtual-landscape #mainMenuOverlay .main-menu-home .main-menu-actions .main-menu-button.exit {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
    padding: 0 8px !important;
    border-width: 4px !important;
    font-size: 13px !important;
  }

  html.qsd-mobile-virtual-landscape #mainMenuOverlay #characterSelectPanel.visible {
    max-width: 100% !important;
    max-height: 100% !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .selection-header {
    flex: 0 0 44px !important;
    min-height: 44px !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-selection-body {
    display: grid !important;
    grid-template-columns: minmax(0, 34%) 0 minmax(0, 66%) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-stage {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 28px !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-divider {
    display: none !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-info {
    grid-column: 3 !important;
    grid-row: 1 !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    padding: 5px 7px 4px !important;
    overflow: hidden !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-info-grid {
    display: grid !important;
    grid-template-columns: minmax(124px, 36%) minmax(0, 64%) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    flex: 1 1 auto !important;
    margin: 0 !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel #characterStatsTrayMount,
  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-description-panel {
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .shared-stat-tray__list,
  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-description-panel {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .shared-stat-tray__row {
    min-height: 25px !important;
    padding: 3px 1px !important;
    gap: 5px !important;
    font-size: 9.5px !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-description-panel {
    gap: 6px !important;
    padding: 7px 9px !important;
    border: 3px solid #050505;
    border-radius: 14px;
    background: rgba(48, 52, 58, .88);
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-intro-label {
    font-size: 9px !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-weapon-detail,
  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-intro {
    font-size: 10px !important;
    line-height: 1.42 !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-info .selection-actions {
    width: min(330px, 76%) !important;
    margin: 5px auto 0 !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-info .selection-actions .main-menu-button {
    min-height: 42px !important;
    font-size: 12px !important;
  }

  html.qsd-mobile-virtual-landscape #characterSelectPanel .character-card {
    flex-basis: clamp(108px, 16%, 170px) !important;
    height: min(52%, 235px) !important;
  }

  html.qsd-mobile-virtual-landscape .toy-leaderboard-panel {
    width: min(1040px, 94%) !important;
    height: 94% !important;
  }

  html.qsd-mobile-virtual-landscape .toy-leaderboard-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}
