/* Phone fit (TODO 19): fixes found by tools/layout-matrix. Scoped to the refined phone layout; presentation only. */
/* Landscape: the left column was only 150px (260px when very low), so "Turn · <company>" was clipped. */
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape],
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape][data-low-height=true]{grid-template-columns:clamp(236px,36vw,310px) minmax(0,1fr)}
/* Narrow landscape (e.g. 667px): keep the deadline, drop the "Connected" word so the company name is never clipped. */
@media(max-width:760px){.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .turn-strip .online-compact-state>span:not(.async-deadline){display:none}}
/* The discoverer ring sits over the planet art, never over the Research deck. */
/* Company ring: centred on the planet art and smaller (it was at the cell centre, on top of the Research deck). */
.phone-refined #phone-faithful .mini[data-map-layout=horizontal] .world>.world-discoverer{left:calc(var(--mobile-terrain-width,100px)/2);transform:translateX(-50%) scale(.72);transform-origin:50% 0}
/* Research deck on the map is a portrait card (back artwork), not a square tile. */
.phone-refined #phone-faithful .board .world>.planet-research-badge>.research-deck-mark{width:19px!important;min-width:19px!important;height:27px!important;min-height:27px!important;flex:0 0 27px!important;aspect-ratio:auto!important}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .board .world>.planet-research-badge>.research-deck-mark{width:16px!important;min-width:16px!important;height:23px!important;min-height:23px!important;flex:0 0 23px!important}
/* Status button reaches a 28px touch target. */
.phone-refined #phone-faithful .online-compact-state{min-height:28px}

/* Space: slimmer bars so the map gets more of the screen. */
/* Portrait */
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]){grid-template-rows:44px var(--players-band) 28px 26px minmax(0,1fr) 40px 80px 42px}
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .footer{height:40px}
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .footer button{height:38px;min-height:38px}
/* Landscape */

/* Landscape: if the map still does not fit, it scrolls inside its own band instead of spilling over the context bar. */
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] main.board{min-height:0;overflow-y:auto;overscroll-behavior:contain}

/* Status text on the dark turn strip was dark brown on dark blue (1.3:1). */
.phone-refined[data-board-background=cosmic] #phone-faithful .turn-strip .online-compact-state,
.phone-refined[data-board-background=cosmic] #phone-faithful .turn-strip .online-compact-state>span{color:#f2dfbd}

/* Landscape: the "Next event" button must fit the slimmer event row. */
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .mobile-next-event{min-height:0;height:26px;padding-block:0}

/* Tabletop view: five player cards fit a 375px phone, and the turn button text is readable. */
.phone-refined #phone-faithful .mini[data-player-count] .players{grid-template-columns:repeat(var(--mobile-player-count),minmax(0,1fr))!important;grid-auto-flow:row;gap:4px}
.phone-refined[data-board-background=tabletop] #phone-faithful .turn-strip .priority-turn-button,
.phone-refined[data-board-background=tabletop] #phone-faithful .turn-strip .priority-turn-button b{color:#f2dfbd}

/* Landscape: leave a few pixels between the last role row of each planet and the context bar below the map. */

/* "Next event" button fits its strip in every orientation. */
.phone-refined #phone-faithful .mobile-event-row .mobile-next-event{min-height:26px!important;height:calc(100% - 2px)!important;align-self:center}

/* Slimmer bars only on really short landscape screens (Safari with its bars), so taller phones keep the established layout exactly. */
@media (orientation:landscape) and (max-height:340px){
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape]{grid-template-rows:28px var(--players-band) 28px minmax(0,1fr) 54px 36px}
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape][data-low-height=true]{grid-template-rows:0 44px 26px minmax(0,1fr) 50px 36px}
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .footer{height:36px}
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .footer button{height:34px;min-height:34px}
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .turn-strip,
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape] .mobile-event-row{min-height:28px;height:28px}
 .phone-refined #phone-faithful .mini[data-refined-orientation=landscape] main.board{padding-bottom:8px!important}
}

/* ---- Dialogs on phones: compact so they fit without scrolling (George, 22/11) ---- */
/* Buying a mission: while paying, the tab strip and the list of cards are not needed. */
.phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-tabs,
.phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-list{display:none}
.phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading{padding-bottom:4px}
.phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading p{margin:2px 0 0;font-size:12px;line-height:1.25}
.phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-buy{margin:6px 0 0}
.phone-refined #modal .mission-buy-heading{display:flex;align-items:baseline;gap:10px;margin:0 0 4px}
.phone-refined #modal .mission-buy-heading h3{font-size:14px;margin:0}
.phone-refined #modal .mission-buy-heading p{font-size:12px;margin:0}
.phone-refined #modal .mission-price{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px;margin:0 0 6px;padding:6px 10px}
.phone-refined #modal .mission-price-label{font-size:10.5px}
.phone-refined #modal .mission-price-value{font-size:17px}
.phone-refined #modal .mission-price-note{flex:1 0 100%;font-size:12px;line-height:1.25}
.phone-refined #modal .mission-payment-intro{margin:0 0 6px}
.phone-refined #modal .mission-payment-intro strong{font-size:14px;display:inline}
.phone-refined #modal .mission-payment-intro span{font-size:12px;line-height:1.25;display:block}
.phone-refined #modal .mission-payment-options{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
.phone-refined #modal .mission-payment-options>button{height:auto;min-height:0;padding:6px 4px;display:flex;flex-direction:column;align-items:center;gap:2px}
.phone-refined #modal .mission-payment-options .mp-give{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:4px;height:auto;min-height:0;font-size:15px}
.phone-refined #modal .mission-payment-options .mp-give *{margin:0}
.phone-refined #modal .mission-payment-options .mp-left{font-size:10px;line-height:1.2}
.phone-refined #modal .mission-payment-actions{margin:8px 0 0;display:flex;gap:8px;justify-content:flex-end}
.phone-refined #modal .mission-payment-actions button{min-height:40px;padding:6px 12px}

/* Landscape: price and explanation on the left, the three payment choices and the buttons on the right. */
@media (orientation:landscape) and (max-height:520px){
 .phone-refined #modal[open]:has(#mission-payment>*){padding-top:12px!important;padding-bottom:10px!important}
 .phone-refined #modal:has(#mission-payment>*)>.close{top:4px!important;right:6px!important;width:36px!important;height:36px!important;min-height:36px!important}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading{display:flex;align-items:baseline;gap:10px;padding:0 44px 2px 0;border:0}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading h2{font-size:17px;margin:0}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading p{margin:0;font-size:11px}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-buy-heading{margin:0}
 .phone-refined #modal #mission-payment:not(:empty){display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.4fr);grid-template-rows:auto auto 1fr;gap:4px 12px;align-items:start}
 .phone-refined #modal #mission-payment>.mission-price{grid-column:1;grid-row:1;margin:0}
 .phone-refined #modal #mission-payment>.mission-payment-intro{grid-column:1;grid-row:2;margin:0}
 .phone-refined #modal #mission-payment>.mission-payment-options{grid-column:2;grid-row:1 / span 2}
 .phone-refined #modal #mission-payment>.mission-payment-actions{grid-column:2;grid-row:3;margin:4px 0 0}
 .phone-refined #modal .mission-payment-options>button{padding:4px}
}
/* Payment choice: amount and icon side by side instead of stacked. */
.phone-refined #modal .mission-payment-options .mp-amount{display:inline-flex;flex-direction:row;align-items:center;gap:3px;font-size:1.1em}
.phone-refined #modal .mission-payment-options .mp-amount em{display:none}
.phone-refined #modal .mission-payment-options .mp-amount .game-icon,.phone-refined #modal .mission-payment-options .mp-amount .sw-symbol{width:18px;height:18px}
@media (orientation:landscape) and (max-height:520px){
 .phone-refined #modal #mission-payment>.mission-payment-options{grid-row:1 / span 2;grid-template-columns:repeat(3,minmax(0,1fr))}
 .phone-refined #modal .mission-price-note{font-size:11px}
}
.phone-refined #modal .mission-buy-heading>div{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap}
@media (orientation:landscape) and (max-height:520px){
 .phone-refined #modal .mission-payment-intro span{font-size:11px;line-height:1.2}
 .phone-refined #modal .mission-payment-intro strong{font-size:13px}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-buy{margin:2px 0 0}
 .phone-refined #modal[open]:has(#mission-payment>*){padding-top:8px!important}
}
@media (orientation:landscape) and (max-height:340px){
 .phone-refined #modal[open]:has(#mission-payment>*){padding-top:4px!important;padding-bottom:4px!important}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading{padding-bottom:0}
 .phone-refined #modal .mission-overview:has(#mission-payment>*) .mission-overview-heading h2{font-size:15px}
 .phone-refined #modal .mission-price{padding:4px 8px}
 .phone-refined #modal .mission-price-value{font-size:15px}
 .phone-refined #modal .mission-payment-actions button{min-height:36px;padding:4px 10px}
 .phone-refined #modal .mission-payment-options>button{padding:2px 4px}
}
@media (orientation:landscape) and (max-height:520px){
 .phone-refined #modal #mission-payment:not(:empty){gap:2px 12px}
 .phone-refined #modal #mission-payment>.mission-payment-actions{margin-top:2px}
 .phone-refined #modal .mission-payment-actions button{min-height:36px}
 .phone-refined #modal .mission-price-label{font-size:10px}
 .phone-refined #modal .mission-price{padding:4px 8px}
}

/* Action preview (settle/explore/...) on short landscape screens: tighter, so nothing scrolls. */
@media (orientation:landscape) and (max-height:520px){
 html[data-ui-runtime=web] body.faithful-target.phone-refined dialog#modal:has(.action-preview-label)[open]{padding:6px 12px 6px!important}
 body.phone-refined #modal:has(.action-preview-label)>.close{top:3px!important;right:5px!important;width:36px!important;height:36px!important;min-height:36px!important}
 html[data-ui-runtime=web] body.phone-refined #modal:has(.action-preview-label) .action-preview-label{display:inline-block;max-width:none;font-size:9px!important;margin:0 6px 0 0}
 body.phone-refined #modal:has(.action-preview-label) h2{display:inline-block;font-size:16px!important;margin:0 0 2px!important;padding-right:44px}
 body.phone-refined #modal:has(.action-preview-label) .action-preview-main p{margin:2px 0!important;font-size:12px!important}
 body.phone-refined #modal:has(.action-preview-label) .access-choice{margin:3px 0!important;padding:2px 6px!important}
 body.phone-refined #modal:has(.action-preview-label) .access-choice legend{font-size:12px;padding:0 2px}
 body.phone-refined #modal:has(.action-preview-label) .access-choice label{padding:2px 4px!important;margin:0!important;font-size:12px;line-height:1.25;display:flex;align-items:center;gap:6px}
 body.phone-refined #modal:has(.action-preview-label) .access-choice input{width:18px;height:24px;margin:0}
 body.phone-refined #modal:has(.action-preview-label) .resource>div{padding:2px 8px!important}
 body.phone-refined #modal:has(.action-preview-label) .resource b{font-size:18px}
 body.phone-refined #modal:has(.action-preview-label) .notice{padding:3px 6px!important;margin:3px 0!important;font-size:11px!important;line-height:1.25}
 body.phone-refined #modal .action-cost-details summary{min-height:22px;padding:2px 0}
 body.phone-refined #modal .action-preview-scroll:has(.action-preview-main){gap:2px 12px}
 body.phone-refined #modal .action-preview-footer{padding-top:4px}
 body.phone-refined #modal .action-preview-footer button{min-height:36px!important;padding-block:4px!important}
}
@media (orientation:landscape) and (max-height:340px){
 body.phone-refined #modal:has(.action-preview-label) .access-choice label small{display:none}
 body.phone-refined #modal:has(.action-preview-label) .action-preview-scroll>p.muted,body.phone-refined #modal:has(.action-preview-label) .action-cost-details>small{display:none}
 body.phone-refined #modal:has(.action-preview-label) .player-line,body.phone-refined #modal:has(.action-preview-label) .action-preview-main>p:has(.company-name){margin:0!important}
 body.phone-refined #modal:has(.action-preview-label) .notice{margin:1px 0!important;padding:2px 6px!important}
 body.phone-refined #modal:has(.action-preview-label) .resource>div{padding:0 8px!important}
}
@media (orientation:portrait) and (max-height:620px){
 body.phone-refined #modal:has(.action-preview-label) .preview-scene{height:44px!important}
 body.phone-refined #modal:has(.action-preview-label) .preview-scene>*{max-height:44px!important}
}
@media (orientation:landscape) and (max-height:300px){
 /* Event effect line repeats what the cost breakdown already includes. */
 body.phone-refined #modal:has(.action-preview-label) .effect-notice{display:none}
 html[data-ui-runtime=web] body.faithful-target.phone-refined dialog#modal:has(.action-preview-label)[open]{padding:2px 12px 4px!important}
 body.phone-refined #modal:has(.action-preview-label) .access-choice{margin:0!important}
}
@media (orientation:portrait) and (max-height:620px){
 html[data-ui-runtime=web] body.faithful-target.phone-refined dialog#modal:has(.action-preview-label)[open]{padding-top:56px!important}
}
@media (orientation:landscape) and (max-height:520px){
 /* Keep the close button clear of the right-hand column. */
 body.phone-refined #modal:has(.action-preview-label) .action-preview-summary{padding-top:0}
 body.phone-refined #modal:has(.action-preview-label) .action-cost-details summary{margin-right:44px}
}
@media (orientation:landscape) and (max-height:520px){
 body.phone-refined #modal:has(.action-preview-label)>.close{width:32px!important;height:32px!important;min-height:32px!important;top:2px!important}
 body.phone-refined #modal .action-cost-details summary{min-height:32px;padding:0;display:flex;align-items:center}
}
@media (orientation:landscape) and (max-height:340px){
 body.phone-refined #modal .action-cost-details summary{min-height:38px}
 body.phone-refined #modal:has(.action-preview-label)>.close{width:30px!important;height:30px!important;min-height:30px!important}
}

/* ---- Slimmer planet bar, Actions button and bars (George, 22/11) ---- */
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .turn-strip{height:28px;min-height:0}
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .mobile-event-row{height:26px;min-height:0}
.phone-refined #phone-faithful .mobile-context{align-items:center}
.phone-refined #phone-faithful .mobile-context .detail-name{font-size:15px;min-height:28px!important;height:28px!important;line-height:28px;padding:0 4px;opacity:.92}
.phone-refined #phone-faithful .mobile-context .mobile-tasks{font-size:12px;min-height:28px!important;height:28px!important;line-height:1;padding:0 10px}
/* Company rings on planets: smaller everywhere (they were ~26px and crowded the planet). */
.phone-refined #phone-faithful .board .world>.world-discoverer{transform:translateX(-50%) scale(.72);transform-origin:50% 0}

.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .footer .market-nav-label{font-size:10px;line-height:1}
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .footer{height:42px}
.phone-refined #phone-faithful .mini.dense:not([data-refined-orientation=landscape]) .footer button{height:40px;min-height:40px}

/* Tabletop view: dialog body was capped (190px) and clipped; let the dialog use the available height like Cosmic. */
html body.phone-refined.faithful-target[data-board-background=tabletop] dialog#modal[open]{overflow-y:auto!important}
html body.phone-refined.faithful-target[data-board-background=tabletop] dialog#modal[open] #modalbody{max-height:none!important;overflow:visible!important}
.phone-refined #phone-faithful .footer .market-nav-label{white-space:nowrap}

/* Landscape: planet name + Actions sit on the same line as the four actions, same height and offsets,
   as a quiet card of the same family instead of a separate dark block (George, SS4). */
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector{align-self:stretch;height:auto!important;margin:0;padding:0;background:transparent!important;border:0!important;box-shadow:none!important}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector .mobile-context{height:calc(100% - 6px);min-height:0;margin:3px 3px 3px 5px;padding:0 6px;display:flex;align-items:center;justify-content:space-between;gap:6px;background:rgba(14,32,45,.72);border:1px solid rgba(165,135,78,.55);border-radius:6px;box-sizing:border-box}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector .detail-name{font-size:13px;opacity:.9;min-height:0!important;height:auto!important;line-height:1.2;padding:0 2px;background:none;border:0;max-width:60%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector .mobile-tasks{font-size:11.5px;min-height:28px!important;height:28px!important;padding:0 8px;border-radius:5px;flex:none}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector .mobile-context>:not(.detail-name):not(.mobile-tasks){display:none}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector{height:auto!important;max-height:none!important;min-height:0!important;box-sizing:border-box;align-self:stretch!important;margin-block:0!important}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector .mobile-context{width:calc(100% - 8px)!important;margin:3px 3px 3px 5px!important;height:calc(100% - 6px)!important;min-height:0!important}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector{position:relative!important;top:auto!important;inset-block:auto!important}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector{padding:0!important}
.phone-refined #phone-faithful .mini[data-refined-orientation=landscape] aside.inspector .detail-name{align-self:stretch;display:flex;align-items:center;min-height:28px!important;height:auto!important;flex:1 1 auto;text-align:left;justify-content:flex-start}
