/* Mobile overrides only. Desktop rules and markup remain authoritative above 760px. */
@media (max-width:760px) {
 html {min-width:0;scroll-padding-top:12px;}
 body {min-width:0!important;background-attachment:scroll!important;}
 body #app {width:100%!important;max-width:100%!important;min-width:0!important;margin:0!important;padding:0 0 24px!important;}
 body[data-auth="1"] .workspace,body[data-auth="1"] .content {display:block!important;box-sizing:border-box;width:100%!important;max-width:100%!important;min-width:0!important;margin:0!important;padding:10px!important;}
 body[data-auth="1"] .content {padding:0!important;}
 #app *, .gate-screen * {box-sizing:border-box;}
 #app :is(section,article,form,header,footer,div,label) {min-width:0;}
 #app :is(h1,h2,h3,p,blockquote,dd) {overflow-wrap:anywhere;}
 #app :is(input:not([type=radio]):not([type=checkbox]),select,textarea) {max-width:100%;font-size:16px!important;}
 #app :is(button,summary,select) {touch-action:manipulation;}
 #app button {min-height:44px;white-space:normal;}
 body[data-auth="1"] .round-strip {position:static!important;display:grid!important;grid-template-columns:repeat(6,minmax(0,1fr));width:100%!important;height:auto!important;max-width:none!important;margin:0!important;padding:8px!important;gap:0!important;background:#080e12!important;}
 body[data-auth="1"] .round-strip>span {grid-column:span 3;min-width:0!important;min-height:30px;height:auto!important;display:flex!important;flex-wrap:wrap;justify-content:center;gap:4px!important;padding:5px!important;border:0!important;font-size:10px!important;line-height:1.4;white-space:normal!important;}
 body[data-auth="1"] .round-strip .top-resource {grid-column:span 2;flex-direction:column;border-top:1px solid #5b492b!important;border-right:1px solid #5b492b!important;gap:2px!important;}
 body[data-auth="1"] .round-strip .top-resource b {max-width:100%;overflow-wrap:anywhere;font-size:12px!important;}
 body[data-auth="1"] .round-strip .top-resource small {font-size:8px!important;}
 body[data-auth="1"] .round-strip button {min-height:30px;padding:3px!important;}
 body[data-auth="1"] .game-primary {position:static!important;display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr));width:calc(100% - 16px)!important;max-width:none!important;height:auto!important;margin:4px 8px!important;gap:0!important;}
 body[data-auth="1"] .game-primary .game-nav-item,body[data-auth="1"] .game-primary .game-nav-item:first-child {width:100%!important;height:62px!important;padding:6px 2px!important;flex-direction:column;gap:4px;border-bottom:1px solid #542328!important;}
 .game-nav-icon {width:23px;height:26px;flex:0 0 26px;}
 .game-nav-icon svg {width:17px;height:17px;}
 .game-nav-copy b {font-size:10px;letter-spacing:0;}
 .game-nav-copy small {display:none;}
 .mobile-menu {margin:8px;border:1px solid #7f6230;background:#0a1115;color:#e8ce91;}
 .mobile-menu>summary {cursor:pointer;min-height:44px;padding:13px 16px;font:700 12px Arial;letter-spacing:.06em;}
 body[data-auth="1"] .mobile-menu .utility-nav {position:static!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));width:100%!important;max-width:100%!important;height:auto!important;margin:0!important;padding:6px!important;gap:6px!important;overflow:visible!important;}
 body[data-auth="1"] .mobile-menu .utility-nav button {width:100%!important;min-width:0!important;margin:0!important;padding:8px 4px!important;font-size:10px!important;}
 body[data-auth="1"] .army-strip {max-width:100%;flex-wrap:wrap;height:auto;}
 #app .table-scroll {max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;}
 .table-scroll table {min-width:600px;}
 #app dialog {box-sizing:border-box;width:calc(100% - 20px)!important;max-width:calc(100% - 20px)!important;max-height:calc(100dvh - 24px)!important;margin:auto!important;padding:0!important;overflow:auto;}
 #app dialog>section {width:100%!important;min-width:0!important;}
 #app dialog header {flex-wrap:wrap;gap:10px;}
 #toast {left:10px!important;right:10px!important;bottom:12px!important;top:auto!important;width:auto!important;max-width:none!important;}
 /* Main ledger, Kingdom, profile and administration. */
 #app :is(.realm-command-v3,.realm-command,.admin-console,.kingdom-screen,.profile-screen) {width:100%!important;max-width:100%!important;margin:0!important;}
 #app :is(.realm-board-grid,.realm-intel-grid,.command-columns,.admin-dashboard-grid,.admin-settings,.admin-resource-grid,.profile-columns,.kingdom-banner,.message-layout,.mail-layout,.treasury-command,.vault-orders,.transfer-desk) {display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:12px;}
 #app :is(.realm-command-banner,.kingdom-banner,.admin-hero,.profile-hero,.barracks-hero,.production-hero,.collection-hero,.market-hero,.treasury-hero,.travel-hero,.rival-command-hero) {height:auto!important;min-height:0!important;padding:20px 16px!important;gap:14px;flex-wrap:wrap;}
 #app :is(.barracks-hero,.production-hero,.collection-hero,.market-hero,.treasury-hero,.travel-hero,.rival-command-hero) {display:flex!important;flex-direction:column!important;align-items:stretch!important;}
 #app :is(.barracks-hero,.production-hero,.collection-hero,.market-hero,.treasury-hero,.travel-hero) h1 {font-size:28px!important;}
 #app :is(.army-summary,.production-ledger,.collection-ledger,.admin-kpis,.profile-power-grid,.treasury-modal-balances) {display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;}
 .kingdom-roster-v2 {overflow-x:auto;}
 .kingdom-roster-v2 :is(.kingdom-roster-head,.kingdom-member-row) {min-width:1000px;}
 #app :is(.kingdom-standing,.kingdom-identity dl,.admin-player-actions,.admin-tabs,.choice-tabs) {flex-wrap:wrap;height:auto;}
 #app .kingdom-identity dl {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));}
 #app .admin-tabs {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));}
 #app .admin-table {overflow-x:auto;}
 #app :is(.admin-table-head,.admin-player-card) {min-width:650px;}
 /* Full-width cards and touch-sized orders. */
 #app :is(.unit-cards,.production-lines,.collection-policies,.ship-goods,.armory-goods,.market-grid,.action-grid) {display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:14px;}
 #app :is(.unit-card,.production-line,.collection-policy,.ship-card) {display:flex!important;flex-direction:column!important;min-height:0!important;}
 #app :is(.unit-art,.production-art,.collection-art,.ship-art) {height:200px!important;min-height:200px!important;}
 #app :is(.unit-body,.production-copy,.collection-copy,.ship-copy) {padding:16px!important;}
 #app :is(.unit-body,.production-copy,.collection-copy)>p {height:auto;min-height:0;margin-bottom:14px;}
 #app :is(.muster-console,.production-console,.collection-console,.voyage-console,.village-muster,.market-trade,.unified-trade,.vault-order,.transfer-order,.provision-market,.provision-actions) {display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:12px!important;padding:16px!important;}
 #app :is(.muster-console,.production-console,.collection-console,.voyage-console)>* {grid-column:auto!important;}
 #app .quick-turns {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));width:100%;}
 #app .quick-turns button {height:44px!important;}
 #app :is(.unit-yield,.production-output,.collection-reward,.unit-owned,.ship-capacity-line) {flex-wrap:wrap;gap:8px;}
 #app .unified-trade>div {display:grid;grid-template-columns:1fr 1fr;gap:8px;}
 /* Rival banners retain their artwork; mobile gets vertically arranged orders. */
 body[data-page="attack"] .war-room {width:100%;}
 body[data-page="attack"] .war-room-bar {display:grid!important;grid-template-columns:1fr 1fr!important;height:auto!important;gap:8px;padding:10px!important;}
 body[data-page="attack"] .war-room-bar>.war-readiness {grid-column:1/-1;grid-row:1;display:flex!important;flex-wrap:wrap!important;justify-content:center;gap:8px!important;width:100%!important;padding:8px 0!important;}
 body[data-page="attack"] .war-readiness>strong {flex-basis:100%;text-align:center;}
 body[data-page="attack"] .war-readiness>span {padding:0 8px!important;}
 body[data-page="attack"] .war-room-bar button {width:100%;padding:8px!important;font-size:10px!important;}
 body[data-page="attack"] .confrontation {grid-template-columns:minmax(0,1fr)!important;padding:20px 12px!important;gap:14px!important;min-height:0!important;}
 body[data-page="attack"] .confrontation .combatant {width:min(255px,100%)!important;height:360px!important;min-height:360px!important;justify-self:center;grid-template-rows:76px 16px 36px 44px 44px 30px!important;padding:58px 18px 24px!important;}
 body[data-page="attack"] .versus {display:block!important;position:static!important;grid-column:auto!important;grid-row:auto!important;}
 body[data-page="attack"] .versus>span {font-size:38px!important;}
 body[data-page="attack"] .versus>small {display:none!important;}
 #app .war-orders {height:auto!important;display:grid!important;grid-template-columns:minmax(0,1fr)!important;}
 #app .war-order {height:auto!important;min-height:230px!important;}
 body[data-page="attack"] .content .scout-report {display:block!important;}
 #app .scout-sigil {display:none!important;}
 #app .scout-intel {padding:16px;}
 #app .scout-intel>header {display:block;}
 #app .scout-findings {display:grid!important;grid-template-columns:minmax(0,1fr)!important;}
 #app .scout-findings dl {display:block!important;padding:12px 0!important;border-right:0!important;border-bottom:1px solid #61707966;}
 #app .scout-findings dd {text-align:left!important;font-size:14px!important;white-space:normal!important;}
 #app .scout-composition {display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:8px!important;}
 #app .scout-composition>span {display:flex;justify-content:space-between;gap:10px;}
 #app .scout-fleet-panel {grid-template-columns:1fr!important;}
 #app .scout-fleet-panel>div {grid-template-columns:1fr!important;}
 #app .scout-fleet-panel span {flex-direction:row;justify-content:space-between;padding:10px;gap:8px;}
 #app .scout-intel>footer {display:flex;flex-wrap:wrap;gap:8px;}
 #app .scout-intel>footer p {flex-basis:100%;}
 #app .battle-result-field {display:grid!important;grid-template-columns:minmax(0,1fr)!important;padding:16px!important;gap:14px!important;}
 #app :is(.result-army,.result-verdict,.battle-summary) {position:static!important;grid-column:auto!important;grid-row:auto!important;width:100%!important;padding:16px!important;}
 #app :is(.battle-spoils,.battle-result-actions) {display:flex!important;flex-direction:column;gap:10px;padding:14px!important;}
 #app .battle-result-actions button {width:100%;}
 #app .loss-ledger {display:flex;flex-wrap:wrap;}
 /* Sign-in and dialogs fit the visual viewport, including the on-screen keyboard. */
 body[data-auth="0"] .gate-screen {width:100%!important;min-height:100svh!important;padding:24px 14px!important;display:flex!important;flex-direction:column;gap:24px;}
 body[data-auth="0"] .gate-title {position:static!important;transform:none!important;width:100%!important;padding:0!important;}
 body[data-auth="0"] .gate-title h1 {font-size:clamp(32px,9vw,52px)!important;}
 body[data-auth="0"] .gate-title h2 {font-size:15px!important;}
 body[data-auth="0"] .gate-access {position:static!important;transform:none!important;width:100%!important;max-width:440px!important;margin:0 auto!important;padding:20px!important;}
 .gate-dialog {width:calc(100% - 24px)!important;max-width:440px!important;max-height:calc(100dvh - 24px);overflow:auto;}
 body>footer {padding:16px 12px!important;display:flex;flex-wrap:wrap;gap:8px;justify-content:center;font-size:9px;}
}
@media(max-width:760px){
 body[data-auth="1"] .round-strip {grid-template-columns:repeat(6,minmax(0,1fr))!important;overflow:visible!important;}
 body[data-auth="1"] .round-strip>span {grid-row:auto!important;grid-column:span 3!important;width:100%!important;max-width:100%!important;}
 body[data-auth="1"] .round-strip>.top-resource {grid-column:span 2!important;}
 body[data-auth="1"] .round-strip :is(b,strong,button) {white-space:normal!important;font-size:inherit;}
 body[data-auth="1"] .round-strip>span:after {display:none!important;}
}
@media(max-width:760px){
 body[data-page="attack"] .war-room-bar>.war-readiness {height:auto!important;min-height:0!important;overflow:visible!important;}
 body[data-page="attack"] .war-readiness>span {height:auto!important;min-height:30px;white-space:normal!important;}
}
@media(max-width:760px){
 #app .unified-trade>div {grid-template-columns:repeat(2,minmax(0,1fr));}
 #app .unified-trade button,#app .admin-tabs button {min-width:0!important;width:100%!important;padding:8px 4px!important;font-size:10px!important;}
 #app .leaderboard-table {max-width:100%;overflow-x:auto;}
 #app :is(.leaderboard-head,.leaderboard-row,.kingdom-roster-head,.kingdom-member-row) {min-width:1000px!important;}
 #app :is(.leaderboard-table,.kingdom-roster-v2,.table-scroll)::before {content:'Swipe sideways to see all columns';display:block;position:sticky;left:0;width:100%;padding:10px;color:#c8b583;font:11px/1.4 Arial;background:#0b1419;}
}
@media(max-width:760px){
 body[data-page="attack"] .war-room-bar button {min-width:0!important;}
}
@media(max-width:760px){
 body[data-auth="0"] {overflow-x:clip;}
}
