/* Mobile combat controls use the same live game nodes as the desktop console. */
#mobile-toolbar, #mobile-drawer, #mobile-backdrop, #mobile-stop,
#mobile-targeting, #mobile-joystick, #mobile-move-zone, #mobile-attack, .mobile-attack-choice, #mobile-attack-aim, #item-active-dock, #player-hg-button { display: none; }
#mobile-drawer[hidden], #mobile-backdrop[hidden], #mobile-toolbar[hidden],
body.mobile-layout #mobile-targeting[hidden], body.mobile-layout #mobile-joystick[hidden],
body.mobile-layout #mobile-attack[hidden],
body.mobile-layout .mobile-attack-choice[hidden],
body.mobile-layout #mobile-move-zone[hidden], #item-active-dock[hidden], #inventory-inspector[hidden],
body.mobile-layout [data-mobile-content][hidden] { display: none !important; }
body.mobile-layout {
  --mobile-edge-left: max(8px, var(--rd-safe-area-left));
  --mobile-edge-right: max(8px, var(--rd-safe-area-right));
  --mobile-edge-top: max(8px, var(--rd-safe-area-top));
  --mobile-edge-bottom: max(8px, var(--rd-safe-area-bottom));
  --mobile-skill-size: 60px;
  --mobile-attack-size: 84px;
  --mobile-attack-choice-size: 48px;
  --mobile-map-width: 116px;
  --mobile-joystick-size: 132px;
}
body.mobile-layout button { touch-action: manipulation; }
body.mobile-layout #mobile-toolbar {
  position: fixed; top: var(--mobile-edge-top); right: var(--mobile-edge-right);
  display: flex; gap: 4px; z-index: 60;
}
body.mobile-layout.mobile-panel-open #mobile-toolbar { z-index: 112; }
body.mobile-layout #mobile-toolbar button {
  min-height: 44px; min-width: 44px; box-sizing: border-box; padding: 6px 9px;
  border: 1px solid #8e6c38; border-radius: 6px; background: rgba(14,18,22,.88);
  color: #e8d6ae; font: 11px/1.25 "Microsoft YaHei", system-ui, sans-serif; cursor: pointer;
}
body.mobile-layout #mobile-toolbar button { width: 44px; }
body.mobile-layout #mobile-toolbar button[aria-expanded="true"] { background: #4a3a1f; border-color: #e4bc6a; }
body.mobile-layout.mobile-in-combat #mobile-toolbar > :not([data-mobile-panel="more"]) { display: none; }
body.mobile-layout #minimap-dock {
  top: var(--mobile-edge-top); left: var(--mobile-edge-left); bottom: auto;
  width: var(--mobile-map-width); border-width: 1px; border-radius: 5px;
  background: rgba(12,16,19,.7); box-shadow: none; z-index: 24;
}
body.mobile-layout #minimap-dock .minimap-heading { padding: 3px 5px; font-size: 8px; }
body.mobile-layout #minimap-dock .minimap-heading span:last-child,
body.mobile-layout #minimap-dock .minimap-hint { display: none; }
body.mobile-layout #war3-console { height: 0; padding: 0; border: 0; background: none; box-shadow: none; pointer-events: none; }
body.mobile-layout #war3-console .console-left {
  display: none;
}
body.mobile-layout #mobile-panel-hero .console-left {
  display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%;
  padding: 8px 0; box-sizing: border-box;
}
body.mobile-layout #hero-portrait { width: 32px; height: 34px; border-width: 1px; flex: 0 0 auto; }
body.mobile-layout #hero-level-badge { font-size: 9px; padding: 1px 3px; }
body.mobile-layout .hero-bars-and-stats { width: 138px; gap: 3px; }
body.mobile-layout .hero-name { font-size: 10px; }
body.mobile-layout .hero-title-row { min-width: 0; }
body.mobile-layout .bar-container { height: 11px; }
body.mobile-layout .bar-text { font-size: 9px; white-space: nowrap; }
body.mobile-layout #war3-console .stats-grid, body.mobile-layout #war3-console .hero-talents-panel,
body.mobile-layout #war3-console #btn-switch-hero, body.mobile-layout #war3-console #hero-attr-type,
body.mobile-layout #war3-console .console-center { display: none; }
body.mobile-layout #war3-console .console-right { position: static; pointer-events: none; }
body.mobile-layout .console-right .section-label { display: none; }
body.mobile-layout .command-grid { display: contents; }
body.mobile-layout .command-grid > :not(#skill-slot-q):not(#skill-slot-w):not(#skill-slot-e):not(#skill-slot-r) { display: none; }
body.mobile-layout .command-grid > #skill-slot-q,
body.mobile-layout .command-grid > #skill-slot-w,
body.mobile-layout .command-grid > #skill-slot-r {
  position: fixed; display: block; width: var(--mobile-skill-size); height: var(--mobile-skill-size);
  box-sizing: border-box; border: 2px solid #b89d60; border-radius: 50%; overflow: visible;
  background: #141c25; box-shadow: 0 3px 10px #0009, inset 0 0 0 3px #111; touch-action: none;
  pointer-events: auto; z-index: 28;
}
/* All active skills share one outer arc around the main attack control. */
body.mobile-layout .command-grid > #skill-slot-q { right: calc(var(--mobile-edge-right) + 188px); bottom: calc(var(--mobile-edge-bottom) + 64px); }
body.mobile-layout .command-grid > #skill-slot-w { right: calc(var(--mobile-edge-right) + 122px); bottom: calc(var(--mobile-edge-bottom) + 112px); }
body.mobile-layout .command-grid > #skill-slot-r { right: calc(var(--mobile-edge-right) + 62px); bottom: calc(var(--mobile-edge-bottom) + 174px); }
body.mobile-layout[data-mobile-active-count="2"] .command-grid > #skill-slot-r {
  right: calc(var(--mobile-edge-right) + 122px); bottom: calc(var(--mobile-edge-bottom) + 112px);
}
body.mobile-layout .command-grid .cmd-slot img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; opacity: .92; }
body.mobile-layout .cmd-key { bottom: 4px; left: 50%; transform: translateX(-50%); font-size: 9px; }
body.mobile-layout .cmd-cd { border-radius: 50%; font-size: 16px; }
.skill-uses { position: absolute; right: 2px; top: 2px; padding: 1px 2px; color: #fff1b7; background: #111c; font-size: 8px; z-index: 3; pointer-events: none; }
.skill-uses[hidden] { display: none; }
body.mobile-layout .mobile-skill-unavailable { filter: grayscale(1); opacity: .55; }
body.mobile-layout #mobile-attack {
  display: flex; position: fixed; right: calc(var(--mobile-edge-right) + 12px); bottom: calc(var(--mobile-edge-bottom) + 12px);
  width: var(--mobile-attack-size); height: var(--mobile-attack-size); box-sizing: border-box; flex-direction: column; align-items: center; justify-content: center;
  padding: 3px; border: 3px solid #a68a52; border-radius: 50%; background: #171a16;
  color: #fff0c9; box-shadow: 0 3px 14px #0008; z-index: 29; touch-action: none; user-select: none;
}
body.mobile-layout #mobile-attack img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; pointer-events: none; }
body.mobile-layout #mobile-attack small { position: absolute; bottom: 3px; padding: 1px 5px; border-radius: 3px; font-size: 11px; background: #10150fe6; pointer-events: none; }
body.mobile-layout #mobile-attack small span { display: block; font-size: 10px; line-height: 12px; color: #e1d5b8; }
body.mobile-layout #mobile-attack-thumb {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; box-sizing: border-box;
  border: 2px solid #fff0c9; border-radius: 50%; background: #74613a; box-shadow: 0 2px 4px #000a;
  pointer-events: none;
}
body.mobile-layout #mobile-attack-aim {
  position: fixed; display: block; left: 50%; top: calc(var(--mobile-edge-top) + 64px); right: auto; bottom: auto;
  width: min(240px, calc(100vw - var(--mobile-edge-left) - var(--mobile-edge-right) - 300px)); box-sizing: border-box; transform: translateX(-50%);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 5px 8px; text-align: center;
  border: 1px solid #a68a52; border-radius: 4px; color: #fff0c9; background: #171a16f2;
  font-size: 12px; line-height: 18px; font-weight: normal; pointer-events: none; z-index: 32;
}
body.mobile-layout #mobile-attack [hidden], body.mobile-layout #mobile-attack-aim[hidden] { display: none; }
body.mobile-layout #hero-status-hud {
  left: calc(50% + (var(--mobile-edge-left) - var(--mobile-edge-right)) / 2);
}
body.mobile-layout #mobile-attack:active, body.mobile-layout #mobile-attack[data-active] { border-color: #ffebad; filter: brightness(1.2); }
body.mobile-layout #mobile-attack:focus-visible { outline: 2px solid #ffe2a1; outline-offset: 2px; }
body.mobile-layout .mobile-attack-choice {
  position: fixed; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: var(--mobile-attack-choice-size); height: var(--mobile-attack-choice-size); padding: 3px; box-sizing: border-box;
  border: 1px solid #a68a52; border-radius: 50%; background: #17201cef; color: #f0dfb8;
  font: 11px/13px 'Microsoft YaHei', system-ui, sans-serif; box-shadow: 0 3px 8px #0008;
  z-index: 30; touch-action: none; user-select: none;
}
body.mobile-layout .mobile-attack-choice svg { width: 20px; height: 20px; pointer-events: none; }
body.mobile-layout .mobile-attack-choice span { pointer-events: none; }
body.mobile-layout #mobile-attack-boss { right: var(--mobile-edge-right); bottom: calc(var(--mobile-edge-bottom) + 108px); }
body.mobile-layout #mobile-attack-minion { right: calc(var(--mobile-edge-right) + 108px); bottom: var(--mobile-edge-bottom); }
body.mobile-layout .mobile-attack-choice:active, body.mobile-layout .mobile-attack-choice[data-active] { border-color: #ffebad; background: #3d3d27; }
body.mobile-layout .mobile-attack-choice[aria-pressed="true"] { outline: 2px solid #f1d48d; outline-offset: 2px; background: #303923; }
body.mobile-layout .mobile-attack-choice:focus-visible { outline: 2px solid #ffe2a1; outline-offset: 2px; }
body.mobile-layout #mobile-joystick {
  position: fixed; display: block; left: calc(var(--mobile-edge-left) + 18px); bottom: calc(var(--mobile-edge-bottom) + 24px);
  width: var(--mobile-joystick-size); height: var(--mobile-joystick-size); border-radius: 50%; box-sizing: border-box;
  background: radial-gradient(circle, #58758610 0 35%, #65869a18 36% 64%, #527e9333 65%);
  border: 2px solid #adc6d04d; box-shadow: inset 0 0 16px #11233044; z-index: 27; touch-action: none; user-select: none;
}
body.mobile-layout .mobile-joystick-ring { position: absolute; inset: 15px; border: 1px solid #bddae42b; border-radius: 50%; pointer-events: none; }
body.mobile-layout #mobile-joystick-thumb {
  display: block; position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; box-sizing: border-box; border: 2px solid #abc9d67a;
  background: radial-gradient(circle at 35% 30%, #afc5cf88, #52708f88); box-shadow: 0 3px 8px #0004; pointer-events: none;
}
body.mobile-layout #mobile-joystick[data-active] { border-color: #bde7ffaa; background-color: #578cab20; }
body.mobile-layout #mobile-move-zone {
  display: block; position: fixed; left: var(--mobile-edge-left); bottom: var(--mobile-edge-bottom);
  width: min(42vw, 320px); height: clamp(160px, 38dvh, 280px);
  z-index: 26; touch-action: none; user-select: none;
}
body.mobile-layout .mobile-control-caption { position: absolute; bottom: -19px; left: 0; width: 100%; text-align: center; font-size: 9px; color: #d2dfdc99; pointer-events: none; }
body.mobile-layout #mobile-stop { display: block; position: static; width: 100%; }
body.mobile-layout #preparation-actions { bottom: calc(var(--mobile-edge-bottom) + 16px); max-width: calc(100vw - 24px); padding: 8px; gap: 10px; }
body.mobile-layout .prep-summary { font-size: 11px; }
body.mobile-layout .prep-summary small { display: none; }
body.mobile-layout .prep-buttons button { font-size: 12px; padding: 8px 12px; }
body.mobile-layout #mobile-targeting {
  position: fixed; display: block; top: calc(var(--mobile-edge-top) + 78px);
  left: calc(var(--mobile-edge-left) + 140px); right: calc(var(--mobile-edge-right) + 160px);
  color: #d9f1ff; font-size: 10px; text-shadow: 0 1px 3px #000;
  pointer-events: none; z-index: 32;
}
body.mobile-layout #mobile-targeting-label { display: block; text-align: center; }
body.mobile-layout #mobile-cancel-targeting {
  position: fixed; right: calc(var(--mobile-edge-right) + 8px); top: auto; bottom: calc(var(--mobile-edge-bottom) + 226px); width: 64px; height: 64px;
  padding: 7px; box-sizing: border-box; border: 2px solid #c87d7d; border-radius: 50%;
  background: rgba(70,29,32,.88); color: #ffd3d3; font: inherit; line-height: 1.3; touch-action: none; pointer-events: auto;
}
body.mobile-layout #mobile-cancel-targeting.is-cancelling { border-color: #ffe2e2; background: #a92e37; box-shadow: 0 0 18px #ff4f5c99; }
body.mobile-layout #mobile-targeting.is-cancelling { color: #ffd0d0; }
body.mobile-layout #top-bar {
  top: calc(var(--mobile-edge-top) + 50px); right: var(--mobile-edge-right); width: auto; max-width: 230px;
  display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 4px 7px; border-width: 1px; font-size: 10px; box-shadow: none;
}
body.mobile-layout #top-bar > :not(.top-res-item), body.mobile-layout #top-bar #top-disabled-container { display: none; }
body.mobile-layout #top-bar .top-res-item { gap: 3px; white-space: nowrap; }
body.mobile-layout .top-gold { font-size: 10px; }
body.mobile-layout .top-wave { font-size: 9px; }
body.mobile-layout .top-state { font-size: 9px; padding: 2px 4px; }
body.mobile-layout .top-state.state-revival { color: #ffe3a0; background: #542b20; font-size: 11px; }
body.mobile-layout.mobile-in-combat #top-bar .top-gold-resource,
body.mobile-layout.mobile-in-combat #top-bar .top-res-item:has(#wave-status-text:not(.state-revival)) { display: none; }
body.mobile-layout #loadnote, body.mobile-layout #hud { display: none !important; }
body.mobile-layout #target-frame-dock {
  top: var(--mobile-edge-top) !important; left: 50% !important; width: 186px; min-width: 0;
  transform: translateX(-50%); animation: none; box-shadow: none; border-width: 1px; z-index: 22;
}
body.mobile-layout .tf-inner { padding: 4px 6px; gap: 4px; min-height: 26px; }
body.mobile-layout .tf-avatar-wrap, body.mobile-layout .tf-source, body.mobile-layout .tf-stats-row { display: none; }
body.mobile-layout .tf-center-info { padding-right: 30px; }
body.mobile-layout .tf-name { font-size: 9px; }
body.mobile-layout .tf-hp-text { font-size: 8px; }
body.mobile-layout .tf-btn-close { width: 28px; height: 28px; }

body.mobile-layout #mobile-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.44); z-index: 110; }
body.mobile-layout #mobile-drawer {
  position: fixed;
  top: calc(var(--mobile-edge-top) + 50px);
  right: var(--mobile-edge-right);
  bottom: calc(var(--mobile-edge-bottom) + 12px);
  width: min(420px, calc(100vw - 16px - var(--rd-safe-area-left) - var(--rd-safe-area-right)));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #ad8b4e;
  border-radius: 8px;
  background: rgba(15, 20, 24, 0.98);
  color: #e8d6ae;
  box-shadow: 0 10px 40px #000b;
  z-index: 111;
}
body.mobile-layout #mobile-drawer > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-bottom: 1px solid #55442c;
}
body.mobile-layout #mobile-panel-title { margin: 0; font-size: 14px; }
body.mobile-layout #mobile-panel-close { min-width: 56px; min-height: 44px; }
body.mobile-layout #mobile-drawer [data-mobile-content] { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px; }
body.mobile-layout #mobile-drawer button, body.mobile-layout #mobile-drawer [role="button"] {
  min-height: 44px;
  box-sizing: border-box;
  border-radius: 5px;
  font-size: 12px;
}
body.mobile-layout #mobile-drawer button { background: #24251f; border: 1px solid #76613d; color: #e8d6ae; padding: 7px 10px; }
body.mobile-layout #mobile-panel-hero .stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 10px 0 18px; font-size: 12px; }
body.mobile-layout #mobile-panel-hero .hero-talents-panel { width: 100%; height: auto; min-height: 144px; gap: 10px; padding: 10px; }
body.mobile-layout #mobile-panel-hero #hero-parts-container { flex-wrap: wrap; }
body.mobile-layout .hero-part-help { max-height: none; font-size: 11px; }
body.mobile-layout .hero-part-help summary { min-height: 36px; display: flex; align-items: center; }
body.mobile-layout #mobile-panel-hero .talents-scroll-box { min-height: 44px; }
body.mobile-layout #mobile-panel-hero .talent-pill { padding: 6px 8px; font-size: 12px; }
body.mobile-layout #mobile-panel-hero #hero-attr-type { margin-left: 8px; }
body.mobile-layout #mobile-panel-bag .console-center { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
body.mobile-layout #mobile-panel-bag .inventory-sidebar { min-width: 90px; height: 150px; padding: 8px; }
body.mobile-layout #mobile-panel-bag .inv-toggle-switch { min-height: 52px; justify-content: center; }
body.mobile-layout #mobile-panel-meters #damage-meters-dock {
  position: static;
  inset: auto;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  box-sizing: border-box;
  box-shadow: none;
}
body.mobile-layout #mobile-panel-map #camera-settings { font-size: 12px; }
body.mobile-layout #mobile-panel-map #camera-settings summary { padding: 12px 8px; }
body.mobile-layout #mobile-panel-map #camera-pitch { height: 28px; }
body.mobile-layout #mobile-panel-map #camera-zoom { height: 28px; }
body.mobile-layout #mobile-panel-map .camera-zoom-controls button { padding: 6px 3px; min-width: 44px; }
body.mobile-layout #mobile-panel-meters .dm-header { flex-wrap: wrap; gap: 8px; }
body.mobile-layout #mobile-panel-more { font-size: 12px; line-height: 1.7; }
body.mobile-layout #mobile-panel-more > * { margin-bottom: 10px; }
body.mobile-layout #mobile-panel-more #fullscreen-controls,
body.mobile-layout #mobile-panel-more #btn-open-debug-panel { position: static; inset: auto; transform: none; width: 100%; box-sizing: border-box; }
body.mobile-layout #mobile-panel-more #fullscreen-toggle { width: 100%; }
body.mobile-layout #mobile-panel-more #fullscreen-status { max-width: none; margin-bottom: 0; }
body.mobile-layout #mobile-panel-more #top-disabled-container { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: #24191a; border-radius: 5px; }
body.mobile-layout #mobile-panel-more #mobile-focus,
body.mobile-layout #mobile-panel-more #mobile-shop,
body.mobile-layout #mobile-panel-more #mobile-start,
body.mobile-layout #mobile-panel-more #btn-start-wave { width: 100%; }

/* Existing game dialogs stay usable without scaling their text or buttons down. */
body.mobile-layout #talent-modal,
body.mobile-layout #defeat-modal, body.mobile-layout #debug-panel-dock {
  top: var(--rd-safe-center-y) !important;
  left: var(--rd-safe-center-x) !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: min(620px, calc(100vw - 16px - var(--rd-safe-area-left) - var(--rd-safe-area-right))) !important;
  max-height: calc(100dvh - 20px - var(--rd-safe-area-top) - var(--rd-safe-area-bottom)) !important;
  box-sizing: border-box;
}
body.mobile-layout #shop-modal { left: var(--rd-safe-center-x); top: var(--rd-safe-center-y); width: min(800px, calc(100vw - 16px - var(--rd-safe-area-left) - var(--rd-safe-area-right))); max-height: calc(100dvh - 16px - var(--rd-safe-area-top) - var(--rd-safe-area-bottom)); }
body.mobile-layout .shop-header { gap: 6px; padding: 6px 10px; }
body.mobile-layout .shop-header-left { gap: 6px; font-size: 14px; }
body.mobile-layout .shop-prob-bar, body.mobile-layout .shop-disabled-bar { padding: 5px 10px; }
body.mobile-layout .shop-catalog, body.mobile-layout .shop-detail { padding: 10px; }
body.mobile-layout .shop-grid { gap: 8px; }
body.mobile-layout .shop-market-info summary { min-height: 36px; box-sizing: border-box; display: list-item; padding: 10px; }
body.mobile-layout .shop-footer { gap: 8px; padding: 8px 10px max(8px, var(--rd-safe-area-bottom)); }
body.mobile-layout .shop-auto-toggle { padding: 6px 8px; }
body.shop-open #mobile-joystick, body.shop-open #mobile-attack, body.shop-open .mobile-attack-choice,
body.shop-open .command-grid { visibility: hidden; }
body.mobile-layout .talent-header { padding: 7px 10px; flex-shrink: 0; }
body.mobile-layout .talent-header-title { font-size: 14px; flex-wrap: wrap; }
body.mobile-layout .talent-choices { min-height: 0; grid-template-columns: 1fr; overflow-y: auto; gap: 10px; padding: 10px; }
body.mobile-layout .talent-card { min-height: 115px; padding: 12px; }
body.mobile-layout .talent-card-btn { min-height: 44px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }
body.mobile-layout .talent-footer { flex-shrink: 0; }
body.mobile-layout #defeat-modal { padding: 18px 12px !important; overflow-y: auto; }
body.mobile-layout #defeat-modal button { min-height: 44px; }
body.mobile-layout #debug-panel-dock { z-index: 140; }
body.mobile-layout .dbg-header { flex-shrink: 0; }
body.mobile-layout .dbg-body { min-height: 0; }
body.mobile-layout .dbg-btn-close { width: 44px; height: 44px; }
body.mobile-layout #debug-panel-dock button { min-height: 40px; }
body.mobile-layout #debug-panel-dock input, body.mobile-layout #debug-panel-dock select { max-width: 100%; font-size: 16px; }


body.mobile-layout .mobile-menu-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.mobile-layout #mobile-menu-gold { color: #ffd778; }
body.mobile-layout .mobile-passives h3 { margin: 0 0 8px; font-size: 12px; }
body.mobile-layout #mobile-passive-skills { display: flex; flex-wrap: wrap; gap: 10px; }
body.mobile-layout #mobile-passive-skills .cmd-slot { flex: 0 0 48px; width: 48px; height: 48px; position: relative; overflow: visible; border-radius: 50%; }
body.mobile-layout #mobile-passive-skills .cmd-slot img { width: 44px; height: 44px; border-radius: 50%; }
/* Keep the full touch target beside the passive icon, outside its circular frame. */
body.mobile-layout #mobile-passive-skills .has-learn-plus { margin-right: 52px; }
body.mobile-layout #mobile-passive-skills .skill-learn-plus {
  top: 0; right: auto; left: calc(100% + 8px); width: 44px; height: 44px; padding: 0;
  border: 2px solid #fff1ac; border-radius: 50%; background: linear-gradient(180deg, #ffe066 0%, #ca8a04 100%);
  color: #3b2500; font: bold 28px/38px system-ui, sans-serif;
}
body.mobile-layout #mobile-skill-note { font-size: 12px; color: #aebcae; line-height: 1.6; }
body.mobile-layout #mobile-panel-map #camera-settings { border: 0; }
body.mobile-layout.mobile-panel-open #mobile-joystick,
body.mobile-layout.mobile-panel-open #mobile-attack,
body.mobile-layout.mobile-panel-open .mobile-attack-choice,
body.mobile-layout.mobile-panel-open .command-grid > #skill-slot-q,
body.mobile-layout.mobile-panel-open .command-grid > #skill-slot-w,
body.mobile-layout.mobile-panel-open .command-grid > #skill-slot-r { visibility: hidden; }
@media (orientation: portrait), (max-width: 599px) {
  body.mobile-layout { --mobile-skill-size: 56px; --mobile-map-width: 100px; --mobile-joystick-size: 120px; }
  body.mobile-layout #mobile-toolbar { top: calc(var(--mobile-edge-top) + 54px); }
  body.mobile-layout.mobile-in-combat #mobile-toolbar { top: var(--mobile-edge-top); }
  body.mobile-layout .hero-bars-and-stats { width: 132px; }
  body.mobile-layout #top-bar { top: calc(var(--mobile-edge-top) + 105px); }
  body.mobile-layout.mobile-in-combat #top-bar { top: calc(var(--mobile-edge-top) + 58px); }
  body.mobile-layout #skill-slot-q { right: calc(var(--mobile-edge-right) + 92px); bottom: calc(var(--mobile-edge-bottom) + 56px); }
  body.mobile-layout #skill-slot-r { right: calc(var(--mobile-edge-right) + 6px); bottom: calc(var(--mobile-edge-bottom) + 110px); }
  body.mobile-layout #mobile-attack { width: 76px; height: 76px; right: calc(var(--mobile-edge-right) + 6px); bottom: calc(var(--mobile-edge-bottom) + 8px); }
  body.mobile-layout #mobile-joystick { left: calc(var(--mobile-edge-left) + 8px); bottom: calc(var(--mobile-edge-bottom) + 16px); }
  body.mobile-layout #preparation-actions { bottom: calc(var(--mobile-edge-bottom) + 226px); width: max-content; flex-direction: column; gap: 7px; }
  body.mobile-layout .prep-summary { display: block; max-width: 250px; text-align: center; }
  body.mobile-layout #shop-modal { top: auto; bottom: 0; left: var(--rd-safe-area-left); transform: none; width: calc(100vw - var(--rd-safe-area-left) - var(--rd-safe-area-right)); height: min(760px, calc(100dvh - 20px - var(--rd-safe-area-top))); max-height: none; border-bottom: 0; border-radius: 16px 16px 0 0; }
  body.mobile-layout .shop-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(100px, 1fr) auto; flex: 1; overflow: hidden; }
  body.mobile-layout .shop-catalog { overflow-y: auto; overscroll-behavior: contain; }
  body.mobile-layout .shop-detail { border-left: 0; border-top: 1px solid #44351f; gap: 6px; }
  body.mobile-layout #shop-detail-description { max-height: 90px; overflow-y: auto; overscroll-behavior: contain; }
  body.mobile-layout .shop-actions { display: grid; grid-template-columns: 48px minmax(0, 1fr) minmax(0, 1.2fr); }
  body.mobile-layout .shop-actions > span { font-size: 10px; line-height: 1.5; }
  body.mobile-layout .shop-actions > span b { display: block; font-size: 14px !important; }
  body.mobile-layout .shop-actions button { padding: 8px 4px; font-size: 11px; white-space: normal; }
  body.mobile-layout #mobile-targeting { top: calc(var(--mobile-edge-top) + 152px); left: calc(var(--mobile-edge-left) + 60px); right: calc(var(--mobile-edge-right) + 60px); }
  body.mobile-layout #mobile-cancel-targeting { right: calc(var(--mobile-edge-right) + 6px); top: auto; bottom: calc(var(--mobile-edge-bottom) + 204px); width: 60px; height: 60px; }
  body.mobile-layout #target-frame-dock { left: calc(var(--mobile-edge-left) + 110px) !important; transform: none; width: min(180px, calc(100vw - 176px)); }
  body.mobile-layout #mobile-drawer { top: calc(var(--mobile-edge-top) + 106px); }
}
@media (max-height: 500px) and (orientation: landscape) {
  body.mobile-layout #preparation-actions .prep-summary { display: none; }
  body.mobile-layout .shop-header { padding: 3px 10px; }
  body.mobile-layout .shop-body { flex: 1; min-height: 80px; grid-template-columns: minmax(0, 1fr) 240px; }
  body.mobile-layout .shop-detail { gap: 6px; }
  body.mobile-layout #shop-detail-description { max-height: 90px; overflow-y: auto; }
  body.mobile-layout .shop-item .item-icon { max-width: 48px; }
  body.mobile-layout .shop-footer { flex-direction: row; align-items: center; }
  body.mobile-layout .shop-options { flex: 1; }
  body.mobile-layout .shop-actions { justify-content: flex-end; }
  body.mobile-layout .shop-actions > span { display: none; }
}
@media (max-height: 640px) and (orientation: portrait) {
  body.mobile-layout .shop-detail { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  body.mobile-layout .shop-detail h3 { font-size: 13px; }
  body.mobile-layout #shop-detail-meta { grid-column: 1; }
  body.mobile-layout #shop-buy-btn { grid-column: 2; grid-row: 1 / 3; }
  body.mobile-layout #shop-detail-description { grid-column: 1 / -1; max-height: 64px; }
}
@media (min-width: 800px) and (orientation: landscape) {
  body.mobile-layout #mobile-drawer { width: min(420px, calc(100vw - 32px)); }
  body.mobile-layout .talent-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.mobile-layout .talent-card-title { font-size: 13px; }
  body.mobile-layout .talent-card-desc { font-size: 12px; }
}
@media (max-width: 359px) {
  body.mobile-layout { --mobile-map-width: 86px; --mobile-joystick-size: 108px; }
  body.mobile-layout .hero-bars-and-stats { width: 110px; }
  body.mobile-layout #skill-slot-q { right: calc(var(--mobile-edge-right) + 92px); }
  body.mobile-layout #skill-slot-r { right: calc(var(--mobile-edge-right) + 6px); }
  body.mobile-layout #mobile-toolbar { gap: 3px; top: calc(var(--mobile-edge-top) + 94px); }
  body.mobile-layout #top-bar { top: calc(var(--mobile-edge-top) + 144px); }
  body.mobile-layout #target-frame-dock { left: calc(var(--mobile-edge-left) + 96px) !important; width: min(158px, calc(100vw - 162px)); }
}

/* Shared states keep the same meaning across the touch HUD and desktop console. */
.cmd-slot[data-unavailable] img { opacity: .4 !important; filter: grayscale(.7); }
.cmd-slot[data-unavailable="mana"] { border-color: #65a9ef !important; }
.cmd-slot[data-unavailable="mana"] img { filter: saturate(.35) brightness(.65); }
.cmd-slot[data-unavailable]::after {
  content: attr(data-status-label); position: absolute; inset: auto 0 3px;
  display: block; text-align: center; color: #f6e7cb; background: #121a22e8;
  font: 10px/1.6 "Microsoft YaHei", sans-serif; z-index: 4; pointer-events: none;
}
.cmd-slot[data-unavailable="mana"]::after { color: #a8daff; }
.skill-level-badge {
  position: absolute; left: -3px; top: -5px; padding: 1px 4px; border-radius: 4px;
  color: #fff1bc; background: #171c24ed; border: 1px solid #786344; font-size: 10px;
  pointer-events: none; z-index: 5;
}
body.mobile-layout .skill-learn-plus {
  top: -26px; right: -9px; width: 44px; height: 44px; border: 2px solid #fff1ac;
  font: bold 28px/38px system-ui, sans-serif; box-shadow: 0 2px 9px #0009;
}
body.mobile-layout .command-grid > .cmd-slot .skill-learn-plus { top: -48px; left: -8px; right: auto; }
body.mobile-layout .command-grid > #skill-slot-q .skill-learn-plus,
body.mobile-layout .command-grid > #skill-slot-w .skill-learn-plus,
body.mobile-layout[data-mobile-active-count="2"] .command-grid > #skill-slot-r .skill-learn-plus { left: -48px; top: -48px; }
body.mobile-layout .skill-level-badge { left: -4px; top: 6px; font-size: 10px; }
body.mobile-layout .cmd-slot[data-unavailable]::after { bottom: 8px; left: 5px; right: 5px; border-radius: 8px; font-size: 10px; }
body.mobile-layout .cmd-slot[data-unavailable="cooldown"]::after { display: none; }

/* Combat-use items are explicitly registered, rather than inferred from clickable inventory items. */
body.mobile-layout #item-active-dock {
  position: fixed; left: calc(var(--mobile-edge-left) + var(--mobile-joystick-size) + 32px); right: auto;
  bottom: calc(var(--mobile-edge-bottom) + 88px); display: flex; flex-wrap: wrap;
  justify-content: flex-start; gap: 6px; width: 144px; max-width: 144px; z-index: 31;
}
.item-active-button {
  position: relative; width: 52px; height: 56px; flex: 0 0 52px; border-radius: 12px;
  padding: 3px 3px 14px; border: 1px solid #dec58b; background: #17242be8;
  box-shadow: 0 3px 12px #0009; color: #fff4cf; touch-action: manipulation;
}
body.mobile-layout #item-active-dock .item-active-button[data-midas-aim] { touch-action: none; }
.item-active-button img { width: 38px; height: 36px; object-fit: cover; border-radius: 7px; pointer-events: none; }
body.mobile-layout #item-active-dock .item-active-button { flex: 0 0 44px; width: 44px; height: 48px; padding: 3px 3px 11px; }
body.mobile-layout #item-active-dock .item-active-button img { width: 32px; height: 30px; }
@media (max-width: 700px) and (orientation: landscape) {
  body.mobile-layout #item-active-dock { width: 94px; max-width: 94px; }
}
.item-active-label { position: absolute; bottom: 2px; left: 2px; right: 2px; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-active-charges { position: absolute; right: -3px; top: -6px; padding: 1px 4px; border-radius: 6px; background: #174663; color: white; font-size: 11px; }
.item-active-cooldown { position: absolute; inset: 2px 2px 14px; border-radius: 9px; display: grid; place-items: center; background: #0c1324bb; font-size: 17px; }
.item-active-cooldown[hidden] { display: none; }
.item-active-button[data-unavailable] img { filter: grayscale(.85); opacity: .5; }
.item-active-button:active { border-color: #fff4c3; transform: scale(.95); }
.item-active-button:focus-visible, #inventory-item-actions button:focus-visible, .skill-learn-plus:focus-visible { outline: 2px solid #a7dbff; outline-offset: 3px; }

/* Preparation actions occupy the two lower corners, leaving the center clear. */
body.mobile-layout #preparation-actions {
  left: var(--mobile-edge-left); right: var(--mobile-edge-right); transform: none;
  width: auto; max-width: none; bottom: calc(var(--mobile-edge-bottom) + 8px);
  border: 0; background: none; box-shadow: none; padding: 0; pointer-events: none;
}
body.mobile-layout #preparation-actions .prep-summary { display: none; }
body.mobile-layout #prep-next-boss {
  position: absolute; right: 0; bottom: 60px; max-width: min(300px, calc(100vw - 32px));
  padding: 6px 10px; border: 1px solid #867045; border-radius: 6px;
  background: rgba(17, 21, 20, .94); font-size: 12px; text-align: right;
}
body.mobile-layout .prep-buttons { display: flex; width: 100%; gap: 8px; pointer-events: none; }
body.mobile-layout .prep-buttons button { min-height: 48px; padding: 8px 12px; font-size: 12px; flex: 0 0 auto; pointer-events: auto; }
body.mobile-layout #btn-banner-start-wave { margin-left: auto; }
body.mobile-layout:not(.mobile-in-combat):not(.mobile-practice) #mobile-attack,
body.mobile-layout:not(.mobile-in-combat):not(.mobile-practice) .mobile-attack-choice { display: none; }
body.mobile-layout:not(.mobile-in-combat) #mobile-joystick,
body.mobile-layout:not(.mobile-in-combat) #mobile-move-zone { bottom: calc(var(--mobile-edge-bottom) + 72px); }
body.mobile-layout #prep-growth-btn.has-points { color: #c8f9c9; border-color: #8ad596; box-shadow: inset 0 0 12px #59a46a22; }
#skill-backdrop { position: fixed; inset: 0; background: #050b10a6; z-index: 159; }
#skill-backdrop[hidden] { display: none; }
#skill-feedback { flex-basis: 100%; margin: 0; min-height: 18px; color: #b6e9bf; font-size: 12px; text-align: left; }
#skill-feedback:empty { display: none; }
.skill-next-effect { color: #a9dec1; margin-top: 5px; font-size: 11px; line-height: 1.45; }
.skill-requirement { color: #baad97; margin-top: 4px; font-size: 10px; }
.talent-footer-actions { display: flex; gap: 8px; }
.talent-footer-actions button { background: #202c31; color: #efdfbd; border: 1px solid #82724f; border-radius: 6px; padding: 8px 12px; min-height: 44px; }
button.talent-card { color: #eed; text-align: left; font-family: inherit; }
body.mobile-layout #skill-modal {
  left: var(--rd-safe-center-x); top: var(--rd-safe-center-y);
  width: min(820px, calc(100vw - 16px - var(--rd-safe-area-left) - var(--rd-safe-area-right)));
  max-height: calc(100dvh - 16px - var(--rd-safe-area-top) - var(--rd-safe-area-bottom));
  border-width: 1px; border-radius: 14px; background: #101a20; box-shadow: 0 12px 50px #000a;
  transform: translate(-50%, -50%); animation: none;
}
body.mobile-layout #skill-modal .talent-header { padding: 12px; background: #1d2b30; border-width: 1px; }
body.mobile-layout .skill-rows { min-height: 0; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; gap: 8px; padding: 10px; }
body.mobile-layout .skill-row { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 6px; padding: 10px; border-color: #46514b; background: #18242a; align-items: start; }
body.mobile-layout .skill-row > div:nth-child(2) { grid-column: 2 / 4; min-width: 0; }
body.mobile-layout .skill-key { width: 26px; height: 26px; background: #2e372c; }
body.mobile-layout .skill-name { font-size: 13px; }
body.mobile-layout .skill-desc { font-size: 11px; line-height: 1.5; }
body.mobile-layout .skill-rank { grid-column: 1 / 3; align-self: center; }
body.mobile-layout .skill-plus { min-width: 52px; min-height: 44px; height: 44px; border-radius: 7px; align-self: end; }
body.mobile-layout #skill-modal .skill-footer { flex: 0 0 auto; padding: 10px 12px; background: #152127; border-width: 1px; }
body.mobile-layout #skill-rules { flex: 1; font-size: 10px; text-align: left; }
body.mobile-layout .skill-footer button { min-height: 44px; padding: 8px 12px; border-radius: 7px; }
body.mobile-layout .talent-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* The shop borrows the live inventory, so all actions remain inside the same modal. */
.shop-bag-heading { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #dacda9; margin-bottom: 8px; }
#shop-inventory-count { color: #a5c7cc; font-size: 11px; }
.shop-bag-panel { min-width: 0; padding: 10px; border-left: 1px solid #443b2d; overflow-y: auto; background: #101a1de0; }
#shop-inventory-host .console-center { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#shop-inventory-host .inventory-sidebar { width: 100%; min-width: 0; height: auto; flex-direction: row; padding: 4px; gap: 6px; border: 0; background: none; box-shadow: none; }
#shop-inventory-host .inv-side-title { display: none; }
#shop-inventory-host .inventory-grid { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px); gap: 4px; padding: 4px; }
#shop-inventory-host .inv-slot { width: 48px; height: 48px; }
#shop-inventory-host .inv-slot img { max-width: 44px; max-height: 44px; }
.inv-slot.is-selected { border-color: #b6e1e2; box-shadow: 0 0 0 2px #82bfc566; }
#shop-modal { width: min(1100px, calc(100vw - 24px)); }
#shop-modal .shop-body { grid-template-columns: minmax(180px, 1fr) minmax(170px, .85fr) minmax(210px, .95fr); }
body.mobile-layout #shop-modal { width: calc(100vw - 16px - var(--rd-safe-area-left) - var(--rd-safe-area-right)); }
body.mobile-layout #shop-modal button { min-height: 44px; }
body.mobile-layout #btn-toggle-destroy { min-height: 44px; }
body.mobile-layout .shop-item { min-height: 90px; }
body.mobile-layout #mobile-panel-bag .console-center { gap: 10px; }
body.mobile-layout #mobile-panel-bag .inventory-sidebar { width: 100%; height: auto; flex-direction: row; padding: 6px 10px; }

body.shop-open #mobile-move-zone, body.shop-open #item-active-dock,
body.mobile-panel-open #mobile-move-zone, body.mobile-panel-open #item-active-dock,
body.growth-open #mobile-move-zone, body.growth-open #mobile-joystick, body.growth-open #mobile-attack, body.growth-open .mobile-attack-choice,
body.growth-open #item-active-dock, body.growth-open .command-grid,
body.talent-open #mobile-move-zone, body.talent-open #mobile-joystick, body.talent-open #mobile-attack, body.talent-open .mobile-attack-choice,
body.talent-open #item-active-dock, body.talent-open .command-grid,
body:has(#mobile-targeting:not([hidden])) #item-active-dock { visibility: hidden; }

@media (orientation: portrait), (max-width: 599px) {
  body.mobile-layout #preparation-actions { bottom: calc(var(--mobile-edge-bottom) + 8px); width: auto; gap: 0; }
  body.mobile-layout #preparation-actions .prep-summary { max-width: none; font-size: 10px; }
  body.mobile-layout .prep-buttons { width: 100%; }
  body.mobile-layout .prep-buttons button { min-width: 56px; flex: 0 0 auto; padding: 7px 9px; font-size: 11px; }
  body.mobile-layout .skill-rows { gap: 6px; padding: 8px; }
  body.mobile-layout .skill-row { padding: 8px; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 5px; }
  body.mobile-layout .skill-row > div:nth-child(2) { grid-column: 1 / 4; }
  body.mobile-layout .skill-row .skill-key { display: none; }
  body.mobile-layout #shop-modal { height: calc(100dvh - 8px - var(--rd-safe-area-top)); }
  body.mobile-layout #shop-modal .shop-body { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
  body.mobile-layout .shop-catalog { flex: 0 0 auto; overflow: visible; padding: 8px; }
  body.mobile-layout .shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  body.mobile-layout .shop-grid .shop-item { min-height: 88px; padding: 5px 3px; }
  body.mobile-layout .shop-grid .item-icon { width: 38px; height: 38px; }
  body.mobile-layout .shop-grid .shop-item-name { font-size: 10px; }
  body.mobile-layout .shop-detail { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; padding: 8px; flex: 0 0 auto; }
  body.mobile-layout .shop-detail h3 { margin: 0; font-size: 13px; }
  body.mobile-layout #shop-detail-meta { grid-column: 1; font-size: 10px; }
  body.mobile-layout #shop-buy-btn { grid-column: 2; grid-row: 1 / 3; padding: 6px 10px; }
  body.mobile-layout #shop-detail-description { grid-column: 1 / -1; max-height: 88px; font-size: 11px; }
  body.mobile-layout .shop-bag-panel { flex: 0 0 auto; overflow: visible; border-left: 0; border-top: 1px solid #45534c; padding: 8px; }
  body.mobile-layout #shop-inventory-host .inventory-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: 44px; width: 100%; box-sizing: border-box; }
  body.mobile-layout #shop-inventory-host .inv-slot { width: 100%; height: 44px; box-sizing: border-box; }
  body.mobile-layout #shop-inventory-host .inv-slot img { width: 36px; height: 36px; }
  body.mobile-layout #shop-inventory-host .inventory-sidebar { order: 1; }
  body.mobile-layout #shop-inventory-host #inventory-inspector { order: 2; }
  body.mobile-layout #shop-inventory-host #inventory-item-description { max-height: 100px; }
  body.mobile-layout .shop-footer { flex: 0 0 auto; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body.mobile-layout #shop-modal { height: calc(100dvh - 16px); }
  body.mobile-layout #shop-modal .shop-body { grid-template-columns: minmax(160px, 1fr) minmax(165px, .85fr) minmax(210px, 1fr); min-height: 0; overflow: hidden; }
  body.mobile-layout .shop-catalog, body.mobile-layout .shop-detail, body.mobile-layout .shop-bag-panel { min-height: 0; overflow-y: auto; padding: 8px; }
  body.mobile-layout .shop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  body.mobile-layout .shop-item-name { font-size: 10px; }
  body.mobile-layout #inventory-item-description { max-height: 72px; }
  body.mobile-layout #shop-modal .shop-body { grid-template-columns: minmax(150px, 1fr) minmax(160px, .85fr) 300px; }
  body.mobile-layout #shop-inventory-host .inventory-sidebar { display: none; }
  body.mobile-layout #shop-inventory-host .inventory-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: 44px; width: 100%; box-sizing: border-box; }
  body.mobile-layout #shop-inventory-host .inv-slot { width: 100%; height: 44px; box-sizing: border-box; }
  body.mobile-layout #shop-inventory-host .inv-slot img { width: 36px; height: 36px; }
  body.mobile-layout #shop-inventory-host #inventory-inspector { padding: 7px; }
  body.mobile-layout #shop-inventory-host #inventory-item-description { max-height: 48px; }
  body.mobile-layout #skill-modal .talent-header { padding: 8px 12px; }
  body.mobile-layout #skill-modal .skill-footer { padding: 6px 10px; }
  body.mobile-layout .skill-rows { padding: 8px; }
  body.mobile-layout .skill-row { grid-template-columns: 26px minmax(0, 1fr) 52px; padding: 8px; gap: 5px; }
  body.mobile-layout .skill-row > div:nth-child(2) { grid-column: 2; }
  body.mobile-layout .skill-row .skill-rank { grid-column: 1 / 3; grid-row: 2; }
  body.mobile-layout .skill-row .skill-plus { grid-column: 3; grid-row: 1 / 3; align-self: center; }
}
@media (max-width: 739px) and (orientation: landscape) {
  body.mobile-layout #shop-modal .shop-body { grid-template-columns: minmax(0, 1fr) 286px; grid-template-rows: minmax(90px, 1fr) minmax(80px, 1fr); }
  body.mobile-layout .shop-bag-panel { grid-column: 2; grid-row: 1 / 3; }
  body.mobile-layout .shop-catalog { grid-column: 1; grid-row: 1; }
  body.mobile-layout .shop-detail { grid-column: 1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) {
  #talent-modal, #skill-modal { animation: none; }
  .item-active-button, .skill-learn-plus, .talent-card { transition: none; }
}

/* Compact shop controls stay visible while catalog and inventory scroll. */
.shop-wallet { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; color: #dfc98d; white-space: nowrap; font-size: 11px; }
.shop-wallet b { font-size: 18px; font-variant-numeric: tabular-nums; color: #ffe8a5; }
#shop-mode-toggle { flex: 0 0 auto; min-height: 40px; padding: 6px 10px; border: 1px solid #536761; border-radius: 8px; background: #1b2b2d; color: #d7e8dc; font-size: 12px; }
#shop-mode-toggle[aria-pressed="true"] { border-color: #c6b274; background: #344133; color: #fff0be; }
#shop-auto-soul-toggle { min-height: 44px; }
#shop-auto-soul-toggle[aria-pressed="true"] { border-color: #95bc92; background: #2c4936; color: #ddf4c8; }
#shop-modal .shop-header { flex-wrap: wrap; }
#shop-modal .shop-header-left { flex: 1; min-width: 0; }
#shop-modal .shop-options { flex: 0 0 auto; }
.shop-bag-panel .shop-options { margin-top: 8px; justify-content: flex-end; }
#shop-modal.shop-expert #shop-buy-btn { display: none; }
#shop-modal .shop-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; flex: 1; justify-content: flex-end; min-width: 0; }
.shop-floating-tools { display: flex; gap: 10px; align-items: center; }
#shop-modal .shop-fab {
  width: 58px; height: 58px; min-width: 58px; padding: 6px 3px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; border: 1px solid #8da79c; border-radius: 50%;
  background: linear-gradient(145deg, #314d4b, #172d32); color: #e2f0dc; box-shadow: 0 4px 12px #0008, inset 0 1px 1px #ffffff24;
  transition: transform .12s, border-color .12s;
}
#shop-modal .shop-fab span { max-width: 52px; font-size: 10px; line-height: 1.2; white-space: nowrap; color: inherit !important; }
#shop-modal .shop-fab:active { transform: translateY(2px); }
#shop-modal #shop-lock-toggle { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#shop-modal .shop-fab[aria-pressed="true"] { border-color: #f5d783; background: #565334; color: #ffeeb5; }
#shop-feedback { flex-basis: 100%; order: -1; margin: 0; font-size: 11px; color: #b8d7c8; line-height: 1.4; }
#shop-feedback:empty { display: none; }
#shop-modal.shop-expert .shop-detail { display: none; }
#shop-modal.shop-expert .shop-body { grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); }
body.mobile-layout #shop-modal.shop-expert .shop-body { grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); }
body.mobile-layout #shop-modal.shop-expert .shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#shop-modal.shop-expert .shop-bag-panel { grid-column: 2; grid-row: 1; }
#shop-modal.shop-expert .shop-catalog { grid-column: 1; grid-row: 1; }
body.mobile-layout #shop-modal {
  top: var(--mobile-edge-top); bottom: var(--mobile-edge-bottom);
  left: var(--mobile-edge-left); right: var(--mobile-edge-right); transform: none;
  width: auto; height: auto; max-height: none;
}
body.mobile-layout #shop-modal .shop-footer { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 6px 10px; padding: 8px 10px; }
body.mobile-layout #shop-modal .shop-actions { justify-content: space-between; align-items: flex-end; width: 100%; }
body.mobile-layout .shop-detail { display: flex; flex-direction: column; }
body.mobile-layout #shop-modal .shop-header { gap: 8px; }
body.mobile-layout #shop-auto-toggle { max-width: 74px; min-width: 60px; padding: 5px; font-size: 10px; white-space: normal; }
body.mobile-layout #shop-auto-soul-toggle { min-width: 108px; padding: 5px 7px; font-size: 11px; white-space: normal; }
body.mobile-layout #shop-modal .shop-bag-panel .shop-options { position: sticky; bottom: 0; z-index: 2; background: #101a1d; }
body.mobile-layout #shop-inventory-host .inventory-sidebar { display: flex; height: auto; min-height: 44px; order: 1; }
body.mobile-layout #shop-inventory-host .inv-toggle-switch { display: none; }
body.mobile-layout #shop-inventory-host #btn-toggle-destroy { width: 100%; border-radius: 7px; font-size: 12px; }
body.mobile-layout #btn-toggle-destroy.active { background: #632c29; border-color: #ed9c82; color: #ffe2d1; }
body.mobile-layout #item-tooltip { max-width: min(340px, calc(100vw - 20px)); max-height: min(420px, calc(100dvh - 28px)); overflow-y: auto; overscroll-behavior: contain; pointer-events: auto; box-sizing: border-box; font-size: 12px; }
.item-gesture-hint { position: fixed; z-index: 210; max-width: 240px; padding: 7px 10px; border: 1px solid #79968e; border-radius: 7px; background: #162d34ed; color: #e0f0dd; font-size: 12px; box-shadow: 0 3px 12px #0008; pointer-events: none; }
@media (orientation: portrait), (max-width: 599px) {
  body.mobile-layout #item-active-dock { right: calc(var(--mobile-edge-right) + 6px); bottom: calc(var(--mobile-edge-bottom) + 204px); }
  body.mobile-layout .skill-rows { grid-template-columns: minmax(0, 1fr); }
  body.mobile-layout .skill-row { grid-template-columns: minmax(0, 1fr) 56px; }
  body.mobile-layout .skill-row > div:nth-child(2) { grid-column: 1; }
  body.mobile-layout .skill-row .skill-rank { grid-column: 1; }
  body.mobile-layout .skill-row .skill-plus { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  body.mobile-layout #shop-modal .shop-header { display: grid; grid-template-columns: minmax(0, 1fr) auto 36px; gap: 6px 8px; padding: 8px 10px; }
  body.mobile-layout .shop-header-left { grid-column: 1 / 3; grid-row: 1; }
  body.mobile-layout #shop-close-btn { grid-column: 3; grid-row: 1; justify-self: end; }
  body.mobile-layout .shop-wallet { grid-column: 1; grid-row: 2; }
  body.mobile-layout #shop-mode-toggle { grid-column: 2 / 4; grid-row: 2; }
  body.mobile-layout #shop-modal .shop-fab { min-width: 52px; width: 52px; height: 52px; min-height: 52px; }
  body.mobile-layout .shop-floating-tools { gap: 7px; }
  body.mobile-layout #shop-modal .shop-actions { gap: 7px; }
  body.mobile-layout #shop-modal.shop-expert .shop-body { display: flex; flex-direction: column; overflow: hidden; }
  body.mobile-layout #shop-modal.shop-expert .shop-catalog { min-height: 80px; flex: 1; overflow-y: auto; }
  body.mobile-layout #shop-modal.shop-expert .shop-bag-panel { flex: 0 0 auto; }
}
@media (min-width: 600px) and (orientation: landscape) {
  body.mobile-layout .skill-row:nth-child(odd) { grid-template-columns: 52px minmax(0, 1fr) 26px; }
  body.mobile-layout .skill-row:nth-child(odd) .skill-key { grid-column: 3; grid-row: 1; }
  body.mobile-layout .skill-row:nth-child(odd) > div:nth-child(2) { grid-column: 2; grid-row: 1; }
  body.mobile-layout .skill-row:nth-child(odd) .skill-rank { grid-column: 2 / 4; grid-row: 2; }
  body.mobile-layout .skill-row:nth-child(odd) .skill-plus { grid-column: 1; grid-row: 1 / 3; align-self: center; }
}
@media (max-height: 360px) and (orientation: landscape) {
  body.mobile-layout #mobile-toolbar { top: var(--mobile-edge-top); }
  body.mobile-layout #top-bar { top: var(--mobile-edge-top); right: calc(var(--mobile-edge-right) + 248px); max-width: 200px; }
  body.mobile-layout #mobile-cancel-targeting { bottom: calc(var(--mobile-edge-bottom) + 182px); }
  body.mobile-layout #shop-modal .shop-header { display: flex; flex-wrap: nowrap; gap: 6px; padding: 4px 8px; }
  body.mobile-layout #shop-modal .shop-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(135px, .9fr) 210px; grid-template-rows: minmax(0, 1fr); }
  body.mobile-layout #shop-modal .shop-catalog,
  body.mobile-layout #shop-modal .shop-detail,
  body.mobile-layout #shop-modal .shop-bag-panel { min-height: 0; overflow-y: auto; padding: 6px; }
  body.mobile-layout #shop-modal .shop-catalog { grid-column: 1; grid-row: 1; }
  body.mobile-layout #shop-modal .shop-detail { grid-column: 2; grid-row: 1; border-top: 0; border-left: 1px solid #443b2d; }
  body.mobile-layout #shop-modal .shop-bag-panel { grid-column: 3; grid-row: 1; }
  body.mobile-layout #shop-modal .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.mobile-layout #shop-modal.shop-expert .shop-body { display: grid; grid-template-columns: minmax(0, 1fr) 210px; grid-template-rows: minmax(0, 1fr); }
  body.mobile-layout #shop-modal.shop-expert .shop-bag-panel { grid-column: 2; }
  body.mobile-layout #shop-modal.shop-expert .shop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.hero-part-choices[hidden], .hero-part-help[hidden] { display: none; }
#hero-selection-modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: max(8px, var(--rd-safe-area-top)) max(12px, var(--rd-safe-area-right)) max(8px, var(--rd-safe-area-bottom)) max(12px, var(--rd-safe-area-left)); background: #05090bf0; box-sizing: border-box; }
#hero-selection-modal[hidden] { display: none; }
.hero-selection-dialog { display: flex; flex-direction: column; width: min(920px, 100%); max-height: 100%; min-height: 0; overflow: hidden; padding: 14px; border: 2px solid #b8914b; border-radius: 12px; background: linear-gradient(150deg, #242728, #11171c); color: #f2e7cf; box-shadow: 0 12px 48px #000b; box-sizing: border-box; font-family: 'Microsoft YaHei', sans-serif; }
.hero-selection-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-selection-dialog h2 { margin: 0; font-size: 18px; }
.hero-selection-dialog header, .hero-selection-note, .run-selection-footer { flex: 0 0 auto; }
.hero-selection-note { margin: 4px 0 6px; font-size: 12px; line-height: 1.5; color: #dec895; }
.run-selection-body { display: grid; grid-template-columns: minmax(0, 1fr) 198px; gap: 12px; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.run-heroes, .run-difficulty { min-width: 0; }
.run-section-title { margin: 0 0 8px; font-size: 13px; font-weight: normal; color: #bcc9c7; }
.hero-selection-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hero-selection-dialog button { min-height: 44px; padding: 8px 12px; border: 1px solid #bd9b57; border-radius: 7px; background: #40351e; color: #fff0c9; font-family: inherit; cursor: pointer; touch-action: manipulation; }
.hero-selection-choices button { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-content: start; gap: 3px 6px; min-width: 0; width: 100%; padding: 8px; text-align: left; font-size: 12px; border-color: #536166; background: #1b272c; }
.hero-selection-choices img { grid-row: 1 / 3; width: 28px; height: 28px; border: 1px solid #8b7958; border-radius: 5px; object-fit: cover; }
.hero-selection-choices strong { align-self: end; font-size: 13px; color: #ffe0a0; }
.hero-selection-choices span { color: #c3cecf; font-size: 10px; }
.hero-selection-choices small { grid-column: 1 / -1; min-height: 28px; color: #9cacb0; line-height: 1.4; font-size: 10px; }
.run-difficulty-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.run-difficulty-choices button { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 3px 6px; min-width: 0; min-height: 44px; padding: 6px 8px; background: #1b272c; border-color: #536166; }
.run-difficulty-choices span { font-size: 10px; color: #c3cecf; }
.hero-selection-dialog button[aria-pressed="true"] { border-color: #e2bf75; background: #51432a; box-shadow: inset 0 0 0 1px #e2bf75; }
#run-difficulty-detail { margin: 8px 0 0; font-size: 11px; line-height: 1.5; white-space: pre-line; color: #c6c8b9; }
.run-selection-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; margin-top: 6px; border-top: 1px solid #62604b; }
#run-selection-summary { color: #ffe0a0; font-size: 13px; }
#run-start { min-width: 150px; background: linear-gradient(#866b35, #51401e); font-size: 15px; font-weight: bold; }
.hero-selection-dialog button:focus-visible { outline: 2px solid #fff0bb; outline-offset: 3px; }
@media (max-height: 360px) and (orientation: landscape) {
  .hero-selection-dialog { padding: 10px; }
  .hero-selection-choices button { padding: 6px; }
  .hero-selection-choices strong { font-size: 12px; }
}

/* Acquisition controls and refresh budgets remain outside the shop scroll areas. */
.shop-automation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 6px 10px; flex: 0 0 auto; border-bottom: 1px solid #44534a; background: #14211f; }
#shop-modal .shop-automation .shop-auto-toggle { min-width: 0; max-width: none; min-height: 44px; margin: 0; padding: 6px; font-size: 11px; white-space: normal; line-height: 1.3; }
#shop-modal .shop-automation [aria-pressed="true"] { border-color: #96c48f; color: #ddf7c9; background: #294a35; }
#shop-refresh-status { margin-right: auto; min-width: 0; font-size: 11px; line-height: 1.5; color: #b9c9c0; font-variant-numeric: tabular-nums; }
#shop-refresh-status.limited { color: #ffe19b; font-weight: bold; }
#shop-refresh-status.exhausted { color: #ffb3a4; }
@media (min-width: 600px) and (orientation: landscape) {
  body.mobile-layout #shop-modal .shop-header { flex-wrap: nowrap; padding: 4px 8px; gap: 6px; }
  body.mobile-layout #shop-modal .shop-header-left { flex-wrap: nowrap; gap: 5px; }
  body.mobile-layout #shop-upgrade-btn { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 4px 6px; }
  body.mobile-layout #shop-modal .shop-automation { gap: 4px; padding: 4px 8px; }
  body.mobile-layout #shop-modal .shop-automation .shop-auto-toggle { min-height: 44px; }
  body.mobile-layout #shop-modal .shop-footer { padding: 5px 8px; }
  body.mobile-layout #shop-modal .shop-actions { align-items: center; gap: 8px; }
  body.mobile-layout #shop-modal .shop-floating-tools { gap: 6px; }
  body.mobile-layout #shop-modal .shop-fab { width: 48px; min-width: 48px; height: 48px; min-height: 48px; border-radius: 10px; }
  body.mobile-layout #shop-modal .shop-fab svg { width: 18px; height: 18px; }
  body.mobile-layout #shop-modal #shop-mode-toggle { min-height: 44px; padding: 4px 6px; font-size: 11px; }
  body.mobile-layout #shop-attributes-btn { min-height: 44px; }
  body.mobile-layout #shop-modal .shop-market-info summary { min-height: 0; padding: 4px 10px; }
  body.mobile-layout #shop-modal .shop-market-info[open] { max-height: 30dvh; overflow-y: auto; }
}

#player-commands-overlay[hidden], #player-hg-button[hidden] { display: none !important; }
#player-commands-overlay { position: fixed; inset: 0; z-index: 290; display: grid; place-items: center; padding: max(8px, var(--rd-safe-area-top)) max(8px, var(--rd-safe-area-right)) max(8px, var(--rd-safe-area-bottom)) max(8px, var(--rd-safe-area-left)); background: #000a; box-sizing: border-box; color: #e9dfc5; font-family: 'Microsoft YaHei', sans-serif; }
#player-commands-dialog { display: flex; flex-direction: column; width: min(680px, 100%); max-height: 100%; padding: 10px; gap: 8px; box-sizing: border-box; border: 1px solid #a18a59; border-radius: 8px; background: #152025; overflow-y: auto; overscroll-behavior: contain; }
#player-commands-dialog header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#player-commands-title { margin: 0; font-size: 16px; }
#player-commands-dialog button { min-height: 44px; padding: 6px 10px; border: 1px solid #69756a; border-radius: 5px; background: #293b3a; color: #e9dfc5; font: inherit; font-size: 12px; cursor: pointer; touch-action: manipulation; }
#player-commands-dialog button:disabled { opacity: .5; }
#player-commands-dialog [aria-pressed="true"] { border-color: #abd08e; background: #36523a; }
#player-command-toggles, #player-command-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#player-command-form { display: flex; gap: 6px; }
#player-command-input { flex: 1; min-width: 0; min-height: 44px; box-sizing: border-box; border: 1px solid #738078; border-radius: 4px; background: #0e191d; color: #f4e6c2; font: inherit; padding: 6px 10px; }
#player-command-result { flex: 0 0 auto; margin: 0; white-space: pre-wrap; font-size: 12px; line-height: 1.6; max-height: 110px; overflow-y: auto; }
body.mobile-layout.mobile-in-combat #player-hg-button {
  position: fixed; display: block; right: calc(var(--mobile-edge-right) + 236px); bottom: calc(var(--mobile-edge-bottom) + 196px);
  width: 72px; min-height: 48px; box-sizing: border-box; padding: 6px 8px; z-index: 31;
  border: 1px solid #8e6c38; border-radius: 6px; background: rgba(14,18,22,.88); color: #d5e8f4;
  font: 12px/1.25 'Microsoft YaHei', system-ui, sans-serif; cursor: pointer; touch-action: none; user-select: none;
}
body.mobile-layout #player-hg-button:disabled { opacity: .55; }
body.mobile-layout #player-hg-button:active:not(:disabled) { background: #314451; border-color: #abd5ed; }
body.mobile-layout #player-hg-button:focus-visible { outline: 2px solid #a7dbff; outline-offset: 3px; }
body.shop-open #player-hg-button, body.mobile-panel-open #player-hg-button,
body.growth-open #player-hg-button, body.talent-open #player-hg-button { visibility: hidden; }
