:root {
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html,
body,
#root {
	margin: 0;
	height: 100%;
}

body {
	background: #05060a;
	color: #e6f0ff;
	font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	overflow: hidden;
}

.app {
	position: relative;
	width: 100vw;
	height: 100dvh;
}

.game-canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
}

.hud {
	position: absolute;
	top: 1.25rem;
	left: 1.5rem;
	pointer-events: none;
	text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85);
}

.hud h1 {
	margin: 0;
	font-size: clamp(1.5rem, 4vw, 2.75rem);
	letter-spacing: 0.35em;
	font-weight: 800;
	background: linear-gradient(90deg, #4cc9f0, #b5179e);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.hud p {
	margin: 0.6rem 0 0;
	opacity: 0.72;
	font-size: 0.9rem;
}

.info-panel {
	position: absolute;
	top: 1.25rem;
	right: 1.5rem;
	width: min(300px, calc(100vw - 3rem));
	max-height: calc(100dvh - 2.5rem);
	overflow-y: auto;
	display: flex;
	gap: 0.85rem;
	padding: 0.95rem 1.05rem;
	border-radius: 14px;
	background: rgba(10, 14, 24, 0.72);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	pointer-events: auto;
}

.info-swatch {
	flex: 0 0 auto;
	width: 6px;
	align-self: stretch;
	border-radius: 3px;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.4) inset;
}

.info-body {
	flex: 1;
	min-width: 0;
}

.info-kind {
	margin: 0;
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.18em;
	opacity: 0.55;
}

.info-title {
	margin: 0.15rem 0 0.65rem;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.15;
	overflow-wrap: anywhere;
}

.info-rows {
	margin: 0;
	display: grid;
	gap: 0.3rem;
}

.info-rows > div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	font-size: 0.85rem;
}

.info-rows dt {
	margin: 0;
	opacity: 0.55;
}

.info-rows dd {
	margin: 0;
	text-align: right;
	overflow-wrap: anywhere;
	font-variant-numeric: tabular-nums;
}

.econ {
	margin-top: 0.85rem;
	padding-top: 0.7rem;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	display: grid;
	gap: 0.55rem;
}

.econ-top {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.4rem 0.75rem;
}

.econ-top > div {
	display: flex;
	flex-direction: column;
}

.econ-k {
	font-size: 0.62rem;
	text-transform: uppercase;
	letter-spacing: 0.14em;
	opacity: 0.5;
}

.econ-v {
	font-size: 1.05rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.econ-group {
	display: grid;
	gap: 0.2rem;
}

.econ-cat {
	margin: 0.2rem 0 0.05rem;
	font-size: 0.6rem;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	opacity: 0.45;
}

.econ-row {
	display: grid;
	grid-template-columns: 4.6rem 1fr auto;
	align-items: center;
	gap: 0.55rem;
	font-size: 0.8rem;
}

.econ-res {
	opacity: 0.82;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.econ-bar {
	height: 5px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.09);
	overflow: hidden;
}

.econ-fill {
	display: block;
	height: 100%;
	min-width: 1px;
	border-radius: 3px;
	opacity: 0.9;
}

.econ-amt {
	min-width: 3.3rem;
	text-align: right;
	opacity: 0.85;
	font-variant-numeric: tabular-nums;
}

/* Education is a rate (0–100%), not a production value — divider sets it off from the resource bars. */
.econ-edu {
	padding-bottom: 0.55rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.econ-empty {
	margin: 0.85rem 0 0;
	padding-top: 0.7rem;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	font-size: 0.8rem;
	opacity: 0.5;
}

.info-close {
	position: absolute;
	top: 0.35rem;
	right: 0.5rem;
	width: 1.5rem;
	height: 1.5rem;
	display: grid;
	place-content: center;
	padding: 0;
	border: none;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	opacity: 0.5;
	font-size: 1.15rem;
	line-height: 1;
	cursor: pointer;
	transition: opacity 0.15s, background 0.15s;
}

.info-close:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.1);
}

.perf-overlay {
	position: absolute;
	right: 1.5rem;
	bottom: 1.25rem;
	width: 190px;
	padding: 0.7rem 0.85rem;
	border-radius: 12px;
	background: rgba(10, 14, 24, 0.72);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	/* Pure readout — let clicks/drags pass through to the globe beneath it. */
	pointer-events: none;
	user-select: none;
	font-variant-numeric: tabular-nums;
}

.perf-head {
	display: flex;
	align-items: baseline;
	gap: 0.35rem;
}

.perf-fps {
	font-size: 1.6rem;
	font-weight: 800;
	line-height: 1;
}

.perf-fps-unit {
	font-size: 0.62rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	opacity: 0.55;
}

.perf-rows {
	margin: 0.6rem 0 0;
	display: grid;
	gap: 0.3rem;
}

.perf-rows > div {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	font-size: 0.75rem;
}

.perf-rows dt {
	opacity: 0.55;
}

.perf-rows dd {
	margin: 0;
	opacity: 0.9;
}

.perf-renderer {
	margin: 0.55rem 0 0;
	padding-top: 0.5rem;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	font-size: 0.66rem;
	line-height: 1.25;
	opacity: 0.5;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* 3-stage power toggle. The overlay is pointer-events:none; re-enable it here so
   the segments are clickable without blocking globe drags elsewhere. */
.perf-modes {
	display: flex;
	margin-top: 0.6rem;
	padding: 2px;
	gap: 2px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.06);
	pointer-events: auto;
}

.perf-mode {
	flex: 1;
	padding: 0.28rem 0;
	border: none;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.62rem;
	letter-spacing: 0.02em;
	opacity: 0.6;
	cursor: pointer;
	transition: background 0.15s, opacity 0.15s;
}

.perf-mode:hover:not(:disabled):not(.active) {
	opacity: 0.9;
	background: rgba(255, 255, 255, 0.06);
}

.perf-mode.active {
	opacity: 1;
	background: rgba(76, 201, 240, 0.28);
	box-shadow: 0 0 0 1px rgba(76, 201, 240, 0.4) inset;
}

.perf-mode:disabled {
	cursor: default;
	opacity: 0.35;
}

.error {
	display: grid;
	place-content: center;
	gap: 0.75rem;
	height: 100dvh;
	padding: 2rem;
	text-align: center;
}

.error h2 {
	margin: 0;
	color: #ff6b6b;
}

.error p {
	margin: 0;
	max-width: 42ch;
	opacity: 0.8;
}

/* --- Lobby / room screens --- */
.lobby-screen {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 1.5rem;
	overflow-y: auto;
}

.lobby-panel {
	width: min(460px, 100%);
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	padding: 1.4rem 1.5rem;
	border-radius: 16px;
	background: rgba(10, 14, 24, 0.72);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lobby-panel.room {
	width: min(520px, 100%);
	max-height: calc(100dvh - 3rem);
}

.lobby-title {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 700;
}

.lobby-sub {
	margin: -0.4rem 0 0;
	font-size: 0.82rem;
	opacity: 0.55;
}

.lobby-notice {
	margin: 0;
	padding: 0.5rem 0.7rem;
	border-radius: 8px;
	background: rgba(255, 107, 107, 0.14);
	border: 1px solid rgba(255, 107, 107, 0.35);
	font-size: 0.82rem;
}

.lobby-host {
	display: flex;
	gap: 0.55rem;
}

.lobby-host input,
.country-filter {
	flex: 1;
	min-width: 0;
	padding: 0.55rem 0.7rem;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	background: rgba(0, 0, 0, 0.3);
	color: inherit;
	font: inherit;
}

.lobby-host input:focus,
.country-filter:focus {
	outline: none;
	border-color: #4cc9f0;
}

button {
	padding: 0.55rem 1rem;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: rgba(76, 201, 240, 0.16);
	color: inherit;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) {
	background: rgba(76, 201, 240, 0.28);
	border-color: #4cc9f0;
}

button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.lobby-empty {
	margin: 0;
	padding: 0.6rem 0;
	opacity: 0.55;
	font-size: 0.9rem;
}

.lobby-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.lobby-list li {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: center;
	gap: 0.15rem 0.75rem;
	padding: 0.6rem 0.75rem;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.08);
}

.lobby-game-name {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.lobby-game-meta {
	grid-column: 1;
	font-size: 0.76rem;
	opacity: 0.55;
}

.lobby-list li button {
	grid-column: 2;
	grid-row: 1 / span 2;
}

.room-players {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.room-players h3,
.lobby-panel.room > h3 {
	margin: 0.3rem 0 0;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	opacity: 0.55;
}

.room-players ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.room-players li {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.4rem 0.6rem;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.05);
	font-size: 0.85rem;
}

.room-players .ready {
	opacity: 0.5;
	font-size: 0.78rem;
}

.room-players .ready.yes {
	opacity: 1;
	color: #6ee7a8;
}

.country-picker {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	min-height: 0;
}

.country-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	max-height: 40dvh;
	overflow-y: auto;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(0, 0, 0, 0.2);
}

.country-item {
	width: 100%;
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.5rem 0.7rem;
	border: none;
	border-radius: 0;
	background: transparent;
	text-align: left;
	font-weight: 500;
}

.country-item:hover:not(:disabled) {
	background: rgba(255, 255, 255, 0.08);
	border-color: transparent;
}

.country-item.selected {
	background: rgba(76, 201, 240, 0.28);
}

.country-code {
	opacity: 0.5;
	font-variant-numeric: tabular-nums;
}

.ready-btn {
	align-self: flex-start;
}

.control-human {
	color: #ffe08a;
	font-weight: 600;
}

.control-npc {
	opacity: 0.6;
}
