/* Viewport controls and phone battle layout. Keep desktop typography and map art. */
.topbar{position:sticky;top:0;z-index:20;background:var(--bg)}
body:has(.modal-backdrop:not(.hidden)){overflow:hidden}
.modal-backdrop{height:var(--viewport-height,100dvh);bottom:auto;overscroll-behavior:contain}
.modal-card{max-height:calc(var(--viewport-height,100dvh) - 40px);overscroll-behavior:contain}
.mode-picker{display:flex;flex-direction:column;overflow:hidden}
.mode-picker-heading{flex:none;padding-right:32px}
.mode-picker-heading h2{font-size:32px}
.mode-picker-heading p{margin:12px 0 24px;max-width:650px}
.mode-picker-body{min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:2px}
.mode-picker-footer{flex:none}
.mode-detail{display:none}
.battle-info-toggle,.map-tools-toggle{display:none}
.battle-info-card{width:520px}
.battle-info-actions{gap:8px;margin:12px 0 18px}
.battle-info-actions button{flex:1;min-height:44px;padding:8px;border:1px solid #607288;border-radius:8px;background:#293747;font-size:13px}
.team-map-details>summary{display:flex;justify-content:space-between;align-items:center;min-height:44px;cursor:pointer;list-style:none;color:#c6d7e6;font-size:13px}
.team-map-details>summary::-webkit-details-marker{display:none}
.team-map-details[open] .ui-icon{transform:rotate(180deg)}
.team-map-details .team-maps-heading{margin-top:4px}
.result-actions{position:sticky;bottom:-27px;background:#202b3a;padding:12px 0 0}
#wall-placement{overscroll-behavior:contain}

@media(max-width:900px){
  .app{padding:0 12px;max-width:none}
  .topbar{min-height:0;height:auto;display:grid;grid-template-columns:1fr auto;padding:8px 0 0;gap:6px;border-bottom:1px solid #2a3441}
  .brand-title{font-size:22px}.brand-emblem{width:30px;height:34px}.brand-title small{font-size:10px}
  .top-right{gap:8px}.profile-pill{max-width:38px}.profile-pill #profile-name{display:none}
  .profile-pill>span:first-child{width:36px;height:36px}.gold-pill{min-height:40px;font-size:13px;padding:4px 8px}.gold-pill .gold-icon{width:24px;height:24px}.online-tag{display:none}
  .topnav{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:2px;padding:0 0 5px;width:100%}
  .topnav-btn{min-height:44px;padding:6px 3px;font-size:12px;justify-content:center}.topnav-btn .ui-icon,.topnav-btn .gold-icon{display:none}
  .topnav-btn[data-tab="how"] span{font-size:12px;white-space:nowrap}.topnav .brand-display-link{display:none}
  .home-layout{display:flex;flex-direction:column;gap:18px;padding:16px 0}
  .home-sidebar{display:contents}.home-sidebar .match-menu{order:0;padding:18px;width:100%}.battlefield-preview{order:1;width:100%}.home-sidebar .home-ranking{order:2;width:100%;padding:16px}
  .home-sidebar .match-menu-heading{margin-bottom:14px}.home-sidebar .match-menu-heading h2{font-size:22px}.home-sidebar .match-menu-heading p{font-size:12px}
  .home-sidebar .match-availability{margin-bottom:14px;font-size:12px;padding:8px 10px}.home-sidebar .match-availability strong{font-size:17px}
  .friends-options{margin-top:16px}.friends-options button{min-height:46px;font-size:12px}
  .battlefield-heading h1{font-size:27px}.map-description{font-size:12px}.visual-card{margin-top:12px}.preview-meta .battlefield-tip{font-size:11px}
  .site-footer{padding:12px 0 20px;font-size:11px}.site-footer>span:nth-child(2){display:none}
  .view{min-height:0}

  /* All four modes and the selected action stay in the dialog viewport. */
  .modal-backdrop{padding:10px max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left))}
  .modal-card{max-height:calc(var(--viewport-height,100dvh) - 20px - env(safe-area-inset-bottom));padding:22px 18px;border-radius:16px}
  .modal-close{width:44px;height:44px;top:10px;right:10px}
  .mode-picker{padding:20px 16px 16px;width:100%;gap:0}
  .mode-picker-heading{padding-right:38px}.mode-picker-heading .overlay-kicker{font-size:10px}
  .mode-picker-heading h2{font-size:25px;margin:6px 0 8px}.mode-picker-heading p{font-size:12px;margin:0 0 16px;line-height:1.5}
  .mode-picker .mode-selector,.mode-picker .mode-selector:has(.mode-option.hidden){grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .mode-picker .mode-option{min-height:112px;padding:13px;gap:11px;border-radius:12px;justify-content:space-between}
  .mode-picker .mode-option.selected{padding:12px}
  .mode-picker .mode-card-top{display:grid;grid-template-columns:1fr auto;gap:4px;font-size:10px;line-height:1.3}
  .mode-picker .mode-card-top>.ui-icon{width:24px;height:24px;grid-column:1;grid-row:1;margin:0}
  .mode-picker .mode-card-top>span:not(.mode-check){grid-column:1/-1;grid-row:2}
  .mode-picker .mode-check{grid-column:2;grid-row:1;width:19px;height:19px}
  .mode-picker .mode-option>strong{font-size:18px;line-height:1.15}
  .mode-picker .mode-card-copy,.mode-picker .mode-option>small{display:none}
  .mode-picker .mode-detail{display:block;font-size:12px;line-height:1.45;margin:12px 0 0;color:#c2d0df;min-height:35px}
  .mode-picker-footer{margin-top:14px;padding-top:12px;gap:8px;flex-direction:column;align-items:stretch;background:#202b3a}
  .mode-picker-footer>span{font-size:11px}.mode-picker .mode-picker-footer .primary-button{width:100%;min-height:50px;min-width:0;font-size:16px}
  .team-picker{padding:22px 18px}.team-picker h2{font-size:26px}.team-picker>p{font-size:12px;margin-bottom:16px}
  .team-choice{flex-direction:row;gap:8px}.team-choice>*{min-height:48px;padding:10px;font-size:13px}
  .team-code-input{flex-direction:row;gap:7px}.team-code-input input{padding:10px!important;min-height:44px!important}.team-code-input button{padding:8px!important;min-height:44px!important;font-size:12px}
  #team-code-form{margin:16px 0}.team-maps-heading{padding-top:12px}.team-map-details{border-top:1px solid #42566b;padding-top:6px}
  .team-map-previews{grid-template-columns:1fr;gap:8px;margin-top:10px}.team-map-previews article{display:grid;grid-template-columns:88px 1fr}.team-map-previews canvas{height:95px;grid-row:span 2}.team-map-previews strong{font-size:14px;margin:10px 10px 3px}.team-map-previews p{font-size:11px!important;margin:0 10px 10px!important}
  .team-rules-note{font-size:11px!important;margin:12px 0 0!important}.team-member>span{font-size:13px}.team-party-actions>*{min-height:44px;font-size:13px;padding:8px}
  #result-overlay .result-panel{max-height:calc(var(--viewport-height,100dvh) - 24px - env(safe-area-inset-bottom));padding:20px;scroll-padding-bottom:120px}
  .result-actions{bottom:-20px;margin:0 -20px -20px;padding:12px 20px 16px;border-top:1px solid #3e5067}
  .result-panel h2{font-size:25px}.result-mark{width:38px;height:38px;margin:10px auto 6px}.result-placement strong{font-size:38px}.result-panel>p{font-size:12px}.reward-list{gap:8px;margin:14px 0}.reward-list>div{padding:10px;gap:7px}.reward-list strong{font-size:21px}

  /* Matches own the viewport; optional information opens in a sheet. */
  body:has(.phone-battle){overflow:hidden;overscroll-behavior:none}
  .app.phone-battle{padding:0;height:var(--viewport-height,100dvh)}
  .phone-battle .topbar{display:none}.phone-battle main{height:100%}
  .phone-battle #game-view{display:flex;flex-direction:column;height:100%;min-height:0}
  .phone-battle #game-view .game-heading{flex:none;padding:8px 12px 6px;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 10px;background:var(--bg)}
  .phone-battle .game-heading-left{gap:9px;grid-row:1}.phone-battle .game-heading-right{display:contents}
  .phone-battle .leave-match-button{min-width:48px;min-height:44px;padding:6px;font-size:11px;gap:4px}
  .phone-battle .battle-identity .game-badge{font-size:14px}.phone-battle .battle-identity .muted{font-size:10px}
  .phone-battle .match-clock{grid-row:1;grid-column:2;border:0;padding:0}.phone-battle .match-clock>.ui-icon{display:none}.phone-battle .timer{font-size:25px;min-width:64px;letter-spacing:0}
  .phone-battle .match-pulse{grid-column:1;grid-row:2;margin:0;padding:0;border:0;background:none;font-size:10px;min-width:0;max-width:100%;line-height:20px}
  .phone-battle .match-pulse.has-battle-notice{margin:0}.phone-battle #battle-notice{font-size:10px}
  .phone-battle .battle-sound{grid-row:2;grid-column:2;min-height:24px;min-width:0;border:0;background:none;box-shadow:none;padding:0;font-size:10px}
  .phone-battle .game-layout{flex:1;min-height:0;display:flex;align-items:stretch;gap:0;padding:0}
  .phone-battle .game-main{flex:1;min-height:0;min-width:0;display:flex;flex-direction:column}
  .phone-battle .battle-map-wrapper{flex:1;min-height:0;height:auto!important;border-radius:0;border-left:0;border-right:0}
  .phone-battle #battle-map{height:100%;width:100%}
  .phone-battle #game-view .action-console{position:static;flex:none;display:grid;border:0;border-top:1px solid #41506a;border-radius:0;box-shadow:none}.phone-battle .resource-icon{border-radius:8px}.phone-battle .resource-value small{margin-bottom:3px}.phone-battle .resource-value strong{letter-spacing:0}.phone-battle .resource-value strong span{font-size:10px}
  .phone-battle #game-view .attack-widget{min-width:0}
  .phone-battle .attack-title{font-size:11px;line-height:18px}.phone-battle .attack-title strong{font-size:14px}.phone-battle .attack-widget input[type="range"]{margin:0}
  .phone-battle .attack-hint{font-size:10px;line-height:14px;min-height:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .phone-battle .help-button{display:none}.phone-battle .battle-info-toggle{display:grid;place-items:center;gap:0;width:44px;min-height:44px;border:1px solid #566a82;border-radius:9px;background:#283747;font-size:9px}.battle-info-toggle .ui-icon{width:18px;height:18px}
  
  .phone-battle #game-view[data-phase="waiting"] .action-console,.phone-battle #game-view[data-phase="waiting"] .map-top,.phone-battle #game-view[data-phase="waiting"] .map-zoom{display:none}
  .phone-battle .game-overlay{padding:14px}.phone-battle .waiting-panel{width:420px;max-height:100%;padding:20px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scroll-padding-bottom:65px}
  .phone-battle .lobby-emblem{width:44px;height:44px;margin-bottom:10px;border-radius:12px}.phone-battle .lobby-emblem .ui-icon{width:25px;height:25px}
  .phone-battle .waiting-panel h2{font-size:24px;margin:8px 0 10px}.phone-battle .waiting-panel p{font-size:12px;line-height:1.5}.phone-battle .waiting-players{margin:14px 0;gap:7px;max-height:110px;overflow-y:auto}.phone-battle .player-chip{font-size:12px;padding:6px 8px}.phone-battle .lobby-countdown{font-size:12px;margin-top:12px}
  .phone-battle .waiting-actions{position:sticky;bottom:-20px;background:#202b3a;padding:8px 0 4px}.phone-battle .waiting-actions .simple-button{min-height:44px;margin:0;border:1px solid #62748c;width:100%;background:#2a394b}
  .phone-battle .room-code-box{padding:10px;margin-top:12px}.phone-battle .room-code-box strong{font-size:22px}.phone-battle .room-code-box button{min-height:44px}
  .phone-battle .map-top{top:10px;left:10px;right:10px}.phone-battle .map-top>span:first-child{font-size:10px;gap:5px}.phone-battle #game-map-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .phone-battle .battle-cash{gap:5px}.phone-battle .battle-cash img{width:22px;height:22px}.phone-battle .battle-cash small{font-size:9px}.phone-battle .battle-cash strong{font-size:17px}
  .phone-battle .team-score{top:58px;padding:5px 9px}
  .phone-battle .map-zoom{right:10px;bottom:10px}.phone-battle .map-zoom button{display:none}.phone-battle .map-zoom #zoom-base,.phone-battle .map-zoom #map-tools-toggle{display:grid}
  .phone-battle .map-zoom #map-tools-toggle .ui-icon{transform:rotate(45deg)}.phone-battle .map-zoom:not(.is-open) #map-tools-toggle .ui-icon{transform:none}
  .phone-battle .map-zoom.is-open{border-radius:10px;grid-template-columns:44px 44px}.phone-battle .map-zoom.is-open button{display:grid}
  .phone-battle .wall-console{left:10px;bottom:10px}.phone-battle #wall-build{min-height:50px;padding:8px 10px;gap:7px}.phone-battle .wall-footer button{display:none}
  .phone-battle .wall-placing #wall-build,.phone-battle .wall-placing .wall-footer{display:none}
  .phone-battle .wall-placing .map-zoom{visibility:hidden}
  .phone-battle #wall-placement{position:static;left:auto;bottom:auto;width:100%;display:grid;grid-template-columns:84px minmax(0,1fr);gap:8px;margin:0;padding:12px;border-radius:12px;background:#142b37;border-color:#80c8bc}
  .phone-battle #wall-placement p{grid-column:1/-1;margin:0;font-size:12px;line-height:1.4;color:#d7efe9}
  .phone-battle #wall-placement button{margin:0;min-height:46px;padding:8px;font-size:14px;white-space:nowrap}
  .phone-battle #wall-cancel{grid-column:1;grid-row:2}.phone-battle #wall-confirm{grid-column:2;grid-row:2}
  .phone-battle #wall-selection{position:absolute;bottom:0;left:0;border-radius:12px}
  .phone-battle .battle-bonuses{right:64px;left:auto!important;bottom:10px;width:auto!important;max-width:calc(100% - 220px)}.phone-battle .battle-bonuses summary{padding:8px;min-height:44px}.phone-battle .battle-bonuses #bonus-total{font-size:15px}
  .phone-battle .battle-bonuses[open]{width:calc(100% - 80px)!important;max-width:none;right:64px}.phone-battle .battle-bonuses[open] summary>span{display:flex}.phone-battle .team-pings button{min-height:44px}.phone-battle .team-pings small{font-size:11px}
  #battle-info-modal{align-items:flex-end;padding:0}
  .battle-info-card{width:100%;max-height:calc(var(--viewport-height,100dvh) - 70px);padding:22px 12px max(16px,env(safe-area-inset-bottom));border-radius:18px 18px 0 0;overflow-y:auto}.battle-info-card h2{font-size:22px;padding:0 6px;margin-right:40px}
  #battle-info-content .match-sidebar{display:grid;grid-template-columns:1fr;gap:12px;overflow:visible}.battle-info-card .sidebar-heading{padding:14px}.battle-info-card .match-standings{max-height:280px;overflow-y:auto}.battle-info-card .campaign-strip{padding:12px 14px}.battle-info-card .battle-feed-panel{max-height:none}
  .rankings-page,.gold-page{padding-top:18px}.ranking-heading{padding:14px 12px}.ranking-tabs{gap:2px;overflow-x:auto;flex-wrap:nowrap;max-width:100%;scrollbar-width:thin}.rank-tab{font-size:12px;padding:9px 10px;min-height:44px}.ranking-table th,.ranking-table td{padding:12px 8px}.rank-column{width:34px}.wins-column{width:44px}.score-column{width:108px}.rank-person{gap:8px}.rank-name{font-size:12px}.rank-meta,.rank-honor{font-size:10px}.ranking-score-content{gap:4px}.ranking-table .rating-score{font-size:15px}.ranking-score-content .rank-emblem{width:32px;height:32px;flex-basis:32px}.rank-you{display:none}
}

@media(max-width:350px){
  .mode-picker-heading h2{font-size:23px}.mode-picker .mode-option{padding:11px;min-height:101px}.mode-picker .mode-option.selected{padding:10px}.mode-picker .mode-option>strong{font-size:17px}.mode-picker-heading p{margin-bottom:12px}.mode-picker-footer{margin-top:10px}.phone-battle .troop-widget{gap:5px}.phone-battle #game-view .action-console{padding-left:8px;padding-right:8px}
}
@media(max-width:700px) and (max-height:600px){
  .mode-picker-heading p{display:none}.mode-picker .mode-option{min-height:98px;gap:8px}.mode-picker-heading h2{margin-bottom:12px}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
  .mode-picker{width:760px;max-height:calc(var(--viewport-height,100dvh) - 16px);padding:16px}
  .mode-picker-heading .overlay-kicker,.mode-picker-heading p{display:none}.mode-picker-heading h2{font-size:22px;margin:0 0 12px}
  .mode-picker .mode-selector{grid-template-columns:repeat(4,minmax(0,1fr))}.mode-picker .mode-option{min-height:92px;padding:10px}.mode-picker .mode-option.selected{padding:9px}.mode-picker .mode-detail{min-height:0;margin-top:10px}.mode-picker-footer{flex-direction:row;align-items:center;margin-top:10px;padding-top:10px}.mode-picker .mode-picker-footer .primary-button{width:220px;min-height:44px}
  .phone-battle #game-view .game-heading{padding-top:4px;padding-bottom:4px}.phone-battle .match-pulse,.phone-battle .battle-sound{display:none}
  .phone-battle .troop-widget{grid-column:1/-1}.phone-battle .attack-hint{white-space:normal}
  .phone-battle .waiting-panel{width:440px;padding:14px}.phone-battle .lobby-emblem{display:none}.phone-battle .waiting-panel h2{font-size:21px}.phone-battle .waiting-players{max-height:54px;margin:8px 0}.phone-battle .waiting-actions{bottom:-14px}
}

.resume-battle{display:flex;align-items:center;justify-content:space-between;width:100%;min-height:44px;padding:10px 14px;margin:12px 0;background:#263f50;border:1px solid #688da3;border-radius:9px;color:#e1f3ff;font-size:13px;font-weight:600}
.battle-info-actions{display:grid;grid-template-columns:1fr 1fr}
@media(max-width:900px){
  .phone-battle .battle-sound{display:none}
  .phone-battle .match-pulse{min-height:20px}
}
@media(min-width:901px){.app:has(#resume-battle:not(.hidden)) #home-view{height:calc(100dvh - 156px)}}

/* Persistent controls belong outside the canvas on every screen. */
.map-top{position:static;flex:none;min-height:44px;padding:6px 10px;background:#172533;border:1px solid #41506a;border-bottom:0;border-radius:12px 12px 0 0;gap:12px}
.map-top>span:first-child{background:none;border:0;padding:0}
.battle-map-wrapper{border-radius:0!important}
.battle-cash{padding:3px 7px;box-shadow:none;border:0;background:none}.battle-cash small{display:none}.battle-cash span{display:block}.battle-cash strong{font-size:18px}.battle-cash img{width:24px;height:24px}
.team-score{position:static;transform:none;border:0;padding:0!important;background:none;gap:12px;max-width:none}
.battle-controls{grid-column:1/-1;display:flex;align-items:center;flex-wrap:wrap;gap:12px;padding:0 0 8px;border-bottom:1px solid #3d4a5d}
.wall-console{position:relative;left:auto!important;bottom:auto!important;width:164px;flex-shrink:0}
.wall-console #wall-build{min-height:48px;padding:8px 12px}.wall-footer{background:none}.wall-footer button{min-width:32px;min-height:32px}
.wall-panel{position:static!important;left:auto!important;bottom:auto!important;width:100%}
.map-zoom{position:static;display:flex;flex-wrap:wrap;gap:6px;flex-shrink:0;margin-left:auto}
.battle-controls .battle-bonuses{position:static;left:auto;right:auto;bottom:auto;width:190px;max-width:100%;box-shadow:none}
.battle-controls .bonus-guide{max-height:130px}.team-pings{position:static;right:auto;bottom:auto;width:auto;max-width:240px;margin-left:auto;pointer-events:auto}

#battle-info-content .battle-bonuses{position:static;max-width:100%;width:100%;margin-top:12px;box-shadow:none}
#battle-info-content .battle-bonuses summary>span{display:flex}
@media(max-width:900px){
  .phone-battle .map-top{position:static;border-left:0;border-right:0;border-radius:0;align-items:center}
  .phone-battle .map-top>span:first-child{padding:0;background:none;border:0}.phone-battle .battle-cash{padding:0;border:0;background:none}.phone-battle .battle-cash small{display:none}
  .phone-battle #game-view[data-mode="team"] .map-top>span:first-child{display:none}.phone-battle .team-score{max-width:none;gap:7px}
  .phone-battle #game-view[data-phase="waiting"] .map-top{display:none}
  .phone-battle #game-view .action-console{padding-top:6px;padding-bottom:max(6px,env(safe-area-inset-bottom))}
  .phone-battle #game-view .attack-widget{border:0;padding:0}
  .phone-battle .battle-controls{grid-column:1/-1;grid-row:2;gap:8px;align-items:center;flex-wrap:wrap;padding:0;border:0}.phone-battle .wall-footer{padding:0 5px;line-height:16px}.phone-battle .wall-footer small{font-size:9px}
  .phone-battle .map-zoom{position:static;display:flex;flex-wrap:wrap;margin-left:auto;padding:0;gap:6px;border:0;background:none}.phone-battle .map-zoom button{width:44px;height:44px}
  .phone-battle .map-zoom.is-open{display:flex;flex-basis:100%;justify-content:space-between;border:0;background:none;padding:0;gap:4px}
  .phone-battle .team-pings{position:static;margin:0 0 0 auto;width:auto;max-width:140px;bottom:auto;right:auto}.phone-battle .team-pings button{font-size:10px;padding:6px}.phone-battle #team-ping-options{width:100%}
  .phone-battle .wall-placing .action-console .troop-widget,.phone-battle .wall-placing .attack-widget,.phone-battle .wall-placing .battle-info-toggle,.phone-battle .wall-placing .map-zoom,.phone-battle .wall-placing .team-pings{visibility:hidden}
  .phone-battle #wall-selection{position:static!important;width:100%}
  #battle-info-content .battle-bonuses{max-width:100%;right:auto;left:auto}
  #battle-info-content .battle-bonuses summary>span>small:first-child{display:block}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
  .phone-battle .game-main{flex-direction:column}.phone-battle .map-top{min-height:32px}
  .phone-battle #game-view .action-console{flex-wrap:wrap;align-items:center;justify-content:space-between}
  .phone-battle .troop-widget{min-height:40px}
  .phone-battle .battle-controls{order:2;flex:0 1 auto;flex-wrap:nowrap;border:0}.phone-battle .wall-footer{display:none}.phone-battle .map-zoom{margin:0}
  .phone-battle #game-view .attack-widget{flex-basis:100%;align-items:center;gap:12px}.phone-battle .attack-title{flex-shrink:0;gap:12px}.phone-battle .attack-widget input[type="range"]{flex:1;height:30px}
  .phone-battle .wall-placing .battle-controls{width:100%}
}

.map-controls-label,.ping-placement{display:none}
@media(max-width:900px){
  .phone-battle #game-view .action-console{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 70px 44px;gap:4px 6px;padding:7px 10px max(7px,env(safe-area-inset-bottom))}
  .phone-battle .troop-widget{gap:5px;min-width:0}.phone-battle .resource-icon{width:25px;height:29px}.phone-battle .resource-value strong{font-size:20px}.phone-battle .resource-value small{font-size:9px}
  .phone-battle .battle-info-toggle{grid-column:4;grid-row:1}
  .phone-battle .battle-controls{display:contents}
  .phone-battle .wall-console{grid-column:3;grid-row:1;width:70px;min-width:0}.phone-battle .wall-footer{display:none}.phone-battle .wall-console #wall-build{min-height:44px;padding:5px 7px;gap:0;justify-content:center;text-align:center}.phone-battle #wall-build>.ui-icon{display:none}.phone-battle #wall-build strong{font-size:12px}.phone-battle #wall-build small{font-size:10px}
  .phone-battle #game-view .attack-widget{grid-row:2;grid-column:1/-1}
  .phone-battle .wall-placing .wall-console{grid-column:1/-1;width:100%}
  #battle-info-content{display:flex;flex-direction:column;gap:12px}
  #battle-info-content .map-zoom{order:0;display:flex;flex-wrap:wrap;width:100%;margin:0;padding:12px;border:1px solid #405c74;border-radius:10px;background:#172a3c;justify-content:space-between}
  #battle-info-content .map-controls-label{display:block;flex-basis:100%;font-size:13px;margin-bottom:4px;color:#d3e5f4}
  #battle-info-content .map-zoom button{display:grid;width:44px;height:44px}
  #battle-info-content .map-zoom #map-tools-toggle{display:none}
  #battle-info-content .match-sidebar{order:2}
  #battle-info-content .battle-bonuses{order:3;margin:0;width:100%!important}
  #battle-info-content .team-pings{order:1;position:static;width:100%;max-width:none;display:flex;justify-content:flex-start;margin:0}
  .ping-placement p{font-size:12px;color:#d3e9f9}.ping-placement button{min-height:44px;padding:8px 12px;flex-shrink:0;border:1px solid #607d97;border-radius:8px;background:#263f54;font-size:13px}
}
@media(max-width:350px){.phone-battle #game-view .action-console{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 62px 42px;gap:4px}.phone-battle .resource-value strong{font-size:18px}}

.phone-zoom{display:none}
@media(max-width:900px){
  .phone-battle .map-top{min-height:48px;padding:2px 10px;gap:7px}
  .phone-battle .map-top>span:first-child{min-width:0;flex:1;max-width:none}
  .phone-battle .phone-zoom{display:flex;gap:4px;flex-shrink:0}
  .phone-zoom button{display:grid;place-items:center;width:44px;height:44px;border:1px solid #4b657e;background:#233749;border-radius:8px}
  .phone-zoom .ui-icon{width:17px;height:17px}
  .phone-battle .team-score span{font-size:0}.phone-battle .team-score .team-vs{font-size:9px}.phone-battle .team-score strong{margin-left:4px;font-size:12px}
}
@media(max-width:900px){
  .phone-battle #wall-build>span{width:100%}
  .phone-battle #wall-build strong,.phone-battle #wall-build small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
}
@media(max-width:900px){
  .phone-battle .troop-widget{min-height:44px}
  .phone-battle .attack-widget input[type="range"]{height:44px}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
  .phone-battle .game-main{display:grid;grid-template-columns:minmax(0,1fr) 172px;grid-template-rows:auto minmax(0,1fr);min-height:0}
  .phone-battle .map-top{grid-column:1;grid-row:1;min-width:0}
  .phone-battle .battle-map-wrapper{grid-column:1;grid-row:2;min-width:0}
  .phone-battle #game-view .action-console{grid-column:2;grid-row:1/-1;width:172px;display:grid;grid-template-columns:1fr 1fr;align-content:center;gap:10px 6px;padding:8px;border-left:1px solid #41506a;border-top:0}
  .phone-battle .troop-widget{min-width:0;gap:4px}.phone-battle .resource-icon{display:none}
  .phone-battle #troop-widget-army{grid-column:1;grid-row:1}.phone-battle #troop-widget-land{grid-column:2;grid-row:1}
  .phone-battle .wall-console{grid-column:1;grid-row:2;width:70px}.phone-battle .battle-info-toggle{grid-column:2;grid-row:2;justify-self:end;order:0}
  .phone-battle #game-view .attack-widget{grid-column:1/-1;grid-row:3;display:block}.phone-battle .attack-title{display:flex}.phone-battle .attack-hint{display:none}
  .phone-battle .wall-placing .wall-console{width:100%}
  .phone-battle #wall-placement{grid-template-columns:1fr;gap:6px;padding:10px}.phone-battle #wall-placement p{grid-column:1;font-size:11px}.phone-battle #wall-confirm{grid-column:1;grid-row:2;font-size:12px}.phone-battle #wall-cancel{grid-column:1;grid-row:3;font-size:12px}
  .phone-battle #game-view[data-phase="waiting"] .game-main{display:flex}
  .phone-battle .ping-placement{flex-direction:column;align-items:stretch!important}
}
@media(min-width:901px){
  .action-console{padding:10px 12px;gap:9px 12px;grid-template-columns:125px 115px minmax(100px,1fr) 36px}
  .action-console .resource-icon{width:32px;height:36px}.action-console .resource-value strong{font-size:23px}.action-console .troop-widget{gap:8px}
  .battle-controls{gap:8px;padding-bottom:8px;flex-wrap:nowrap}
  .wall-console{display:flex;align-items:center;flex-wrap:wrap;width:198px;gap:6px}.wall-console #wall-build{width:148px;min-height:48px;padding:6px 8px;gap:7px}.wall-console #wall-build strong{font-size:12px}.wall-console #wall-build small{font-size:10px}
  .wall-footer{padding:0;background:none}.wall-footer small{display:none}.wall-footer button{min-width:44px;min-height:44px;border:1px solid #506a78;border-radius:8px;background:#193440}
  .wall-panel{flex-basis:100%}
  .battle-controls .battle-bonuses{width:170px;flex:0 1 170px}.battle-controls .battle-bonuses summary{padding:8px 10px;min-height:48px}.battle-controls .battle-bonuses summary>span>small{display:none}.battle-controls .battle-bonuses summary strong{font-size:11px}.battle-controls .battle-bonuses #bonus-total{font-size:18px}
  .battle-controls .map-zoom{margin:0;gap:4px}.map-zoom #map-tools-toggle{display:none}
  .battle-controls .team-pings{max-width:160px;width:auto;flex:1;margin-left:auto}.team-pings button{min-height:44px;padding:6px 8px;font-size:11px}
  .commander-panel{display:flex;flex-direction:column;flex:1;min-height:0}.commander-panel:not([open]){flex:none}
}
@media(max-width:900px){
  .phone-battle .wall-managing .wall-console{grid-column:1/-1;width:100%}
  .phone-battle .wall-managing #wall-build,.phone-battle .wall-managing .wall-footer{display:none}
  .phone-battle .wall-managing .troop-widget,.phone-battle .wall-managing .attack-widget,.phone-battle .wall-managing .battle-info-toggle,.phone-battle .wall-managing .map-zoom,.phone-battle .wall-managing .team-pings{visibility:hidden}
  .phone-battle #wall-selection{display:grid;grid-template-columns:minmax(0,1fr) 160px;gap:4px 12px;padding:12px;margin:0}
  .phone-battle .wall-selection-heading{grid-column:1/-1}.phone-battle #wall-hp{grid-column:1;grid-row:2;align-self:center}.phone-battle #wall-hp-label{grid-column:1;grid-row:3;font-size:11px}
  .phone-battle #wall-remove-confirm{grid-column:2;grid-row:2/span 2;min-height:44px;font-size:12px;margin:0}.phone-battle #wall-remove-message{grid-column:1/-1;margin:0}
}

/* Keep the normal wall button in layout while its panel fills the control dock.
   Preserving that space keeps the canvas bounds identical in every wall state. */
#game-view:is(.wall-placing,.wall-managing) .action-console{position:relative;inset:auto;isolation:isolate}
#game-view:is(.wall-placing,.wall-managing) #wall-console:not(.hidden){position:static!important}
#game-view:is(.wall-placing,.wall-managing) #wall-console::before{content:"";position:absolute;inset:0;z-index:10;background:#1e2836f5;border-radius:0 0 12px 12px}
#game-view:is(.wall-placing,.wall-managing) #wall-build{display:flex!important;visibility:hidden!important}
#game-view:is(.wall-placing,.wall-managing) .wall-footer{visibility:hidden!important}
#game-view:is(.wall-placing,.wall-managing) .action-console .troop-widget,#game-view:is(.wall-placing,.wall-managing) .action-console .attack-widget,#game-view:is(.wall-placing,.wall-managing) .action-console .battle-info-toggle,#game-view:is(.wall-placing,.wall-managing) .action-console .help-button,#game-view:is(.wall-placing,.wall-managing) .battle-controls .map-zoom,#game-view:is(.wall-placing,.wall-managing) .battle-controls .team-pings,#game-view:is(.wall-placing,.wall-managing) .battle-controls .battle-bonuses{visibility:hidden!important}
#game-view.wall-placing #wall-placement:not(.hidden){position:absolute!important;inset:0!important;z-index:11;display:flex!important;align-items:center;gap:12px;width:min(100%,720px);margin:auto;padding:10px 12px}
#game-view.wall-placing #wall-placement p{flex:1;min-width:0;margin:0;font-size:13px;line-height:1.4}
#game-view.wall-placing #wall-placement button{flex:0 0 auto;width:auto;min-width:128px;min-height:44px;margin:0;padding:8px 12px;font-size:13px;white-space:nowrap}
#game-view.wall-managing #wall-selection:not(.hidden){position:absolute!important;inset:0!important;z-index:11;display:grid!important;grid-template-columns:minmax(0,1fr) minmax(150px,220px);align-content:center;align-items:center;gap:6px 12px;width:min(100%,720px);margin:auto;padding:8px 12px}
#game-view.wall-managing .wall-selection-heading,#game-view.wall-managing #wall-remove-message{grid-column:1/-1}
#game-view.wall-managing #wall-hp{grid-column:1;grid-row:2}
#game-view.wall-managing #wall-hp-label{grid-column:1;grid-row:3;font-size:11px}
#game-view.wall-managing #wall-remove-confirm{grid-column:2;grid-row:2/span 2;min-height:44px;margin:0;font-size:12px}
@media(max-width:900px){
  .phone-battle #game-view:is(.wall-placing,.wall-managing) #wall-console{grid-column:3;grid-row:1;width:70px}
  #game-view.wall-placing #wall-placement:not(.hidden){display:grid!important;grid-template-columns:minmax(0,1fr) minmax(90px,auto);gap:7px;width:100%;max-width:none;padding:8px 10px}
  #game-view.wall-placing #wall-placement p{grid-column:1/-1;font-size:11px}
  #game-view.wall-placing #wall-placement button{min-width:0;min-height:44px;padding:7px;font-size:12px}
  #game-view.wall-placing #wall-cancel{grid-column:1;grid-row:2}
  #game-view.wall-placing #wall-confirm{grid-column:2;grid-row:2}
  #game-view.wall-managing #wall-selection:not(.hidden){grid-template-columns:minmax(0,1fr) minmax(120px,160px);gap:4px 10px;padding:8px 10px}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
  .phone-battle #game-view:is(.wall-placing,.wall-managing) #wall-console{grid-column:1;grid-row:2}
  #game-view.wall-managing #wall-selection:not(.hidden){grid-template-columns:1fr}
  #game-view.wall-managing #wall-hp,#game-view.wall-managing #wall-hp-label,#game-view.wall-managing #wall-remove-confirm{grid-column:1;grid-row:auto}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
  .phone-battle #wall-selection{grid-template-columns:1fr;gap:6px}
  .phone-battle #wall-hp{grid-column:1;grid-row:2}.phone-battle #wall-hp-label{grid-column:1;grid-row:3}.phone-battle #wall-remove-confirm{grid-column:1;grid-row:4}
  .phone-battle .match-pulse.has-battle-notice{display:flex;min-height:18px;line-height:18px}
}
@media(max-width:900px){
  .modal-card:not(.mode-picker) .modal-emblem{width:36px;height:36px;margin-bottom:10px}.modal-card:not(.mode-picker) .modal-emblem .ui-icon{width:22px;height:22px}
  .modal-card:not(.mode-picker) h2{font-size:25px;line-height:1.2;margin:7px 0 12px}.modal-card:not(.mode-picker)>p{font-size:12px;line-height:1.5;margin-bottom:16px}
  .modal-card .privacy-note{font-size:11px;line-height:1.5;padding-top:12px;margin-top:14px}.modal-card .primary-button{min-height:48px;font-size:15px}
}
@media(min-width:901px) and (max-height:650px){
  .topbar{height:72px}
  #home-view,#game-view{height:calc(100dvh - 72px)}
  .app:has(#resume-battle:not(.hidden)) #home-view{height:calc(100dvh - 140px)}
  #game-view .game-heading{padding:8px 0}
  .battle-controls{padding-bottom:4px}.wall-console #wall-build{min-height:44px}.battle-controls .battle-bonuses summary{min-height:44px}
  .action-console{padding:8px 12px;gap:6px 12px}.action-console .attack-title{font-size:11px}.action-console .attack-title strong{font-size:13px}.action-console input[type="range"]{height:36px}.action-console .attack-hint{font-size:10px;min-height:14px}
}
.result-details{margin:8px 0 12px;text-align:left}.result-details summary{min-height:36px;display:flex;align-items:center;color:#bdcfe1;font-size:12px;cursor:pointer}.result-details p{font-size:11px;line-height:1.5;color:#aebfd3;margin:6px 0 10px}.result-panel:has(.result-note:empty) .result-details{display:none}
.result-actions .secondary-button{width:100%;min-height:48px;padding:10px 12px;border:1px solid #5b7895;border-radius:9px;background:#293f54;margin-top:8px;font-size:13px;font-weight:600}
@media(max-width:900px){
  .result-panel .reward-list{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .result-panel .reward-list>div{display:flex;flex-direction:column;gap:4px;align-items:center;padding:8px 4px;text-align:center;min-width:0}
  .result-panel .reward-list .ui-icon,.result-panel .gold-earned-icon{width:17px;height:17px}
  .result-panel .reward-list small{font-size:9px}.result-panel .reward-list strong{font-size:20px;white-space:nowrap}
  .result-details summary{min-height:44px}
  #result-overlay .result-panel .primary-button{min-height:48px}.result-panel .simple-button{min-height:44px}
}
.result-details summary{justify-content:space-between;gap:8px}.result-details summary .ui-icon{width:16px;height:16px}.result-details[open] summary .ui-icon{transform:rotate(180deg)}
#game-view[data-mode="team"] .battle-cash small{display:block;font-size:9px;line-height:1.1;margin-bottom:2px;color:#bbcfdd}
@media(max-width:900px){
  .phone-battle #wall-build{position:relative}
  .phone-battle #wall-build .wall-uses-badge{position:absolute;right:3px;top:-4px;display:grid;place-items:center;width:15px;height:15px;border-radius:5px;border:1px solid #91d4c7;background:#244e4f;color:#dbfff7;font-size:9px;font-weight:600;pointer-events:none}
}

.wall-uses-badge{display:none}
@media(max-width:900px){.phone-battle #wall-build .wall-uses-badge{display:grid}}
@media(max-width:900px){
  .result-actions:has(#team-rematch:not(.hidden)){display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .result-actions:has(#team-rematch:not(.hidden)) .primary-button,.result-actions #team-rematch{margin:0;min-width:0;min-height:50px;font-size:12px;padding:8px;gap:6px}
  .result-actions:has(#team-rematch:not(.hidden)) .primary-button .ui-icon{display:none}
  .result-actions:has(#team-rematch:not(.hidden)) #result-home{grid-column:1/-1;margin:0}
}
@media(max-width:900px) and (max-height:600px){
  .result-panel .result-mark{display:none}.result-panel h2{font-size:22px;margin:8px 0}.result-placement strong{font-size:32px}.result-placement{margin-bottom:10px}
  .result-panel .reward-list>div{padding:6px 4px;gap:3px}.result-panel .reward-list .ui-icon,.result-panel .gold-earned-icon{width:14px;height:14px}
}

@media(max-width:900px){
 .phone-battle .team-score span{display:flex;flex-direction:column;align-items:center;gap:2px;font-size:9px;line-height:1.1}
 .phone-battle .team-score strong{display:block;margin:0;font-size:13px;line-height:1.1}
}
@media(max-width:900px){
  .topbar{padding-top:max(8px,env(safe-area-inset-top))}
  .app.phone-battle{padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}
  .phone-battle #game-view .game-heading{padding-top:max(8px,env(safe-area-inset-top))}
  .battle-info-card{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
}

/* Status and feedback share a reserved slot. Text never sizes the match header. */
@media(min-width:901px) and (max-height:700px){
  .app:has(#game-view:not(.hidden)) .topbar{display:none}
  .app #game-view{height:100dvh}
}
#game-view .game-heading-right{min-width:0}
#game-view[data-phase="waiting"] .action-console{position:relative;inset:auto;isolation:isolate}
#game-view[data-phase="waiting"] .action-console>:not(#lobby-overlay){visibility:hidden}
#game-view[data-phase="waiting"].emotes-open #emote-picker-host{visibility:visible}
.lobby-dock{position:absolute;inset:0;z-index:10;background:#1e2836;border-radius:0 0 12px 12px;overflow:hidden}
#lobby-overlay .waiting-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;align-content:center;align-items:center;gap:4px 16px;width:100%;height:100%;max-height:100%;padding:12px 16px;border:0;border-radius:0;background:none;box-shadow:none;text-align:left;overflow:auto}
#lobby-overlay .lobby-emblem,#lobby-overlay .overlay-kicker,#lobby-overlay .waiting-players,#lobby-overlay .lobby-countdown{display:none}
#lobby-overlay h2{grid-column:1;grid-row:1;font-size:15px;line-height:20px;margin:0}
#lobby-overlay #wait-message{grid-column:1;grid-row:2;margin:0;font-size:12px;line-height:16px;color:#c0cedd}
#lobby-overlay .room-code-box{grid-column:1;grid-row:3;display:flex;align-items:center;gap:10px;margin:0;padding:0;border:0;background:none}
#lobby-overlay .room-code-box>small{display:none}
#lobby-overlay .room-code-box>div{gap:12px}
#lobby-overlay .room-code-box strong{font-size:20px;line-height:24px}
#lobby-overlay .room-code-box button{min-height:44px}
#lobby-overlay .waiting-actions{grid-column:2;grid-row:1/span 3;position:static;display:flex;align-items:center;gap:8px;margin:0;padding:0;background:none}
#lobby-overlay .waiting-actions button{min-height:44px;margin:0;padding:8px 12px;font-size:12px;white-space:nowrap}
#lobby-overlay .waiting-actions .simple-button{border:1px solid #62748c;border-radius:8px;background:#2a394b;color:#dae6f4}
@media(min-width:901px){.battle-controls{min-height:57px}}
#game-view .match-pulse{position:relative;flex-shrink:0;width:clamp(160px,18vw,280px);max-width:none;height:30px;min-height:30px;margin:0;padding:0;overflow:hidden}
#game-view .match-pulse>span{position:absolute;inset:0;display:block;padding:5px 9px;max-width:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px}
#game-view.ping-placing .action-console,.action-console:has(#team-ping-options:not(.hidden)),.action-console:has(#battle-bonuses[open]){position:relative;inset:auto;isolation:isolate}
#game-view.ping-placing .action-console>:not(.ping-placement){visibility:hidden}
#game-view.ping-placing .ping-placement{position:absolute;inset:0;z-index:12;display:flex;align-items:center;justify-content:center;gap:16px;padding:12px;background:#1e2836;border-radius:0 0 12px 12px}
.ping-placement p{font-size:13px;line-height:1.4;color:#d3e9f9}.ping-placement button{min-height:44px;padding:8px 12px;flex-shrink:0;border:1px solid #607d97;border-radius:8px;background:#263f54;font-size:13px}
.bonus-guide-heading{position:sticky;top:0;display:flex;align-items:center;justify-content:space-between;gap:12px;background:#1e2836;padding:6px 0;color:#e5eef8}
.bonus-guide-heading button,#team-ping-close{min-height:44px;padding:8px 12px;border:1px solid #607d97;border-radius:8px;background:#263f54;font-size:12px}
@media(min-width:901px){
  .battle-controls .battle-bonuses{min-width:0}
  .battle-controls .battle-bonuses summary{height:48px;min-height:48px;overflow:hidden}
  .battle-controls .battle-bonuses summary>span{min-width:0;overflow:hidden}
  .battle-controls .battle-bonuses summary strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .action-console:has(#team-ping-options:not(.hidden)) .battle-controls>:not(#team-pings),.action-console:has(#team-ping-options:not(.hidden)) #team-ping-toggle,.action-console:has(#battle-bonuses[open]) .battle-controls>:not(#battle-bonuses){visibility:hidden}
  .action-console:has(#team-ping-options:not(.hidden),#battle-bonuses[open])>.troop-widget,.action-console:has(#team-ping-options:not(.hidden),#battle-bonuses[open])>.attack-widget,.action-console:has(#team-ping-options:not(.hidden),#battle-bonuses[open])>.help-button{visibility:hidden}
  .battle-controls #team-ping-options:not(.hidden){position:absolute;inset:0;z-index:12;align-items:center;justify-content:center;margin:0;background:#1e2836;border:0;border-radius:0 0 12px 12px}
  .battle-controls #team-ping-options small{flex-basis:100%;text-align:center}
  .battle-controls #battle-bonuses[open] .bonus-guide{position:absolute;inset:0;z-index:12;max-height:100%!important;margin:0;padding:0 14px 12px;border:0;background:#1e2836;border-radius:0 0 12px 12px;overscroll-behavior:contain}
}
@media(max-width:900px){
  .phone-battle #game-view[data-phase="waiting"] .map-top{display:flex}
  .phone-battle #game-view[data-phase="waiting"] .action-console{display:grid}
  #lobby-overlay .waiting-panel{grid-template-columns:minmax(0,1fr) auto;gap:2px 8px;padding:8px 10px;align-content:center}
  #lobby-overlay h2{font-size:13px;line-height:18px}
  #lobby-overlay #wait-message{font-size:11px;line-height:15px}
  #lobby-overlay .waiting-actions{flex-direction:column;align-items:stretch;gap:5px}
  #lobby-overlay .waiting-actions button{padding:6px 8px;font-size:11px}
  #lobby-overlay .room-code-box strong{font-size:17px}
  .phone-battle #game-view .match-pulse{display:block;grid-column:1/-1;grid-row:2;width:100%;height:20px;min-height:20px;max-width:100%;border:0;border-radius:4px}
  .phone-battle #game-view .match-pulse>span{padding:0 5px;font-size:10px;line-height:20px}
  .phone-battle #game-view .match-pulse.has-battle-notice{background:#342e23!important;color:#ffe0a0}
}
@media(max-width:900px) and (max-height:500px) and (orientation:landscape){
  .phone-battle #game-view[data-phase="waiting"] .game-main{display:grid}
  #lobby-overlay .waiting-panel{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:8px}
  #lobby-overlay .waiting-actions{flex:none;gap:6px}
  .phone-battle #game-view .match-pulse{height:18px;min-height:18px}
  .phone-battle #game-view .match-pulse>span{line-height:18px}
}

/* Battles use the window, rather than the remaining space under site navigation.
   Explicit map/dock tracks prevent any ability panel from consuming map height. */
.battle-fullscreen{min-height:44px;padding:8px 11px;border:1px solid #52657b;border-radius:8px;background:#253344;font-size:12px;font-weight:600;white-space:nowrap}
.battle-fullscreen:hover{background:#32465b;border-color:#a4bdd4}
:root:fullscreen{background:var(--bg)}
@media(min-width:901px){
  body:has(#game-view:not(.hidden)){overflow:hidden}
  .app:has(#game-view:not(.hidden)){padding:0 8px}
  .app:has(#game-view:not(.hidden)) .topbar{display:none}
  .app #game-view{height:var(--viewport-height,100dvh);min-height:0;display:flex;flex-direction:column}
  .app #game-view .game-heading{height:56px;min-height:56px;padding:6px 0;gap:10px}
  #game-view .game-heading-left,#game-view .game-heading-right{gap:8px;min-width:0}
  #game-view .battle-identity{min-width:0}
  #game-view .battle-identity .game-badge{font-size:16px;white-space:nowrap}
  #game-view .match-pulse{width:160px}
  #game-view .match-clock{padding-left:9px;gap:6px}
  #game-view .game-layout{grid-template-columns:minmax(0,1fr) 248px;gap:10px;padding:0 0 8px;min-height:0;min-width:0}
  #game-view .game-main{display:grid;grid-template-rows:36px minmax(0,1fr) 128px;min-width:0;min-height:0;overflow:hidden}
  #game-view .map-top{min-height:0;height:36px;padding:2px 10px;overflow:hidden}
  #game-view .battle-map-wrapper{height:auto!important;min-height:0;min-width:0}
  #game-view .action-console{height:128px;min-height:0;min-width:0;overflow:hidden;grid-template-rows:52px minmax(0,1fr);padding:8px 12px;gap:4px 10px}
  #game-view .battle-controls{grid-row:1;min-width:0;min-height:0;height:52px;padding:0;border:0}
  #game-view .action-console>.troop-widget,#game-view .action-console>.attack-widget,#game-view .action-console>.help-button,#game-view .action-console>.battle-info-toggle{grid-row:2}
  #game-view .action-console>.attack-widget{grid-column:3;align-self:center}
  #game-view .action-console>.help-button,#game-view .action-console>.battle-info-toggle{grid-column:4;width:44px;min-height:44px}
  #game-view .action-console input[type="range"]{height:22px;margin:0}
  #game-view .attack-hint{line-height:14px;min-height:14px;margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #game-view .map-zoom button{width:44px;height:44px}
  #game-view .wall-console{flex:0 0 198px}
  #game-view .commander-panel{overflow-y:auto;overscroll-behavior:contain}
  #game-view .commander-panel::details-content{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
  #game-view .battle-info-toggle{display:none}
  #battle-info-content .match-sidebar{display:flex;flex-direction:column;overflow:visible}
  #battle-info-content .commander-panel{flex:none}
  #battle-info-content .match-standings{max-height:320px}
}
@media(min-width:901px) and (max-width:1279px){
  #game-view .game-layout{grid-template-columns:minmax(0,1fr)}
  #game-view .match-pulse{width:120px}
  #game-view .battle-sound{display:none}
  #game-view .game-main{grid-template-rows:36px minmax(0,1fr) 96px}
  #game-view .action-console{height:96px;grid-template-columns:110px 110px 152px minmax(140px,1fr) 44px;grid-template-rows:minmax(0,1fr);align-items:center}
  #game-view .battle-controls{display:contents}
  #game-view .action-console>.troop-widget,#game-view .action-console>.attack-widget,#game-view .action-console>.battle-info-toggle{grid-row:1}
  #game-view .action-console>.attack-widget{grid-column:4}
  #game-view .action-console>.battle-info-toggle{grid-column:5}
  #game-view .wall-console{grid-column:3;grid-row:1;width:152px;flex-wrap:nowrap;gap:4px}
  #game-view .wall-console #wall-build{width:104px;flex-shrink:0}
  #game-view .wall-console #wall-build>.ui-icon{display:none}
  #game-view .battle-info-toggle{display:grid;place-items:center;border:1px solid #52657b;border-radius:8px;background:#253344;font-size:9px}
  #game-view .help-button{display:none}
  #battle-info-content .map-zoom{display:flex;flex-wrap:wrap;width:100%;margin:0;padding:12px;border:1px solid #405c74;border-radius:10px;background:#172a3c;justify-content:space-between}
  #battle-info-content .map-controls-label{display:block;flex-basis:100%;margin-bottom:6px;font-size:13px}
  #battle-info-content .map-zoom button{width:44px;height:44px}
  #battle-info-content .team-pings{margin:0;max-width:none;width:100%;justify-content:flex-start}
}
@media(min-width:901px){
  /* Reactions retain a 64px row alongside the header, reclaiming the empty strip. */
  .app #game-view{display:grid;grid-template-columns:max-content minmax(0,1fr) auto;grid-template-rows:64px minmax(0,1fr);column-gap:12px}
  .app #game-view .game-heading{display:contents}
  #game-view .game-heading-left{grid-column:1;grid-row:1;padding-inline:8px;gap:12px}
  #game-view .battle-identity{flex:none}
  #game-view .leave-match-button{flex:none;justify-content:center;align-items:center;min-height:44px;padding:8px 12px}
  #game-view .game-heading-right{grid-column:3;grid-row:1}
  #game-view #emote-rail{grid-column:2;grid-row:1;width:100%;min-width:0;background:none;border:0;padding:3px 0}
  #game-view .game-layout{grid-column:1/-1;grid-row:2}
}
@media(min-width:901px) and (max-width:1279px){
  .app #game-view{column-gap:8px}
  #game-view .game-heading-right{gap:6px}
  #game-view #emote-rail{gap:3px}
  #game-view .emote-face{width:38px;height:auto;aspect-ratio:1}
  #game-view .emote-player-name{font-size:9px}
}
@media(max-width:900px){
  #battle-fullscreen{display:none}
}

/* Matchmaking is the one map overlay: it never participates in map sizing and
   disappears before battle controls unlock. Fight notifications stay in the HUD. */
.map-countdown{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);z-index:3;display:flex;flex-direction:column;align-items:center;gap:6px;width:min(310px,calc(100% - 24px));max-height:calc(100% - 16px);padding:clamp(10px,2vh,22px) 16px;overflow:hidden;border:1px solid #b89450;border-radius:16px;background:#111d2ded;box-shadow:0 12px 36px #0005;text-align:center;pointer-events:none}
#map-countdown-title{font-size:clamp(14px,2vh,18px);font-weight:600;color:#f4d79d;line-height:1.3}
#map-countdown-value{font-size:clamp(32px,8vh,68px);font-weight:800;line-height:1.05;font-variant-numeric:tabular-nums;color:#fff3d6}
#map-countdown-players{font-size:12px;line-height:1.4;color:#d4e0ee}
.map-countdown.countdown-message #map-countdown-value{font-size:clamp(18px,3vh,26px);line-height:1.2}
