/* Landscape touch HUD: one attack anchor, one utility band, one preparation path. */
#mobile-practice-toggle { display: none; }
#mobile-practice-toggle[hidden] { display: none !important; }
#mobile-skill-upgrade { display: none; }
#mobile-skill-upgrade[hidden] { display: none !important; }
#skill-points-badge { color: #b8d7ad; font-size: 12px; font-weight: normal; }
#skill-modal .skill-details > summary { display: none; }
#skill-modal .skill-details { grid-column: 1 / -1; min-width: 0; }
#skill-modal .skill-key img { width: 100%; height: 100%; object-fit: cover; }
#skill-modal .skill-key img[hidden], #skill-modal .skill-key-label[hidden] { display: none; }
#skill-modal .skill-kind { display: none; }
#skill-modal-close { min-width: 56px; min-height: 44px; border: 1px solid #65766c; border-radius: 6px; background: #223332; color: #eee6d3; font: 12px/18px "Microsoft YaHei", system-ui, sans-serif; cursor: pointer; }

@media (orientation: landscape) {
  body.mobile-layout {
    --mobile-map-width: 112px;
    --mobile-joystick-size: 112px;
    --mobile-skill-size: 60px;
    --mobile-attack-size: 80px;
    --mobile-attack-choice-size: 44px;
    --hud-gap: 8px;
    --hud-attack-center-right: 58px;
    --hud-attack-center-bottom: 58px;
    --hud-skill-q-outset: 158px;
    --hud-skill-w-outset: 88px;
    --hud-skill-r-outset: 18px;
    --hud-skill-q-rise: -2px;
    --hud-skill-w-rise: 70px;
    --hud-skill-r-rise: 128px;
    --hud-control-surface: rgba(17, 27, 29, .84);
    --hud-control-edge: #b79b66;
  }

  body.mobile-layout #mobile-toolbar,
  body.mobile-layout.mobile-in-combat #mobile-toolbar {
    top: var(--mobile-edge-top); right: var(--mobile-edge-right); gap: 0;
  }
  body.mobile-layout #mobile-toolbar > :not([data-mobile-panel="more"]) { display: none; }
  body.mobile-layout #mobile-toolbar button {
    width: 44px; min-height: 44px; padding: 4px; font-size: 11px;
    background: var(--hud-control-surface); box-shadow: none;
  }
  body.mobile-layout #minimap-dock { width: var(--mobile-map-width); }
  body.mobile-layout #minimap-dock .minimap-heading { font-size: 9px; }

  body.mobile-layout #top-bar {
    top: var(--mobile-edge-top); right: calc(var(--mobile-edge-right) + 56px); left: auto;
    width: auto; max-width: calc(100vw - var(--mobile-edge-left) - var(--mobile-edge-right) - 192px);
    min-height: 44px; padding: 0; align-items: center; gap: 12px; flex-wrap: nowrap;
    border: 0; border-radius: 0; background: none; box-shadow: none;
    color: #f4e9cf; text-shadow: 0 1px 3px #000;
  }
  body.mobile-layout #top-bar .top-res-item { gap: 4px; }
  body.mobile-layout #top-bar .top-gold,
  body.mobile-layout #top-bar .top-wave { font-size: 11px; }
  body.mobile-layout #top-bar .top-state { font-size: 11px; }
  body.mobile-layout #top-bar .top-res-item:has(#wave-status-text:not(.state-revival)),
  body.mobile-layout:not(.mobile-in-combat) #top-bar .top-res-item:has(#wave-enemies-left),
  body.mobile-layout #top-bar #top-disabled-container { display: none; }
  body.mobile-layout #mobile-menu-rules-host #top-disabled-container {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0;
    font-size: 12px; line-height: 1.5; color: #e4b9b0;
  }
  body.mobile-layout #target-frame-dock {
    top: calc(var(--mobile-edge-top) + 44px) !important;
    left: calc(50% + (var(--mobile-edge-left) - var(--mobile-edge-right)) / 2) !important;
    width: 186px; transform: translateX(-50%); background: rgba(16, 24, 27, .8);
  }
  body.mobile-layout #hero-status-hud {
    top: calc(var(--mobile-edge-top) + 92px); bottom: auto;
    left: calc(50% + (var(--mobile-edge-left) - var(--mobile-edge-right)) / 2);
    width: min(350px, calc(100vw - var(--mobile-edge-left) - var(--mobile-edge-right) - 360px));
    justify-content: center; align-items: flex-start;
  }

  body.mobile-layout #mobile-joystick,
  body.mobile-layout:not(.mobile-in-combat) #mobile-joystick {
    left: calc(var(--mobile-edge-left) + 12px); bottom: calc(var(--mobile-edge-bottom) + 24px);
    width: var(--mobile-joystick-size); height: var(--mobile-joystick-size);
    border-width: 1px; background: rgba(68, 103, 119, .12); box-shadow: none;
  }
  body.mobile-layout #mobile-move-zone,
  body.mobile-layout:not(.mobile-in-combat) #mobile-move-zone {
    left: var(--mobile-edge-left); bottom: var(--mobile-edge-bottom);
    width: min(32vw, 240px); height: 164px;
  }
  body.mobile-layout .mobile-control-caption,
  body.mobile-layout .desktop-hotkey { display: none; }

  body.mobile-layout #mobile-attack {
    right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right) - var(--mobile-attack-size) / 2);
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom) - var(--mobile-attack-size) / 2);
    width: var(--mobile-attack-size); height: var(--mobile-attack-size);
    border-width: 2px; border-color: var(--hud-control-edge); box-shadow: 0 3px 10px #0006;
    background: var(--hud-control-surface);
  }
  body.mobile-layout #mobile-attack small { bottom: 4px; padding: 1px 7px; font-size: 11px; }
  body.mobile-layout #mobile-attack small span { display: none; }
  body.mobile-layout .mobile-attack-choice {
    width: var(--mobile-attack-choice-size); height: var(--mobile-attack-choice-size);
    padding: 2px; gap: 0; background: var(--hud-control-surface); box-shadow: none;
    border-color: var(--hud-control-edge); font-size: 10px; line-height: 12px;
  }
  body.mobile-layout .mobile-attack-choice svg { width: 18px; height: 18px; }
  body.mobile-layout #mobile-attack-boss {
    right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right) - 32px - var(--mobile-attack-choice-size) / 2);
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom) + 70px - var(--mobile-attack-choice-size) / 2);
  }
  body.mobile-layout #mobile-attack-minion {
    right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right) + 88px - var(--mobile-attack-choice-size) / 2);
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom) - 32px - var(--mobile-attack-choice-size) / 2);
  }

  body.mobile-layout .command-grid > #skill-slot-q,
  body.mobile-layout .command-grid > #skill-slot-w,
  body.mobile-layout .command-grid > #skill-slot-r {
    width: var(--mobile-skill-size); height: var(--mobile-skill-size); border-width: 2px;
    border-color: var(--hud-control-edge); box-shadow: 0 2px 8px #0006;
  }
  body.mobile-layout .command-grid > #skill-slot-q {
    right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right) + var(--hud-skill-q-outset) - var(--mobile-skill-size) / 2);
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom) + var(--hud-skill-q-rise) - var(--mobile-skill-size) / 2);
  }
  body.mobile-layout .command-grid > #skill-slot-w,
  body.mobile-layout[data-mobile-active-count="2"] .command-grid > #skill-slot-r {
    right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right) + var(--hud-skill-w-outset) - var(--mobile-skill-size) / 2);
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom) + var(--hud-skill-w-rise) - var(--mobile-skill-size) / 2);
  }
  body.mobile-layout .command-grid > #skill-slot-r {
    right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right) + var(--hud-skill-r-outset) - var(--mobile-skill-size) / 2);
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom) + var(--hud-skill-r-rise) - var(--mobile-skill-size) / 2);
  }
  body.mobile-layout .command-grid > .cmd-slot .skill-learn-plus,
  body.mobile-layout[data-mobile-active-count="2"] .command-grid > #skill-slot-r .skill-learn-plus {
    left: -48px; top: -48px; right: auto; width: 44px; height: 44px;
    box-shadow: 0 2px 7px #0007;
  }
  body.mobile-layout .command-grid .cmd-key { display: none; }
  body.mobile-layout .command-grid .skill-level-badge { top: 5px; left: -4px; font-size: 10px; }
  body.mobile-layout .command-grid .skill-level-badge[data-level="0"] { display: none; }
  body.mobile-layout .command-grid .cmd-slot[data-unavailable="unlearned"]::after {
    content: attr(data-learn-label); bottom: 7px; font-size: 10px; line-height: 16px;
  }

  body.mobile-layout #item-active-dock {
    left: auto; right: var(--item-active-right, calc(var(--mobile-edge-right) + 310px));
    bottom: var(--item-active-bottom, calc(var(--mobile-edge-bottom) + 4px));
    width: max-content; max-width: var(--item-active-max-width, 144px);
    display: flex; flex-direction: row-reverse; flex-wrap: wrap-reverse;
    gap: var(--hud-gap) 6px; align-items: end; justify-content: flex-start;
  }
  body.mobile-layout #item-active-dock .item-active-button {
    width: 44px; height: 48px; min-height: 48px; padding: 4px; border-radius: 8px;
    border-color: var(--hud-control-edge); background: var(--hud-control-surface); box-shadow: none;
  }
  body.mobile-layout #item-active-dock .item-active-button img { width: 34px; height: 36px; border-radius: 4px; }
  body.mobile-layout #item-active-dock .item-active-label { display: none; }
  body.mobile-layout #item-active-dock .item-active-cooldown { inset: 2px; border-radius: 6px; }
  body.mobile-layout.mobile-in-combat #player-hg-button {
    right: calc(var(--mobile-edge-right) + 258px); bottom: calc(var(--mobile-edge-bottom) + 4px);
    width: 44px; min-height: 44px; height: 44px; padding: 3px; border-radius: 50%;
    font-size: 10px; line-height: 14px; background: var(--hud-control-surface); box-shadow: none;
  }

  body.mobile-layout #preparation-actions {
    left: var(--mobile-edge-left); right: var(--mobile-edge-right); bottom: var(--mobile-edge-bottom);
    width: auto; height: 0; max-width: none; margin: 0; padding: 0;
    border: 0; border-radius: 0; background: none; box-shadow: none; transform: none;
  }
  body.mobile-layout #preparation-actions .prep-buttons { display: contents; }
  body.mobile-layout #preparation-actions .prep-buttons button {
    min-height: 44px; padding: 6px; font-size: 12px; line-height: 16px; white-space: normal;
    background: var(--hud-control-surface);
  }
  body.mobile-layout #prep-growth-btn,
  body.mobile-layout #prep-shop-btn {
    position: fixed; top: calc(var(--mobile-edge-top) + 112px); bottom: auto;
    margin: 0; height: 44px; border-radius: 6px;
  }
  body.mobile-layout #prep-growth-btn { left: var(--mobile-edge-left); width: 96px; }
  body.mobile-layout #prep-shop-btn { left: calc(var(--mobile-edge-left) + 104px); width: 64px; }
  body.mobile-layout #preparation-actions #prep-claim-advanced {
    position: fixed; top: calc(var(--mobile-edge-top) + 112px); left: calc(var(--mobile-edge-left) + 176px);
    margin: 0; width: 108px; height: 44px; border-radius: 6px;
  }
  body.mobile-layout.mobile-in-combat #mobile-skill-upgrade {
    display: block; position: fixed; left: var(--mobile-edge-left); top: calc(var(--mobile-edge-top) + 112px);
    width: 96px; min-height: 44px; padding: 6px; box-sizing: border-box;
    border: 1px solid #a4c48f; border-radius: 6px; background: var(--hud-control-surface);
    color: #d6f0c9; font: 12px/16px "Microsoft YaHei", system-ui, sans-serif;
    touch-action: manipulation; z-index: 30;
  }
  body.mobile-layout #mobile-skill-upgrade:focus-visible { outline: 2px solid #ffe2a1; outline-offset: 3px; }
  body.mobile-layout #skill-modal .talent-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; }
  body.mobile-layout #skill-modal .talent-header-title { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; }
  body.mobile-layout #skill-modal .skill-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 4px 18px; padding: 4px 12px; overflow-y: auto; }
  body.mobile-layout #skill-modal .skill-row {
    grid-template-columns: 44px minmax(0, 1fr) 64px; grid-template-rows: auto auto;
    gap: 0 8px; padding: 8px 0 0; border: 0; border-bottom: 1px solid #354741;
    border-radius: 0; background: none; align-items: center;
  }
  body.mobile-layout #skill-modal .skill-row .skill-key { grid-column: 1; grid-row: 1; width: 44px; height: 44px; padding: 0; overflow: hidden; border: 0; border-radius: 6px; background: #263b3c; }
  body.mobile-layout #skill-modal .skill-row .skill-content { grid-column: 2; grid-row: 1; min-width: 0; }
  body.mobile-layout #skill-modal .skill-name { color: #f0e4cd; font-size: 13px; line-height: 18px; }
  body.mobile-layout #skill-modal .skill-kind { display: block; color: #b5c3b9; font-size: 10px; line-height: 15px; }
  body.mobile-layout #skill-modal .skill-row .skill-rank { color: #b9d7b0; margin: 0; font-size: 11px; line-height: 16px; }
  body.mobile-layout #skill-modal .skill-row .skill-plus { grid-column: 3; grid-row: 1; align-self: center; width: 64px; min-width: 64px; height: 44px; min-height: 44px; padding: 4px; border: 1px solid #849c66; border-radius: 6px; background: #354b34; color: #eff2d8; font: 12px/16px "Microsoft YaHei", system-ui, sans-serif; }
  body.mobile-layout #skill-modal .skill-row .skill-plus:disabled { background: #202e2d; border-color: #46574e; color: #a7b4aa; opacity: 1; cursor: default; }
  body.mobile-layout #skill-modal .skill-details { grid-column: 1 / -1; grid-row: 2; }
  body.mobile-layout #skill-modal .skill-details > summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 8px; color: #afc5bf; font-size: 11px; line-height: 16px; list-style: none; cursor: pointer; }
  body.mobile-layout #skill-modal .skill-details > summary::-webkit-details-marker { display: none; }
  body.mobile-layout #skill-modal .skill-details > summary::after { content: ""; width: 6px; height: 6px; margin-right: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); }
  body.mobile-layout #skill-modal .skill-details[open] > summary::after { transform: rotate(225deg); }
  body.mobile-layout #skill-modal .skill-details .skill-mechanism { margin-top: 0; }
  body.mobile-layout #skill-modal .skill-details .skill-requirement { padding-bottom: 8px; }
  body.mobile-layout #skill-modal .skill-footer { min-height: 30px; padding: 4px 12px; flex-wrap: nowrap; gap: 8px; }
  body.mobile-layout #skill-modal #skill-feedback { display: block; flex: 1 1 auto; min-height: 18px; margin: 0; color: #b9d7b0; font-size: 11px; line-height: 18px; }
  body.mobile-layout #skill-modal #skill-rules { display: none; }
  body.mobile-layout #skill-modal .skill-footer > span:has(#skill-open-talents[hidden]) { display: none; }
  body.mobile-layout #skill-modal button:focus-visible,
  body.mobile-layout #skill-modal summary:focus-visible { outline: 2px solid #ffe2a1; outline-offset: 2px; }
  body.mobile-layout #prep-next-boss {
    position: fixed; left: auto; right: calc(var(--mobile-edge-right) + 12px);
    bottom: calc(var(--mobile-edge-bottom) + 72px); width: 210px; max-width: 210px;
    box-sizing: border-box; min-height: 34px; max-height: 54px; margin: 0; padding: 8px 10px;
    border: 1px solid #867045; border-bottom: 0; border-radius: 8px 8px 0 0;
    font-size: 12px; line-height: 18px; text-align: left; background: rgba(17, 27, 29, .92);
  }
  body.mobile-layout #preparation-actions #btn-banner-start-wave {
    position: fixed; right: calc(var(--mobile-edge-right) + 12px);
    bottom: calc(var(--mobile-edge-bottom) + 16px); width: 210px; height: 56px;
    margin: 0; border-radius: 0 0 8px 8px; background: #235239; border-color: #6aaf7e;
    font-size: 16px; line-height: 20px;
  }
  body.mobile-layout #mobile-practice-toggle {
    display: block; position: fixed; top: calc(var(--mobile-edge-top) + 56px);
    right: calc(var(--mobile-edge-right) + 12px); width: 80px; min-height: 44px;
    padding: 5px; border: 1px solid #8e6c38; border-radius: 6px;
    color: #eddfbd; background: var(--hud-control-surface); font: 12px/18px "Microsoft YaHei", system-ui, sans-serif;
    touch-action: manipulation; z-index: 30;
  }
  body.mobile-layout #mobile-practice-toggle[aria-expanded="true"] { border-color: #d6bc7b; color: #fff0c9; }
  body.mobile-layout #mobile-practice-toggle:focus-visible { outline: 2px solid #ffe2a1; outline-offset: 3px; }
  body.mobile-layout:not(.mobile-in-combat):not(.mobile-practice) .command-grid > #skill-slot-q,
  body.mobile-layout:not(.mobile-in-combat):not(.mobile-practice) .command-grid > #skill-slot-w,
  body.mobile-layout:not(.mobile-in-combat):not(.mobile-practice) .command-grid > #skill-slot-r,
  body.mobile-layout:not(.mobile-in-combat):not(.mobile-practice) #item-active-dock,
  body.mobile-layout.mobile-practice #prep-next-boss,
  body.mobile-layout.mobile-practice #btn-banner-start-wave { visibility: hidden; }
  body.mobile-layout.mobile-practice #btn-banner-start-wave { pointer-events: none; }
  body.mobile-layout #mobile-cancel-targeting {
    top: calc(var(--mobile-edge-top) + 56px); bottom: auto;
    right: calc(var(--mobile-edge-right) + 12px); width: 64px; height: 64px;
  }
  body.mobile-layout #mobile-attack-aim {
    top: calc(var(--mobile-edge-top) + 148px);
    left: calc(var(--mobile-edge-left) + var(--mobile-map-width) + 24px); transform: none;
    width: clamp(120px, calc(100vw - var(--mobile-edge-left) - var(--mobile-edge-right) - 440px), 220px);
    max-width: 220px;
    border: 0; padding: 4px 8px; background: rgba(17, 27, 29, .88);
  }
  body.shop-open #mobile-practice-toggle,
  body.mobile-panel-open #mobile-practice-toggle,
  body.growth-open #mobile-practice-toggle,
  body.talent-open #mobile-practice-toggle,
  body:has(#mobile-targeting:not([hidden])) #mobile-practice-toggle { visibility: hidden; }
  body.shop-open #mobile-skill-upgrade,
  body.mobile-panel-open #mobile-skill-upgrade,
  body.growth-open #mobile-skill-upgrade,
  body.talent-open #mobile-skill-upgrade,
  body:has(#mobile-targeting:not([hidden])) #mobile-skill-upgrade { visibility: hidden; }
}
/* Oshd has four active skills. Other heroes retain their three-slot arc. */
body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-e {
  position: fixed; display: block; width: var(--mobile-skill-size); height: var(--mobile-skill-size);
  box-sizing: border-box; border: 2px solid var(--hud-control-edge, #b89d60); border-radius: 50%; overflow: visible;
  background: #141c25; box-shadow: 0 2px 8px #0006; touch-action: none; pointer-events: auto; z-index: 28;
}
body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-q {
  right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right, 70px) + 152px - var(--mobile-skill-size) / 2);
  bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 10px - var(--mobile-skill-size) / 2);
}
body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-w {
  right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right, 70px) + 138px - var(--mobile-skill-size) / 2);
  bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 78px - var(--mobile-skill-size) / 2);
}
body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-e {
  right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right, 70px) + 80px - var(--mobile-skill-size) / 2);
  bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 123px - var(--mobile-skill-size) / 2);
}
body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-r {
  right: calc(var(--mobile-edge-right) + var(--hud-attack-center-right, 70px) + 10px - var(--mobile-skill-size) / 2);
  bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 152px - var(--mobile-skill-size) / 2);
}
body.mobile-layout.hero-serpent-master.mobile-panel-open .command-grid > #skill-slot-e,
body.mobile-layout.hero-serpent-master.mobile-subpage-open .command-grid > #skill-slot-e,
body.mobile-layout.hero-serpent-master:not(.mobile-in-combat):not(.mobile-practice) .command-grid > #skill-slot-e {
  visibility: hidden; pointer-events: none;
}
@media (max-height: 360px) {
  body.mobile-layout.hero-serpent-master { --mobile-skill-size: 54px; }
  body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-q {
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) - var(--mobile-skill-size) / 2);
  }
  body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-w {
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 55px - var(--mobile-skill-size) / 2);
  }
  body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-e {
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 100px - var(--mobile-skill-size) / 2);
  }
  body.mobile-layout.hero-serpent-master .command-grid > #skill-slot-r {
    bottom: calc(var(--mobile-edge-bottom) + var(--hud-attack-center-bottom, 68px) + 100px - var(--mobile-skill-size) / 2);
  }
}
