html, body { margin: 0; padding: 0; height: 100%; background: #0a1624; color: #dde; font-family: 'Archivo Narrow', system-ui, sans-serif; overflow: hidden; }
body { overscroll-behavior: contain; }

#map { position: absolute; inset: 0; }
#map canvas { display: block; }

/* CSS2DRenderer root — pointer events pass through empty areas so the
 * canvas underneath still receives OrbitControls drag events. Individual
 * markers and popups re-enable pointer-events on themselves. */
.preview-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }


/* Header */
#preview-header {
	position: absolute;
	top: 1rem;
	left: 1rem;
	display: flex;
	align-items: center;
	gap: 0.875rem;
	padding: 0.625rem 1.125rem;
	background: rgba(10, 22, 36, 0.82);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 0.5rem;
	z-index: 10;
	color: #f3f4ef;
	font-size: 1rem;
}
#preview-header .home { color: #a7b7c9; font-size: 1.125rem; text-decoration: none; padding: 0 0.25rem; }
#preview-header .home:hover { color: #fff; }
#preview-header .name { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 1.0625rem; }


/* Empty state */
#preview-empty {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	text-align: center;
	color: #aab6c4;
}
#preview-empty h1 { font-size: 1.75rem; color: #f3f4ef; margin: 0 0 0.875rem 0; }
#preview-empty code { background: rgba(255, 255, 255, 0.06); padding: 0.25rem 0.625rem; border-radius: 0.25rem; font-size: 0.875rem; }


/* Capital marker + popup anchor pattern.
 *
 * CSS2DRenderer writes `transform: translate(-50%,-50%) translate(Xpx,Ypx)`
 * onto each CSSObject's root element, centering it at the 3D world point.
 * We don't want our markers/popups centered on that point — we want them
 * bottom-anchored (so they stand up above the terrain). Solution: wrap
 * each in a 0×0 anchor and absolutely-position the visible content with
 * `bottom:0; left:50%; transform: translate(-50%, 0)`. */

.capital-marker, .popup-anchor {
	position: relative;
	width: 0;
	height: 0;
}

.capital-marker .cm-pin {
	position: absolute;
	bottom: 0;
	left: 50%;
	transform: translate(-50%, 0);
	width: 1.625rem;
	height: 1.625rem;
	border-radius: 50%;
	border: 0.1875rem solid #fff8e6;
	color: #0a1a10;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.8125rem;
	cursor: pointer;
	pointer-events: auto;
	filter: drop-shadow(0 0.25rem 0.5rem rgba(0, 0, 0, 0.65));
	transition: transform 120ms ease, filter 120ms ease;
}
.capital-marker.available .cm-pin { background: #3fa84f; }
.capital-marker.taken     .cm-pin { background: #d14545; color: #ffe9e9; }
.capital-marker .cm-pin:hover {
	transform: translate(-50%, 0) scale(1.18);
	filter: drop-shadow(0 0.25rem 0.5rem rgba(0, 0, 0, 0.65)) brightness(1.12);
}


/* Popup */
.popup-anchor .capital-popup {
	position: absolute;
	bottom: 0;
	left: 50%;
	transform: translate(-50%, 0);
	pointer-events: auto;
	width: 20rem;
	max-width: calc(100vw - 2rem);
	background: rgba(14, 28, 44, 0.96);
	color: #e5e7ec;
	border: 1px solid rgba(212, 160, 75, 0.4);
	border-radius: 0.5rem;
	padding: 0.875rem 1rem 1rem;
	box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.45);
}

.capital-popup .pp-close {
	position: absolute;
	top: 0.25rem;
	right: 0.5rem;
	background: none;
	border: 0;
	color: #a7b7c9;
	font-size: 1.375rem;
	cursor: pointer;
	padding: 0 0.375rem;
	line-height: 1;
}
.capital-popup .pp-close:hover { color: #fff; }

.capital-popup .pp-title {
	font-size: 1.0625rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #f3d48a;
	margin: 0 1.5rem 0.75rem 0;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.capital-popup .pp-country-dot {
	display: inline-block;
	width: 0.875rem;
	height: 0.875rem;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, 0.3);
	flex-shrink: 0;
}

.capital-popup .pp-scores { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.875rem; }
.capital-popup .cs-row {
	display: grid;
	grid-template-columns: 4.5rem 1fr 2.25rem;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.8125rem;
}
.capital-popup .cs-label { color: #a7b7c9; text-transform: uppercase; letter-spacing: 0.03em; font-size: 0.75rem; }
.capital-popup .cs-bar { height: 0.375rem; background: rgba(255, 255, 255, 0.08); border-radius: 0.1875rem; overflow: hidden; display: block; }
.capital-popup .cs-fill { display: block; height: 100%; background: linear-gradient(90deg, #d4a04b 0%, #f3d48a 100%); border-radius: 0.1875rem; }
.capital-popup .cs-val { text-align: right; color: #dde; font-variant-numeric: tabular-nums; font-size: 0.8125rem; }

.capital-popup .pp-actions { display: flex; }
.capital-popup .pp-btn {
	flex: 1;
	display: block;
	padding: 0.625rem 1rem;
	background: #d4a04b;
	color: #1a1000;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	text-align: center;
	text-decoration: none;
	border: 0;
	border-radius: 0.3125rem;
	font-size: 0.875rem;
	cursor: pointer;
	font-family: inherit;
	transition: background 120ms ease;
}
.capital-popup .pp-btn:hover { background: #f3d48a; }
.capital-popup .pp-btn:disabled { opacity: 0.6; cursor: not-allowed; background: #d4a04b; }


/* Inline claim form — shown after clicking "Claim This Country" */
.capital-popup .cc-error {
	color: #ffb8b8;
	background: rgba(209, 69, 69, 0.15);
	border: 1px solid rgba(209, 69, 69, 0.35);
	padding: 0.5rem 0.75rem;
	border-radius: 0.25rem;
	font-size: 0.875rem;
	margin-bottom: 0.75rem;
}
.capital-popup .cc-field { margin-bottom: 0.75rem; }
.capital-popup .cc-field label {
	display: block;
	font-size: 0.75rem;
	color: #a7b7c9;
	margin-bottom: 0.375rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	font-weight: 700;
}
.capital-popup .cc-field input {
	width: 100%;
	box-sizing: border-box;
	padding: 0.5rem 0.625rem;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 0.25rem;
	color: #f3f4ef;
	font-family: inherit;
	font-size: 0.9375rem;
	transition: border-color 120ms ease, background 120ms ease;
}
.capital-popup .cc-field input:focus {
	outline: none;
	border-color: #d4a04b;
	background: rgba(255, 255, 255, 0.1);
}
.capital-popup .cc-palette {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(1.625rem, 1fr));
	gap: 0.375rem;
}
.capital-popup .cc-swatch {
	width: 1.625rem;
	height: 1.625rem;
	border-radius: 0.25rem;
	cursor: pointer;
	border: 0.125rem solid transparent;
	transition: border-color 120ms ease, transform 120ms ease;
}
.capital-popup .cc-swatch:hover { transform: scale(1.15); }
.capital-popup .cc-swatch.cc-selected {
	border-color: #fff8e6;
	box-shadow: 0 0 0 0.125rem rgba(212, 160, 75, 0.55);
}
.capital-popup .cc-actions {
	display: flex;
	gap: 0.5rem;
	margin-top: 0.875rem;
}
.capital-popup .cc-actions .pp-btn,
.capital-popup .cc-actions .pp-btn-cancel { flex: 1; }
.capital-popup .pp-btn-cancel {
	padding: 0.625rem 1rem;
	background: rgba(255, 255, 255, 0.08);
	color: #a7b7c9;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	text-align: center;
	border: 0;
	border-radius: 0.3125rem;
	font-size: 0.875rem;
	cursor: pointer;
	font-family: inherit;
	transition: background 120ms ease, color 120ms ease;
}
.capital-popup .pp-btn-cancel:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
