/* Mobile layouts use independent panels instead of shrinking the desktop HUD. */
@media (max-width: 700px) and (orientation: portrait), (max-width: 540px) {
  html { -webkit-text-size-adjust:100%; }
  .wrap,.live .wrap { padding: max(6px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left)); }
  .stage,.live .stage { max-width:none; width:100%; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding:8px; overflow:hidden; }
  .stage:before { display:none; }
  .stage .player-profile { position:relative; inset:auto; transform:none; grid-column:1/-1; grid-row:1; width:100%; max-width:none; min-height:50px; margin:0; padding:7px 12px; }
  .stage .player-avatar { width:34px; height:34px; }
  .stage .player-identity b { font-size:17px; }
  .stage .player-identity small { font-size:8px; }
  .stage .player-rank { font-size:11px; margin-left:auto; }
  .stage .battle-scenario-status { position:relative; inset:auto; transform:none; grid-column:1/-1; grid-row:2; max-width:none; font-size:10px; padding:4px 8px; }
  .stage #scene { position:relative; grid-column:1/-1; grid-row:3; width:100%; height:auto; aspect-ratio:1000/560; border-radius:5px; }
  .stage .battle-hud { position:relative; inset:auto; transform:none; grid-column:1/-1; grid-row:4; width:100%; padding:0; }
  .stage .battle-hud .round-panel { min-height:0; padding:13px 15px; gap:8px; background:linear-gradient(135deg,#173447,#091824); border:1px solid #668fa3; border-radius:8px; filter:none; }
  .stage .round-heading { gap:12px; }
  .stage .account-balance>span,.stage .today-profit>span { font-size:9px; letter-spacing:1px; }
  .stage .account-balance>b,.stage .today-profit>b { font-size:19px; }
  .stage .round-panel strong { font-size:32px; line-height:1.15; }
  .stage .battle-hud .round-panel .targets-button { min-height:40px; font-size:11px; padding:8px 10px; clip-path:none; }
  .stage .targets-button>span:first-child { display:inline; font-size:11px; }
  .stage .target-pair { gap:12px; }
  .stage .target-pair b { font-size:12px; }
  .stage .target-pair small { font-size:10px; }
  .stage .battle-hud .round-bottom { height:auto; flex:0 0 auto; flex-wrap:wrap; gap:7px; }
  .stage .battle-hud #roundAction { width:100%; min-height:48px; font-size:20px; padding:11px; }
  .stage .signal-status { position:static; width:100%; font-size:11px; padding:7px 9px; }
  .stage .signal-status b { font-size:12px; }
  .stage .corner-panel { position:relative; inset:auto; width:auto; min-width:0; min-height:0; height:auto; padding:11px; align-self:start; }
  .stage .army-panel { grid-row:6; grid-column:1; }
  .stage .regime-panel { grid-row:6; grid-column:2; }
  .stage .lumi-panel { grid-row:7; grid-column:1; background:#102838; border:1px solid #7cabc05e; border-radius:5px; padding:0; overflow:hidden; }
  .stage .signals-panel { grid-row:7; grid-column:2; }
  .stage .corner-panel h2 { font-size:10px; letter-spacing:.7px; margin:0 28px 9px 0; }
  .stage .corner-panel h2 small { display:block; font-size:9px; margin:2px 0 0; }
  .stage .panel-toggle { top:3px; right:3px; width:32px; min-height:32px; }
  .stage .unit-line { gap:5px; margin-top:7px; }
  .stage .unit-line canvas { width:28px; height:32px; }
  .stage .unit-line b { font-size:12px; }
  .stage .unit-line small { font-size:10px; }
  .stage .unit-line .army-pending { font-size:9px; line-height:1.4; }
  .stage .corner-panel dl { font-size:12px; }
  .stage .corner-panel dl>div { gap:4px; margin-top:9px; }
  .stage .lumi-portrait { height:110px; }
  .stage .lumi-speech { position:relative; padding:9px; border:0; border-top:1px solid #72b6d555; }
  .stage .lumi-speech:before { display:none; }
  .stage .lumi-speech h2 { margin-right:0; }
  .stage .lumi-speech p { font-size:11px; line-height:1.5; }
  .stage .radar-lights { gap:5px; }
  .stage .lamp-housing { width:32px; height:32px; }
  .stage .lamp-label { font-size:7px; }
  .stage .corner-panel.collapsed { min-height:40px; padding:0; width:100%; }
  .stage .corner-panel.collapsed .panel-toggle { inset:0; width:100%; min-height:40px; }
  .stage .game-dock { position:relative; inset:auto; grid-column:1/-1; grid-row:5; display:grid; grid-template-columns:1fr auto; gap:8px; padding:10px 0 0; min-width:0; }
  .stage .dock-nav { grid-column:1/-1; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; width:100%; overflow:visible; }
  .stage .game-dock .dock-nav button { min-width:0; min-height:42px; padding:6px 3px; font-size:10px; white-space:normal; overflow-wrap:anywhere; }
  .stage .game-dock .point-button { justify-self:start; min-height:38px; font-size:11px; padding:7px 10px; }
  .stage .ea-link { min-width:0; font-size:9px; }
  .stage .ea-link small { font-size:8px; }
  .demo-note { font-size:9px; line-height:1.5; padding:9px 4px; }
  .settings-open aside.cards { inset:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) auto; width:calc(100% - 16px); max-width:400px; }
  .settings-open input,.settings-open select,.settings-open textarea,.account-dialog input,.account-dialog select { font-size:16px; }
}

@media (orientation:landscape) and (max-height:600px) and (max-width:1200px) and (min-width:541px) {
  .wrap,.live .wrap { padding:4px max(4px,env(safe-area-inset-right)) 4px max(4px,env(safe-area-inset-left)); }
  .stage,.live .stage { width:100%; max-width:none; height:calc(100dvh - 8px); min-height:260px; }
  .stage #scene { position:absolute; left:50%; top:calc((100% - 50px)/2); transform:translate(-50%,-50%); width:min(100%,calc((100dvh - 58px)*1000/560)); height:auto; aspect-ratio:1000/560; }
  .stage .player-profile { top:5px; min-height:38px; width:210px; padding:4px 8px; }
  .stage .player-avatar { width:28px; height:28px; }
  .stage .player-identity b { font-size:14px; }
  .stage .player-identity small { font-size:6px; }
  .stage .player-rank { font-size:9px; }
  .stage .battle-scenario-status { top:47px; max-width:36%; font-size:8px; padding:3px 6px; }
  .stage .corner-panel { width:clamp(132px,19%,180px); min-width:0; padding:9px; }
  .stage .army-panel { top:6px; left:6px; }
  .stage .regime-panel { top:6px; right:6px; }
  .stage .corner-panel h2 { font-size:9px; margin:0 25px 6px 0; letter-spacing:.4px; }
  .stage .corner-panel h2 small { display:none; }
  .stage .unit-line { gap:4px; margin-top:5px; }
  .stage .unit-line canvas { width:26px; height:28px; }
  .stage .unit-line b { font-size:11px; }
  .stage .unit-line small { font-size:9px; }
  .stage .unit-line .army-pending { font-size:8px; }
  .stage .corner-panel dl { font-size:11px; }
  .stage .corner-panel dl>div { margin-top:6px; }
  .stage .panel-toggle { width:28px; min-height:28px; top:2px; right:2px; }
  .stage .lumi-panel { left:6px; bottom:57px; min-height:0; padding:0; }
  .stage .lumi-portrait { display:none; }
  .stage .lumi-speech { position:relative; padding:8px; }
  .stage .lumi-speech p { font-size:10px; line-height:1.4; }
  .stage .lumi-speech h2 { font-size:9px; }
  .stage .lumi-speech:before { display:none; }
  .stage .signals-panel { right:6px; bottom:57px; }
  .stage .radar-lights { gap:5px; }
  .stage .lamp-housing { width:28px; height:28px; }
  .stage .lamp-label { font-size:7px; }
  .stage .radar-indicator { gap:5px; }
  .stage .corner-panel.collapsed { width:32px; height:32px; min-height:32px; padding:0; }
  .stage .battle-hud { width:min(330px,calc(100% - 300px)); bottom:56px; }
  .stage .battle-hud .round-panel { min-height:0; padding:9px 13px; gap:5px; background:linear-gradient(135deg,#132b3bf0,#07131be8); border:1px solid #7cabc07a; border-radius:6px; }
  .stage .battle-hud .round-panel { display:grid; grid-template-columns:1fr 1fr; }
  .stage .battle-hud .round-heading { grid-column:1; grid-row:1; padding-bottom:4px; gap:6px; }
  .stage .battle-hud .round-panel strong { grid-column:2; grid-row:1; }
  .stage .battle-hud .round-panel .targets-button { grid-column:1; grid-row:2; }
  .stage .battle-hud .round-panel .targets-button>span:first-child { display:none; }
  .stage .battle-hud .round-panel .target-pair { flex-wrap:wrap; gap:2px 6px; }
  .stage .battle-hud .round-bottom { grid-column:2; grid-row:2; height:38px; flex:0 0 auto; }
  .stage .account-balance>span,.stage .today-profit>span { font-size:7px; }
  .stage .account-balance>b,.stage .today-profit>b { font-size:12px; }
  .stage .round-panel strong { font-size:24px; }
  .stage .battle-hud #roundAction { min-height:38px; min-width:0; width:100%; font-size:17px; padding:7px 10px; }
  .stage .battle-hud .round-panel .targets-button { min-height:28px; padding:4px 6px; }
  .stage .targets-button>span:first-child { font-size:9px; }
  .stage .target-pair { gap:6px; }
  .stage .target-pair b { font-size:9px; }
  .stage .signal-status { left:0; right:0; font-size:9px; padding:4px 6px; }
  .stage .game-dock { min-height:48px; padding:5px 7px; gap:7px; }
  .stage .dock-nav { gap:4px; }
  .stage .game-dock .dock-nav button { min-height:36px; padding:5px 7px; font-size:10px; }
  .stage .game-dock .point-button { font-size:10px; padding:5px 7px; min-height:36px; }
  .stage .ea-link { min-width:75px; font-size:8px; }
  .stage .ea-link small { font-size:7px; }
  .demo-note { display:none; }
  .settings-open aside.cards { top:6px; bottom:6px; }
  .account-dialog,.scenario-dialog,.leaderboard-dialog { max-height:calc(100dvh - 16px); }
}

@media (orientation:landscape) and (max-height:600px) and (min-width:541px) and (max-width:740px) {
  .stage .game-dock .dock-nav button { font-size:9px; padding:5px; }
  .stage .game-dock .point-button { font-size:9px; padding:5px; }
  .stage .ea-link { min-width:65px; }
}
