/* HUD 2.0 — combat content first. Loaded last to supersede legacy portrait patches. */
.compact-hud,.touch-context,.compact-soul-charge,.compact-dodge-charge{display:none}
.touch-context[hidden]{display:none!important}

@media (pointer:coarse){
  .left-hud,.right-hud,.objective,.arsenal,
  #app:has(#upgradeBtn:not(.hidden)) .arsenal{display:none!important}
  .topbar{height:0!important;padding:0!important;background:none!important;pointer-events:none}
  .topbar .brand,.topbar .wave-seal,.header-actions #pauseBtn{display:none!important}
  .topbar .header-actions{position:fixed;top:calc(var(--hud-safe-top,12px) + 2px);right:var(--hud-safe-right,12px);z-index:20;pointer-events:auto}
  .hud-menu summary{display:flex;align-items:center;justify-content:center;list-style:none;width:48px;height:48px;min-height:48px!important;min-width:48px!important;padding:0!important;font-size:0!important;color:#e5d4b1;border:1px solid #b69a654d;border-radius:8px;background:#0f1b1de8}
  .hud-menu summary::-webkit-details-marker{display:none}
  .hud-menu summary::before{content:'☰';font:600 22px system-ui;line-height:1}
  .hud-menu-panel{position:fixed;top:calc(var(--hud-safe-top,12px) + 56px)!important;right:var(--hud-safe-right,12px);max-height:min(58dvh,420px);z-index:21}

  .compact-hud{display:block;position:fixed;top:var(--hud-safe-top,12px);left:var(--hud-safe-left,12px);width:calc(100vw - var(--hud-safe-left,12px) - var(--hud-safe-right,12px) - 58px);max-width:470px;min-width:0;box-sizing:border-box;padding:7px 9px 6px;z-index:8;pointer-events:none;border:1px solid #a38b5852;border-radius:8px;background:#0c1719e9;box-shadow:0 4px 18px #0007}
  .compact-hud.hidden{display:none!important}
  .compact-hud-values{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1.3fr) minmax(0,.85fr) minmax(0,.5fr);gap:8px;align-items:center}
  .compact-hud-values>span{min-width:0;display:flex;flex-direction:column;gap:2px}
  .compact-hud-values small{font:600 9px/1 system-ui;letter-spacing:.04em;color:#8daba5;white-space:nowrap}
  .compact-hud-values b{font:700 clamp(10px,2.6vw,13px)/1.2 system-ui;color:#e7d7b9;white-space:nowrap;font-variant-numeric:tabular-nums}
  .compact-hud-bars{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-top:6px}
  .compact-hud-bars>span{display:block;height:3px;overflow:hidden;border-radius:3px;background:#39413d}
  .compact-hud-bars i{display:block;height:100%;background:#d2aa68;border-radius:3px;transition:width .2s linear}
  .compact-hud-bars>span:nth-child(2) i{background:#86b7a9}
  .compact-hud-detail{display:flex;justify-content:space-between;gap:8px;margin-top:5px;color:#b7c9c1;font:600 9px/1.2 system-ui;font-variant-numeric:tabular-nums}
  .controls .compact-dodge-charge{display:block;position:absolute;bottom:5px;font:700 8px/1 system-ui;color:#f0dca9;pointer-events:none}
  .compact-objective{margin-top:5px;font:600 10px/1.2 system-ui;letter-spacing:.02em;color:#e5c58e}
  .compact-objective.hidden{display:none!important}
  .compact-next-wave{display:block;pointer-events:auto;width:100%;min-height:44px;margin:7px 0 0;background:#514126;color:#f6e3b9;border:1px solid #dbb979;border-radius:6px;font:700 12px system-ui}
  .compact-next-wave.hidden{display:none!important}

  .controls,.controls:has(#buildBtn:not(.hidden)),.controls:has(#upgradeBtn:not(.hidden)),
  .controls:has(#sellBtn:not(.hidden)),.controls:has(#targetBtn:not(.hidden)){
    position:fixed!important;left:auto!important;right:var(--hud-safe-right,12px)!important;
    bottom:calc(var(--hud-safe-bottom,12px) + 12px)!important;transform:none!important;
    width:auto!important;max-width:none!important;display:flex!important;flex-direction:row!important;
    flex-wrap:nowrap!important;gap:10px!important;z-index:7
  }
  .controls #buildBtn,.controls #upgradeBtn,.controls #sellBtn,.controls #targetBtn{display:none!important}
  .controls #soulBtn,.controls #dodgeBtn{position:relative;display:flex;align-items:center;justify-content:center;flex:none;width:58px!important;height:58px!important;min-height:58px!important;min-width:58px!important;padding:0!important;border-radius:50%;border:1px solid #8b927f8c;background:#132225e8;box-shadow:0 3px 12px #0008}
  .controls #soulBtn{border-color:#79c8bd9c;background:#13302eec}
  .controls #dodgeBtn{border-color:#b6a17198;background:#24251ee8}
  .controls #soulBtn span,.controls #dodgeBtn span{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  .controls #soulBtn::before{content:'✦';font:600 27px/1 Georgia,serif;color:#8cd5c5}
  .controls #dodgeBtn::before{content:'➜';font:600 24px/1 system-ui;color:#e9cd91}
  .controls .compact-soul-charge{display:block;position:absolute;bottom:3px;right:3px;font:700 9px/1 system-ui;color:#c9f5e9;text-shadow:0 1px 3px #000;pointer-events:none}
  .joystick{display:flex;left:calc(var(--hud-safe-left,12px) + 4px)!important;bottom:calc(var(--hud-safe-bottom,12px) + 9px)!important;width:94px!important;height:94px!important;border-color:#c5a76b8c;background:#172326b0}
  .joystick span{width:38px;height:38px}
  .boss-hud{position:fixed;top:calc(var(--hud-safe-top,12px) + 78px)!important;left:50%!important;right:auto!important;transform:translateX(-50%)!important;width:min(275px,75vw)!important;box-sizing:border-box;padding:5px 9px!important;border-radius:6px;background:#200f12e5;z-index:8;pointer-events:none}
  .boss-hud>div:first-child{gap:7px;font-size:11px!important;letter-spacing:.03em}
  .boss-meter{height:4px;margin-top:5px}
  .hero-subtitle{top:auto!important;bottom:calc(var(--hud-safe-bottom,12px) + 124px)!important;left:50%!important;right:auto!important;transform:translateX(-50%)!important;width:min(260px,75vw)!important;max-height:70px!important;box-sizing:border-box;padding:6px 9px!important;text-align:left;font-size:12px;box-shadow:0 3px 14px #0009}
  .hero-subtitle b{font-size:9px;margin-bottom:1px}
  .hero-subtitle span{font-size:11px;line-height:1.3}
  .fps-overlay{bottom:calc(var(--hud-safe-bottom,12px) + 130px)!important;left:var(--hud-safe-left,12px)!important;max-width:calc(100vw - 2 * var(--hud-safe-left,12px));font-size:9px!important;overflow-wrap:anywhere}

  .touch-context{display:block;position:fixed;bottom:calc(var(--hud-safe-bottom,12px) + 86px);right:var(--hud-safe-right,12px);width:min(242px,65vw);box-sizing:border-box;padding:9px;z-index:10;border:1px solid #b9a06e88;border-radius:10px;background:linear-gradient(145deg,#132223f5,#0b1315f7);box-shadow:0 7px 26px #000b}
  #touchContext{max-height:calc(100dvh - var(--hud-safe-top,12px) - var(--hud-safe-bottom,12px) - 170px);overflow-y:auto;overscroll-behavior:contain}
  .touch-context.hidden{display:none!important}
  .touch-context-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;color:#e3d0ad}
  .touch-context-title{font:700 12px/1.2 Georgia,serif;letter-spacing:.07em}
  .touch-context-close{width:48px;height:48px;min-width:48px;min-height:48px;border:1px solid #bda56d66;border-radius:7px;color:#e5d4ae;background:#27302c;font-size:20px}
  .touch-context-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  .touch-context-options button{min-width:0;min-height:48px;padding:7px 5px;border:1px solid #a48b5d73;border-radius:7px;background:#1a2928;color:#e7d8bc;font:600 11px/1.25 system-ui;overflow-wrap:anywhere;touch-action:manipulation}
  .touch-context-options button:disabled{opacity:.4;filter:saturate(.5)}
  .touch-context-options button:focus-visible,.touch-context-close:focus-visible{outline:2px solid #edcb87;outline-offset:2px}
}

@media (pointer:coarse) and (orientation:landscape) and (max-height:600px){
  .compact-hud{max-width:440px;width:min(440px,calc(100vw - 135px))}
  .boss-hud{top:calc(var(--hud-safe-top,12px) + 6px)!important;left:70%!important;width:min(230px,30vw)!important}
  .touch-context{bottom:calc(var(--hud-safe-bottom,12px) + 82px);right:var(--hud-safe-right,12px);width:min(270px,43vw)}
  .joystick{width:82px!important;height:82px!important}
  .controls #soulBtn,.controls #dodgeBtn{width:54px!important;height:54px!important;min-width:54px!important;min-height:54px!important}
  .hero-subtitle{bottom:calc(var(--hud-safe-bottom,12px) + 90px)!important}
}
@media (prefers-reduced-motion:reduce){.compact-hud-bars i{transition:none}}
