:root {
	color-scheme: dark;
	--panel: rgba(6, 13, 25, 0.84);
	--line: rgba(126, 180, 230, 0.16);
	--text: #d6e7f5;
	--dim: #728ca6;
	--accent: #ffcf6e;
	--mint: #8ef0c0;
	--diff: #8ef0c0;
	--ice: #67e0ff;
	--warn: #ff9478;
	--ore: #ffb26b;
	--gas: #c58bff;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: #02060c;
	color: var(--text);
	font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	user-select: none;
}

#f,
#c,
#g {
	position: fixed;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
}

#f {
	z-index: 0;
	pointer-events: none;
}

#c {
	z-index: 1;
	cursor: crosshair;
	touch-action: none;
}

/* the cargo layer only draws; pointer input still reaches the trade canvas */
#g {
	z-index: 2;
	pointer-events: none;
}

.panel {
	position: fixed;
	z-index: 4;
	padding: 12px 15px 11px;
	border: 1px solid var(--line);
	border-radius: 14px;
	background: var(--panel);
	backdrop-filter: blur(10px);
}

.panelHead {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
	flex: none;
}

.headBtns {
	display: flex;
	gap: 5px;
	flex: none;
}

.roleTag {
	margin-top: 1px;
	color: var(--mint);
	font-size: 11px;
	letter-spacing: 0.01em;
}

#leftHud {
	position: fixed;
	top: 14px;
	left: 14px;
	z-index: 4;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: clamp(280px, 24vw, 350px);
	max-height: calc(100vh - 88px);
	max-height: var(--hudMaxH, calc(100dvh - 88px));
	overflow-y: auto;
	overflow-x: hidden;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: rgba(126, 180, 230, 0.28) transparent;
	pointer-events: auto;
}

#leftHud::-webkit-scrollbar {
	width: 6px;
}

#leftHud::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background: rgba(126, 180, 230, 0.28);
}

#leftHud > .panel {
	position: relative;
	top: auto;
	right: auto;
	bottom: auto;
	left: auto;
	flex: none;
	width: 100%;
	min-width: 0;
	pointer-events: auto;
}

#cargoHud {
	top: 14px;
	right: 14px;
	width: 294px;
	max-height: calc(100vh - 88px);
	max-height: var(--hudMaxH, calc(100dvh - 88px));
	display: flex;
	flex-direction: column;
	overflow: hidden;
	pointer-events: none;
}

/* only the content blocks catch the pointer, so the panel padding stays see-through */
#cargoHud > .panelHead,
#cargoBody,
#flightHud {
	pointer-events: auto;
}

#cargoBody {
	flex: 0 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding-right: 2px;
	scrollbar-width: thin;
	scrollbar-color: rgba(126, 180, 230, 0.28) transparent;
}

#cargoBody::-webkit-scrollbar {
	width: 6px;
}

#cargoBody::-webkit-scrollbar-thumb {
	border-radius: 3px;
	background: rgba(126, 180, 230, 0.28);
}

/* the flight hud: ship facts, the context action, the open work and the scans */
#flightHud {
	top: auto;
	right: 14px;
	bottom: calc(var(--footReserve, 64px) + var(--cheatReserve, 0px));
	left: auto;
	width: 294px;
	/* Leave room for the upper HUD on short screens; all actions still scroll. */
	max-height: max(160px, calc(100dvh - var(--footReserve, 64px) - var(--cheatReserve, 0px) - 212px));
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: rgba(126, 180, 230, 0.28) transparent;
	padding: 10px 15px 11px;
	pointer-events: auto;
}

/* the cheat panel: a dev strip docked under the flight hud; the hud stops
 * above it via --cheatReserve, which reserveGameFooter measures */
#cheatPanel {
	top: auto;
	right: 14px;
	bottom: var(--footReserve, 64px);
	left: auto;
	width: max-content;
	max-width: 294px;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 12px;
	font-size: 11px;
}

.cheatCb {
	display: flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
}

.cheatCb input {
	margin: 0;
}

#cargoHud > .panelHead {
	flex-wrap: wrap;
}

#cargoHud > .panelHead .headBtns {
	flex-wrap: wrap;
}

.runHint {
	margin: 5px 0 7px;
	color: var(--dim);
	font-size: 11px;
	line-height: 1.4;
}

/* H is a non-modal card next to the flight panel; answers are plain text so
 * the live numbers remain selectable and screen-reader visible. */
.commsButton {
	white-space: nowrap;
}

.commsButton.called {
	border-color: rgba(255, 207, 110, 0.72);
	background: rgba(255, 207, 110, 0.14);
	color: var(--accent);
}

.commsBadge {
	margin-left: 2px;
	color: var(--warn);
	font-weight: 800;
}

.commsTag {
	max-width: 74px;
	margin-left: 3px;
	overflow: hidden;
	text-overflow: ellipsis;
	vertical-align: bottom;
	white-space: nowrap;
	font-size: 10px;
}

.commsCall {
	top: 14px;
	right: 322px;
	width: min(380px, calc(100vw - 340px));
	z-index: 7;
	border-color: rgba(255, 207, 110, 0.72);
	background: rgba(28, 21, 12, 0.97);
	color: var(--accent);
}

.commsCall,
.commsCard {
	user-select: text;
}

.commsCall .actions {
	justify-content: flex-start;
	margin-top: 6px;
}

#commsCallReason {
	margin-top: 3px;
	color: var(--text);
}

.commsCard {
	left: auto;
	right: 322px;
	bottom: calc(var(--footReserve, 64px) + 8px);
	width: min(620px, calc(100vw - 340px));
	max-height: min(52vh, 460px);
	display: flex;
	flex-direction: column;
	gap: 8px;
	overflow-y: auto;
	z-index: 7;
	background: rgba(5, 12, 23, 0.96);
}

.commsStamp {
	color: var(--dim);
	font-size: 10px;
	font-variant-numeric: tabular-nums;
}

.commsTranscript {
	max-height: 160px;
	overflow-y: auto;
	white-space: pre-line;
	font-size: 12px;
}

.commsAnswer {
	padding: 8px;
	border-left: 2px solid var(--mint);
	background: rgba(142, 240, 192, 0.06);
	white-space: pre-line;
	font-size: 12px;
}

.commsChips,
.commsActions {
	justify-content: flex-start;
}

.commsCtas {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin-top: 6px;
}

.commsActRow {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
}

.commsWhy {
	color: var(--dim);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

.commsCard .panelHead {
	align-items: center;
}

.commsCard.collapsed #commsBody {
	display: none;
}

/* the first group sits right under the header; every later group keeps the
 * shared separator, and the scans close the panel */
#flightHud #flightShip {
	margin-top: 4px;
	padding-top: 0;
	border-top: 0;
}

/* ship facts: a compact two-column readout, the fuel gauge under it */
.flightFacts {
	margin-top: 2px;
}

.flightRefuel {
	margin-top: 5px;
	justify-content: flex-end;
}

#flightRefuel:not(:disabled) {
	border-color: rgba(142, 240, 192, 0.42);
	background: rgba(142, 240, 192, 0.1);
	color: var(--mint);
}

/* the open work: one row per planet the contract or the competition wants next */
.flightQuests {
	display: grid;
	gap: 2px;
}

.questRow {
	padding: 2px 4px;
	border-bottom: 0;
	border-radius: 4px;
	cursor: help;
}

.questRow.on {
	background: rgba(142, 240, 192, 0.12);
	box-shadow: inset 0 0 0 1px rgba(142, 240, 192, 0.24);
}

.questRow .careerKind {
	color: var(--mint);
}

#cargoHud.folded #cargoBody,
#scoreHud.folded .scoreRows,
#scoreHud.folded .statsStrip,
#careerHud.folded #careerBox,
#tradeHud.folded #tradeBody,
#gameHud.folded #gameBody {
	display: none;
}

#tradeHud.folded .clock,
#gameHud.folded .clock {
	margin-bottom: 0;
}

#careerBox {
	margin-top: 6px;
}

#careerPad .careerBtns .miniBtn {
	flex: 1 1 120px;
	min-width: 0;
	white-space: normal;
	text-align: left;
}

#scoreHud {
	padding: 10px 13px;
}

.scoreHead {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.scoreRuleTag {
	margin-top: 2px;
	color: var(--dim);
	font-size: 10px;
}

.scoreStanding {
	flex: none;
	padding: 2px 6px;
	border: 1px solid var(--line);
	border-radius: 999px;
	color: var(--dim);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.08em;
}

.scoreStanding b {
	font: inherit;
	color: inherit;
}

.scoreRows {
	display: grid;
	gap: 4px;
	margin-top: 8px;
	max-height: min(55vh, 620px);
	overflow-y: auto;
}

.playerCountRow {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-top: 6px;
	padding: 3px 6px;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: rgba(126, 180, 230, 0.035);
	color: var(--dim);
	font-size: 11px;
}

.playerCountRow .miniBtn {
	flex: none;
	min-width: 20px;
	padding: 1px 5px;
	text-align: center;
}

.playerCountLabel {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.playerCountLabel b {
	color: var(--text);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-variant-numeric: tabular-nums;
}

.planetRow {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 6px;
	padding: 3px 6px;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: rgba(126, 180, 230, 0.035);
	color: var(--dim);
	font-size: 11px;
}

.planetRow .planetPadsLabel,
.planetRow .planetPlanetsLabel {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.planetRow .planetPadsLabel b,
.planetRow .planetPlanetsLabel {
	color: var(--text);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-variant-numeric: tabular-nums;
}

.planetRowSep {
	color: var(--dim);
}

/* 0.7.47 WS3: a roster that no fair opening can seat highlights its counters
 * amber so the fix (fewer companies, or more planets) reads at a glance. The
 * counters stay editable: the class is a signal, not a lock. */
.playerCountRow.rosterUnfair,
.planetRow.rosterUnfair {
	border-color: var(--warn);
	background: rgba(255, 148, 120, 0.10);
	color: var(--warn);
}

.playerCountRow.rosterUnfair .playerCountLabel b,
.planetRow.rosterUnfair .planetPadsLabel b,
.planetRow.rosterUnfair .planetPlanetsLabel {
	color: var(--warn);
}

.scoreEntry {
	display: grid;
	grid-template-columns: 42px minmax(0, 1fr);
	grid-template-rows: auto auto;
	align-items: center;
	gap: 0 8px;
	padding: 4px 6px 4px 8px;
	border: 1px solid transparent;
	border-left: 3px solid;
	border-radius: 4px;
	background: rgba(126, 180, 230, 0.035);
	pointer-events: auto;
}

.scoreEntry.isUser {
	cursor: pointer;
}

.scoreEntry.isUser:hover {
	background-color: rgba(126, 180, 230, 0.09);
}

.scoreEntry.isActive {
	background-color: rgba(142, 240, 192, 0.09);
	border-color: rgba(142, 240, 192, 0.28);
	border-left-color: var(--mint);
}

.scoreRival.isActive {
	background-color: var(--rival-active-bg);
	border-color: var(--rival-active-border);
	border-left-color: var(--rival-colour);
}

/* a human whose pause holds the shared clock. Colour and border already say
 * who and selected (and some rivals are amber), so the hold gets a channel of
 * its own: a hatch, still because a held clock freezes every animation, plus
 * the pause bars sharing the value's cell, where its line ends free */
.scoreEntry.isPaused {
	background-image: repeating-linear-gradient(-45deg,
		rgba(255, 207, 110, 0.13) 0 3px, transparent 3px 8px);
}

.scoreEntry.isPaused::after {
	content: "";
	grid-area: 1 / 2;
	justify-self: end;
	width: 2px;
	height: 9px;
	border: solid var(--accent);
	border-width: 0 3px;
}

.scoreEntry:focus-visible {
	outline: 1px solid rgba(142, 240, 192, 0.5);
	outline-offset: 1px;
}

.scoreName {
	grid-row: 1 / 3;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
}

.scoreActorName {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 3px;
}

.scoreEntry.isActive .scoreActorName > span:first-child::before {
	content: "▸ ";
	letter-spacing: 0;
}

.scoreValue {
	grid-area: 1 / 2;
	min-width: 0;
	font: 700 12px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.scoreMeta {
	grid-area: 2 / 2;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--dim);
	font-size: 9.5px;
	line-height: 1.35;
}

.scorePlayer {
	border-left-color: var(--mint);
}

.scorePlayer .scoreName,
.scorePlayer .scoreValue {
	color: var(--mint);
}

.scoreBotToggle {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	color: var(--dim);
	font-size: 9px;
	font-weight: 500;
	letter-spacing: 0;
	cursor: pointer;
}

.scoreBotToggle:hover {
	color: var(--text);
}

.scoreBotToggle input {
	width: 11px;
	height: 11px;
	margin: 0;
	accent-color: var(--mint);
	pointer-events: auto;
	cursor: pointer;
}

.scoreRival {
	border-left-color: var(--rival-colour);
}

.scoreRival .scoreName,
.scoreRival .scoreValue {
	color: var(--rival-colour);
}

.scoreRival .scoreBotToggle input {
	accent-color: var(--rival-colour);
}

/* the bought ships under the YOU row (0.7.45): compact, player-coloured,
 * selectable for inspection; the flagship stays the hand-flown ship */
.scoreFleetRows {
	display: grid;
	gap: 2px;
}

.scoreFleet {
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-rows: auto auto;
	align-items: center;
	padding: 2px 6px 2px 12px;
	border-left-color: var(--mint);
	background: rgba(126, 180, 230, 0.02);
}

.scoreFleet .scoreFleetName {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--mint);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
}

.scoreFleet .scoreValue {
	grid-area: auto;
	font-size: 10px;
	color: var(--mint);
}

.scoreFleet .scoreMeta {
	grid-column: 1 / -1;
	grid-row: 2;
	text-align: right;
}

/* career map statistics: six small plots under the score rows, closed by
 * default; the captions carry the latest values so the strip reads as a
 * table too, and the income/running splits sit in the profit caption's
 * tooltip */
.statsStrip {
	margin-top: 6px;
	padding: 3px 6px 5px;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: rgba(126, 180, 230, 0.035);
}

.statsSummary {
	color: var(--dim);
	font-size: 10px;
	letter-spacing: 0.06em;
	cursor: pointer;
}

.statsSummary:hover {
	color: var(--text);
}

.statsPlots {
	display: grid;
	gap: 6px;
	margin-top: 5px;
}

.statsCaption {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--dim);
	font-size: 9.5px;
	line-height: 1.4;
}

.statsCaption b {
	color: var(--text);
	font-weight: 700;
}

.statsSvg {
	display: block;
	width: 100%;
	height: auto;
	min-width: 0;
	border-radius: 4px;
	background: rgba(2, 8, 16, 0.5);
}

.statsFrame {
	fill: none;
	stroke: rgba(126, 180, 230, 0.26);
	stroke-width: 0.7;
	pointer-events: none;
}

.statsZero {
	stroke: rgba(126, 180, 230, 0.3);
	stroke-width: 0.6;
	stroke-dasharray: 2.4 2.2;
	pointer-events: none;
}

.statsLine {
	fill: none;
	stroke-width: 1.1;
	stroke-linejoin: round;
	pointer-events: none;
}

.drawer {
	top: 14px;
	right: 320px;
	width: 318px;
	max-height: calc(100vh - 84px);
	overflow-y: auto;
	z-index: 6;
	background: rgba(5, 12, 23, 0.94);
	opacity: 0;
	pointer-events: none;
	transform: translateX(14px);
	transition: opacity 0.16s ease, transform 0.16s ease;
}

.drawer.open {
	opacity: 1;
	pointer-events: auto;
	transform: translateX(0);
}

.helpRuleName {
	margin-top: 2px;
	color: var(--text);
	font-size: 15px;
	font-weight: 700;
}

.helpSectionTitle {
	margin: 14px 0 0;
	padding-top: 8px;
	border-top: 1px solid var(--line);
	color: var(--accent);
	font-size: 10px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

.ruleHelp {
	display: grid;
	gap: 9px;
	margin: 4px 0 0;
}

.ruleHelp div {
	padding-top: 6px;
}

.ruleHelp dt {
	color: var(--accent);
	font-size: 9.5px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.ruleHelp dd {
	margin: 3px 0 0;
	color: var(--text);
	font-size: 12.5px;
	line-height: 1.45;
}

.helpControls {
	margin: 6px 0 0;
	color: var(--dim);
	font-size: 11px;
	line-height: 1.45;
}

.kicker {
	color: var(--accent);
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

#tradeHud .kicker {
	color: var(--dim);
}

.clock {
	margin: 2px 0 8px;
	color: #f3f8fd;
	font: 600 19px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace;
	font-variant-numeric: tabular-nums;
}

#cargoHud .clock {
	color: var(--accent);
}

.stats {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1px;
}

.stat {
	display: flex;
	justify-content: space-between;
	gap: 6px;
	min-width: 0;
	color: var(--dim);
	font-size: 12px;
	white-space: nowrap;
}

.stat span {
	flex: none;
}

.stat b {
	min-width: 0;
	overflow: hidden;
	color: var(--text);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	text-align: right;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#aimReadout {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-align: right;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#aimReadout.profitable,
#predVisitReadout.profitable,
#predProfitReadout.profitable {
	color: var(--mint);
}

#aimReadout.neutral,
#predVisitReadout.neutral,
#predProfitReadout.neutral {
	color: var(--text);
}

#aimReadout.unlaunchable,
#predVisitReadout.unlaunchable,
#predProfitReadout.unlaunchable {
	color: var(--warn);
}

.stat.goalStat b {
	color: var(--mint);
}

#planetCountInput {
	flex: 1 1 4.5em;
	min-width: 0;
	width: 4.5em;
	padding: 1px 4px;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: var(--panel);
	color: var(--mint);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: inherit;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	text-align: right;
}

#gamePurse.loss,
#rivalReadout.loss {
	color: var(--warn);
}

#gamePurse.gain,
#rivalReadout.gain {
	color: var(--mint);
}

#predVisitReadout {
	color: var(--accent);
}

#tradeLegend {
	display: flex;
	gap: 12px;
	margin-top: 9px;
	padding-top: 9px;
	border-top: 1px solid var(--line);
}

.good {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	color: var(--dim);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 11px;
}

.good::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 2px;
	background: currentColor;
}

.good.ice {
	color: var(--ice);
}

.good.ore {
	color: var(--ore);
}

.good.gas {
	color: var(--gas);
}

.group {
	margin-top: 9px;
	padding-top: 8px;
	border-top: 1px solid var(--line);
}

.caption {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 5px;
	color: var(--dim);
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.caption span:last-child {
	max-width: 155px;
	overflow: hidden;
	color: var(--text);
	text-align: right;
	text-overflow: ellipsis;
	text-transform: none;
	letter-spacing: 0;
}

.ctl {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--dim);
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.ctl input[type="range"] {
	flex: 1;
	min-width: 0;
	accent-color: var(--accent);
}

#cargoHud .ctl input[type="range"] {
	width: 140px;
	flex: none;
}

.wearCtl span {
	white-space: nowrap;
}

#cargoHud .wearCtl input[type="range"] {
	width: auto;
	flex: 1 1 0;
}

.ctl output {
	min-width: 38px;
	color: var(--accent);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	text-align: center;
	letter-spacing: 0;
	text-transform: none;
}

.ctl input[type="checkbox"] {
	margin: 0;
	accent-color: var(--accent);
}

.soundSettings summary,
.backgroundSettings summary {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--dim);
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
	list-style: none;
}

.soundSettings summary::-webkit-details-marker,
.backgroundSettings summary::-webkit-details-marker {
	display: none;
}

.soundSettings summary::after,
.backgroundSettings summary::after {
	content: '+';
	color: var(--accent);
	font-size: 12px;
}

.soundSettings[open] summary::after,
.backgroundSettings[open] summary::after {
	content: '−';
}

.soundSettings summary span:nth-child(2),
.backgroundSettings summary span:nth-child(2) {
	flex: 1;
	overflow: hidden;
	color: var(--text);
	text-align: right;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-transform: none;
	letter-spacing: 0;
}

.soundSettings[open] summary,
.backgroundSettings[open] summary {
	margin-bottom: 6px;
}

.backgroundControls {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 8px;
}

.backgroundControls > * {
	min-width: 0;
}

.backgroundTimeControls {
	display: flex;
	align-items: center;
	gap: 8px;
}

.backgroundTimeControls .ctl {
	flex: 1;
	min-width: 0;
}

#cargoHud .backgroundTimeControls .ctl input[type="range"] {
	width: auto;
	min-width: 0;
	flex: 1;
}

#tradePause {
	flex: none;
	min-width: 58px;
}

.settingsHint {
	margin: 0;
	color: var(--dim);
	font-size: 10px;
	line-height: 1.4;
}

.backgroundOptions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 5px 10px;
	padding-top: 8px;
	border-top: 1px solid var(--line);
}

.backgroundOptions label {
	display: flex;
	align-items: center;
	gap: 5px;
	color: var(--dim);
	font-size: 11px;
	cursor: pointer;
}

.backgroundOptions input {
	margin: 0;
	accent-color: var(--accent);
}

.tradeViewRow {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-top: 6px;
	color: var(--dim);
	font-size: 11px;
}

.tradeViewRow label {
	display: flex;
	align-items: center;
	gap: 4px;
	cursor: pointer;
}

.tradeViewRow input {
	margin: 0;
	accent-color: var(--accent);
}

.tradeViewRow label.unavailable {
	opacity: 0.45;
	cursor: not-allowed;
}

.soundCtl {
	margin-top: 6px;
}

.soundCtl select {
	flex: 1;
	min-width: 0;
	padding: 3px 5px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: rgba(2, 8, 16, 0.7);
	color: var(--text);
	font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
}

#cargoHud .soundCtl input[type="range"] {
	flex: 1;
	width: auto;
}

/* start gifts (0.7.48): three budget sliders and the preview line */
.giftBlock {
	margin-top: 7px;
	padding-top: 6px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.giftHead {
	display: flex;
	justify-content: space-between;
	margin-bottom: 3px;
	color: var(--dim);
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.giftHead label {
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
}

.giftBlock .ctl span {
	white-space: nowrap;
	min-width: 58px;
}

#cargoHud .giftBlock .ctl input[type="range"] {
	width: auto;
	flex: 1 1 0;
}

.giftPreview {
	margin-top: 3px;
	color: var(--dim);
	font-size: 10px;
	line-height: 1.45;
}

.soundHint {
	margin: 7px 0 0;
	color: var(--dim);
	font-size: 10px;
	line-height: 1.45;
}

.radioRow {
	display: flex;
	gap: 14px;
}

.rivalRadios {
	gap: 10px;
	flex-wrap: wrap;
}

.radioRow label,
.viewCheck {
	display: flex;
	align-items: center;
	gap: 5px;
	color: var(--dim);
	font-size: 12px;
	cursor: pointer;
}

.viewCheck {
	margin-top: 6px;
}

body.periodicWorld #viewFullLabel {
	display: none;
}

/* one view line over the canvas: the three backdrops, the full view switch and
 * the clean render toggle, so the picture is switched over the picture; the
 * legend hangs under it only while potential is the visible backdrop */
.viewBar {
	position: fixed;
	top: 10px;
	left: 50%;
	z-index: 4;
	display: flex;
	align-items: center;
	gap: 6px 12px;
	max-width: min(760px, calc(100vw - 700px));
	padding: 5px 10px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--panel);
	backdrop-filter: blur(10px);
	transform: translateX(-50%);
	flex-wrap: wrap;
	justify-content: center;
	pointer-events: auto;
}

.viewBar .radioRow,
.viewBar .viewCheck {
	flex: none;
	margin: 0;
	white-space: nowrap;
}

.viewBar .radioRow {
	flex-wrap: wrap;
	gap: 4px 10px;
}

.viewBarTag {
	color: var(--dim);
	font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
	white-space: nowrap;
}

.viewBar .potentialLegend {
	flex: 1 1 100%;
	order: 9;
	margin-top: 0;
}

.potentialLegend {
	font: 10.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* the page shows through where the map is clear, so the track is the page colour;
 * the gradient is painted at boot from the field's own palette */
.zoneBar {
	height: 10px;
	border: 1px solid var(--line);
	border-radius: 5px;
	background-color: #02060c;
}

.zoneTicks {
	position: relative;
	height: 15px;
	margin-top: 2px;
	color: var(--dim);
}

/* --lo and --hi (the planet gravity range) are set at boot with the gradient */
.zoneTicks span {
	position: absolute;
	left: calc((var(--z) - var(--lo)) / (var(--hi) - var(--lo)) * 100%);
	transform: translateX(-50%);
}

.zoneTicks span:first-child {
	transform: none;
}

.zoneTicks span:last-child {
	transform: translateX(-100%);
}

.zoneWords {
	display: flex;
	flex-wrap: wrap;
	gap: 2px 12px;
}

.potentialNegative {
	color: #57a8ff;
}

.potentialPositive {
	color: #5cff8b;
}

.potentialHeavy {
	color: #ff5f57;
}

.radioRow label:has(input:checked),
.viewCheck:has(input:checked) {
	color: var(--text);
}

.radioRow input,
.viewCheck input {
	margin: 0;
	accent-color: var(--accent);
}

.actions {
	display: flex;
	gap: 8px;
	margin-top: 9px;
}

/* launch owns a full row, so its changing label cannot reflow clear / use best */
.flightActions {
	display: grid;
	grid-template-columns: 98px minmax(0, 1fr);
	gap: 6px 8px;
	margin-top: 0;
}

.flightActions button {
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#launchGroup,
#planetActions {
	grid-column: 1 / -1;
}

/* main action + caret; the menu drops under the row without reflowing it */
#launchGroup {
	position: relative;
	display: flex;
	gap: 2px;
	min-width: 0;
}

#launch {
	flex: 1 1 auto;
}

#launchMenuBtn {
	flex: 0 0 30px;
	padding-left: 0;
	padding-right: 0;
}

#launchMenu {
	position: absolute;
	top: 100%;
	right: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 60%;
	max-width: 100%;
	margin-top: 4px;
	padding: 6px;
	border: 1px solid rgba(255, 207, 110, 0.4);
	border-radius: 6px;
	background: #060d19;
}

#launch[value="evac"],
#launchEvac {
	white-space: normal;
}

/* the pad block: the build offer, and the landing setting that belongs to the
 * planet under the ship; both stay on the row above clear */
.planetActions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 10px;
	min-width: 0;
}

.planetActions button {
	flex: 1 1 45%;
	min-width: 0;
	padding: 5px 8px;
}

.planetActions .careerPauseLand {
	flex: 1 1 100%;
}

/* the launch menu is a small sheet: every entry the planet offers, one per row */
#launchMenu button {
	text-align: left;
	padding: 4px 8px;
	font-size: 11.5px;
}

#clear {
	grid-column: 1 / -1;
}

#flightHud.routeMode #clear {
	grid-column: 1;
}

#routeBest {
	grid-column: 2;
	border-color: rgba(126, 180, 230, 0.3);
	background: rgba(126, 180, 230, 0.05);
	color: var(--text);
}

#routeBest:disabled {
	opacity: 0.62;
	color: var(--dim);
}

#routeBest.bestReady:not(:disabled) {
	border-color: rgba(142, 240, 192, 0.52);
	background: rgba(142, 240, 192, 0.12);
	color: var(--mint);
}

#routeBest.bestReady.on:not(:disabled) {
	border-color: rgba(255, 207, 110, 0.62);
	background: rgba(255, 207, 110, 0.18);
	color: var(--accent);
}

button {
	padding: 5px 13px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: transparent;
	color: var(--dim);
	font: inherit;
	font-size: 12px;
	cursor: pointer;
}

button.miniBtn {
	padding: 2px 9px;
	font-size: 11px;
	flex: none;
}

/* the saved-map picker sits beside the load buttons and reads like one */
select.miniSelect {
	min-width: 0;
	max-width: 100%;
	padding: 2px 6px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: rgba(2, 8, 16, 0.7);
	color: var(--dim);
	font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
	cursor: pointer;
}

select.miniSelect:disabled {
	color: rgba(148, 163, 184, 0.5);
	cursor: default;
}

.presetRow {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 6px 0 6px;
}

.presetRow .presetSelect {
	flex: 1 1 0;
	color: var(--text);
}

button:hover:not(:disabled) {
	border-color: rgba(126, 180, 230, 0.42);
	color: var(--text);
}

button.on {
	border-color: rgba(255, 207, 110, 0.45);
	background: rgba(255, 207, 110, 0.14);
	color: var(--accent);
}

button.primary {
	border-color: rgba(255, 207, 110, 0.4);
	background: rgba(255, 207, 110, 0.12);
	color: var(--accent);
}

button.primary.exitWarning {
	border-color: rgba(255, 112, 102, 0.65);
	background: rgba(255, 92, 82, 0.2);
	color: #ff9b91;
}

button.primary.exitWarning:hover:not(:disabled) {
	border-color: #ff9b91;
	background: rgba(255, 92, 82, 0.3);
	color: #ffc0b9;
}

button:disabled,
input:disabled {
	opacity: 0.35;
	cursor: default;
}

/* the purse, not a state gate (HQ only, cargo too big, no catapult), is what
 * blocks this price: keep it readable and red instead of dim */
button.costly,
button.costly:disabled {
	border-color: rgba(255, 148, 120, 0.32);
	color: var(--warn);
	opacity: 1;
}

#runBox {
	margin-top: 7px;
}

#runBox .radioRow {
	margin-bottom: 7px;
}

/* the flat mode row replaces the old mode + rule groups: five labels wrap */
.modeRow {
	flex-wrap: wrap;
	gap: 6px 12px;
}

/* career drawer: upgrades / shots / science tabs, pad, shop and research lab */
.careerTabs {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 3px;
	margin: 2px 0 6px;
	padding: 2px;
	border: 1px solid var(--line);
	border-radius: 9px;
	background: rgba(2, 8, 16, 0.42);
}

.careerTab {
	min-width: 0;
	overflow: hidden;
	padding: 3px 5px;
	border-color: transparent;
	border-radius: 6px;
	font-size: 10px;
	letter-spacing: 0.06em;
	text-overflow: ellipsis;
	text-transform: uppercase;
}

.careerTab.on {
	border-color: rgba(255, 207, 110, 0.24);
	background: rgba(255, 207, 110, 0.12);
}

#careerUpgrades,
#careerShots,
#careerSciencePanel {
	min-width: 0;
}

.careerPick {
	justify-content: space-between;
	gap: 6px;
	margin-bottom: 5px;
}

.careerPick select {
	flex: 1;
	min-width: 0;
	padding: 2px 5px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: rgba(2, 8, 16, 0.7);
	color: var(--text);
	font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
	letter-spacing: 0;
	text-transform: none;
	cursor: pointer;
}

.careerBlock {
	font-size: 11px;
	line-height: 1.45;
}

.careerHead {
	margin-top: 6px;
	color: var(--dim);
	font-size: 9.5px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.careerLine {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.careerLine.dim {
	color: var(--dim);
}

.careerLine.warn {
	color: var(--warn);
}

.careerBar {
	height: 4px;
	margin: 2px 0 3px;
	border-radius: 2px;
	background: rgba(140, 170, 200, 0.2);
	overflow: hidden;
}

.careerBar i {
	display: block;
	height: 100%;
	background: var(--mint);
}

.careerRow {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px 7px;
	padding: 2px 0;
	border-bottom: 1px dotted rgba(126, 180, 230, 0.12);
}

.careerRow:last-child {
	border-bottom: 0;
}

.careerRow.dim {
	color: var(--dim);
}

.careerKind {
	min-width: 48px;
	color: var(--dim);
	font-size: 9.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.careerNow {
	flex: 1 1 96px;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 10.5px;
}

/* what the pad (or a row's fitted part) can fire as it is now; the before →
 * after change sits in a hidden span that reserves its width, so revealing it
 * on hover / eye-press never reflows the row */
.careerCap {
	max-width: 100%;
	min-width: 0;
	color: var(--dim);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 10px;
	white-space: nowrap;
}

/* the before → after change; hidden until hovered (fine pointer) or the row's
 * eye is pressed (touch / no cursor). visibility (not display) reserves the
 * width so the row does not shift when the delta appears */
.careerCap .capDelta {
	visibility: hidden;
	color: var(--diff);
}

@media (hover: hover) and (pointer: fine) {
	.careerRow:hover .careerCap .capDelta { visibility: visible; }
}

.careerRow.showCap .careerCap .capDelta { visibility: visible; }

/* compact eye that reveals a row's delta where there is no cursor */
.peekBtn {
	padding: 2px 6px;
	font-size: 11px;
	line-height: 1;
}

.careerBtns {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px;
	margin-left: auto;
}

.careerBtns i {
	color: var(--dim);
	font-style: normal;
	font-size: 10px;
}

/* why a saved shot cannot fire: its own line under the row, because a disabled
 * button does not show a tooltip */
.careerWhy {
	flex: 1 1 100%;
	padding-left: 55px;
	color: var(--warn);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 9.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* science: the fee surface is an inline SVG so file:// needs no library */
.sciFamilyRow {
	border-bottom: 0;
}

.sciFamilyRow .careerBtns {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 4px;
	width: 100%;
	margin-left: 0;
}

.sciAcceptRow .careerBtns {
	width: 100%;
	margin-left: 0;
}

.sciAcceptRow .miniBtn {
	flex: 1 1 0;
}

.sciPlotWrap {
	min-width: 0;
	margin: 2px 0 5px;
}

.sciPlot {
	display: block;
	width: 100%;
	height: auto;
	min-width: 0;
	border-radius: 6px;
	background: rgba(2, 8, 16, 0.5);
}

.sciPlotFrame {
	fill: none;
	stroke: rgba(126, 180, 230, 0.26);
	stroke-width: 0.7;
	pointer-events: none;
}

.sciRange {
	fill: none;
	stroke: rgba(154, 198, 228, 0.45);
	stroke-width: 0.75;
	stroke-dasharray: 2.6 2.4;
	pointer-events: none;
}

.sciRangeHard {
	fill: none;
	stroke: rgba(244, 158, 98, 0.92);
	stroke-width: 1.05;
	stroke-dasharray: 3.2 2.2;
	pointer-events: none;
}

.sciKnownHull {
	fill: rgba(142, 240, 192, 0.14);
	stroke: var(--mint);
	stroke-width: 1.15;
	stroke-linejoin: round;
	pointer-events: none;
}

polyline.sciKnownHull {
	fill: none;
}

.sciKnownPoint {
	fill: var(--text);
	stroke: #07101c;
	stroke-width: 0.8;
}

.sciDraft {
	fill: var(--accent);
	stroke: #fff4d6;
	stroke-width: 1.2;
	pointer-events: none;
}

.sciPlotTick,
.sciPlotLabel {
	fill: var(--dim);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 7px;
}

.sciPlotLabel {
	font-size: 7.5px;
}

.sciPlotLegend {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 1px 6px;
	margin-top: 2px;
	color: var(--dim);
	font-size: 8.5px;
	line-height: 1.35;
}

.sciPlotLegend span {
	white-space: nowrap;
}

.sciPlotLegend i {
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-right: 3px;
	border-radius: 2px;
	background: #164c42;
}

.sciPlotLegend i.sciRamp {
	width: 16px;
	background: linear-gradient(90deg, #11273e 0%, #1b526c 26%, #9e6834 56%, #cc4e2e 80%, #e63630 100%);
}

/* research sliders: fill the row, wrap before the drawer can overflow */
.careerRow.sciAxis {
	gap: 5px;
}

.careerRow.sciAxis input[type="range"] {
	flex: 1 1 64px;
	min-width: 48px;
	max-width: 100%;
	accent-color: var(--accent);
}

.sciVal {
	flex: none;
	min-width: 38px;
	color: var(--dim);
	text-align: right;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 10px;
}

.sciPreview,
.sciMetric {
	overflow: visible;
	white-space: normal;
	text-overflow: clip;
}

.sciPreview {
	margin-top: 3px;
	color: var(--text);
	font-size: 10px;
}

.sciMetric {
	font-size: 9px;
	line-height: 1.35;
}

.sciKnobsRow {
	gap: 4px 7px;
}

.sciKnobsRow .sciMetric {
	flex: 1 1 220px;
	min-width: 0;
}

.sciKnobsRow .miniBtn {
	margin-left: auto;
}

.sciHull {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.careerMsg {
	margin-top: 6px;
	color: var(--mint);
	font-size: 10.5px;
	line-height: 1.35;
}

.gameActions {
	flex-wrap: wrap;
	gap: 5px;
	margin-top: 7px;
}

.mapNote {
	margin-top: 6px;
	min-height: 13px;
	color: var(--mint);
	font-size: 10.5px;
	line-height: 1.35;
}

.replayImport {
	margin: 7px 0;
	color: var(--dim);
	font-size: 11px;
}

.replayImport summary {
	cursor: pointer;
	color: var(--mint);
}

.replayImport label {
	display: block;
	margin: 5px 0;
}

.replayText {
	width: 100%;
	max-height: 30vh;
	margin-top: 4px;
	padding: 5px 7px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: rgba(2, 8, 16, 0.7);
	color: var(--text);
	font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
	white-space: pre;
	overflow: auto;
	resize: vertical;
	user-select: text;
	pointer-events: auto;
}

.helperActions {
	flex-wrap: wrap;
	gap: 5px;
}

.helperActions .miniBtn {
	flex: 1 1 70px;
}

.helperProgress {
	display: flex;
	align-items: center;
	gap: 7px;
	margin-top: 7px;
}

.helperBar {
	flex: 1;
	height: 6px;
	border-radius: 999px;
	background: rgba(126, 180, 230, 0.16);
	overflow: hidden;
}

.helperBar div {
	height: 100%;
	width: 0%;
	background: var(--mint);
	transition: width 0.12s linear;
}

#helperProgressText {
	min-width: 72px;
	color: var(--dim);
	font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

#gameControls {
	position: fixed;
	right: auto;
	bottom: 14px;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	max-width: calc(100vw - 24px);
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--panel);
	backdrop-filter: blur(10px);
	transform: translateX(-50%);
	flex-wrap: wrap;
	z-index: 4;
}

/* career time and flight playback live in the game bar */
#careerWait,
#playbackGroup {
	flex: none;
}

.careerPauseLand {
	display: flex;
	align-items: center;
	gap: 4px;
	color: var(--dim);
	font-size: 11px;
	cursor: pointer;
	white-space: nowrap;
}

.careerPauseLand input {
	margin: 0;
	accent-color: var(--accent);
}

/* keep the bar still while the label runs wait · 30 min → waiting · 100 % */
#careerWait {
	min-width: 96px;
	text-align: center;
}

#playbackGroup {
	display: flex;
	align-items: center;
	gap: 4px;
	padding-left: 10px;
	border-left: 1px solid var(--line);
}

#playbackGroup .miniBtn {
	padding: 2px 7px;
	font-variant-numeric: tabular-nums;
}

.playbackLabel {
	color: var(--dim);
	font-size: 10px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	white-space: nowrap;
}

.playbackLabel b {
	color: var(--text);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	letter-spacing: 0;
}

#careerWaitInfo {
	flex: 1 1 100%;
	max-width: 100%;
	text-align: center;
	font-size: 10px;
}

@media (max-width: 1100px) {
	/* the view line keeps the gap between the two HUD columns, which is the
	 * only strip of canvas it can own; it wraps and drops the tag first */
	.viewBar {
		max-width: max(190px, calc(100vw - 620px));
		gap: 4px 9px;
	}

	.viewBarTag {
		display: none;
	}
}

@media (max-width: 960px) {
	/* keep help beside—never over—the rule radios it explains */
	.drawer {
		left: 14px;
		right: auto;
		width: min(318px, calc(100vw - 336px));
	}

	.viewBar {
		padding: 4px 8px;
	}

	.viewBar .radioRow,
	.viewBar .viewCheck {
		font-size: 11px;
		gap: 4px;
	}

	/* keep the game bar compact on tablet widths */
	#gameControls {
		gap: 8px;
	}

	#careerPauseLandLabel {
		font-size: 10px;
	}

	#careerWait {
		min-width: 84px;
	}
}

@media (max-width: 820px) {
	#leftHud {
		top: 8px;
		left: 8px;
		width: 248px;
		gap: 6px;
	}

	#leftHud > .panel {
		padding: 9px 10px;
	}

	.scoreRuleTag {
		font-size: 8.5px;
	}

	.scoreStanding {
		padding: 2px 5px;
		font-size: 8px;
	}

	.scoreRows {
		gap: 3px;
		margin-top: 6px;
	}

	.scoreEntry {
		grid-template-columns: 36px minmax(0, 1fr);
		gap: 0 5px;
		padding: 3px 4px 3px 6px;
	}

	.scoreBotToggle {
		font-size: 8px;
	}

	.scoreValue {
		font-size: 9.5px;
	}

	.scoreMeta {
		font-size: 8px;
	}

	#tradeHud {
		padding: 9px 11px;
	}

	#tradeHud .clock {
		font-size: 15px;
	}

	#cargoHud {
		top: 8px;
		right: 8px;
		width: 248px;
		padding: 10px 12px;
	}

	#flightHud {
		right: 8px;
		bottom: var(--footReserve, 60px);
		width: 248px;
		padding: 9px 12px 10px;
	}

	/* the cheat strip has no room beside the full-width footer bar */
	#cheatPanel {
		display: none;
	}

	.planetActions button {
		padding: 5px 6px;
		font-size: 11px;
	}

	.drawer {
		top: 8px;
		left: 8px;
		right: auto;
		width: min(312px, calc(100vw - 272px));
	}

	#cargoHud .clock {
		font-size: 17px;
	}

	#cargoHud .ctl input[type="range"] {
		width: 104px;
	}

	#gameControls {
		right: 8px;
		bottom: 8px;
		left: 8px;
		max-width: none;
		padding: 8px;
		transform: none;
		justify-content: space-between;
		gap: 5px 8px;
	}

	#playbackGroup {
		padding-left: 0;
		border-left: 0;
	}

	#careerWaitInfo {
		font-size: 9px;
		white-space: normal;
	}


	#flightHud.routeMode .flightActions {
		grid-template-columns: auto minmax(0, 1fr);
		gap: 5px;
	}

	#flightHud.routeMode #clear {
		padding: 6px 8px;
		font-size: 11px;
	}

	#routeBest {
		padding: 6px 7px;
		font-size: 11px;
	}
}

@media (max-width: 599px) {
	#leftHud {
		width: 158px;
	}

	/* the two HUD columns leave no strip for the view line, so it docks at the
	 * left edge under them: the canvas keeps its own left strip */
	.viewBar {
		top: auto;
		left: 8px;
		bottom: calc(var(--footReserve, 60px) + 8px);
		max-width: calc(100vw - 16px);
		padding: 4px 8px;
		transform: none;
		justify-content: flex-start;
	}

	.viewBar .radioRow,
	.viewBar .viewCheck {
		font-size: 10px;
		gap: 3px;
	}

	.careerTab,
	.sciFamilyRow .miniBtn {
		padding: 3px 3px;
		font-size: 9px;
		letter-spacing: 0.02em;
	}
}

@media (max-width: 460px) {
	#leftHud {
		width: clamp(144px, 38vw, 158px);
	}

	#cargoHud,
	#flightHud {
		width: min(248px, calc(100vw - clamp(144px, 38vw, 158px) - 24px));
	}

	#cargoHud > .panelHead {
		flex-direction: column;
		align-items: stretch;
	}

	#cargoHud > .panelHead .headBtns {
		justify-content: flex-end;
	}

	#cargoHud > .panelHead .miniBtn {
		padding: 2px 5px;
		font-size: 10px;
	}

	#cargoHud .ctl input[type="range"] {
		width: auto;
		flex: 1 1 0;
	}

	/* top-mounted on narrow phones so the bottom launch / use best row stays visible */
	.drawer {
		top: 8px;
		right: 8px;
		bottom: auto;
		left: 8px;
		width: auto;
		max-height: 52vh;
	}
}

@media (max-width: 360px) {
	#flightHud.routeMode .flightActions {
		grid-template-columns: 1fr;
	}

	#flightHud.routeMode #routeBest {
		grid-column: 1;
	}

	#cargoHud .wearCtl {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
	}

	#cargoHud .wearCtl span {
		grid-column: 1 / -1;
	}

	#cargoHud .wearCtl input[type="range"] {
		width: 100%;
	}
}

/* postcard popup: bottom-left, above the game footer, aspect kept */
.photoCard {
	position: fixed;
	left: 14px;
	bottom: var(--footReserve, 64px);
	z-index: 5;
	width: min(340px, calc(100vw - 28px));
	max-height: min(52vh, 430px);
	overflow: hidden;
	border: 1px solid rgba(126, 180, 230, 0.24);
	border-radius: 12px;
	background: rgba(5, 12, 23, 0.94);
	box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
}

.photoCard img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: min(34vh, 300px);
	margin: 0 auto;
	background: #030a14;
}

.photoCard.compact {
	width: 256px;
	z-index: 9;
}

.photoCard.compact .photoCaption {
	display: none;
}

.photoBody {
	padding: 7px 11px 9px;
	background: linear-gradient(180deg, rgba(6, 13, 25, 0.5), rgba(6, 13, 25, 0.94));
}

.photoKicker {
	color: var(--dim);
	font-size: 9px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.photoTitle {
	margin-top: 1px;
	color: var(--accent);
	font-size: 12.5px;
	font-weight: 600;
}

.photoCaption {
	margin-top: 2px;
	color: var(--dim);
	font-size: 11px;
	line-height: 1.35;
}

.photoClose {
	position: absolute;
	top: 5px;
	right: 5px;
	z-index: 2;
	width: 22px;
	height: 22px;
	padding: 0;
	border-color: rgba(126, 180, 230, 0.24);
	border-radius: 50%;
	background: rgba(3, 8, 16, 0.66);
	color: var(--text);
	font-size: 13px;
	line-height: 1;
}

/* fallback postcard painted in CSS until real art exists */
.photoArt {
	position: relative;
	width: 100%;
	height: 210px;
	overflow: hidden;
	background: radial-gradient(130% 90% at 72% 12%, #16263d 0%, #050a14 68%);
}

.photoArt::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 55%;
	width: 116px;
	height: 116px;
	margin: -58px 0 0 -58px;
	border-radius: 50%;
	background: radial-gradient(circle at 34% 30%, #b9c4cd, #5c6a76 55%, #222b34 100%);
	box-shadow: inset -16px -10px 26px rgba(0, 0, 0, 0.55), 0 0 34px rgba(126, 180, 230, 0.12);
}

.photoArt::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		radial-gradient(1.5px 1.5px at 18% 28%, rgba(255, 255, 255, 0.7), transparent),
		radial-gradient(1.2px 1.2px at 76% 18%, rgba(255, 255, 255, 0.55), transparent),
		radial-gradient(1.4px 1.4px at 88% 62%, rgba(255, 255, 255, 0.45), transparent),
		radial-gradient(1px 1px at 32% 76%, rgba(255, 255, 255, 0.5), transparent),
		radial-gradient(1px 1px at 60% 40%, rgba(255, 255, 255, 0.35), transparent);
	pointer-events: none;
}

.photoArt.terran::before {
	background: radial-gradient(circle at 32% 28%, #9fe3ff 0%, #2f7fb8 38%, #1e5b3f 65%, #0a2030 100%);
	width: 124px;
	height: 124px;
	margin: -62px 0 0 -62px;
}

.photoArt.super::before {
	background: radial-gradient(circle at 36% 30%, #b6f4e4 0%, #4c7f8c 42%, #223238 75%, #0b1418 100%);
	width: 138px;
	height: 138px;
	margin: -69px 0 0 -69px;
}

.photoArt.dwarf::before {
	background: radial-gradient(circle at 30% 26%, #efe6d2, #9a8f7a 52%, #3a352c 100%);
	width: 74px;
	height: 74px;
	margin: -37px 0 0 -37px;
	box-shadow: 0 0 70px 24px rgba(255, 214, 150, 0.22);
}

.photoArt.mini::before {
	background: radial-gradient(circle at 34% 30%, #ffd9c2, #b77b62 58%, #4a2f26 100%);
	width: 56px;
	height: 56px;
	margin: -28px 0 0 -28px;
}

.photoArt.gas::before {
	background:
		repeating-linear-gradient(8deg, #d9b27f 0 9px, #a9794f 9px 17px, #e6cda3 17px 26px, #8a5f3d 26px 33px),
		radial-gradient(circle at 34% 30%, #f6e1bd, #a9794f 60%, #3a2415 100%);
	width: 156px;
	height: 156px;
	margin: -78px 0 0 -78px;
	box-shadow: inset -20px -12px 34px rgba(0, 0, 0, 0.6);
}

.photoArt.ice::before {
	background: radial-gradient(circle at 34% 30%, #dff8ff, #7fb9cc 46%, #2b5666 78%, #0c1e26 100%);
	width: 118px;
	height: 118px;
	margin: -59px 0 0 -59px;
	box-shadow: 0 0 42px rgba(140, 220, 255, 0.28), inset -14px -10px 26px rgba(0, 0, 0, 0.5);
}

/* ring for the ice giant, painted behind the disc is not possible with one
   pseudo-element; the flat ellipse reads as a ring across the disc */
.photoArt.ice {
	background:
		radial-gradient(ellipse 190px 34px at 50% 57%, transparent 58%, rgba(220, 245, 255, 0.55) 60%, transparent 66%),
		radial-gradient(130% 90% at 72% 12%, #132a3a 0%, #050a14 68%);
}

.photoArt.rock {
	background:
		radial-gradient(circle at 46% 62%, rgba(255, 255, 255, 0.05), transparent 55%),
		radial-gradient(130% 90% at 72% 12%, #1b2230 0%, #05080e 70%);
}

/* a landed card puts the same world on the horizon: big disc low, dark ground */
.photoArt.landed::before {
	top: 96%;
	width: 440px;
	height: 440px;
	margin: -220px 0 0 -220px;
}

.photoArt.landed::after {
	background:
		linear-gradient(180deg, transparent 63%, rgba(3, 8, 16, 0.88) 63%),
		radial-gradient(1.5px 1.5px at 18% 28%, rgba(255, 255, 255, 0.7), transparent),
		radial-gradient(1.2px 1.2px at 76% 18%, rgba(255, 255, 255, 0.55), transparent),
		radial-gradient(1.4px 1.4px at 88% 52%, rgba(255, 255, 255, 0.45), transparent),
		radial-gradient(1px 1px at 32% 46%, rgba(255, 255, 255, 0.5), transparent);
}

.photoArt.rock::before {
	background: radial-gradient(circle at 34% 30%, #b9b0a4, #6d655b 52%, #26221d 100%);
}

@media (max-width: 820px) {
	.photoCard {
		left: 8px;
		bottom: var(--footReserve, 60px);
	}
}

/* landed variants: the world's colour decides the ground */
.photoArt.landed.terran {
	background: linear-gradient(180deg, #1b2f48 0%, #4f7fa3 38%, #2f5b3c 63%, #12241a 100%);
}

.photoArt.landed.terran::before {
	box-shadow: inset -18px -12px 28px rgba(0, 0, 0, 0.5), 0 0 46px rgba(120, 200, 255, 0.22);
}

.photoArt.landed.gas {
	background: linear-gradient(180deg, #2b1a0e 0%, #8a5f3d 34%, #d9b27f 58%, #a9794f 100%);
}

.photoArt.landed.gas::before {
	display: none;
}

.photoArt.landed.gas::after {
	background:
		radial-gradient(ellipse 240px 60px at 50% 66%, rgba(255, 232, 190, 0.5), transparent 68%),
		linear-gradient(180deg, transparent 63%, rgba(43, 26, 14, 0.55) 63%),
		radial-gradient(1.4px 1.4px at 22% 24%, rgba(255, 240, 210, 0.6), transparent),
		radial-gradient(1.2px 1.2px at 78% 20%, rgba(255, 240, 210, 0.5), transparent);
}

.photoArt.landed.ice {
	background: linear-gradient(180deg, #05101a 0%, #0f3a48 40%, #7fb9cc 58%, #16323c 100%);
}

.photoArt.landed.ice::after {
	background:
		radial-gradient(ellipse 200px 26px at 50% 74%, rgba(180, 255, 220, 0.22), transparent 70%),
		linear-gradient(180deg, rgba(120, 255, 190, 0.16) 0%, transparent 42%),
		linear-gradient(180deg, transparent 63%, rgba(4, 14, 20, 0.5) 63%);
}

/* career scenes use the same postcard slot, with CSS stand-ins until art exists */
.photoArt.career {
	background: radial-gradient(110% 100% at 70% 15%, #182b3d 0%, #050b14 72%);
}

.photoArt.career.catapult::before {
	left: 8%;
	top: 72%;
	width: 88%;
	height: 9px;
	margin: 0;
	border-radius: 5px;
	background: linear-gradient(180deg, #8ef0c0, #245f59 45%, #10252c 50%, #071018);
	box-shadow: 0 0 18px rgba(103, 224, 255, 0.4);
	transform: rotate(-13deg);
}

.photoArt.career.catapult::after {
	background:
		radial-gradient(ellipse 24px 8px at 68% 38%, #d6e7f5 0 35%, #415a70 42%, transparent 70%),
		radial-gradient(1.5px 1.5px at 18% 28%, rgba(255, 255, 255, 0.7), transparent),
		radial-gradient(1.2px 1.2px at 76% 18%, rgba(255, 255, 255, 0.55), transparent),
		linear-gradient(165deg, transparent 58%, rgba(103, 224, 255, 0.14) 59%, transparent 62%);
}

.photoArt.career.delivery {
	background: linear-gradient(180deg, #172c42 0%, #395a68 54%, #181f25 55%, #080d13 100%);
}

.photoArt.career.delivery::before {
	left: 50%;
	top: 62%;
	width: 94px;
	height: 62px;
	margin: -31px 0 0 -47px;
	border-radius: 16px 16px 5px 5px;
	background: linear-gradient(135deg, #d6e7f5, #64788a 58%, #263746);
	box-shadow: -26px 52px 0 -23px #64788a, 26px 52px 0 -23px #64788a;
}

.photoArt.career.delivery::after {
	background:
		linear-gradient(180deg, transparent 70%, rgba(3, 8, 16, 0.78) 70%),
		repeating-linear-gradient(90deg, transparent 0 16px, rgba(255, 207, 110, 0.24) 16px 27px, transparent 27px 37px);
}

.photoArt.career.sport::before {
	left: 50%;
	top: 61%;
	width: 238px;
	height: 142px;
	margin: -72px 0 0 -119px;
	border: 2px solid transparent;
	border-top-color: var(--accent);
	border-radius: 50%;
	background: transparent;
	box-shadow: none;
	transform: rotate(-12deg);
}

.photoArt.career.sport::after {
	background:
		radial-gradient(circle at 72% 33%, #fff4d6 0 2px, var(--accent) 3px, transparent 6px),
		radial-gradient(1.5px 1.5px at 18% 28%, rgba(255, 255, 255, 0.7), transparent),
		radial-gradient(1.2px 1.2px at 76% 18%, rgba(255, 255, 255, 0.55), transparent),
		radial-gradient(1px 1px at 32% 66%, rgba(255, 255, 255, 0.5), transparent);
}

@media (max-width: 1050px) {
	.commsTag {
		max-width: 54px;
	}

	.commsCall {
		top: 8px;
		right: 8px;
		left: 8px;
		width: auto;
	}

	.commsCard {
		top: 8px;
		right: 8px;
		bottom: auto;
		left: 8px;
		width: auto;
		max-height: min(44vh, 360px);
	}
}
