:root {
  --bg: #252a3a;
  --panel: rgba(38, 44, 60, 0.92);
  --panel-strong: rgba(43, 49, 66, 0.97);
  --panel-solid: #30364a;
  --border: #65677e;
  --border-gold: #e0b979;
  --text: #f0f3fa;
  --muted: #bac3d6;
  --gold: #f5c358;
  --hp: #e64257;
  --armor: #47b8ff;
  --magic: #b17bff;
  --melee: #ff8c52;
  --ranged: #5be08f;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background: radial-gradient(ellipse at 48% 8%, #53586a 0%, #333a4d 48%, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-shell {
  position: relative;
  width: min(960px, 100vw);
  aspect-ratio: 16 / 10;
  max-height: 100vh;
  border-radius: 8px;
  overflow: hidden;
  border: 4px solid #6c6d80;
  box-shadow: 0 0 0 1px #252b3b, 0 20px 52px rgba(20, 25, 38, 0.45);
  background: #343b50;
}

#game-canvas,
#minimap-canvas,
.pixel-weapon-preview,
.pixel-weapon-hud {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#game-canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg stroke='%230e1018' stroke-width='4' stroke-linecap='square'%3E%3Cline x1='14' y1='2' x2='14' y2='9'/%3E%3Cline x1='14' y1='19' x2='14' y2='26'/%3E%3Cline x1='2' y1='14' x2='9' y2='14'/%3E%3Cline x1='19' y1='14' x2='26' y2='14'/%3E%3C/g%3E%3Cg stroke='%23ffe359' stroke-width='2' stroke-linecap='square'%3E%3Cline x1='14' y1='2' x2='14' y2='9'/%3E%3Cline x1='14' y1='19' x2='14' y2='26'/%3E%3Cline x1='2' y1='14' x2='9' y2='14'/%3E%3Cline x1='19' y1='14' x2='26' y2='14'/%3E%3C/g%3E%3Crect x='12' y='12' width='4' height='4' fill='%230e1018'/%3E%3Crect x='13' y='13' width='2' height='2' fill='%23ffffff'/%3E%3C/svg%3E") 14 14, crosshair;
}

.pixel-weapon-preview {
  width: 64px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.7));
}

.pixel-weapon-hud {
  width: 30px;
  height: 20px;
  object-fit: contain;
}

.hidden {
  display: none !important;
}

/* 状态和武器信息默认放在画布外。 */
#game-shell:has(#hud:not(.hidden)) {
  --hud-top-height: 42px;
  --hud-bottom-height: 42px;
  width: min(960px, 100vw, calc((100dvh - var(--hud-top-height) - var(--hud-bottom-height) - 8px) * var(--arena-ratio, 1.6) + 8px));
  aspect-ratio: auto;
}

#battlefield {
  position: relative;
}

#battlefield-hud {
  --boss-bar-top: 6px;
  --boss-status-offset: 0px;
  container-type: inline-size;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud-top-rail,
.hud-bottom-rail {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  white-space: nowrap;
  background: #292e40;
}

.hud-top-rail {
  position: relative;
  z-index: 2;
  height: var(--hud-top-height);
  border-bottom: 1px solid #565b70;
}

.status-list {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-start: var(--status-inset, 12px);
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: calc(100% - 2 * var(--status-inset, 12px));
  pointer-events: none;
  white-space: normal;
}

.status-list[hidden] {
  display: none;
}

.status-entry {
  pointer-events: auto;
  cursor: help;
  outline: none;
}

.status-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid #6b708598;
  background: #171c29eb;
}

.status-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: conic-gradient(#05070cdf var(--status-elapsed, 0deg), transparent 0);
}

.status-entry:is(:hover, :focus-visible, .is-open) .status-tile {
  border-color: #e0b979;
}

.status-icon {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.status-count {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 1px;
  font: 800 9px/1 "Courier New", monospace;
  color: #fff;
  text-shadow: -1px 0 #111522, 0 1px #111522, 1px 0 #111522;
}

.status-tooltip {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  display: none;
  width: 192px;
  padding: 7px 9px;
  gap: 3px;
  border: 1px solid #777d92;
  background: #1d2333fa;
  color: var(--text);
  box-shadow: 0 4px 12px #10121b85;
  font-size: 11px;
  line-height: 1.45;
  pointer-events: none;
}

.status-entry:is(:hover, :focus-visible, .is-open) .status-tooltip {
  display: grid;
}

.status-list:has(.status-entry:hover) .status-entry:not(:hover):not(.is-open) .status-tooltip {
  display: none;
}

.status-time {
  color: var(--muted);
}

#hud:has(.status-list:not([hidden])) #battlefield-hud {
  --boss-status-offset: 26px;
}

.hud-bottom-rail {
  container-type: inline-size;
  height: var(--hud-bottom-height);
  border-top: 1px solid #565b70;
}

.stat-panel,
.hud-location {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.stat-panel {
  flex: 0 1 320px;
}

.hud-location {
  margin-inline-start: auto;
  gap: 8px;
}

.floor-badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.4px;
}

.gold-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #ffd96e;
  font-weight: 800;
  background: rgba(245, 195, 88, 0.12);
  border: 1px solid rgba(245, 195, 88, 0.28);
  padding: 1px 6px;
  border-radius: 2px;
}

.hud-coin {
  width: 14px;
  height: 12px;
  image-rendering: pixelated;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.bar-label {
  font-size: 12px;
  font-weight: 800;
  width: 15px;
  text-align: center;
  flex-shrink: 0;
}

.hp-label { color: #ff697b; }
.armor-label { color: #67cbff; }

.bar-track {
  position: relative;
  flex: 1;
  height: 16px;
  background: #10131e;
  overflow: hidden;
  border: 2px solid #08090e;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.bar-fill {
  height: 100%;
  transition: width 0.14s steps(8, end);
}

.hp-fill {
  background: repeating-linear-gradient(
    90deg,
    #e63e54 0px,
    #e63e54 11px,
    #c4293e 11px,
    #c4293e 13px
  );
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28);
}

.armor-fill {
  background: repeating-linear-gradient(
    90deg,
    #45b8ff 0px,
    #45b8ff 11px,
    #258cd1 11px,
    #258cd1 13px
  );
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  text-shadow: 0 1px 2px #000;
}

.room-badge {
  font-size: 10px;
  white-space: nowrap;
  color: #cdd5e8;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 2px;
}

.dash-mini {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-width: 62px;
  gap: 4px;
  color: #7ee0ff;
  font-weight: 700;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dash-mini.cooling {
  color: #7c879e;
}

.dash-dot {
  width: 6px;
  height: 6px;
  background: #5ad4ff;
  box-shadow: 0 0 6px rgba(90, 212, 255, 0.7);
  display: inline-block;
}

.dash-mini.cooling .dash-dot {
  background: #4d5568;
  box-shadow: none;
}

/* 顶部居中 BOSS 血条 */
#boss-bar-wrap {
  position: absolute;
  top: calc(var(--boss-bar-top) + var(--boss-status-offset));
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, calc(100% - 32px));
  text-align: center;
}

.boss-name {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  color: #ffe0e7;
  text-shadow: 0 1px 2px #160810, 0 0 3px #160810;
  margin-bottom: 3px;
}

.boss-track {
  position: relative;
  height: 11px;
  background: rgba(20, 9, 16, 0.76);
  border: 1px solid #a24f68;
  overflow: hidden;
}

.boss-fill {
  height: 100%;
  background: linear-gradient(90deg, #b81d46, #ff4769, #ff8f5c);
  transition: width 0.12s ease;
}

.boss-hp-text {
  position: absolute;
  inset: 0;
  font-size: 9px;
  line-height: 1;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 2px #000;
}

.boss-cc-wrap {
  margin-top: 3px;
}

.boss-cc-track {
  position: relative;
  height: 8px;
  background: rgba(18, 15, 22, 0.78);
  border: 1px solid #8a6d3b;
  overflow: hidden;
}

.boss-cc-fill {
  height: 100%;
  background: linear-gradient(90deg, #c98a2c, #f6c95e);
  transition: width 0.08s linear;
}

.boss-cc-wrap.immune .boss-cc-track {
  border-color: #ffe999;
  box-shadow: 0 0 6px rgba(255, 228, 120, 0.45);
}

.boss-cc-wrap.immune .boss-cc-fill {
  background: linear-gradient(90deg, #ffe27a, #fff8d6, #ffd059);
}

.boss-cc-text {
  position: absolute;
  inset: 0;
  font-size: 7.5px;
  line-height: 1;
  font-weight: 800;
  color: #fff6df;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 2px #000;
}

@container (max-width: 560px) {
  #boss-bar-wrap {
    left: 10px;
    width: min(280px, calc(100% - var(--boss-map-space, 146px)));
    transform: none;
  }

  .boss-name {
    font-size: 11px;
  }
}

/* ==================== 右上角：紧凑可展开小地图 ==================== */
.hud-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.minimap-box {
  pointer-events: auto;
  cursor: pointer;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 4px;
  padding: 4px 5px 5px;
  box-shadow: 2px 3px 7px rgba(22, 27, 43, 0.32);
  transition: border-color 0.14s, background 0.14s;
}

.minimap-box:hover {
  border-color: var(--border-gold);
  background: var(--panel-strong);
}

.minimap-box.expanded {
  border-color: var(--border-gold);
  background: var(--panel-strong);
  padding: 6px 7px;
  box-shadow: 2px 3px 8px rgba(22, 27, 43, 0.38);
}

.minimap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  padding: 0 2px;
}

.minimap-title {
  font-size: 10px;
  font-weight: 800;
  color: #b7c1d9;
  letter-spacing: 0.4px;
}

.minimap-box.expanded .minimap-title {
  color: var(--gold);
}

.minimap-toggle-icon {
  font-size: 10px;
  color: var(--muted);
  line-height: 1;
}

.minimap-box:hover .minimap-toggle-icon {
  color: var(--gold);
}

#minimap-canvas {
  display: block;
  border: 1px solid #455064;
  background: #272e40;
}

.minimap-legend {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
  padding: 5px 2px 1px;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 3px;
}

.dot-cur { background: #fff; border: 1px solid #f5c358; }
.dot-combat { background: #e64c5f; }
.dot-hard-combat { background: #d061bc; }
.dot-shop { background: #f2be47; }
.dot-portal { background: #7868ff; }

.hud-actions {
  display: flex;
  gap: 5px;
  pointer-events: auto;
}

.icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 2px;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(22, 27, 43, 0.32);
  transition: transform 0.1s, border-color 0.12s;
}

.icon-btn:hover {
  border-color: var(--border-gold);
  transform: translate(-1px, -1px);
}

/* 底栏装备和冷却计时器 */
.weapon-dock,
.cooldown-dock,
.cooldown-slot {
  display: flex;
  align-items: center;
  min-width: 0;
}

.weapon-dock {
  flex: none;
  min-width: max-content;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
}

#hud-weapon-name {
  flex: none;
}

.cooldown-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.weapon-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 25px;
  border-radius: 2px;
  background: #171b28;
  border: 1px solid #46506a;
}

.cooldown-dock {
  --clock-size: 20px;
  --clock-gap: 10px;
  --clock-dock-inset: 0px;
  min-width: calc(2 * var(--clock-size) + var(--clock-gap) + 2 * var(--clock-dock-inset));
  gap: var(--clock-gap);
  margin-inline-start: 4px;
  margin-inline-end: auto;
  padding-inline: var(--clock-dock-inset);
}

.cooldown-slot {
  min-width: var(--clock-size);
  gap: 6px;
}

.cooldown-name {
  max-inline-size: 9em;
  color: #ccd3e5;
  font-size: 11px;
  font-weight: 700;
}

.cooldown-clock {
  --cooldown-fill: 0%;
  --cooldown-empty: #1b2132;
  position: relative;
  flex: none;
  width: var(--clock-size);
  height: var(--clock-size);
  display: grid;
  place-content: center;
  text-align: center;
  border: 1px solid #7d7358;
  border-radius: 2px;
  background: conic-gradient(var(--gold) var(--cooldown-fill), var(--cooldown-empty) 0);
  color: #fff7db;
  font-weight: 800;
  line-height: 1;
  paint-order: stroke fill;
  -webkit-text-stroke: 1.5px #1b2132;
}

.cooldown-value {
  font-size: 8.5px;
  font-variant-numeric: tabular-nums;
}

.cooldown-clock.ready {
  background: var(--gold);
  border-color: #ffe5a6;
  color: #292018;
  -webkit-text-stroke: 0;
}

.cooldown-clock.has-charge {
  border-color: #ffe5a6;
  box-shadow: 0 0 0 1px rgba(255, 229, 166, 0.35);
}

.core-charge-pips {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  -webkit-text-stroke: 0;
  pointer-events: none;
}

.core-charge-pips[hidden] {
  display: none;
}

.core-charge-pip {
  display: block;
  width: 5px;
  height: 3px;
  background: #1b2132;
  border: 1px solid #6b748d;
}

.core-charge-pips.compact {
  gap: 1px;
}

.core-charge-pips.compact .core-charge-pip {
  width: 4px;
}

.core-charge-pips.dense .core-charge-pip {
  width: 3px;
}

.core-charge-pip.filled {
  background: #ffd452;
  border-color: #fff2b2;
  box-shadow: 0 0 3px rgba(255, 212, 82, 0.55);
}

.core-charge-pips.numeric {
  top: calc(100% + 1px);
  color: #ffe5a6;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #1b2132;
}

.cooldown-clock.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: #fff2ab;
  box-shadow: 0 0 0 2px #fff2ab, 0 0 10px 3px #ffc849;
  pointer-events: none;
  animation: cooldown-ready-flash 0.45s ease-out both;
}

@keyframes cooldown-ready-flash {
  from { opacity: 0.95; }
  to { opacity: 0; }
}

#hud-core-icon {
  flex: none;
  width: 21px;
  height: 21px;
  image-rendering: pixelated;
}

#pause-core-active:empty,
#pause-core-passive:empty {
  display: none;
}

.weapon-tag {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 800;
}

.tag-melee { background: rgba(255, 140, 82, 0.22); color: var(--melee); }
.tag-ranged { background: rgba(91, 224, 143, 0.2); color: var(--ranged); }
.tag-magic { background: rgba(177, 123, 255, 0.22); color: var(--magic); }

.help-anchor {
  position: relative;
  flex: none;
  pointer-events: auto;
  display: inline-flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.help-badge {
  width: 26px;
  height: 26px;
  border-radius: 2px;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--gold);
  font-family: "Courier New", monospace;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 rgba(7, 8, 13, 0.9);
  transition: border-color 0.14s, background 0.14s, transform 0.12s;
}

.help-anchor:hover .help-badge {
  border-color: var(--gold);
  background: var(--panel-strong);
  transform: translate(-1px, -1px);
}

.help-popover {
  position: absolute;
  bottom: 34px;
  right: 0;
  width: 224px;
  background: rgba(13, 16, 26, 0.96);
  border: 2px solid var(--border-gold);
  border-radius: 2px;
  padding: 9px 11px;
  box-shadow: 4px 4px 0 rgba(5, 6, 10, 0.95);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.help-anchor:is(:hover, :focus-within, .is-open) .help-popover {
  opacity: 1;
  transform: translateY(0);
}

.help-pop-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.6px;
  padding-bottom: 5px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #d6ddf0;
  margin-bottom: 5px;
}

.help-row span {
  white-space: normal;
}

.help-row:last-child {
  margin-bottom: 0;
}

.help-row span {
  color: #b7c2da;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ==================== 房内选择、交互提示与横幅 ==================== */
.room-choice {
  --choice-width: min(330px, calc(100% - 16px));
  --choice-bottom: max(var(--choice-y), var(--choice-min-bottom, 60px));
  position: absolute;
  z-index: 1;
  left: clamp(calc(8px + var(--choice-width) / 2), var(--choice-x), calc(100% - 8px - var(--choice-width) / 2));
  top: var(--choice-bottom);
  width: var(--choice-width);
  max-height: calc(var(--choice-bottom) - 5px);
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  pointer-events: auto;
  background: #302a3de8;
  border: 1px solid #83718f;
  border-radius: 4px;
}

.room-choice::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  background: inherit;
  border-right: 1px solid #83718f;
  border-bottom: 1px solid #83718f;
  pointer-events: none;
}

.room-choice h2 {
  flex: none;
  padding: 0 4px;
  color: #f4dfa8;
  font-size: 14px;
  line-height: 1.25;
}

.room-choice-buttons {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow: auto;
}

.room-choice-buttons:empty {
  display: none;
}

.room-choice.merchant-choice {
  --choice-width: min(260px, calc(100% - 16px));
  text-align: center;
}

.room-choice.merchant-choice .room-choice-option {
  text-align: center;
}

.room-choice button {
  border: 1px solid #655672;
  border-radius: 2px;
  color: var(--text);
  background: #352d41;
  font-family: inherit;
  cursor: pointer;
}

.room-choice button:is(:hover, :focus-visible):not(:disabled) {
  outline: 1px solid currentColor;
  outline-offset: -2px;
  filter: brightness(1.2);
}

.room-choice button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.room-choice-option {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 4px 7px;
  text-align: left;
}

.room-choice-option strong {
  color: #f4eafd;
  font-size: 12px;
  line-height: 1.25;
}

.room-choice-option small {
  color: #cdc2dc;
  font-size: 10px;
  line-height: 1.35;
}

.room-choice.portal-choice {
  --choice-width: min(224px, calc(100% - 16px));
  text-align: center;
}

.portal-choice .room-choice-buttons {
  grid-template-columns: repeat(2, 48px);
  justify-content: center;
  gap: 8px;
}

.room-choice .portal-choice-button {
  height: 34px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.room-choice .portal-choice-button.cancel {
  color: #ffb0b4;
  background: #632c39;
  border-color: #a75867;
}

.room-choice .portal-choice-button.confirm {
  color: #a8f7bd;
  background: #24553d;
  border-color: #4a956b;
}

@container (max-width: 580px) {
  .room-choice {
    --choice-width: min(406px, calc(100% - 16px));
    gap: 4px;
    padding: 4px 5px;
  }

  .room-choice h2 {
    font-size: 12px;
  }

  .room-choice:not(.portal-choice, .boss-relic-choice) .room-choice-buttons {
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  }

  .room-choice-option {
    padding: 4px;
  }

  .room-choice-option strong {
    font-size: 11px;
  }

  .room-choice.portal-choice {
    --choice-min-bottom: 53px;
    gap: 2px;
    padding-block: 2px;
  }

  .room-choice .portal-choice-button {
    height: 25px;
    font-size: 19px;
  }
}

@container (max-width: 340px) {
  .room-choice:not(.portal-choice) {
    gap: 3px;
    padding-block: 3px;
  }

  .room-choice:not(.portal-choice) h2 {
    font-size: 11px;
  }

  .room-choice:not(.portal-choice, .boss-relic-choice) .room-choice-buttons:has(> :nth-child(3):last-child) {
    grid-template-columns: minmax(0, 1.45fr) repeat(2, minmax(0, 1fr));
  }

  .room-choice-option {
    padding-block: 2px;
  }

  .room-choice-option small {
    line-height: 1.2;
  }
}

.room-choice.boss-relic-choice {
  --choice-width: min(460px, calc(100% - 16px));
  --choice-bottom: clamp(min(166px, calc(100% - 9px)), var(--choice-y), calc(100% - 9px));
  background: #2b241c;
  border-color: #b98c4c;
  text-align: center;
}

.boss-relic-choice::after {
  border-color: #b98c4c;
}

.boss-relic-choice .room-choice-buttons {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}

.boss-relic-choice button {
  justify-items: center;
  gap: 4px;
  padding: 5px;
  color: #ffdb8d;
  background: #392d21;
  border-color: #735335;
  text-align: center;
}

.boss-relic-choice .relic-icon {
  width: clamp(24px, 10cqw, 40px);
  height: auto;
  margin: 0;
}

.boss-relic-choice .room-choice-option strong { color: #ffebbf; }
.boss-relic-choice .room-choice-option small { color: #e0cdb4; }

#interact-tooltip {
  position: absolute;
  width: max-content;
  max-width: min(280px, calc(100% - 12px));
  padding: 3px 7px;
  background: #30384ae8;
  border: 1px solid #788399;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.tip-heading,
.tip-name {
  display: flex;
  align-items: center;
}

.tip-heading {
  justify-content: space-between;
  gap: 10px;
}

.tip-name {
  gap: 4px;
}

.tip-icon {
  flex: none;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.tip-title {
  color: var(--tip-accent, #fff1d0);
}

.tip-detail {
  margin-top: 2px;
  font-size: 10px;
  color: #dde5f4;
}

.tip-detail:empty {
  display: none;
}

.tip-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #cbedc9;
  white-space: nowrap;
}

.tip-action kbd {
  padding: 0 4px;
}

#interact-tooltip.unavailable .tip-action {
  color: #fad1b4;
}

#banner-toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(340px, calc(100% - 16px));
  padding: 3px 9px;
  background: #343d50db;
  border: 1px solid #aa916a;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  color: #fff1d0;
  text-align: center;
  animation: fadeSlideDown 0.18s ease;
}

#boss-bar-wrap:not(.hidden) ~ #banner-toast {
  top: max(56px, calc(var(--boss-bar-top) + var(--boss-status-offset) + 34px));
}

#boss-bar-wrap:not(.hidden):has(#boss-cc-wrap:not(.hidden)) ~ #banner-toast {
  top: max(68px, calc(var(--boss-bar-top) + var(--boss-status-offset) + 46px));
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==================== 全屏叠层 ==================== */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(54, 58, 78, 0.88), rgba(33, 38, 53, 0.96));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 30px;
  z-index: 20;
  backdrop-filter: blur(5px);
}

.menu-screen {
  display: block;
  overflow-y: auto;
  padding: 0;
  backdrop-filter: none;
}

.menu-screen :is(button, summary):focus-visible {
  outline: 2px solid #fff3c5;
  outline-offset: 4px;
}

.home-screen {
  isolation: isolate;
  background: #32384d;
}

#home-backdrop,
.home-screen::before {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#home-backdrop {
  z-index: -2;
  object-fit: cover;
  object-position: 72% center;
  image-rendering: pixelated;
}

.home-screen::before {
  content: "";
  z-index: -1;
  background:
    linear-gradient(90deg, #303649 4%, #303649ed 30%, #3036492e 61%, #30364900 78%),
    linear-gradient(0deg, #272b3d77, transparent 32%, transparent 83%, #272b3d35);
}

.home-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(32px, 6vh, 54px);
  padding: clamp(24px, 6vw, 66px);
}

.home-heading h1 {
  margin-bottom: 26px;
  color: #fff1c7;
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  font-size: clamp(42px, 8vw, 76px);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-shadow: 0 3px 0 #292637, 0 0 24px #f6c99738;
}

.home-heading {
  max-width: 100%;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-actions .primary-btn {
  width: 186px;
  padding-inline: 18px;
}

.home-actions .catalog-button {
  display: grid;
  flex: 0 0 54px;
  height: 44px;
  place-items: center;
  padding: 0;
  border-color: #a99071;
  background: #414155;
  color: #f0cc80;
}

.home-actions .catalog-button:hover {
  border-color: #ebbc6a;
  background: #50485a;
}

.book-icon {
  position: relative;
  width: 26px;
  height: 18px;
}

.book-icon::before,
.book-icon::after {
  content: "";
  position: absolute;
  top: 1px;
  width: 13px;
  height: 16px;
  border: 2px solid currentColor;
  background:
    linear-gradient(currentColor, currentColor) center 4px / 6px 1px no-repeat,
    linear-gradient(currentColor, currentColor) center 8px / 6px 1px no-repeat;
}

.book-icon::before {
  left: 0;
  transform: skewY(10deg);
}

.book-icon::after {
  right: 0;
  transform: skewY(-10deg);
}

.release-notes {
  width: min(365px, 100%);
  max-height: 190px;
  overflow-y: auto;
  background: #313749e8;
  border: 1px solid #676679;
  border-left: 3px solid #d8b07c;
  padding: 14px 17px;
}

.release-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.release-header h2 {
  color: #f4e7cc;
  font-size: 14px;
}

.game-version {
  color: var(--gold);
  font: 700 12px ui-monospace, monospace;
}

#release-history {
  color: #b9bdd1;
  font-size: 13px;
  line-height: 1.65;
}

#release-history ul {
  padding-inline-start: 1.25em;
}

#release-history details {
  margin-top: 8px;
}

#release-history summary {
  color: #e3c486;
  cursor: pointer;
}

.character-screen,
.catalog-screen {
  background:
    radial-gradient(ellipse at 50% 34%, #494b62 0%, #393e54 55%, #30364a 100%);
}

.character-content {
  min-height: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding: clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

.menu-header {
  display: flex;
  align-items: center;
  gap: 18px;
}

.menu-header h2 {
  color: #fff1c7;
  font-size: clamp(24px, 4vw, 36px);
}

.menu-header h2:focus {
  outline: none;
}

.menu-header .secondary-btn {
  padding: 7px 11px;
  font-size: 12px;
}

#btn-catalog-menu {
  margin-inline-start: auto;
  width: 32px;
  height: 32px;
}

.catalog-menu-icon {
  width: 14px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -5px currentColor, 0 5px currentColor;
}

/* 解锁后的工具悬浮于场景和菜单之上。 */
.developer-tools {
  --developer-top: 7px;
  position: absolute;
  top: var(--developer-top);
  right: 12px;
  z-index: 24;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  width: min(314px, calc(100% - 24px));
  max-height: calc(100% - var(--developer-top) - 8px);
  pointer-events: none;
}

#game-shell:has(#developer-tools:not(.hidden)) .hud-actions {
  margin-inline-end: 31px;
}

#btn-developer-tools {
  flex: 0 0 auto;
  color: #f4d192;
  font: 800 12px monospace;
  pointer-events: auto;
}

#btn-developer-tools[aria-expanded="true"] {
  border-color: var(--border-gold);
}

.developer-panel {
  min-height: 0;
  width: 100%;
  padding: 10px 12px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  pointer-events: auto;
  color: #e7ecfa;
  background: #24293a;
  border: 1px solid #b98c55;
  border-radius: 3px;
  box-shadow: 3px 4px 0 rgba(6, 8, 14, 0.65);
  font-size: 12px;
}

.developer-header,
.developer-pages,
.developer-row,
.developer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.developer-header {
  justify-content: space-between;
  gap: 10px;
}

.developer-header h2 {
  color: #ffe1a5;
  font-size: 14px;
  white-space: nowrap;
}

#developer-equipped-core,
#developer-context,
#developer-seed {
  color: #b3bfd5;
  font-size: 11px;
}

.developer-pages {
  margin: 8px 0;
  padding-bottom: 7px;
  border-bottom: 1px solid #4b5369;
}

.developer-pages button {
  flex: 1;
}

.developer-panel :is(button, select, input[type="number"]) {
  min-height: 27px;
  padding: 3px 6px;
  color: inherit;
  background: #333a50;
  border: 1px solid #5b667f;
  border-radius: 2px;
  color-scheme: dark;
  font: inherit;
}

.developer-panel button {
  cursor: pointer;
  white-space: nowrap;
}

.developer-panel button[aria-pressed="true"],
.developer-panel button:not(:disabled):hover {
  color: #ffe1a5;
  border-color: #b78d54;
  background: #4a3c37;
}

.developer-panel :is(button, input, select):focus-visible,
#btn-developer-tools:focus-visible {
  outline: 2px solid #ffe1a5;
  outline-offset: 1px;
}

.developer-panel :disabled {
  opacity: 0.6;
}

#developer-controls {
  min-inline-size: 0;
  border: 0;
}

.developer-group {
  display: grid;
  gap: 7px;
}

.developer-row label {
  flex: 0 0 auto;
}

.developer-row select,
#developer-equipped {
  flex: 1;
  min-width: 0;
}

.developer-actions {
  flex-wrap: wrap;
}

.developer-check {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  cursor: pointer;
}

#developer-stacks {
  width: 48px;
}

#developer-feedback:not(:empty) {
  margin-top: 8px;
  color: #c6dfa8;
}

@media (max-width: 600px) {
  #game-shell:has(#hud:not(.hidden)) .developer-tools {
    --developer-top: 32px;
    right: 9px;
  }
}

@media (max-height: 690px) and (min-aspect-ratio: 8/5), (max-height: 300px) {
  #game-shell:has(#hud:not(.hidden)) .developer-tools {
    --developer-top: 4px;
    right: 6px;
  }
}

.catalog-content {
  height: 100%;
  display: grid;
  grid-template: auto auto minmax(0, 1fr) / minmax(0, 1fr);
  gap: 14px;
  padding: clamp(16px, 4vw, 38px) clamp(14px, 5vw, 48px) 0;
}

.catalog-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #494458;
}

.catalog-tabs [role="tab"] {
  flex: 0 1 86px;
  min-width: 0;
  padding: 8px clamp(8px, 3vw, 16px);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: #b9bdd1;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.catalog-tabs [role="tab"]:hover,
.catalog-tabs [aria-selected="true"] {
  background: #342d3c;
  color: #fff1c7;
}

.catalog-tabs [aria-selected="true"] {
  border-bottom-color: #edbe69;
}

.catalog-scroll {
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 2px 5px 24px 1px;
}

.catalog-scroll:focus-visible {
  outline: 1px solid #edbe69;
  outline-offset: -1px;
}

.catalog-content:has(.catalog-weapon-panel:not(.hidden)) {
  gap: 11px;
  padding-top: clamp(14px, 3vw, 24px);
}

.catalog-weapon-panel {
  display: grid;
  grid-template-columns: clamp(164px, 27%, 226px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  padding-bottom: 14px;
  scrollbar-color: #777e98 #222737;
  scrollbar-width: thin;
}

.catalog-weapon-list,
.catalog-weapon-detail {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid #62677d;
  border-radius: 4px;
  background: #292e40;
}

.catalog-weapon-list {
  padding: 9px;
}

.catalog-weapon-group + .catalog-weapon-group {
  margin-top: 12px;
}

.catalog-weapon-group h3 {
  margin-bottom: 4px;
  padding: 3px 5px;
  color: var(--weapon-rarity);
  font-size: 12px;
  font-weight: 650;
}

.catalog-weapon-group ul {
  display: grid;
  gap: 4px;
  list-style: none;
}

.catalog-weapon-choice {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 43px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-inline-start: 2px solid transparent;
  border-radius: 3px;
  background: #343a50;
  color: #e5e7f0;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: start;
  cursor: pointer;
}

.catalog-weapon-choice:hover {
  background: #444b63;
}

.catalog-weapon-choice[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--weapon-rarity) 40%, #575d75);
  border-inline-start-color: var(--weapon-rarity);
  background: color-mix(in srgb, var(--weapon-rarity) 15%, #363c53);
  color: #fff5df;
}

.catalog-weapon-list .catalog-weapon-choice:focus-visible,
.catalog-weapon-detail:focus-visible {
  outline: 2px solid #fff3c5;
  outline-offset: -2px;
}

.catalog-weapon-thumb {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: 48px;
  height: 30px;
  color: var(--weapon-rarity);
  font-size: 16px;
}

.catalog-weapon-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(1px 2px 0 #161b27a8);
}

.catalog-weapon-detail {
  padding: 12px;
}

.catalog-weapon-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(95px, 35%);
  align-items: center;
  gap: 8px;
  min-height: 104px;
  padding: 12px 16px;
  border: 1px solid #62677d;
  border-radius: 3px;
  background:
    radial-gradient(ellipse at 86% 50%, color-mix(in srgb, var(--weapon-rarity) 23%, transparent), transparent 61%),
    repeating-linear-gradient(90deg, #afb9de0c 0 1px, transparent 1px 16px),
    repeating-linear-gradient(#afb9de0c 0 1px, transparent 1px 16px),
    #353b51;
}

.catalog-weapon-identity h3 {
  color: #fff1d1;
  font-size: clamp(21px, 3vw, 30px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.catalog-weapon-tags,
.catalog-weapon-origin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 7px;
}

.catalog-weapon-rarity {
  border: 1px solid color-mix(in srgb, var(--weapon-rarity) 35%, #41465d);
  background: #262b3b;
  color: var(--weapon-rarity);
}

.catalog-weapon-origin {
  color: #f1e0b7;
  font-size: 12px;
}

.catalog-weapon-origin dt,
.catalog-weapon-stats dt,
.catalog-weapon-max-stats dt {
  color: #bfc7dd;
}

.catalog-weapon-art {
  display: grid;
  place-items: center;
  min-width: 0;
}

.catalog-weapon-art .catalog-weapon-thumb {
  /* 预览图在留白内等比缩放，留出的边距同时容纳阴影。 */
  width: min(100%, 148px);
  height: 72px;
  padding: 8px;
  overflow: hidden;
  font-size: 38px;
}

.catalog-weapon-art img {
  filter: drop-shadow(2px 5px 0 #151b2990);
}

.catalog-weapon-stats,
.catalog-weapon-max-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 9px;
  font-size: 12px;
}

.catalog-weapon-stats div,
.catalog-weapon-max-stats div {
  padding: 6px 8px;
  border: 1px solid #4d566f;
  border-radius: 3px;
  background: #30364a;
}

.catalog-weapon-stats dd,
.catalog-weapon-max-stats dd {
  margin-top: 3px;
  color: #f5e6bf;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

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

.catalog-weapon-info {
  padding: 9px 11px;
  border: 1px solid #505971;
  border-radius: 3px;
  background: #343a50;
}

.catalog-weapon-info h4 {
  color: #eecd8d;
  font-size: 13px;
}

.catalog-weapon-skill-name {
  margin-inline-start: 5px;
  color: #f3eee0;
}

.catalog-weapon-info p {
  margin-top: 6px;
  color: #e0e4f1;
  font-size: 13px;
  line-height: 1.6;
}

.catalog-weapon-max,
.catalog-weapon-passive {
  margin-top: 8px;
}

.catalog-weapon-max {
  border-color: color-mix(in srgb, var(--weapon-rarity) 35%, #505971);
}

.catalog-weapon-max-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .catalog-weapon-moves {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-height: 430px) {
  .catalog-content:has(.catalog-weapon-panel:not(.hidden)) {
    gap: 8px;
    padding-top: 10px;
  }

  .catalog-content:has(.catalog-weapon-panel:not(.hidden)) .menu-header h2 {
    font-size: 24px;
  }
}

@media (max-width: 560px) {
  .catalog-weapon-panel {
    grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
    gap: 8px;
    padding-bottom: 8px;
  }

  .catalog-weapon-list {
    display: flex;
    gap: 10px;
    overflow: auto hidden;
    scrollbar-gutter: auto;
    padding: 4px 6px 6px;
  }

  .catalog-weapon-group + .catalog-weapon-group {
    margin-top: 0;
  }

  .catalog-weapon-group h3 {
    margin-bottom: 2px;
  }

  .catalog-weapon-group ul {
    display: flex;
  }

  .catalog-weapon-choice {
    display: flex;
    gap: 3px;
    min-height: 40px;
    padding-inline: 4px 7px;
    white-space: nowrap;
  }

  .catalog-weapon-choice .catalog-weapon-thumb {
    width: 39px;
    height: 26px;
  }

  .catalog-weapon-detail {
    padding: 8px;
  }

  .catalog-weapon-hero {
    min-height: 90px;
    padding: 8px 10px;
  }

  .catalog-weapon-art .catalog-weapon-thumb {
    height: 60px;
    padding: 6px;
  }

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

.catalog-enemy-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.catalog-map-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: #3c4056;
  border: 1px solid #515770;
  border-radius: 3px;
  color: #e1d6bc;
  font-size: 13px;
}

.catalog-map-filter select {
  flex: 0 1 155px;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid #706b7e;
  border-radius: 3px;
  background: #30354a;
  color: #fff1c7;
  color-scheme: dark;
  font: inherit;
}

.catalog-map-filter select:focus-visible {
  outline: 1px solid #edbe69;
  outline-offset: 2px;
}

.catalog-empty {
  color: var(--muted);
  font-size: 13px;
}

.catalog-groups {
  display: grid;
  align-content: start;
  gap: 24px;
}

.catalog-group,
.catalog-tier {
  display: grid;
  gap: 10px;
}

.catalog-group-title {
  padding: 2px 2px 6px;
  border-bottom: 1px solid #626881;
  color: #f3d6a0;
  font-size: 16px;
}

.catalog-tier + .catalog-tier {
  margin-top: 6px;
}

.catalog-tier .catalog-group-title {
  border: 0;
  padding-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 12px;
  list-style: none;
}

.catalog-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid #626881;
  border-radius: 3px;
  background: #343a50;
  box-shadow: 2px 3px 5px #242a3b66;
}

.catalog-portrait {
  --portrait-tint: #aaa1bc;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid #62627c;
  border-radius: 2px;
  background: #3c4057;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--portrait-tint) 24%, #3c4057), #33394e);
  color: var(--portrait-tint);
  font-size: 22px;
}

.catalog-portrait img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  image-rendering: pixelated;
}

.catalog-item-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.catalog-item-name {
  color: #f6ebd0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.catalog-type {
  white-space: nowrap;
}

.catalog-rarity {
  background: #222639aa;
  white-space: nowrap;
}

.catalog-description {
  margin-top: 6px;
  color: #bdc5dc;
  font-size: 12px;
  line-height: 1.55;
}

.catalog-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  color: #eece91;
  font-size: 11px;
  line-height: 1.4;
}

.catalog-stats div {
  display: flex;
  gap: 4px;
}

.catalog-stats dt {
  color: var(--muted);
}

.character-loadout {
  display: grid;
  grid-template-columns: minmax(124px, 1fr) minmax(0, 4fr);
  gap: 18px;
}

.character-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  align-self: stretch;
  padding: 15px;
  border: 2px solid #907443;
  border-radius: 3px;
  background: radial-gradient(circle at 50% 48%, #5a526b, #3a3c51 74%);
  box-shadow: 2px 4px 10px #242a3b66;
}

#character-portrait {
  width: 112px;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 5px 0 #100e1ab5);
}

.character-profile h3 {
  color: #fff1c7;
  font-size: 18px;
}

.weapon-select-title {
  font-size: 14px;
  font-weight: 700;
  color: #e3e8f5;
  margin-bottom: 12px;
}

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

.starter-card {
  background: #343c51;
  border: 1px solid #686f87;
  border-radius: 4px;
  padding: 10px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.starter-card:hover {
  transform: translate(-1px, -2px);
  border-color: #9e8a62;
}

.starter-card[aria-pressed="true"] {
  border-color: var(--gold);
  background: #3e4357;
}

.starter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.starter-icon {
  font-size: 26px;
}

.starter-name {
  font-size: 17px;
  font-weight: 800;
}

.starter-desc {
  font-size: 12px;
  color: #bac4db;
  line-height: 1.5;
  flex: 1;
}

.starter-skill {
  font-size: 11px;
  color: #f4d898;
  line-height: 1.45;
}

.starter-stats {
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 4px 10px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 7px;
}

.starter-stats span:last-child {
  grid-column: 1 / -1;
}

.character-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.key-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 600px) {
  #game-shell:has(#hud:not(.hidden)) {
    --hud-top-height: 63px;
  }

  .hud-top-rail {
    --status-inset: 9px;
    display: grid;
    grid-template: 25px 25px / minmax(0, 1fr) auto;
    gap: 3px 8px;
    padding: 4px 9px;
  }

  .stat-panel {
    grid-column: 1 / -1;
    gap: 8px;
  }

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

  .hud-actions {
    justify-self: end;
  }

  .hud-bottom-rail {
    gap: 7px;
    padding-inline: 9px;
  }

  #boss-bar-wrap {
    --boss-map-space: 118px;
  }

  .minimap-box:not(.expanded) #minimap-canvas {
    width: 78px;
    height: auto;
  }
}

@container (max-width: 420px) {
  .cooldown-name,
  #hud-core-icon {
    display: none;
  }

  .cooldown-dock {
    --clock-gap: 7px;
    margin-inline-start: 0;
  }

  .weapon-dock {
    font-size: 12px;
  }
}

@container (max-width: 310px) {
  .dash-mini {
    min-width: 0;
  }

  #hud-dash-text {
    position: absolute;
    clip-path: inset(50%);
  }
}

@container (max-width: 245px) {
  .weapon-dock .weapon-icon {
    display: none;
  }
}

/* 矮的横向窗口将紧凑状态条停靠在墙边。 */
@media (max-height: 690px) and (min-aspect-ratio: 8/5), (max-height: 300px) {
  #game-shell:has(#hud:not(.hidden)) {
    --hud-top-height: 0px;
    --hud-bottom-height: 0px;
  }

  .hud-top-rail,
  .hud-bottom-rail {
    position: absolute;
    left: 6px;
    right: 6px;
    z-index: 2;
    display: flex;
    height: auto;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
  }

  .hud-top-rail {
    --status-inset: 5px;
    top: 4px;
  }
  .hud-bottom-rail { bottom: 4px; }

  .stat-panel,
  .weapon-dock,
  .cooldown-dock,
  .dash-mini {
    padding: 3px 5px;
    border-radius: 2px;
    background: rgba(24, 28, 40, 0.84);
  }

  .cooldown-dock {
    --clock-dock-inset: 5px;
    margin-inline-start: 0;
    padding-inline: var(--clock-dock-inset);
  }

  .cooldown-dock.has-charge-pips {
    padding-bottom: 8px;
  }

  .stat-panel {
    flex: 0 1 240px;
    gap: 6px;
  }

  .hud-location,
  .cooldown-name,
  #hud-core-icon {
    display: none;
  }

  .hud-actions {
    margin-inline-start: auto;
  }

  #battlefield-hud {
    --boss-bar-top: 33px;
  }

  .hud-top-right {
    top: 33px;
  }
}

@media (max-width: 660px) {
  #game-shell:has(.menu-screen:not(.hidden)) {
    aspect-ratio: auto;
    height: min(100dvh, 600px);
  }

  .home-screen::before {
    background: linear-gradient(90deg, #303649e8, #30364969);
  }

  .character-content {
    gap: 18px;
  }

  .character-loadout {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-profile {
    flex-direction: row;
    justify-content: flex-start;
    padding: 10px 14px;
  }

  #character-portrait {
    width: 64px;
  }
}

@media (max-width: 500px) {
  .character-screen {
    scroll-padding-bottom: 80px;
  }

  .character-content {
    padding-bottom: 0;
  }

  .weapon-cards-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-footer {
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding: 12px 0;
    background: #33384b;
  }

  .character-footer .key-guide {
    display: none;
  }

  .character-footer .primary-btn {
    width: 100%;
  }
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 3px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.1s, filter 0.12s, background 0.12s;
}

.primary-btn {
  padding: 11px 40px;
  font-size: 16px;
  color: #191308;
  background: linear-gradient(180deg, #ffda88, #efb956);
  border: 3px solid #ffe5a5;
  box-shadow: 0 3px 0 #96643e, 0 5px 12px #20253875;
}

.primary-btn:hover {
  transform: translate(-1px, -2px);
  filter: brightness(1.06);
}

.primary-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 1px 2px #20253875;
}

.secondary-btn {
  padding: 10px 22px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.09);
  border: 2px solid #68718a;
  box-shadow: 0 2px 6px #24293c65;
}

.secondary-btn:hover {
  border-color: var(--border-gold);
  background: rgba(255, 255, 255, 0.14);
}

/* 弹窗卡片 */
.modal-card {
  width: min(490px, 90%);
  background: var(--panel-solid);
  border: 3px solid var(--border-gold);
  border-radius: 3px;
  padding: 22px 24px;
  text-align: center;
  box-shadow: 6px 6px 0 rgba(5, 6, 10, 0.92);
}

#pause-overlay {
  padding: 12px;
}

#pause-overlay .modal-card {
  width: min(460px, 100%);
  max-height: 100%;
  overflow: auto;
}

.pause-loadout {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  text-align: left;
}

.pause-loadout h3 {
  color: #f3d6a0;
  font-size: 14px;
}

.pause-loadout p,
.pause-loadout li {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.pause-loadout ul {
  list-style: none;
}

.relic-icon {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  image-rendering: pixelated;
}

.modal-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
  background: rgba(245, 195, 88, 0.14);
  border: 1px solid rgba(245, 195, 88, 0.3);
  padding: 2px 10px;
  border-radius: 2px;
  margin-bottom: 10px;
}

.modal-card h2 {
  font-size: 23px;
  margin-bottom: 10px;
}

.modal-card p {
  font-size: 13px;
  color: #c2cbe0;
  line-height: 1.65;
  margin-bottom: 18px;
}

.modal-choices {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  padding: 10px;
}

.stat-item-label {
  font-size: 11px;
  color: var(--muted);
}

.stat-item-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--gold);
  margin-top: 2px;
}

/* ==================== 移动端触控与横屏零遮挡布局 ==================== */
html,
body {
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

button,
[role="button"],
.minimap-box,
.status-entry {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pause-touch-settings {
  padding: 8px 12px;
}

.touch-setting-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  color: #dce3f5;
}

.touch-setting-row select {
  padding: 3px 7px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: #232839;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
}

.touch-setting-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: auto;
  cursor: pointer;
}

.pwa-install-btn {
  padding: 10px 16px;
  font-size: 13px;
}

/* 触控模式：全屏横屏容器，战场按比例撑满高度居中，左右留白承接虚拟按键 */
body.touch-mode {
  background: #1a1e2b;
  min-height: 100dvh;
  height: 100dvh;
  width: 100dvw;
}

body.touch-mode #game-shell,
body.touch-mode #game-shell:has(#hud:not(.hidden)),
body.touch-mode #game-shell:has(.menu-screen:not(.hidden)) {
  width: 100dvw;
  height: 100dvh;
  max-height: 100dvh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #1a1e2b;
}

body.touch-mode #hud {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1e2b;
}

body.touch-mode #battlefield {
  position: relative;
  height: 100dvh;
  width: min(100dvw, calc(100dvh * var(--arena-ratio, 1.6)));
  max-height: 100%;
  flex: none;
}

body.touch-mode #game-canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}

body.touch-mode .hud-bottom-rail {
  display: none;
}

body.touch-mode .hud-top-rail {
  position: absolute;
  top: max(4px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  z-index: 6;
  display: flex;
  align-items: center;
  height: auto;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

body.touch-mode .stat-panel {
  flex: 0 1 248px;
  gap: 6px;
  padding: 3px 7px;
  border-radius: 3px;
  border: 1px solid rgba(120, 128, 156, 0.42);
  background: rgba(24, 28, 40, 0.78);
  pointer-events: auto;
}

body.touch-mode .bar-track {
  height: 14px;
}

body.touch-mode .hud-location {
  display: flex;
  margin-inline-start: 0;
  gap: 5px;
  padding: 3px 6px;
  border-radius: 3px;
  background: rgba(24, 28, 40, 0.68);
  border: 1px solid rgba(120, 128, 156, 0.3);
}

body.touch-mode .room-badge {
  display: none;
}

body.touch-mode .hud-actions {
  margin-inline-start: auto;
  gap: 6px;
}

body.touch-mode .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 14px;
  background: rgba(28, 33, 47, 0.82);
}

body.touch-mode .status-list {
  top: calc(100% + 5px);
  inset-inline-start: 0;
}

body.touch-mode .status-tile {
  width: 26px;
  height: 26px;
}

body.touch-mode #battlefield-hud {
  --boss-bar-top: max(38px, calc(env(safe-area-inset-top) + 34px));
}

body.touch-mode .hud-top-right {
  top: max(40px, calc(env(safe-area-inset-top) + 36px));
  right: 8px;
  z-index: 5;
}

body.touch-mode .minimap-box:not(.expanded) {
  padding: 3px 4px;
  opacity: 0.86;
}

body.touch-mode .minimap-box:not(.expanded) #minimap-canvas {
  width: 72px;
  height: auto;
}

body.touch-mode #interact-tooltip {
  pointer-events: auto;
  cursor: pointer;
  padding: 5px 9px;
  border-color: var(--border-gold);
  box-shadow: 0 3px 10px rgba(8, 10, 18, 0.55);
}

body.touch-mode .room-choice {
  z-index: 7;
}

body.touch-mode .room-choice button {
  min-height: 36px;
  padding: 6px 9px;
}

/* 暂停或结算时隐藏触控操作层 */
#game-shell:has(#pause-overlay:not(.hidden), #end-overlay:not(.hidden)) #touch-controls {
  opacity: 0;
  pointer-events: none;
}

/* 触控操作层 */
.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  touch-action: none;
  transition: opacity 0.14s ease;
}

/* 左手浮动摇杆区 */
.touch-left-zone {
  position: absolute;
  left: 0;
  top: max(46px, calc(env(safe-area-inset-top) + 42px));
  bottom: 0;
  width: clamp(148px, 34dvw, 270px);
  pointer-events: auto;
  touch-action: none;
}

.touch-stick-base {
  position: absolute;
  left: calc(max(14px, env(safe-area-inset-left)) + 56px);
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px);
  width: 96px;
  height: 96px;
  transform: translate(-50%, 50%);
  border-radius: 50%;
  border: 2px solid rgba(224, 185, 121, 0.45);
  background: radial-gradient(circle, rgba(35, 42, 60, 0.32) 0%, rgba(20, 24, 36, 0.52) 100%);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  opacity: 0.46;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.touch-stick-base.active {
  bottom: auto;
  transform: translate(-50%, -50%);
  opacity: 0.92;
  border-color: rgba(245, 195, 88, 0.85);
}

.touch-stick-knob {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 229, 166, 0.85);
  background: radial-gradient(circle at 35% 35%, rgba(245, 195, 88, 0.72), rgba(140, 102, 46, 0.72));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  will-change: transform;
}

/* 右手扇形按键区 */
.touch-right-zone {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: 176px;
  height: 212px;
  pointer-events: none;
  touch-action: none;
}

/* 取消施法区（仅在拖动战技/核心轮盘时显示） */
.touch-cancel-zone {
  position: fixed;
  top: max(46px, calc(env(safe-area-inset-top) + 42px));
  right: max(12px, env(safe-area-inset-right));
  padding: 7px 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 120, 134, 0.72);
  background: rgba(54, 22, 30, 0.88);
  color: #ffc5cc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 9;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}

.touch-cancel-zone.armed {
  background: rgba(208, 46, 68, 0.94);
  border-color: #fff0f2;
  color: #ffffff;
  transform: scale(1.08);
}

/* 右下主攻击/瞄准摇杆（类元气骑士） */
.touch-attack-pad {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(245, 195, 88, 0.78);
  background: radial-gradient(circle, rgba(56, 46, 36, 0.62) 0%, rgba(25, 28, 40, 0.78) 100%);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45), inset 0 0 12px rgba(245, 195, 88, 0.18);
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  opacity: 0.84;
  transition: opacity 0.1s ease, border-color 0.1s ease;
}

.touch-attack-pad.pressed {
  opacity: 1;
  border-color: #ffe8a3;
  box-shadow: 0 0 0 2px rgba(255, 224, 102, 0.35), 0 4px 14px rgba(0, 0, 0, 0.5);
}

.touch-attack-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 225, 145, 0.85);
  background: radial-gradient(circle at 35% 30%, rgba(255, 214, 118, 0.36), rgba(45, 48, 66, 0.88));
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform;
}

.touch-attack-icon {
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

.touch-weapon-sprite {
  width: 34px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

/* 通用圆形技能/闪避/交互键 */
.touch-action-btn {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(145, 156, 186, 0.75);
  background: rgba(28, 34, 48, 0.8);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  overflow: visible;
  opacity: 0.84;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.42);
  transition: transform 0.08s ease, opacity 0.1s ease, border-color 0.12s ease;
}

.touch-action-btn.pressed,
.touch-action-btn.aiming {
  transform: scale(0.94);
  opacity: 1;
  border-color: #ffe8a3;
}

.touch-action-btn.cooling {
  opacity: 0.62;
  border-color: rgba(110, 118, 142, 0.55);
}

.touch-action-btn.ready {
  border-color: rgba(245, 195, 88, 0.86);
}

.touch-action-btn.denied {
  animation: touch-shake 0.2s ease;
}

@keyframes touch-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.touch-cd-ring {
  --cd-fill: 100%;
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(rgba(245, 195, 88, 0.34) var(--cd-fill), rgba(14, 17, 26, 0.68) 0);
  pointer-events: none;
}

.touch-action-btn.ready .touch-cd-ring {
  background: radial-gradient(circle, rgba(245, 195, 88, 0.22), rgba(245, 195, 88, 0.05));
}

.touch-btn-sublabel {
  position: relative;
  z-index: 1;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  color: #f6f0dc;
  text-shadow: 0 1px 2px #0b0d14;
  padding: 0 3px;
}

.touch-cd-value {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.touch-cd-value:empty {
  display: none;
}

.touch-action-btn.cooling .touch-btn-sublabel,
.touch-action-btn.cooling .touch-core-sprite {
  opacity: 0.36;
}

.touch-charge-badge {
  position: absolute;
  z-index: 3;
  right: -4px;
  bottom: -4px;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid #ffe5a6;
  background: #222638;
  color: #ffe5a6;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* 闪避键（攻击键左下侧） */
.touch-btn-dash {
  right: 92px;
  bottom: 8px;
  width: 54px;
  height: 54px;
}

.touch-btn-dash.ready {
  border-color: rgba(114, 214, 255, 0.88);
}

.touch-btn-dash.ready .touch-cd-ring {
  background: radial-gradient(circle, rgba(90, 212, 255, 0.24), rgba(90, 212, 255, 0.04));
}

/* 武器战技键（攻击键左上方） */
.touch-btn-skill {
  right: 84px;
  bottom: 72px;
  width: 58px;
  height: 58px;
}

/* 核心主动键（攻击键正上方，未装备时隐藏） */
.touch-btn-core {
  right: 12px;
  bottom: 94px;
  width: 54px;
  height: 54px;
}

.touch-core-sprite {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

/* 动态交互键（平时隐藏，靠近可交互物时弹出） */
.touch-btn-interact {
  right: 80px;
  bottom: 142px;
  width: auto;
  min-width: 66px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  border-color: #82f0a8;
  background: rgba(29, 64, 48, 0.92);
  color: #e6ffed;
  font-size: 13px;
  opacity: 0.96;
  box-shadow: 0 0 0 2px rgba(130, 240, 168, 0.28), 0 4px 12px rgba(0, 0, 0, 0.45);
}

/* 竖屏锁定提示层（仅横屏游玩） */
.portrait-lock-overlay {
  z-index: 40;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(44, 50, 68, 0.96), rgba(22, 26, 38, 0.99));
}

.portrait-lock-card {
  max-width: 300px;
  padding: 24px 20px;
  border: 2px solid var(--border-gold);
  border-radius: 4px;
  background: var(--panel-solid);
  text-align: center;
  box-shadow: 6px 6px 0 rgba(5, 6, 10, 0.85);
}

.rotate-phone-icon {
  position: relative;
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
}

.phone-frame {
  display: block;
  width: 28px;
  height: 48px;
  border: 3px solid var(--gold);
  border-radius: 5px;
  box-shadow: inset 0 -5px 0 rgba(245, 195, 88, 0.35);
  animation: rotate-phone-hint 2.2s ease-in-out infinite;
}

.rotate-arrow {
  position: absolute;
  right: 2px;
  top: 2px;
  font-size: 20px;
  font-weight: 800;
  color: #ffe7a8;
}

@keyframes rotate-phone-hint {
  0%, 15% { transform: rotate(0deg); }
  50%, 75% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

.portrait-lock-card h2 {
  font-size: 18px;
  color: #ffe7a8;
  margin-bottom: 8px;
}

.portrait-lock-card p {
  font-size: 13px;
  line-height: 1.55;
  color: #c8d1e6;
}

/* 手机横屏矮窗口下的外围菜单适配（首页、选角、图鉴、结算、暂停） */
body.touch-mode .menu-screen {
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.touch-mode .home-content {
  gap: 14px;
}

body.touch-mode .character-content {
  gap: 10px;
}

body.touch-mode .character-footer .key-guide {
  display: none;
}

body.touch-mode #pause-overlay .modal-card,
body.touch-mode #end-overlay .modal-card {
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px;
}

body.touch-mode .modal-card h2 {
  font-size: 19px;
  margin-bottom: 8px;
}

body.touch-mode .modal-card p {
  margin-bottom: 10px;
}

body.touch-mode .stats-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

@media (max-height: 440px) {
  body.touch-mode .touch-right-zone {
    transform: scale(0.9);
    transform-origin: right bottom;
  }

  body.touch-mode .touch-stick-base {
    width: 86px;
    height: 86px;
  }

  body.touch-mode .touch-stick-knob {
    width: 36px;
    height: 36px;
  }
}
