@media (any-pointer:coarse) and (max-width:1100px), (max-width:700px) {
  header nav [data-action="controls"] { display:none; }
}

/* Keep the playfield and the sponsor in separate rows. The engine projects
   the complete combat world into the first row at a single uniform scale. */
@media (orientation:landscape) and (any-pointer:coarse),
       (orientation:landscape) and (max-width:1000px) and (max-height:550px) {
  body.fight-mode {
    --fight-left:max(9px,env(safe-area-inset-left,0px));
    --fight-right:max(9px,env(safe-area-inset-right,0px));
    --fight-top:max(3px,env(safe-area-inset-top,0px));
    --fight-bottom:env(safe-area-inset-bottom,0px);
    --sponsor-height:48px;
    --thumb-size:clamp(44px,10.8dvh,62px);
    background:#0b101e;
    overflow:hidden;
    overscroll-behavior:none;
  }
  body.fight-mode #header { display:none; }
  body.fight-mode #fight-screen.active {
    position:fixed;
    inset:0;
    z-index:25;
    width:100%;
    height:100vh;
    height:100dvh;
    min-height:0;
    padding:0;
    display:grid;
    grid-template: minmax(0,1fr) calc(var(--sponsor-height) + var(--fight-bottom)) / minmax(0,1fr);
    justify-content:stretch;
    align-items:stretch;
    isolation:isolate;
    overflow:hidden;
  }
  body.fight-mode #game-frame {
    grid-area:1 / 1;
    width:100%;
    height:100%;
    max-width:none;
    max-height:none;
    min-width:0;
    min-height:0;
    aspect-ratio:auto;
  }
  body.fight-mode #fight-canvas { position:absolute; inset:0; width:100%; height:100%; }

  body.fight-mode .fight-hud {
    top:calc(var(--fight-top) + 2px);
    left:calc(var(--fight-left) + 3px);
    right:calc(var(--fight-right) + 3px);
    gap:clamp(8px,2vw,24px);
    grid-template-columns:minmax(0,1fr) clamp(46px,7vw,72px) minmax(0,1fr);
  }
  body.fight-mode .hud-name { margin:0 0 2px; }
  body.fight-mode .hud-name>span { max-width:100%; font-size:clamp(14px,2.6dvh,24px); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  body.fight-mode .hud-name small { display:none; }
  body.fight-mode .health-track { height:clamp(11px,3.4dvh,19px); }
  body.fight-mode .hud-timer { margin:0; }
  body.fight-mode .hud-timer>b { font-size:clamp(29px,8.5dvh,49px); line-height:.94; }
  body.fight-mode .hud-timer>span { display:none; }
  body.fight-mode .hud-timer>small { font-size:8px; letter-spacing:.7px; }
  body.fight-mode .fight-location { left:50%; top:calc(var(--fight-top) + clamp(55px,13dvh,75px)); transform:translateX(-50%); align-items:center; text-align:center; }
  body.fight-mode .fight-location>span { font-size:clamp(8px,2dvh,11px); }
  body.fight-mode .fight-location>small { display:none; }
  body.fight-mode .energy-hud {
    left:calc(var(--fight-left) + 4px);
    right:calc(var(--fight-right) + 4px);
    bottom:4px;
  }
  body.fight-mode .energy-hud>div { width:min(34%,270px); }
  body.fight-mode .energy-hud>div>span { font-size:8px; margin:0 0 2px; letter-spacing:.4px; }
  body.fight-mode .energy-hud .energy-track { height:6px; }
  body.fight-mode .energy-hud .arena-stamp { display:none; }
  body.fight-mode .fight-announcement { font-size:clamp(35px,11dvh,75px); }
  body.fight-mode .combo-label { top:22%; }
  body.fight-mode #game-frame .power-cue { left:var(--fight-left); bottom:auto; top:calc(var(--fight-top) + 45px); }
  body.fight-mode #game-frame .power-cue.right { left:auto; right:var(--fight-right); }
  body.fight-mode .power-cue small { font-size:7px; }
  body.fight-mode .power-cue strong { font:italic 700 clamp(12px,3.2dvh,20px)/1 var(--display); padding:3px 6px; }

  body.fight-mode .touch-controls {
    left:calc(var(--fight-left) + 2px);
    right:calc(var(--fight-right) + 2px);
    bottom:clamp(25px,6.5dvh,48px);
    align-items:end;
  }
  body.fight-mode .dpad {
    grid-template:repeat(2,var(--thumb-size)) / repeat(3,var(--thumb-size));
    gap:2px;
    filter:drop-shadow(0 2px 2px #00122566);
  }
  body.fight-mode .touch-controls button {
    height:var(--thumb-size);
    min-height:44px;
    width:var(--thumb-size);
    min-width:44px;
    padding:0;
    margin:0;
    border:1.5px solid #eaf5ffb8;
    color:white;
    background:linear-gradient(150deg,#213847cf,#0b1423d4);
    box-shadow:inset 0 2px 0 #ffffff14,0 2px 4px #0005;
    text-shadow:0 1px 2px #000;
    -webkit-touch-callout:none;
    -webkit-tap-highlight-color:transparent;
    backdrop-filter:none;
  }
  body.fight-mode .dpad button { border-radius:28%; font:700 clamp(18px,4.6dvh,28px)/1 system-ui,sans-serif; }
  body.fight-mode .touch-attacks {
    grid-template:repeat(2,var(--thumb-size)) / repeat(2,var(--thumb-size));
    gap:3px 5px;
  }
  body.fight-mode .touch-attacks button { border-radius:50%; font:italic 800 clamp(16px,4.3dvh,24px)/1 var(--display); }
  body.fight-mode .touch-attacks small { font:700 clamp(7px,1.85dvh,10px)/1 var(--body); margin-top:2px; }
  body.fight-mode .touch-attacks [data-input="light"] { grid-area:2/1; }
  body.fight-mode .touch-attacks [data-input="heavy"] { grid-area:2/2; }
  body.fight-mode .touch-attacks #touch-special { grid-area:1/1; border-color:#d9f36f; color:#effdbb; }
  body.fight-mode .touch-attacks #touch-super { grid-area:1/2; border-color:#e9acff; color:#f9ddff; }
  body.fight-mode .touch-controls button.held { background:#d5f460; box-shadow:inset 0 0 0 2px #fff9; color:#15201d; text-shadow:none; }

  body.fight-mode .fight-footer {
    grid-area:2/1;
    z-index:2;
    position:static;
    align-self:start;
    justify-self:start;
    display:inline-flex;
    width:auto;
    height:var(--sponsor-height);
    min-height:0;
    margin:0 0 0 var(--fight-left);
    padding:0;
    border:0;
    background:transparent;
  }
  body.fight-mode .fight-footer .key-legend,
  body.fight-mode .fight-footer #touch-toggle,
  body.fight-mode .fight-footer #match-label { display:none; }
  body.fight-mode .fight-footer #pause-fight {
    display:inline-flex; align-items:center; justify-content:center;
    width:44px; height:44px; padding:0;
    border:0; border-radius:0; color:#e1f2ff; background:#09223b;
  }
  body.fight-mode #pause-fight .pause-glyph { font:800 22px/1 system-ui,sans-serif; }
  body.fight-mode #pause-fight .pause-label { display:none; }
  body.fight-mode .fight-campaign {
    grid-area:2/1;
    height:100%;
    min-height:0;
    display:flex;
    flex-wrap:nowrap;
    gap:clamp(9px,1.9vw,23px);
    align-items:center;
    padding:0 var(--fight-right) var(--fight-bottom) calc(var(--fight-left) + 52px);
    border:0;
    border-top:1px solid #6997b87a;
    background:linear-gradient(100deg,#0c2943,#102d46 62%,#132037);
    overflow:hidden;
  }
  body.fight-mode .campaign-brand { display:flex; padding:0 10px 0 0; margin:0; gap:0; }
  body.fight-mode .campaign-brand .nm-logo { width:clamp(63px,9vw,92px); height:32px; }
  body.fight-mode .campaign-brand small,body.fight-mode .campaign-kicker,
  body.fight-mode .campaign-copy p,body.fight-mode .campaign-note,body.fight-mode .campaign-progress { display:none; }
  body.fight-mode .campaign-copy { flex:1; min-width:0; }
  body.fight-mode .fight-campaign h2 { margin:0; font:700 clamp(12px,1.9vw,21px)/1.05 var(--display); letter-spacing:.1px; }
  body.fight-mode #campaign-cta {
    padding:3px 12px; margin:0;
    min-height:38px; max-width:26%; border-radius:6px;
    font:700 clamp(9px,1.3vw,13px)/1.1 var(--body); text-align:center; letter-spacing:.15px;
  }
  body.fight-mode .arena-overlay { align-items:safe center; overflow:auto; padding:6px var(--fight-right) 6px var(--fight-left); }
  body.fight-mode .overlay-box { width:min(94%,520px); margin:auto; gap:5px; }
  body.fight-mode .overlay-box h2 { margin:0; font-size:clamp(32px,9dvh,60px); }
  body.fight-mode .overlay-box p { margin:0; font-size:12px; line-height:1.25; }
  body.fight-mode .overlay-box .primary,body.fight-mode .overlay-box .secondary { min-height:36px; padding:4px 12px; }
  body.fight-mode .overlay-box .result-sponsor { margin:2px 0; padding:5px 9px; }
  body.fight-mode .overlay-box .result-sponsor .nm-logo,
  body.fight-mode .overlay-box .result-sponsor p { display:none; }
  body.fight-mode #pause-panel [data-action="controls"] { display:none; }
  body.tv-mode .fight-footer { gap:4px; }
  body.tv-mode .fight-footer #tv-fullscreen,body.tv-mode .fight-footer #tv-stop { min-height:42px; padding:2px 5px; font-size:8px; white-space:normal; }
  body.tv-mode .fight-campaign { padding-left:calc(var(--fight-left) + 155px); }
  body.tv-mode .tv-bug { top:calc(var(--fight-top) + 47px); }
}
/* Restrict browser gestures to the active arcade controls. Keep document
   zoom, assistive technologies, forms and reading screens at their defaults. */
body.fight-mode #fight-canvas,
body.fight-mode #touch-controls,
body.fight-mode #touch-controls button {
  touch-action:none;
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
}
body.fight-mode #game-frame { overscroll-behavior:contain; }
body.fight-mode .arena-overlay button,body.fight-mode .fight-footer button { touch-action:manipulation; }

.full-control { display:inline-flex; align-items:center; gap:5px; min-height:44px; }
.full-icon { font:700 20px/1 system-ui,sans-serif; }
.full-control[aria-pressed="true"] .full-icon { color:#c9ef80; }
body.tv-mode #fight-fullscreen { display:none; }
#online-fullscreen { margin-left:auto; }
#immersive-help:not([hidden]) {
  position:fixed; z-index:102; left:50%; transform:translateX(-50%);
  top:max(8px,env(safe-area-inset-top)); width:min(440px,94vw);
  display:flex; align-items:center; gap:12px; padding:7px 12px;
  background:#172735; color:#fff; border:1px solid #8ac2ce; border-radius:6px;
  box-shadow:0 3px 14px #0008;
}
#immersive-instructions { margin:0; font:500 13px/1.35 var(--body); }
#immersive-dismiss { flex:none; color:#d1ff92; min-height:44px; font:700 12px var(--body); }
.immersive-active body.fight-mode #header,.immersive-lobby #header { display:none; }
.immersive-lobby #online-screen.active {
  position:fixed; z-index:25; inset:0; width:100%; max-width:none;
  height:100vh; height:100dvh; min-height:0; overflow:auto; overscroll-behavior:contain;
  padding:max(9px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(9px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
}
.immersive-active body.fight-mode #fight-screen { min-height:100dvh; }
@media (orientation:landscape) and (min-width:1001px) and (pointer:fine) {
  .immersive-active body.fight-mode #fight-screen.active {
    height:100dvh; display:grid; grid-template-rows:minmax(0,1fr) auto auto; width:100%; justify-items:stretch;
  }
  .immersive-active body.fight-mode #game-frame { width:100%; height:100%; max-width:none; aspect-ratio:auto; min-height:0; }
}
@media (orientation:landscape) and (any-pointer:coarse),
       (orientation:landscape) and (max-width:1000px) and (max-height:550px) {
  body.fight-mode { --sponsor-height:76px; --fight-tools:96px; }
  .immersive-active body.fight-mode { --sponsor-height:64px; }
  body.tv-mode { --fight-tools:130px; }
  body.fight-mode .fight-footer { gap:2px; align-items:center; }
  body.fight-mode .fight-footer #fight-fullscreen,
  body.fight-mode .fight-footer #tv-fullscreen {
    flex-direction:column; justify-content:center; gap:2px; width:46px; min-height:44px;
    padding:0; color:#deedf8; background:#09223b;
  }
  body.fight-mode .fight-footer .full-label { font:700 8px/1 var(--body); letter-spacing:0; }
  body.fight-mode .fight-campaign {
    gap:clamp(6px,1.2vw,14px);
    padding-left:calc(var(--fight-left) + var(--fight-tools));
  }
  body.fight-mode .campaign-brand { border:0; padding:0; }
  body.fight-mode .campaign-brand .nm-logo { width:clamp(55px,8vw,95px); }
  body.fight-mode .campaign-copy p { display:block; margin:3px 0 0; color:#dceaf1; font:500 clamp(11px,1.4vw,14px)/1.15 var(--body); }
  body.fight-mode .fight-campaign h2 { font:750 clamp(13px,1.8vw,20px)/1.04 var(--display); }
  body.fight-mode #campaign-cta { min-height:44px; max-width:17%; padding:5px 8px; font:750 clamp(10px,1.3vw,13px)/1.15 var(--body); }
}
@media (orientation:landscape) and (max-width:760px) {
  body.fight-mode .campaign-brand { display:none; }
  body.fight-mode .fight-campaign { gap:7px; }
  body.fight-mode #campaign-cta { flex-direction:column; gap:2px; }
  body.fight-mode #campaign-cta::before { content:'NÚCLEOMED'; font-size:8px; letter-spacing:.7px; color:#d6fff0; }
}
@media (orientation:portrait) and (max-width:760px) {
  #online-screen .room-mast { position:relative; flex-wrap:wrap; justify-content:space-between; gap:3px 9px; }
  #online-screen .room-mast>span { flex-basis:100%; }
  #online-fullscreen { margin-left:0; }
  body.fight-mode .fight-footer { flex-wrap:wrap; align-items:center; justify-content:center; }
  body.fight-mode .campaign-copy p { display:block; color:#dceaf1; font:500 13px/1.25 var(--body); }
  body.fight-mode .fight-campaign { height:auto; min-height:0; }
}
