/* Meteors — responsive, portrait-friendly, no page scroll during play. */
*, *::before, *::after { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background: #0b1020;
	color: #e8eaf2;
	font-family: "Segoe UI", system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans JP", "Noto Sans", sans-serif;
	touch-action: none;
	overscroll-behavior: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

#stars {
	position: fixed;
	inset: 0;
	pointer-events: none;
	background:
		radial-gradient(1px 1px at 12% 18%, #fff 0 50%, transparent 51%),
		radial-gradient(1px 1px at 28% 72%, #cde 0 50%, transparent 51%),
		radial-gradient(1.5px 1.5px at 47% 32%, #fff 0 50%, transparent 51%),
		radial-gradient(1px 1px at 63% 81%, #bbd 0 50%, transparent 51%),
		radial-gradient(1px 1px at 81% 22%, #fff 0 50%, transparent 51%),
		radial-gradient(1.5px 1.5px at 91% 64%, #def 0 50%, transparent 51%),
		radial-gradient(1px 1px at 8% 88%, #fff 0 50%, transparent 51%),
		radial-gradient(2px 2px at 72% 48%, #89a 0 50%, transparent 51%),
		linear-gradient(180deg, #0b1020 0%, #141a33 55%, #1a1440 100%);
	z-index: 0;
}

.screen {
	position: fixed;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 24px 20px;
	text-align: center;
}

.screen[hidden], #hud[hidden], #game-over[hidden], #online-panel[hidden], #minis[hidden], #spectator[hidden], #podium[hidden], #flights[hidden], #flights-back[hidden], #planet-select[hidden], #offline-result[hidden], #game-menu[hidden], #btn-game-menu[hidden], #offline-hud[hidden], #chain-indicator[hidden], #designer[hidden], #designer-edit[hidden], #reward[hidden], #login-prompt[hidden] { display: none !important; }

h1 {
	font-size: clamp(48px, 14vw, 96px);
	letter-spacing: 0.06em;
	margin: 0 0 8px;
	font-weight: 800;
	background: linear-gradient(180deg, #fff6c8 0%, #ff9a3a 45%, #e85d3a 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	filter: drop-shadow(0 2px 12px rgba(232, 93, 58, 0.55));
}

.tagline {
	margin: 0 0 28px;
	font-size: clamp(15px, 3.6vw, 20px);
	color: #c5cae0;
	max-width: 28em;
}

#btn-play, #btn-planet-go {
	appearance: none;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-size: clamp(20px, 5vw, 28px);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #1a1020;
	background: linear-gradient(180deg, #ffe27a, #f0c53a 40%, #e89a20);
	padding: 14px 48px;
	border-radius: 999px;
	box-shadow:
		0 0 0 3px rgba(255, 220, 120, 0.25),
		0 8px 24px rgba(240, 197, 58, 0.45);
	touch-action: manipulation;
	min-height: 52px;
	min-width: 200px;
}

#btn-play:is(:hover, :focus-visible), #btn-planet-go:is(:hover, :focus-visible) {
	transform: translateY(-1px);
	box-shadow:
		0 0 0 3px rgba(255, 220, 120, 0.4),
		0 10px 28px rgba(240, 197, 58, 0.6);
}

#btn-play:active, #btn-planet-go:active { transform: translateY(1px); }

.last-score {
	margin: 22px 0 0;
	font-size: clamp(16px, 4vw, 22px);
	color: #ffe27a;
}

.hint {
	margin: 36px auto 0;
	max-width: 32em;
	font-size: clamp(13px, 3.2vw, 16px);
	line-height: 1.45;
	color: #8e95b3;
}

#hud {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 4;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 4px;
	pointer-events: none;
	text-shadow: 0 1px 4px #000;
	gap: 12px;
}

.hud-label {
	font-size: 11px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: #9aa3c2;
}

#score {
	font-size: clamp(28px, 8vw, 42px);
	font-weight: 800;
	line-height: 1;
	color: #fff6c8;
}

#planet-name {
	font-weight: 700;
	font-size: clamp(14px, 3.5vw, 18px);
	text-align: right;
}

#planet-stats {
	font-variant-numeric: tabular-nums;
	font-size: clamp(11px, 2.8vw, 14px);
	color: #b7bdd4;
	text-align: right;
	white-space: nowrap;
}

.overlay {
	background: rgba(8, 10, 22, 0.78);
	backdrop-filter: blur(6px);
}

.overlay h2 {
	font-size: clamp(32px, 9vw, 56px);
	margin: 0 0 8px;
	color: #ffb0a0;
}

.go-score {
	font-size: clamp(20px, 5vw, 28px);
	color: #ffe27a;
	margin-top: 18px;
}

/* Framework canvases sit on the body. Keep them above the starfield, below HUD. */
canvas {
	z-index: 2;
	touch-action: none;
	display: block;
}

/* Very narrow / short phones: shrink hints so the Play button stays on screen. */
@media (max-height: 520px) {
	.hint { display: none; }
	h1 { font-size: 42px; }
	#btn-play, #btn-planet-go { padding: 10px 36px; }
}


/* ---- Stage 2: online, lobby, miniatures, flights, podium ---- */

#btn-online, .btn-secondary, a.button {
	margin-top: 12px;
	padding: 10px 36px;
	font-size: clamp(16px, 4vw, 20px);
	border: 1px solid #6a7394;
	border-radius: 999px;
	color: #e8eaf2;
	background: linear-gradient(180deg, #2a3150, #1b2038);
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
	font-family: inherit;
}
#btn-online:is(:hover, :focus-visible),
.btn-secondary:is(:hover, :focus-visible),
a.button:is(:hover, :focus-visible) {
	border-color: #ffe27a;
	color: #fff6c8;
}
#btn-create, #btn-join, #btn-ready, #btn-start, #btn-spectate,
#btn-play, #btn-planet-go, #btn-designer-new, #btn-designer-save {
	/* play already styled */
}

#btn-create, #btn-join, #btn-ready, #btn-start, #btn-spectate,
#btn-designer-new, #btn-designer-save {
	padding: 10px 28px;
	font-size: clamp(16px, 4vw, 20px);
	border: 0;
	border-radius: 999px;
	color: #1a1020;
	background: linear-gradient(180deg, #ffe27a, #f0c53a 40%, #e89a20);
	cursor: pointer;
	font-weight: 700;
	font-family: inherit;
}
#btn-start:disabled, #btn-ready:disabled {
	opacity: 0.45;
	cursor: default;
}

#online-panel h1 {
	font-size: clamp(36px, 9vw, 64px);
}
#online-panel {
	z-index: 5;
	overflow: auto;
	text-align: center;
	padding: 16px 16px 24px;
}
#online-panel .who {
	color: #c5cae0;
	margin: 0 0 8px;
}
#online-lobby .tagline { margin-bottom: 8px; }
#online-lobby .lobby-code { margin: 4px 0 6px; }
#online-panel .notice {
	max-width: 36em;
	margin: 0 auto 16px;
	text-align: left;
	line-height: 1.45;
	color: #c5cae0;
}
#online-panel code {
	font-size: 0.92em;
	color: #ffe27a;
}
#online-panel a { color: #9ec5ff; }
.error {
	color: #ffb0a0;
	margin: 8px 0;
}
.notice {
	background: rgba(20, 24, 48, 0.7);
	border: 1px solid #3a4268;
	border-radius: 12px;
	padding: 14px 16px;
}
.join-form {
	display: flex;
	gap: 8px;
	justify-content: center;
	align-items: flex-end;
	flex-wrap: wrap;
	margin: 16px 0;
}
.join-form label {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	font-size: 13px;
	color: #9aa3c2;
}
.join-form input {
	font-size: 22px;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	width: 8em;
	padding: 8px 10px;
	border-radius: 8px;
	border: 1px solid #6a7394;
	background: #141a33;
	color: #fff6c8;
	font-family: inherit;
	text-align: center;
}
.lobby-code {
	font-size: clamp(22px, 6vw, 34px);
	margin: 8px 0 16px;
	color: #ffe27a;
}
.btn-tiny {
	font-size: 13px;
	padding: 4px 10px;
	margin-left: 8px;
	border-radius: 999px;
	border: 1px solid #6a7394;
	background: #1b2038;
	color: #e8eaf2;
	cursor: pointer;
	font-family: inherit;
	letter-spacing: 0;
	vertical-align: middle;
}
.player-list {
	list-style: none;
	padding: 0;
	margin: 0 auto 18px;
	max-width: 22em;
	text-align: left;
}
.player-list li {
	display: flex;
	justify-content: space-between;
	padding: 8px 12px;
	border-bottom: 1px solid #2a3150;
	color: #e8eaf2;
}
.player-list .ready { color: #8eec9a; }
.player-list .waiting { color: #8e95b3; }
.player-list .you { font-weight: 700; }
.lobby-actions {
	display: flex;
	gap: 10px;
	justify-content: center;
	flex-wrap: wrap;
	margin-top: 12px;
}

#minis {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 4;
	display: flex;
	gap: 10px;
	justify-content: center;
	align-items: flex-end;
	flex-wrap: wrap;
	padding: 6px 8px 0;
	pointer-events: none;
}
#minis.sides {
	inset: 0;
	display: block;
	padding: 0;
	overflow: visible;
	max-height: none;
	gap: 0;
}
#minis.sides .mini {
	position: absolute;
	margin: 0;
	min-width: 0;
}
#minis.sides .mini-name {
	max-width: 100%;
}
.mini {
	text-align: center;
	color: #c5cae0;
	font-size: 11px;
	min-width: 72px;
}
.mini-name {
	max-width: 90px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 700;
}
.mini-canvas {
	display: block;
	width: 80px;
	height: 104px;
	background: #0c1020;
	border: 1px solid #2a3150;
	border-radius: 4px;
	image-rendering: pixelated;
}
.mini.eliminated { opacity: 0.45; }
.mini.eliminated .mini-meta { color: #ffb0a0; }

#flights {
	position: fixed;
	inset: 0;
	z-index: 6;
	pointer-events: none;
	overflow: visible;
}
/* Enemy-to-enemy arcs: above the starfield and minis, but the field
   rectangle is clipped out so they pass behind the player's field (t1125). */
#flights-back {
	position: fixed;
	inset: 0;
	z-index: 5;
	pointer-events: none;
	overflow: visible;
}
#flights .flight,
#flights-back .flight {
	position: fixed;
	top: 0;
	left: 0;
	width: 40px;
	height: 40px;
	will-change: transform;
	pointer-events: none;
}

#spectator h2, #podium h2 {
	color: #ffe27a;
}
.podium-list {
	list-style: none;
	padding: 0;
	margin: 16px auto;
	max-width: 16em;
	font-size: clamp(20px, 5vw, 28px);
}
.podium-list li {
	padding: 6px 0;
	color: #e8eaf2;
}
.podium-list li:first-child { color: #ffe27a; font-size: 1.2em; font-weight: 700; }
.podium-list li:nth-child(2) { color: #d0d6ea; }
.podium-list li:nth-child(3) { color: #e0a878; }

@media (max-height: 520px) {
	#online-panel .hint, #online-panel .tagline { display: block; }
	.mini-canvas { width: 56px; height: 73px; }
}

/* Stage 3: planet (field) selection */
#planet-select {
	justify-content: flex-start;
	overflow-y: auto;
	touch-action: pan-y;
	-webkit-overflow-scrolling: touch;
	padding-top: 20px;
	padding-bottom: 32px;
}
#planet-select h1 {
	font-size: clamp(32px, 9vw, 64px);
	margin-bottom: 4px;
}
#planet-select .tagline { margin-bottom: 16px; }
.planet-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 12px;
	width: min(1000px, 100%);
	margin: 0 auto 16px;
	text-align: left;
	touch-action: pan-y;
}
.planet-card {
	appearance: none;
	display: block;
	width: 100%;
	margin: 0;
	padding: 12px 14px 10px;
	border: 1px solid rgba(200, 210, 240, 0.16);
	border-radius: 14px;
	background: rgba(16, 20, 40, 0.72);
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	touch-action: manipulation;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.planet-card:hover, .planet-card:focus-visible {
	border-color: rgba(255, 226, 122, 0.55);
	outline: none;
}
.planet-card.selected {
	border-color: #ffe27a;
	box-shadow: 0 0 0 2px rgba(255, 226, 122, 0.35), 0 8px 24px rgba(0,0,0,0.35);
	background: rgba(40, 32, 16, 0.78);
}
.planet-card .planet-title {
	font-size: 1.15rem;
	font-weight: 700;
	letter-spacing: 0.03em;
	color: #fff6c8;
}
.planet-card .planet-people {
	font-size: 0.85rem;
	color: #8e95b3;
	margin: 0 0 6px;
}
.planet-card .planet-nums {
	font-variant-numeric: tabular-nums;
	font-size: 0.78rem;
	color: #c5cae0;
	letter-spacing: 0.01em;
	line-height: 1.35;
	margin: 0 0 8px;
}
.planet-card .planet-swatches {
	display: flex;
	gap: 6px;
	align-items: center;
}
.planet-card .planet-swatches img {
	width: 26px;
	height: 26px;
	image-rendering: auto;
	flex: 0 0 auto;
}
.planet-actions {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
	justify-content: center;
	margin-top: 8px;
	flex-shrink: 0;
}
.planet-grid.compact {
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 8px;
	width: min(920px, 92vw);
	min-width: min(920px, 92vw);
	max-height: none;
	overflow: visible;
	touch-action: pan-y;
	margin-bottom: 10px;
	align-self: center;
}
@media (max-width: 720px) {
	.planet-grid.compact {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}
.planet-grid.compact .planet-card { padding: 6px 8px; }
.planet-grid.compact .planet-title { font-size: 1rem; }
.planet-grid.compact .planet-nums { font-size: 0.7rem; margin-bottom: 6px; }
.planet-grid.compact .planet-swatches img { width: 20px; height: 20px; }
.lobby-planet-label { margin: 8px 0 6px; }
.player-list .planet-tag {
	display: block;
	font-size: 0.78rem;
	font-weight: 500;
	color: #9aa3c4;
}
#online-lobby {
	overflow-y: auto;
	touch-action: pan-y;
	-webkit-overflow-scrolling: touch;
	justify-content: flex-start;
	padding-top: 8px;
}
@media (max-width: 520px) {
	.planet-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
	.planet-card .planet-nums { font-size: 0.68rem; }
	.planet-card { padding: 10px 8px 8px; }
}

/* t1106: on-screen log for ?debug=drag */
#drag-debug {
	position: fixed;
	left: 6px;
	right: 6px;
	bottom: 6px;
	z-index: 50;
	pointer-events: none;
	background: rgba(8, 10, 22, 0.82);
	color: #c6f6c8;
	font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	padding: 8px 10px;
	border-radius: 6px;
	border: 1px solid #3a6;
	white-space: pre-wrap;
	word-break: break-word;
	max-height: 28vh;
	overflow: hidden;
}


/* ---- Offline Strijd (t1119), chain bonus (t1120), column warn (t1123) ---- */
.hud-offline {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: 6px;
	font-size: 12px;
	color: #c5cae0;
	white-space: nowrap;
	letter-spacing: 0.02em;
	pointer-events: none;
}
.hud-sep { opacity: 0.55; margin: 0 0.25em; }
#chain-indicator {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	top: 100%;
	margin-top: 4px;
	/* t1197: plain "+x%", yellow with an orange stroke. */
	color: #ffe600;
	font-weight: 900;
	font-size: 20px;
	line-height: 1;
	-webkit-text-stroke: 3px #ff7a00;
	paint-order: stroke fill;
	text-shadow: 0 2px 3px rgba(0, 0, 0, 0.45);
	white-space: nowrap;
	pointer-events: none;
	z-index: 5;
}
#offline-result h2 { color: #ffe27a; }
#minis {
	overflow: auto;
	flex-wrap: wrap;
}
#minis.crowded .mini { min-width: 44px; }
#minis.crowded .mini-canvas {
	width: 56px;
	height: 73px;
}
@media (max-width: 520px) {
	.hud-offline { font-size: 11px; bottom: 4px; }
}

/* —— t1139 Planet Designer + account chrome —— */
.menu-account {
	margin-top: 1.2rem;
	font-size: 0.9rem;
	color: #c8c4d4;
}
.menu-account a { color: #ffe27a; }
.menu-account a:hover { color: #fff; }
#btn-designer {
	display: block;
	margin: 0.7rem auto 0;
}
#btn-designer[hidden] { display: none; }
#menu-user[hidden], #menu-guest[hidden], #menu-local-login[hidden],
#btn-designer-delete[hidden] { display: none; }
.designer-card { cursor: default; text-align: left; }
.designer-card-actions {
	display: flex;
	gap: 6px;
	margin-top: 8px;
	justify-content: center;
}
.btn-tiny {
	font: inherit;
	font-size: 0.85rem;
	padding: 6px 10px;
	border-radius: 8px;
	border: 1px solid #5a5470;
	background: #2a2540;
	color: #eee;
	cursor: pointer;
	min-height: 36px;
}
.btn-tiny:hover, .btn-tiny:focus-visible { background: #3a3555; border-color: #ffe27a; }
.btn-danger-lite { color: #ffb4b4; }
.designer-form {
	max-width: 28rem;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	text-align: left;
}
.des-field { display: flex; flex-direction: column; gap: 4px; }
.des-field > span:first-child { font-weight: 600; color: #ddd; }
.des-field input[type="text"] {
	font: inherit;
	padding: 8px 10px;
	border-radius: 8px;
	border: 1px solid #5a5470;
	background: #1a1628;
	color: #fff;
	min-height: 40px;
}
.des-slider input[type="range"] { width: 100%; min-height: 32px; }
.des-val, .des-power {
	font-variant-numeric: tabular-nums;
	color: #ffe27a;
	font-weight: 700;
}
.des-power {
	font-size: 1.25rem;
	text-align: center;
	margin: 0.2rem 0;
}
.des-slots {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 8px;
}
.des-slot {
	font: inherit;
	background: #1a1628;
	border: 1px solid #5a5470;
	border-radius: 10px;
	padding: 8px 4px;
	cursor: pointer;
	color: #eee;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	min-height: 88px;
}
.des-slot img { width: 48px; height: 48px; image-rendering: pixelated; }
.des-slot span { font-size: 0.7rem; text-align: center; line-height: 1.15; }
.des-slot:hover, .des-slot:focus-visible { border-color: #ffe27a; background: #2a2540; }
.des-modal {
	position: fixed;
	inset: 0;
	background: rgba(8, 6, 16, 0.78);
	z-index: 40;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 12px;
	overflow: auto;
}
.des-modal[hidden] { display: none !important; }
.des-modal-card {
	background: #161226;
	border: 1px solid #5a5470;
	border-radius: 14px;
	padding: 14px 14px 18px;
	max-width: 56rem;
	width: 100%;
	margin: 1.5rem auto 3rem;
	box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.des-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}
.des-modal-head h2 { margin: 0; font-size: 1.2rem; }
.des-block-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
	gap: 8px;
}
.des-block {
	position: relative;
	font: inherit;
	background: #1a1628;
	border: 1px solid #5a5470;
	border-radius: 10px;
	padding: 6px 4px 8px;
	cursor: pointer;
	color: #eee;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	min-height: 92px;
}
.des-block img { width: 48px; height: 48px; image-rendering: pixelated; }
.des-block-name {
	font-size: 0.65rem;
	text-align: center;
	line-height: 1.15;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}
.des-block:hover:not(:disabled), .des-block:focus-visible:not(:disabled) {
	border-color: #ffe27a;
	background: #2a2540;
}
.des-block.current { outline: 2px solid #ffe27a; }
.des-block.used img, .des-block.locked img,
.des-block.used .des-block-name, .des-block.locked .des-block-name {
	opacity: 0.42;
	filter: grayscale(1);
}
.des-block.used, .des-block.locked {
	cursor: not-allowed;
}
.des-block-need {
	font-size: 0.6rem;
	color: #ffe27a;
	opacity: 0.9;
}
.des-lock {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 22px;
	height: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(16, 12, 28, 0.92);
	border-radius: 5px;
	pointer-events: none;
	z-index: 2;
	box-shadow: 0 0 0 1px rgba(255, 226, 122, 0.35);
}
.des-lock svg { display: block; }
.planet-card.custom { position: relative; }
.planet-card .custom-badge {
	position: absolute;
	top: 6px;
	right: 6px;
	font-size: 0.65rem;
	background: #3a2a10;
	color: #ffe27a;
	border: 1px solid #ffe27a;
	border-radius: 999px;
	padding: 1px 6px;
	letter-spacing: 0.02em;
}
@media (max-width: 520px) {
	.des-slots { grid-template-columns: repeat(5, 1fr); gap: 4px; }
	.des-slot { min-height: 76px; padding: 4px 2px; }
	.des-slot img, .des-block img { width: 36px; height: 36px; }
	.des-block { min-height: 80px; }
	.des-block-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
	.des-field input[type="text"], .btn-tiny { min-height: 44px; }
}

#designer, #designer-edit {
	justify-content: flex-start;
	overflow-y: auto;
	touch-action: pan-y;
	-webkit-overflow-scrolling: touch;
	padding-top: 16px;
	padding-bottom: 40px;
}
#designer h1, #designer-edit h1 {
	font-size: clamp(28px, 8vw, 56px);
	margin-bottom: 6px;
}
#designer .tagline, #designer-edit .tagline { margin-bottom: 12px; }
#designer-list {
	width: min(1000px, 100%);
	margin-bottom: 16px;
}
@media (max-width: 520px) {
	#designer-edit .designer-form { gap: 0.45rem; }
	.des-slots { margin-bottom: 8px; }
	#designer-edit .planet-actions, #designer .planet-actions {
		position: sticky;
		bottom: 0;
		padding-bottom: 8px;
		background: linear-gradient(180deg, transparent, #0b1020 30%);
	}
}

#designer-edit .hint, #designer .hint { margin: 8px auto 4px; }
#designer-edit .designer-form { max-width: 26rem; }
#designer-edit .planet-actions { margin-top: 12px; padding-bottom: 16px; }


/* —— t1141 i18n: flags, CJK, wrapping —— */
html[lang="ja"], html[lang="zh-Hans"], html[lang="ko"] {
	line-height: 1.55;
}
#btn-play, #btn-offline, #btn-online, #btn-designer,
#btn-planet-go, #btn-create, #btn-join, #btn-ready, #btn-start,
#btn-designer-new, #btn-designer-save {
	white-space: normal;
	overflow-wrap: anywhere;
	max-width: 92vw;
	line-height: 1.2;
}
.lang-picker {
	position: absolute;
	right: max(12px, env(safe-area-inset-right, 0px));
	bottom: max(12px, env(safe-area-inset-bottom, 0px));
	z-index: 9;
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-end;
	gap: 8px;
	pointer-events: auto;
}
.lang-current {
	appearance: none;
	border: 1px solid rgba(200, 210, 240, 0.35);
	background: rgba(16, 20, 40, 0.86);
	border-radius: 8px;
	padding: 6px 7px;
	cursor: pointer;
	line-height: 0;
	box-shadow: 0 4px 14px rgba(0,0,0,0.4);
	min-width: 52px;
	min-height: 40px;
}
.lang-current img, .lang-option img {
	display: block;
	width: 36px;
	height: 24px;
	object-fit: cover;
	border-radius: 3px;
	/* flags are vector art, not pixel blocks */
	image-rendering: auto;
	box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
}
.lang-current:hover, .lang-current:focus-visible,
.lang-option:hover, .lang-option:focus-visible {
	border-color: #ffe27a;
	outline: none;
}
.lang-current[aria-expanded="true"] {
	border-color: #ffe27a;
}
.lang-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	background: rgba(16, 14, 30, 0.96);
	border: 1px solid #5a5470;
	border-radius: 12px;
	padding: 8px;
	max-height: min(70vh, 28rem);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-y;
	box-shadow: 0 12px 32px rgba(0,0,0,0.45);
	min-width: 11.5rem;
}
.lang-list[hidden] { display: none !important; }
.lang-option {
	appearance: none;
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	border: 1px solid transparent;
	background: transparent;
	color: #e8eaf2;
	font: inherit;
	font-size: 0.95rem;
	padding: 6px 8px;
	border-radius: 8px;
	cursor: pointer;
	text-align: left;
	min-height: 40px;
	white-space: nowrap;
}
.lang-option.current {
	border-color: #ffe27a;
	background: rgba(40, 32, 16, 0.7);
}
.lang-option span {
	overflow: hidden;
	text-overflow: ellipsis;
}
@media (max-width: 520px) {
	.lang-picker { right: max(8px, env(safe-area-inset-right, 0px)); bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
	.lang-list { min-width: 10.5rem; }
	.menu-account { padding-bottom: 48px; } /* room for the flag */
	.hint { overflow-wrap: anywhere; }
	.planet-card .planet-title, .planet-card .planet-people, .planet-card .planet-nums {
		overflow-wrap: anywhere;
	}
	#designer .tagline, #designer-edit .tagline { overflow-wrap: anywhere; }
}
/* CJK in tight HUD */
#planet-name, #planet-stats, .hud-offline, .des-block-name, .des-val {
	overflow-wrap: anywhere;
}

#start-error {
	max-width: 28rem;
	margin: 16px auto 0;
	padding: 10px 16px;
	border-radius: 10px;
	border: 1px solid #e88;
	background: rgba(80, 16, 24, 0.85);
	color: #ffd6d6;
	font-size: 0.95rem;
	line-height: 1.45;
}

/* ---------- t1173 reward screen ---------- */
.reward {
	position: fixed;
	inset: 0;
	z-index: 70;
	background: rgba(8, 10, 22, 0.82);
	overflow: hidden;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}
.reward-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	z-index: 1;
}
.reward-title {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	margin: 0;
	padding: 0 16px;
	text-align: center;
	font-size: clamp(36px, 11vw, 72px);
	font-weight: 800;
	transform: translateY(-50%);
	transition: top 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), font-size 0.6s ease;
	z-index: 2;
	text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.reward-title.won { color: #ffe27a; }
.reward-title.lost { color: #ffb0a0; }
.reward.risen .reward-title {
	top: max(18px, env(safe-area-inset-top));
	transform: translateY(0);
	font-size: clamp(28px, 8vw, 52px);
}
.reward.reduced .reward-title { transition: none; }
.reward-counter {
	position: absolute;
	left: 50%;
	bottom: max(28px, calc(env(safe-area-inset-bottom) + 20px));
	transform: translateX(-50%);
	text-align: center;
	z-index: 3;
}
.reward-counter[hidden] { display: none !important; }
.reward-label {
	font-size: clamp(12px, 3.2vw, 15px);
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: #b7bdd4;
}
.reward-total {
	display: inline-block;
	font-size: clamp(40px, 12vw, 72px);
	font-weight: 800;
	color: #ffe27a;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 0 18px rgba(255, 200, 80, 0.45);
	transform-origin: 50% 60%;
	will-change: transform;
}
.reward-hint {
	position: absolute;
	left: 0;
	right: 0;
	bottom: max(4px, env(safe-area-inset-bottom));
	margin: 0;
	font-size: 13px;
	color: #8f96b2;
	z-index: 3;
}

/* —— t1193 in-game menu (Spelen / Offline Strijd) —— */
.hud-right-wrap {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	min-width: 0;
}
.btn-game-menu {
	pointer-events: auto;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid #6a7394;
	border-radius: 10px;
	background: rgba(27, 32, 56, 0.85);
	color: #e8eaf2;
	font-size: 20px;
	line-height: 38px;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
.btn-game-menu:is(:hover, :focus-visible) {
	border-color: #ffe27a;
	color: #fff6c8;
}
#game-menu {
	z-index: 60;
}
#game-menu h2 {
	color: #ffe27a;
}
.game-menu-buttons {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	margin-top: 8px;
}
.game-menu-buttons .btn-secondary {
	min-width: min(80vw, 300px);
}
.btn-primary-ish {
	border-color: #ffe27a !important;
	color: #fff6c8 !important;
}
@media (max-width: 520px) {
	.hud-right-wrap { gap: 6px; }
	.btn-game-menu { width: 36px; height: 36px; line-height: 34px; font-size: 18px; }
}

/* t1201: which mode a planet choice / pause menu belongs to. */
.planet-mode, .game-menu-mode {
	margin: -4px 0 10px;
	color: #ffe27a;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	font-size: 14px;
}
.planet-mode:empty, .game-menu-mode:empty { display: none; }

/* t1203: top-row minis placed (and scaled) by MiniLayout.topPositions. */
#minis.placed {
	inset: 0;
	display: block;
	padding: 0;
	overflow: visible;
	max-height: none;
	gap: 0;
}
#minis.placed .mini {
	position: absolute;
	margin: 0;
	min-width: 0;
	line-height: 1.3;
}
#minis.placed .mini-name { max-width: 100%; }
#minis.placed .mini-meta {
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
#minis.placed .mini-canvas { margin: 0 auto; }

/* t1246: startup login / play-as-guest prompt. */
#login-prompt {
	z-index: 70;
}
#login-prompt h2 {
	color: #ffe27a;
}
#login-prompt .tagline {
	margin-bottom: 20px;
}
#btn-login-prompt {
	margin-top: 0;
	padding: 14px 48px;
	font-size: clamp(20px, 5vw, 28px);
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #1a1020;
	background: linear-gradient(180deg, #ffe27a, #f0c53a 40%, #e89a20);
	border: 0;
	border-radius: 999px;
	min-height: 52px;
	min-width: min(80vw, 300px);
	box-shadow:
		0 0 0 3px rgba(255, 220, 120, 0.25),
		0 8px 24px rgba(240, 197, 58, 0.45);
	touch-action: manipulation;
}
#btn-login-prompt:is(:hover, :focus-visible) {
	color: #1a1020;
	border-color: transparent;
	transform: translateY(-1px);
	box-shadow:
		0 0 0 3px rgba(255, 220, 120, 0.4),
		0 10px 28px rgba(240, 197, 58, 0.6);
}
#btn-login-prompt:active { transform: translateY(1px); }
#btn-play-guest {
	min-width: min(80vw, 300px);
	min-height: 48px;
	touch-action: manipulation;
}
#login-prompt-local {
	margin-top: 20px;
}
#login-prompt-local a { color: #ffe27a; }
#login-prompt-local a:hover { color: #fff; }
@media (max-height: 520px) {
	#login-prompt .tagline { margin-bottom: 12px; }
	#btn-login-prompt { padding: 10px 36px; }
}

