/* Shared themed close control; keep at least a 44px touch target. */
body :is(dialog,#faithful-context,#desktop-drawer,#phone-faithful) :is(.close,.sheet-head .close,#desktop-drawer-close,#game-menu-close,#faithful-context-close){display:inline-flex;align-items:center;justify-content:center;line-height:1;padding:0;min-width:44px;min-height:44px;width:44px;height:44px;border-radius:50%;background:#efdcba;color:#493323;border:1px solid #b58b58;box-shadow:inset 0 1px 2px #fff6,0 2px 3px #38251d22}
#phone-faithful .sheet{background:#f3e2c2;color:#392a1e}#phone-faithful .sheet-head{align-items:center}#phone-faithful .sheet-body :is(.notice,.drone-panel,.trait-panel,.connection-panel,.installation-panel,.research-panel,.access-choice,.cost-total,fieldset){background:#efdcba!important;color:#392a1e;border-color:#ba996d}#phone-faithful .sheet-body details{background:#f3e2c2!important}#phone-faithful .sheet-body :is(button,input,select){background:#efdcba;color:#392a1e;border-color:#ba996d}
.phone-faithful-active #phone-faithful .turn-strip{position:relative;z-index:4;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:2px 6px;height:auto;min-height:30px;padding:2px 8px}.phone-faithful-active #phone-faithful .turn-strip .online-compact-state{grid-column:1/-1;justify-content:space-between;min-height:24px;font-size:11px!important;padding:1px 6px;background:#ecd9b8;border:0;border-radius:4px}.phone-faithful-active #phone-faithful .event{position:relative;z-index:1}
@media(max-width:700px) and (orientation:portrait){.phone-faithful-active #phone-faithful .mini.dense{grid-template-rows:58px 102px auto 32px minmax(0,1fr) 145px 102px 42px}#phone-faithful .action{height:96px;grid-template-rows:50px 44px}#phone-faithful .action-circle{width:50px;height:50px}#phone-faithful .action-caption{height:44px;grid-template-rows:25px 16px}#phone-faithful .detail-tabs button{height:44px;min-height:44px;padding:2px;grid-template-rows:14px 24px;gap:0}#phone-faithful .detail-tabs button>span{font-size:11px;line-height:12px}#phone-faithful .inspector{padding:4px 8px}#phone-faithful .selected-units{margin:2px 0} }
@media(orientation:landscape) and (max-height:500px){.phone-faithful-active #phone-faithful .mini.dense{grid-template-rows:36px 60px auto 24px minmax(0,1fr) 80px 32px}.phone-faithful-active #phone-faithful .turn-strip{display:flex;flex-wrap:nowrap;gap:6px;min-height:26px}.phone-faithful-active #phone-faithful .turn-strip .online-compact-state{margin-left:auto;flex:none}.phone-faithful-active #phone-faithful .turn-strip .company-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}

@media(max-width:350px) and (orientation:portrait){#phone-faithful .detail-tabs button{height:48px;min-height:48px}.phone-faithful-active #phone-faithful .mini.dense{grid-template-rows:58px 102px auto 32px minmax(0,1fr) 160px 102px 42px}}

body #game-menu-close,body #desktop-drawer-close,body #faithful-context-close{display:inline-flex;align-items:center;justify-content:center;line-height:1;padding:0;width:44px;height:44px;min-width:44px;border-radius:50%;background:#efdcba;color:#493323;border:1px solid #b58b58}

/* Portrait: one status row, compact header, and cards with a protected bottom inset. */
@media(orientation:portrait) and (max-width:950px){
 .phone-faithful-active #phone-faithful .mini.dense{grid-template-rows:44px 96px 30px 28px minmax(0,1fr) 145px 102px 42px}
 #phone-faithful .mini-header{padding:0 8px;gap:5px}
 #phone-faithful .logo{width:145px;height:35px;max-width:50%}
 #phone-faithful .round{width:78px;height:33px;border-radius:9px;flex-direction:row;gap:4px;font-size:11px;box-shadow:none}
 #phone-faithful .round strong{font-size:16px}
 #phone-faithful .menu{width:44px;height:44px;padding:9px}
 #phone-faithful .players{display:grid;grid-template-columns:none!important;grid-auto-flow:column;grid-auto-columns:minmax(72px,1fr);padding:4px 5px;gap:3px;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:thin}
 #phone-faithful .player{display:grid;grid-template-columns:1fr;grid-template-rows:16px 27px 28px;min-height:0;gap:2px;padding:3px 2px 7px;align-content:start}
 #phone-faithful .player-line{grid-column:1;grid-row:1;flex-direction:row;font-size:11px;line-height:14px;gap:1px;height:auto}
 #phone-faithful .player-line img{width:13px;height:13px}
 #phone-faithful .player-stats{grid-column:1;grid-row:2;font-size:11px}
 #phone-faithful .player-stats>span{grid-template-rows:12px 13px}
 #phone-faithful .player-stats .sw-symbol{width:11px;height:11px}
 #phone-faithful .player-production{grid-column:1;grid-row:3;margin:0;padding:1px 0 0;line-height:12px}
 #phone-faithful .player-production small{display:block;font-size:11px;line-height:12px}
 #phone-faithful .production-values{margin:1px 0 0;font-size:11px;line-height:12px}
 .phone-faithful-active #phone-faithful .turn-strip{display:flex;flex-wrap:nowrap;gap:4px;min-height:30px;height:30px;padding:1px 5px;font-size:11px;justify-content:space-between;white-space:nowrap}
 .phone-faithful-active #phone-faithful .turn-strip>.company-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
 .phone-faithful-active #phone-faithful .turn-strip .action-counter{font-size:11px;gap:2px;flex:none}
 .phone-faithful-active #phone-faithful .turn-strip .counter-values{font-size:11px}
 .phone-faithful-active #phone-faithful .turn-strip .online-compact-state{grid-column:auto;min-height:26px;font-size:11px!important;padding:0 3px;background:transparent;border:0;display:flex;gap:5px;flex:none;margin:0}
 .phone-faithful-active #phone-faithful .event{background:#503a2540;color:#2f2016;border-bottom:1px solid #9a754966;text-shadow:0 1px 1px #fff7;font-size:11px;padding:2px 8px}
 #phone-faithful .event img{width:21px;height:21px}
 #phone-faithful .live-puck{max-height:84px}
}
@media(orientation:portrait) and (max-width:350px){
 .phone-faithful-active #phone-faithful .mini.dense{grid-template-rows:44px 96px 30px 28px minmax(0,1fr) 160px 102px 42px}
}

/* Short usable viewports scroll only the map; controls keep their touch targets. */
@media(orientation:portrait) and (max-width:950px){
 #phone-faithful .dense .board{grid-template-rows:repeat(var(--world-rows,4),minmax(64px,1fr))!important;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
}

/* Account names share the online identity source with desktop; reserve their row. */
#phone-faithful .compact-planet-detail{display:none}
#phone-faithful .mobile-player-name{display:block;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;font:10px/12px Georgia,serif;color:#fff0cf}
@media(orientation:portrait) and (max-width:950px){
 #phone-faithful .has-player-names .player{grid-template-rows:14px 12px 25px 24px;gap:1px;padding:2px 2px 3px}
 #phone-faithful .has-player-names .player-line{grid-row:1;line-height:14px}
 #phone-faithful .has-player-names .mobile-player-name{grid-row:2;grid-column:1;align-self:center}
 #phone-faithful .has-player-names .player-stats{grid-row:3}
 #phone-faithful .has-player-names .player-stats>span{grid-template-rows:11px 12px}
 #phone-faithful .has-player-names .player-production{grid-row:4;padding:0}
 #phone-faithful .has-player-names .player-production small,#phone-faithful .has-player-names .production-values{line-height:11px}
 /* Only crowded maps use the shorter inspector and Action art band. */
 .phone-faithful-active:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .mini.dense{grid-template-rows:44px 96px 30px 28px minmax(0,1fr) 100px 84px 42px}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .inspector>.detail-top,
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .inspector>.detail-expanded{display:none}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .compact-planet-detail{display:flex;align-items:center;gap:6px;width:100%;height:44px;min-height:44px;margin:0 0 2px;padding:0;border:0;border-radius:0;background:none;box-shadow:none;text-align:left}
 #phone-faithful .compact-planet-detail>img{width:45px;height:36px;object-fit:cover;border:1px solid #8e6849;border-radius:4px;flex:none}
 #phone-faithful .compact-planet-text{flex:1;min-width:0}
 #phone-faithful .compact-planet-heading{display:flex;align-items:center;justify-content:space-between;gap:4px;font-size:15px;line-height:20px}
 #phone-faithful .compact-planet-heading>span:first-child{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 #phone-faithful .compact-planet-heading .production{font-size:11px;flex:none}
 #phone-faithful .compact-presence{display:block;font-size:11px;line-height:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .action{height:78px;grid-template-rows:32px 44px}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .action-circle{width:34px;height:34px}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .dense .board{grid-template-rows:repeat(var(--world-rows),minmax(96px,1fr))!important}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .terrain-wrap{display:grid;grid-template-rows:minmax(0,1fr) auto;justify-items:center;align-items:center}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .world .live-puck{grid-row:1;height:min(54px,100%);width:auto;aspect-ratio:var(--puck-ratio);max-height:none;max-width:100%;flex:none}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .occupants{position:static;grid-row:2;flex-wrap:nowrap;max-width:100%;gap:1px}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .occupants .unit-token{min-width:13px;height:16px}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) .occupants .unit-token img{width:13px;height:13px}
}
/* Landscape keeps its existing inspector and dock geometry; names stay on their own line. */
@media(orientation:landscape){
 #phone-faithful .has-player-names .player{gap:0;padding-block:0}
 #phone-faithful .has-player-names .player-line{font-size:10px;line-height:12px}
 #phone-faithful .has-player-names .player-line img{width:12px;height:12px}
 #phone-faithful .has-player-names .mobile-player-name{font-size:10px;line-height:11px}
 #phone-faithful .has-player-names .player-stats>span{display:flex;gap:2px}
 #phone-faithful .has-player-names .player-production{margin:0;padding-top:0}
 #phone-faithful .has-player-names .player-production{display:flex;align-items:center;gap:2px}
 #phone-faithful .has-player-names .player-production small{display:block;font-size:9px;line-height:11px}
 #phone-faithful .has-player-names .production-values{flex:1;margin:0;font-size:9px;line-height:11px}
}

/* Mobile sprite windows contain the complete illustration, without the desktop plaque. */
#phone-faithful span.action-circle{width:50px;height:50px;max-width:100%;display:grid;place-items:center;border:1px solid #d8af65;border-radius:50%;background:radial-gradient(#3f3444,#211d29);box-shadow:inset 0 0 0 1px #614322;overflow:hidden;clip-path:none;transform:none}
#phone-faithful .production-resource{display:flex;align-items:center;justify-content:center;gap:1px;min-width:0}
#phone-faithful .production-resource .sw-symbol{width:9px;height:9px}
#phone-faithful .production-choice-symbol .sw-symbol{width:7px;height:7px}
#phone-faithful .production-amount{display:block;white-space:nowrap;font:500 10px/11px system-ui,sans-serif;font-variant-numeric:tabular-nums;text-align:center}
@media(orientation:portrait) and (max-width:950px){
 #phone-faithful .mini:not(.has-player-names) .player{grid-template-rows:16px 24px 31px}
 #phone-faithful .has-player-names .player{grid-template-rows:14px 12px 21px 31px}
 #phone-faithful .has-player-names .player-stats>span{grid-template-rows:9px 11px}
 #phone-faithful .has-player-names .player-stats .sw-symbol{width:9px;height:9px}
 #phone-faithful .has-player-names .player-stats b{font-size:11px;line-height:11px}
 #phone-faithful .mini:not(.has-player-names) .player-stats>span{grid-template-rows:11px 12px}
 #phone-faithful .mini:not(.has-player-names) .player-stats b{line-height:12px}
 #phone-faithful .player-production{margin:0;padding:0;border-top:1px solid #d6c49b4d}
 #phone-faithful .player-production small,#phone-faithful .has-player-names .player-production small{font-size:10px;line-height:10px}
 #phone-faithful .production-values{margin:0;min-width:0}
 #phone-faithful .production-values>.production-value{display:grid;grid-template-rows:9px 11px;min-width:0;gap:0;align-items:center}
 body:not(.phone-refined) #phone-faithful:is([data-players="4"],[data-players="5"]) span.action-circle{width:32px;height:32px}
}
@media(orientation:landscape){
 #phone-faithful span.action-circle{width:32px;height:32px}
 #phone-faithful .player-production{display:flex;align-items:center;gap:2px;margin:0;padding:0}
 #phone-faithful .player-production small{font-size:9px;line-height:11px}
 #phone-faithful .production-values{flex:1;margin:0}
 #phone-faithful .production-values>.production-value{display:flex;align-items:center;justify-content:center;gap:1px;min-width:0}
 #phone-faithful .production-amount{font-size:9px;line-height:11px}
}
/* Give landscape production the whole card width instead of a narrow side column. */
@media(orientation:landscape){
 #phone-faithful .player{grid-template-columns:minmax(0,1fr);grid-template-rows:14px 14px 12px;align-content:center}
 #phone-faithful .has-player-names .player{grid-template-rows:12px 11px 14px 12px}
 #phone-faithful .player-line{grid-column:1;grid-row:1;flex-direction:row;font-size:11px;line-height:12px;gap:2px}
 #phone-faithful .player-line img{width:12px;height:12px}
 #phone-faithful .mobile-player-name{grid-column:1;grid-row:2}
 #phone-faithful .player-stats{grid-column:1;grid-row:2}
 #phone-faithful .has-player-names .player-stats{grid-row:3}
 #phone-faithful .player-stats>span{display:flex;align-items:center;justify-content:center;gap:2px}
 #phone-faithful .player-stats b{font-size:11px;line-height:12px}
 #phone-faithful .player-stats .sw-symbol{width:11px;height:11px}
 #phone-faithful .player-production{grid-column:1;grid-row:3;width:100%;min-width:0}
 #phone-faithful .has-player-names .player-production{grid-row:4}
 #phone-faithful .production-resource,#phone-faithful .production-amount{flex:none}
}

#phone-faithful .mobile-action-illustration{display:block;width:70%;height:70%;overflow:hidden}

#phone-faithful .board .world{position:relative}
#phone-faithful .board .trait-face{position:absolute;left:2px;top:2px;width:27px;height:auto;min-height:34px;display:flex;flex-direction:column;gap:1px;background:transparent;border:0;border-radius:0;box-shadow:none;z-index:5;overflow:visible;color:#392a1e}
#phone-faithful .board .trait-face>img{width:22px;height:22px;object-fit:cover;border-radius:50%}
#phone-faithful .board .trait-face>b{position:static;font-size:10px;display:flex;align-items:center;white-space:nowrap;background:none;padding:0}
#phone-faithful .board .trait-face .sw-symbol{width:12px;height:12px}
#phone-faithful .board .trait-number,#phone-faithful .board .trait-tooltip{display:none}
#phone-faithful [data-mobile-company]{cursor:pointer}

/* Planet annotations sit directly on the board, matching the desktop treatment. */
#phone-faithful .board .world>.planet-research-badge{background:transparent;border:0;border-radius:0;box-shadow:none}
/* Mirrored annotation columns: common top, width and two-row rhythm. */
#phone-faithful .board .world>.trait-face,
#phone-faithful .board .world>.planet-research-badge{
 top:2px;width:28px;min-width:28px;height:39px;min-height:39px;margin:0;padding:0;
 display:grid;grid-template-rows:22px 14px;row-gap:3px;justify-items:center;align-items:center;
 font-size:10px;line-height:14px;box-sizing:border-box;
}
#phone-faithful .board .world>.trait-face{left:2px;right:auto}
#phone-faithful .board .world>.planet-research-badge{right:2px;left:auto}
#phone-faithful .board .world>.trait-face>img{width:22px;height:22px}
#phone-faithful .board .world>.trait-face>b{font-size:10px;line-height:14px;gap:1px}
#phone-faithful .board .world>.planet-research-badge>.research-deck-mark{width:16px;height:22px;min-width:16px}
