@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Cormorant+Garamond:wght@400;600&display=swap');
/* --- Grid overlay for city placement --- */
.grass-field { position: relative; }

#city-grid.grid-overlay {
	position: absolute;
	/* fill the full field so no outer border is visible */
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: grid;
	gap: 0;
	pointer-events: auto; /* allow clicks always (cells ignore when not placing) */
	z-index: 10; /* ensure grid sits above walls for clicks */
}

/* Read-only historical view styles */
.read-only .grid-cell { pointer-events: none; }
.read-only .grid-cell .building, .read-only .grid-cell .worker, .read-only .grid-cell .resource { opacity: 0.98; }
.read-only #city-grid.placement-mode .grid-cell:hover { background-color: initial; outline: none; }

.historical-scale .container { transform: scale(0.96); transform-origin: top center; }

/* historical badge/note removed — links are now inline on the page */

#city-grid.grid-overlay.placement-mode { pointer-events: auto; }

/* When in placement mode, disable pointer events on walls so grid gets clicks */
#city-grid.grid-overlay.placement-mode ~ .city-walls { pointer-events: none; }

.city-walls { z-index: 5; }

#city-grid .grid-cell {
	border: 1px solid rgba(0,0,0,0.07);
	box-sizing: border-box;
	background-color: transparent;
	position: relative; /* allow building marker positioning */
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.018), inset 0 -1px 0 rgba(0,0,0,0.07);
	transition: background-color 140ms ease, box-shadow 140ms ease, outline-color 140ms ease;
}
#city-grid .grid-cell.tile-even,
#city-grid .grid-cell.tile-odd {
	background-color: rgba(20, 65, 38, 0.18);
}

/* Highlight last action tile */
#city-grid .grid-cell.last-action {
	background-color: rgba(255, 229, 120, 0.20);
	outline: 1px solid rgba(255, 229, 120, 0.55);
	box-shadow: inset 0 0 0 2px rgba(255, 229, 120, 0.18), 0 0 0 1px rgba(255, 229, 120, 0.28);
	animation: tile-pulse 760ms ease-out;
}

@keyframes tile-pulse {
	0% { box-shadow: inset 0 0 0 1px rgba(255, 229, 120, 0.14), 0 0 0 0 rgba(255, 229, 120, 0.45); }
	55% { box-shadow: inset 0 0 0 2px rgba(255, 229, 120, 0.22), 0 0 0 6px rgba(255, 229, 120, 0.08); }
	100% { box-shadow: inset 0 0 0 2px rgba(255, 229, 120, 0.18), 0 0 0 1px rgba(255, 229, 120, 0.28); }
}

#city-grid.move-mode .grid-cell.move-origin {
	background-color: rgba(212, 175, 55, 0.22);
	outline: 2px solid rgba(212, 175, 55, 0.75);
	outline-offset: -2px;
}

#city-grid.move-mode .grid-cell.move-target-legal {
	background-color: rgba(34, 197, 94, 0.14);
	outline: 1px solid rgba(34, 197, 94, 0.55);
	outline-offset: -1px;
}

#city-grid.move-mode .grid-cell.move-target-blocked {
	background-color: rgba(239, 68, 68, 0.10);
	outline: 1px solid rgba(239, 68, 68, 0.38);
	outline-offset: -1px;
}

/* Default placement hover (fallback) */
#city-grid.placement-mode .grid-cell:hover {
	background-color: rgba(255, 255, 0, 0.18);
	outline: 1px solid rgba(255, 255, 0, 0.45);
}

/* Player-specific placement colors */
#city-grid.player-1.placement-mode .grid-cell:hover {
	background-color: rgba(249, 115, 22, 0.20);
	outline: 1px solid rgba(249, 115, 22, 0.55);
}
#city-grid.player-2.placement-mode .grid-cell:hover {
	background-color: rgba(60, 140, 255, 0.20);
	outline: 1px solid rgba(60, 140, 255, 0.55);
}

/* Building markers inside grid cells */
#city-grid .grid-cell .building {
	position: absolute;
	inset: 3px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	background: linear-gradient(180deg, rgba(10, 15, 22, 0.28), rgba(10, 15, 22, 0.18));
	border: 1px solid rgba(255,255,255,0.08);
	box-shadow: 0 6px 12px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.06);
	pointer-events: auto; /* clickable even when not in placement mode */
	z-index: 1;
}

#city-grid .grid-cell .building::after {
	content: "";
	position: absolute;
	inset: 1px;
	border-radius: 5px;
	pointer-events: none;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

/* Resource markers (block building placement) */
#city-grid .grid-cell .resource {
	position: absolute;
	inset: 3px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	background: transparent;
	border: 1px solid rgba(255,255,255,0.08);
	box-shadow: none;
	pointer-events: none; /* decorative; does not intercept clicks */
}
#city-grid .grid-cell .resource .label { font-size: 18px; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
/* Make SVG icons fill the containing label so they scale with the grid cell and inherit color */
#city-grid .grid-cell .resource .label svg,
#city-grid .grid-cell .building .label svg,
#city-grid .grid-cell .worker .label svg {
	width: 95%;
	height: 95%;
	max-width: 100%;
	max-height: 100%;
	display: block;
	color: inherit;
	fill: currentColor;
	stroke: currentColor;
}
/* Per-resource type coloring */
#city-grid .grid-cell .resource.type-forest .label { color: var(--wood); }
#city-grid .grid-cell .resource.type-quarry .label { color: var(--stone); }
#city-grid .grid-cell .resource.type-farm .label { color: var(--food); }
#city-grid .grid-cell .resource.type-ironmine .label { color: var(--iron); }

/* Worker markers (block building placement) */
#city-grid .grid-cell .worker {
	position: absolute;
	inset: 2px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: clamp(12px, 2.6vmin, 22px); /* responsive: scales with viewport so badge (em) scales with worker */
	background: linear-gradient(180deg, rgba(10, 15, 22, 0.30), rgba(10, 15, 22, 0.18));
	border: 1px solid rgba(255,255,255,0.09);
	box-shadow: 0 7px 14px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.08);
	pointer-events: none;
	z-index: 5;
}
/* Give workers a subtle background and icon color per owner so the
	worker visually matches the player (orange = p1, blue = p2) */
#city-grid .grid-cell .worker.owner-p1 { background: linear-gradient(180deg, rgba(224,122,62,0.15), rgba(10, 15, 22, 0.20)); }
#city-grid .grid-cell .worker.owner-p2 { background: linear-gradient(180deg, rgba(92,154,236,0.15), rgba(10, 15, 22, 0.20)); }
#city-grid .grid-cell .worker.owner-p1 .label { color: rgb(224,122,62); }
#city-grid .grid-cell .worker.owner-p2 .label { color: rgb(92,154,236); }
/* Worker label should fill the worker box so its SVG can scale */
#city-grid .grid-cell .worker .label { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--pop); }

/* Red cross for workers without yield due to food shortage */
#city-grid .grid-cell .worker.unpaid .worker-no-yield {
	position: absolute;
	inset: 1px;
	pointer-events: none;
	z-index: 9;
}
#city-grid .grid-cell .worker.unpaid .worker-no-yield::before,
#city-grid .grid-cell .worker.unpaid .worker-no-yield::after {
	content: '';
	position: absolute;
	left: 50%;
	top: 50%;
	width: 140%;
	height: 2px;
	background: rgba(239, 68, 68, 0.9);
	box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
	transform-origin: center;
}
#city-grid .grid-cell .worker.unpaid .worker-no-yield::before { transform: translate(-50%, -50%) rotate(45deg); }
#city-grid .grid-cell .worker.unpaid .worker-no-yield::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* Worker yield badge */
#city-grid .grid-cell .worker .yield-badge {
	position: absolute;
	right: 2px; /* closer to corner */
	bottom: 2px; /* closer to corner */
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.15em; /* slightly smaller so it fits neatly */
	line-height: 1;
	color: #ffffff;
	font-weight: 800;
	text-align: center;
	pointer-events: none;
	background: rgba(0, 0, 0, 0.55);
	border-radius: 2px;
	padding: 0 2px; /* minimal horizontal padding */
	text-shadow: 0 1px 2px rgba(0,0,0,0.95), 0 0 6px rgba(0,0,0,0.6);
	z-index: 10;
}

#city-grid .grid-cell .worker .yield-tooltip {
	position: absolute;
	bottom: calc(100% + 6px);
	right: 0;
	padding: 6px 8px;
	font-size: 14px;
	line-height: 1.2;
	border-radius: 6px;
	background: rgba(0,0,0,0.9);
	color: #fff;
	white-space: pre-line;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity 120ms ease, transform 120ms ease;
	pointer-events: none;
	box-shadow: 0 6px 18px rgba(0,0,0,0.28);
	z-index: 10;
}
#city-grid .grid-cell .worker .yield-tooltip.yield-tooltip--below {
	top: calc(100% + 6px);
	bottom: auto;
	transform: translateY(-4px);
}
#city-grid .grid-cell:hover .worker .yield-tooltip {
	opacity: 1;
	transform: translateY(0);
}

/* Owner colors persist on building markers */
#city-grid .grid-cell .building.owner-p1 {
	box-shadow: 0 6px 12px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
}
#city-grid .grid-cell .building.owner-p2 {
	box-shadow: 0 6px 12px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
}
/* Subtle background tint to indicate building ownership (orange/blue) */
#city-grid .grid-cell .building.owner-p1 { background: linear-gradient(180deg, rgba(249,115,22,0.16), rgba(10, 15, 22, 0.20)); }
#city-grid .grid-cell .building.owner-p2 { background: linear-gradient(180deg, rgba(60,140,255,0.16), rgba(10, 15, 22, 0.20)); }
/* Ensure icons remain visible on tinted backgrounds */
#city-grid .grid-cell .building.owner-p1 .label { color: rgb(224, 122, 62); }
#city-grid .grid-cell .building.owner-p2 .label { color: rgb(92, 154, 236); }

/* Buildings should read primarily as player ownership. */
#city-grid .grid-cell .building.owner-p1.type-hut .label,
#city-grid .grid-cell .building.owner-p1.type-house .label,
#city-grid .grid-cell .building.owner-p1.type-lumber_camp .label,
#city-grid .grid-cell .building.owner-p1.type-quarry .label,
#city-grid .grid-cell .building.owner-p1.type-mine .label,
#city-grid .grid-cell .building.owner-p1.type-farmhouse .label,
#city-grid .grid-cell .building.owner-p1.type-warehouse .label,
#city-grid .grid-cell .building.owner-p1.type-factory .label,
#city-grid .grid-cell .building.owner-p1.type-villa .label,
#city-grid .grid-cell .building.owner-p1.type-market .label {
	color: rgb(224, 122, 62);
	text-shadow: 0 0 6px rgba(224, 122, 62, 0.22);
}

#city-grid .grid-cell .building.owner-p2.type-hut .label,
#city-grid .grid-cell .building.owner-p2.type-house .label,
#city-grid .grid-cell .building.owner-p2.type-lumber_camp .label,
#city-grid .grid-cell .building.owner-p2.type-quarry .label,
#city-grid .grid-cell .building.owner-p2.type-mine .label,
#city-grid .grid-cell .building.owner-p2.type-farmhouse .label,
#city-grid .grid-cell .building.owner-p2.type-warehouse .label,
#city-grid .grid-cell .building.owner-p2.type-factory .label,
#city-grid .grid-cell .building.owner-p2.type-villa .label,
#city-grid .grid-cell .building.owner-p2.type-market .label {
	color: rgb(92, 154, 236);
	text-shadow: 0 0 6px rgba(92, 154, 236, 0.22);
}

/* Building icon label */
#city-grid .grid-cell .building .label {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

/* Ensure SVG building icons size nicely inside labels and inherit color */
#city-grid .grid-cell .building .label svg { width: 100%; height: 100%; max-width: 100%; max-height: 100%; display: block; fill: currentColor; }

/* Distinguish building types by icon color on the grid */
#city-grid .grid-cell .building.type-hut .label { color: var(--accent); }
#city-grid .grid-cell .building.type-house .label { color: var(--gold); }
#city-grid .grid-cell .building.type-lumber_camp .label { color: var(--wood); }
#city-grid .grid-cell .building.type-quarry .label { color: var(--stone); }
#city-grid .grid-cell .building.type-mine .label { color: var(--iron); }
#city-grid .grid-cell .building.type-farmhouse .label { color: var(--food); }
#city-grid .grid-cell .building.type-warehouse .label { color: var(--cap); }
#city-grid .grid-cell .building.type-factory .label { color: var(--iron); }
#city-grid .grid-cell .building.type-villa .label { color: var(--pop); }
#city-grid .grid-cell .building.type-market .label { color: var(--wood); }

/* Worker icon specifics */
.icon-worker { width: 85%; height: 85%; display: block; fill: currentColor; color: inherit; }

#city-grid .grid-cell .building,
#city-grid .grid-cell .worker,
#city-grid .grid-cell .resource {
	animation: unit-appear 170ms ease-out;
}

@keyframes unit-appear {
	from { opacity: 0; transform: scale(0.94); }
	to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	#city-grid .grid-cell,
	#city-grid .grid-cell .building,
	#city-grid .grid-cell .worker,
	#city-grid .grid-cell .resource,
	#city-grid .grid-cell.last-action {
		transition: none !important;
		animation: none !important;
	}
}

/* Build dropdown icon sizing + coloring by type */
.build-toolbar .dropdown button.build-item .bi { width: 20px; height: 20px; margin-right: 8px; vertical-align: text-bottom; }
.build-toolbar .dropdown button.build-item.type-hut .bi { color: var(--accent); }
.build-toolbar .dropdown button.build-item.type-house .bi { color: var(--gold); }
.build-toolbar .dropdown button.build-item.type-lumber_camp .bi { color: var(--wood); }
.build-toolbar .dropdown button.build-item.type-quarry .bi { color: var(--stone); }
.build-toolbar .dropdown button.build-item.type-mine .bi { color: var(--iron); }
.build-toolbar .dropdown button.build-item.type-farmhouse .bi { color: var(--food); }
.build-toolbar .dropdown button.build-item.type-warehouse .bi { color: var(--cap); }
.build-toolbar .dropdown button.build-item.type-factory .bi { color: var(--iron); }
.build-toolbar .dropdown button.build-item.type-market .bi { color: var(--wood); }
.build-toolbar .dropdown button.build-item.type-villa .bi { color: var(--pop); }

/* Dropdown resource cost icons: match stats bar styling */
.build-toolbar .dropdown .icon svg {
	width: 20px;
	height: 20px;
	display: inline-block;
	vertical-align: text-bottom;
	stroke: currentColor;
	fill: none;
	stroke-width: 2px;
}
/* Small descriptor under build item label */
.build-toolbar .dropdown button.build-item {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	min-height: 44px; /* ensure at least two lines worth of height */
	padding: 6px 8px;
}
.build-toolbar .dropdown button.build-item .item-main { display:flex; align-items:center; gap:8px; width:100%; justify-content:flex-start; }
.build-toolbar .dropdown button.build-item .item-main .item-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.build-toolbar .dropdown button.build-item .item-cost {
	display: inline-flex;
	gap: 6px;
	align-items: center;
	flex: 0 0 auto;
	margin-left: auto;
	font-size: 0.85rem;
	color: var(--muted);
}
.build-toolbar .dropdown button.build-item .item-cost .cost-item { margin-left: 6px; }
.build-toolbar .dropdown button.build-item .item-effect {
	font-size: 0.75rem;
	color: var(--muted);
	margin-top: 4px;
	margin-left: 0px;
}

:root {
	--bg: #0b0f18;
	--panel: #121624;
	--panel-2: #151a2b;
	--text: #e5e7eb;
	--muted: #a1a5b5;
	--gold: #d4af37;
	--accent: #b87333; /* koper */
	--danger: #b91c1c;
	--danger-bg: #2a1212;
	--border: #2a3447;

	/* stat accents */
	--wood: #7fbf4f;
	--stone: #6b7280;
	--iron: #9aa4b2;
	--food: #d4af37;
	--pop: #c084fc;
	--cap: #60a5fa;
	--yield: #22c55e;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
	margin: 0;
	font-family: 'Cormorant Garamond', serif;
	background:
		radial-gradient(1200px 600px at 10% 0%, #101426 0%, var(--bg) 70%),
		linear-gradient(180deg, rgba(212,175,55,0.06) 0%, rgba(0,0,0,0) 40%);
	color: var(--text);
	min-height: 100vh;
}

body:not(.auth-page):not(.welcome-page) {
	background:
		radial-gradient(1300px 620px at 10% -6%, rgba(229, 193, 116, 0.22), rgba(0,0,0,0) 62%),
		radial-gradient(1000px 520px at 96% 0%, rgba(120, 149, 194, 0.2), rgba(0,0,0,0) 58%),
		linear-gradient(170deg, #131c29 0%, #0c141f 52%, #0a121c 100%);
}

.brand {
	max-width: 900px;
	margin: 24px auto 0;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 12px;
	color: var(--gold);
	justify-content: space-between;
}
/* Modifier: match the main page content width (used on welcome) */
.brand.brand--match {
	max-width: 900px;
}
.brand-right { display:flex; align-items:center; gap:8px; }
.brand-right .options-menu { position: relative; }
.brand-right .options-menu #options-toggle {
	width: auto;
	min-height: 32px;
	padding: 6px 10px;
	font-size: .9rem;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	align-self: center; /* ensure vertical centering within .brand */
	height: 36px; /* enforce consistent height matching brand */
	margin-top: 0; /* override global button top margin */
}
.brand-right .options-menu #options-toggle svg { display:block; color: var(--text); }
.brand-right .options-menu #options-toggle::after { content: "▾"; font-size: 1.4em; margin-left: 6px; transition: transform 150ms ease; }
.brand-right .options-menu #options-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
.dropdown.options {
	position: absolute;
	right: 0;
	left: auto;
	transform: translateY(0);
	top: 38px;
	min-width: 180px;
	list-style: none;
	margin: 0;
	padding: 4px;
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	box-shadow: 0 10px 22px rgba(0,0,0,.35);
	z-index: 50;
	opacity: 1;
	transition: opacity 120ms ease, transform 120ms ease;
	will-change: opacity, transform;
}
.dropdown.options[hidden] {
	display: block;
	opacity: 0;
	pointer-events: none;
	transform: translateY(-6px);
}
.dropdown.options li { margin: 6px 0; }
.dropdown.options form { margin: 0; }

/* Options arrow size consolidated above */

/* Ensure buttons inside options dropdown are full width and visually consistent */
.dropdown.options button,
.dropdown.options .logout-brand button {
	width: 100%;
	box-sizing: border-box;
	text-align: left;
	padding: 8px 10px;
	background: transparent;
	border: none;
	color: var(--text);
}
.dropdown.options button svg { width: 16px; height: 16px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.dropdown.options button#cancel-game-btn svg { color: var(--danger); }
.dropdown.options button:hover,
.dropdown.options .logout-brand button:hover {
	background: rgba(255,255,255,0.03);
}
.brand-left { display: flex; align-items: center; gap: 12px; }
.site-brand-logo {
	display: block;
	width: clamp(170px, 24vw, 250px);
	height: auto;
	filter: drop-shadow(0 8px 14px rgba(0,0,0,0.4));
}
.brand .mark {
	width: 36px;
	height: 36px;
	border: 1px solid var(--gold);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: inset 0 0 12px rgba(212,175,55,.25), 0 0 18px rgba(212,175,55,.15);
	font-family: 'Cinzel', serif;
}
.brand .title {
	font-family: 'Cinzel', serif;
	font-size: 28px;
	letter-spacing: 1px;
	text-transform: uppercase;
	text-shadow: 0 2px 8px rgba(0,0,0,.6);
}

.container {
	max-width: 480px;
	margin: 24px auto;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	padding: 24px;
	border-radius: 12px;
	border: 1px solid var(--border);
	box-shadow: 0 20px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.03);
	position: relative;
}

.container.wide {
	max-width: 900px;
}

.stats-summary {
	margin-top: 12px;
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.stats-summary-top {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
}

.stats-pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.1;
	border: 1px solid rgba(255,255,255,0.1);
	background: rgba(255,255,255,0.04);
	color: var(--text);
}

.stats-pill--rank {
	border-color: rgba(212,175,55,0.35);
	background: rgba(212,175,55,0.12);
	color: #f3dc9d;
}

.stats-pill--elo {
	border-color: rgba(96,165,250,0.34);
	background: rgba(96,165,250,0.12);
	color: #dbeafe;
}

.stats-summary-main {
	font-size: 1.35rem;
	font-weight: 600;
	line-height: 1.15;
}

@media (max-width: 640px) {
	.stats-pill {
		padding: 3px 8px;
		font-size: 0.92rem;
	}

	.stats-summary-main {
		font-size: 1.15rem;
	}
}

.welcome-list-section {
	margin-top: 24px;
}

.welcome-list-title {
	margin: 0;
	text-align: center;
	font-size: 26px;
	letter-spacing: 0.3px;
	font-family: 'Cinzel', serif;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.welcome-list-title--games {
	color: #d6e8ff;
}

.welcome-list-title--active-games {
	color: #d6ffe2;
}

.welcome-list-title--active-games::before {
	content: "⚡";
	font-size: 18px;
	color: #34d399;
}

.welcome-list-title--games::before {
	content: "🏁";
	font-size: 18px;
	color: #60a5fa;
}

.welcome-list-title--leaderboard {
	color: #f2deb2;
}

.welcome-list-title--leaderboard::before {
	content: "🏆";
	font-size: 18px;
	color: var(--gold);
}

.ranked-trophy {
	display: inline-block;
	margin-right: 6px;
	color: var(--gold);
	font-size: 14px;
	line-height: 1;
	vertical-align: middle;
}

.welcome-list-surface {
	margin-top: 10px;
	padding: 14px;
	border-radius: 12px;
	border: 1px solid rgba(255,255,255,0.07);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 12px 26px rgba(0,0,0,0.22);
}

.welcome-list-surface--games {
	background: linear-gradient(180deg, rgba(24, 38, 64, 0.72), rgba(18, 30, 52, 0.66));
	border-color: rgba(96,165,250,0.36);
}

.welcome-list-surface--active-games {
	background: linear-gradient(180deg, rgba(14, 46, 28, 0.66), rgba(12, 34, 22, 0.62));
	border-color: rgba(52,211,153,0.34);
}

.welcome-list-surface--leaderboard {
	background: linear-gradient(180deg, rgba(46, 38, 18, 0.66), rgba(30, 24, 14, 0.64));
	border-color: rgba(212,175,55,0.36);
}

#active-games-root,
#finished-games-root,
#leaderboard-root {
	min-height: 48px;
}

#active-games-root .finished-games tbody tr:hover td {
	background: rgba(34,197,94,0.12);
}

#active-games-root .finished-games {
	table-layout: auto;
}

#active-games-root .finished-games .active-turn-col,
#active-games-root .finished-games .active-turn-cell {
	width: 40px;
	text-align: center;
	padding-left: 6px;
	padding-right: 6px;
	font-weight: 700;
}

#active-games-root .finished-games th:nth-child(2),
#active-games-root .finished-games td:nth-child(2) {
	width: auto;
}

#active-games-root .finished-games th:nth-child(3),
#active-games-root .finished-games td:nth-child(3) {
	width: 86px;
	white-space: nowrap;
	text-align: center;
}

#active-games-root .finished-games th:nth-child(4),
#active-games-root .finished-games td:nth-child(4) {
	width: 1%;
	white-space: nowrap;
}

#active-games-root .finished-games td:nth-child(4) a.btn-small {
	white-space: nowrap;
}

#active-games-root .finished-games .active-games-actions-head {
	text-align: right;
}

#active-games-root .finished-games .active-games-actions-head .start-game {
	display: inline-flex;
	vertical-align: middle;
}

.start-game .btn-small.btn-loading {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: default;
}

.start-game .btn-small.btn-loading::after {
	content: "";
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 2px solid rgba(31,41,55,0.28);
	border-top-color: rgba(17,24,39,0.96);
	animation: spin 0.9s linear infinite;
}

#finished-games-root .finished-games tbody tr:hover td {
	background: rgba(96,165,250,0.10);
}

#finished-games-root .finished-games {
	table-layout: auto;
}

#finished-games-root .finished-games th:nth-child(1),
#finished-games-root .finished-games td:nth-child(1),
#finished-games-root .finished-games th:nth-child(3),
#finished-games-root .finished-games td:nth-child(3),
#finished-games-root .finished-games th:nth-child(4),
#finished-games-root .finished-games td:nth-child(4),
#finished-games-root .finished-games th:nth-child(5),
#finished-games-root .finished-games td:nth-child(5) {
	width: 1%;
	white-space: nowrap;
}

#finished-games-root .finished-games th:nth-child(2),
#finished-games-root .finished-games td:nth-child(2) {
	width: auto;
}

#leaderboard-root .leaderboard-table tbody tr:hover td {
	background: rgba(212,175,55,0.12);
}

#leaderboard-root .leaderboard-table {
	table-layout: auto;
}

#leaderboard-root .leaderboard-table th:nth-child(1),
#leaderboard-root .leaderboard-table td:nth-child(1),
#leaderboard-root .leaderboard-table th:nth-child(3),
#leaderboard-root .leaderboard-table td:nth-child(3),
#leaderboard-root .leaderboard-table th:nth-child(4),
#leaderboard-root .leaderboard-table td:nth-child(4),
#leaderboard-root .leaderboard-table th:nth-child(5),
#leaderboard-root .leaderboard-table td:nth-child(5) {
	width: 1%;
	white-space: nowrap;
}

#leaderboard-root .leaderboard-table th:nth-child(2),
#leaderboard-root .leaderboard-table td:nth-child(2) {
	width: auto;
}

#leaderboard-root .leaderboard-table thead th {
	color: #f2deb2;
	border-bottom-color: rgba(212,175,55,0.26);
}

#finished-games-root #finished-games-pager .pager-btn {
	background: rgba(96,165,250,0.10);
	border-color: rgba(96,165,250,0.26);
}

#active-games-root .finished-games .result.active-game {
	background: rgba(34,197,94,0.16);
	color: #34d399;
}

#active-games-root .finished-games tr.active-game td {
	border-left: 4px solid rgba(34,197,94,0.32);
}

#active-games-root .finished-games tr.active-game .score-badge {
	background: rgba(34,197,94,0.16);
	color: #22c55e;
	border: 1px solid rgba(34,197,94,0.24);
}

#leaderboard-root #leaderboard-pager .pager-btn {
	background: rgba(212,175,55,0.12);
	border-color: rgba(212,175,55,0.30);
	color: #f2deb2;
}

@media (max-width: 640px) {
	.welcome-list-title {
		font-size: 22px;
	}

	.welcome-list-surface {
		padding: 10px;
	}
}

/* Turn badge styles */
.turn-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 999px;
	font-family: 'Cinzel', serif;
	font-size: .85rem;
	border: 1px solid var(--border);
	background: rgba(255,255,255,0.04);
	color: var(--muted);
}
.turn-badge::before { content: '⏳'; }
.turn-badge.my-turn {
	border-color: rgba(224, 122, 62, 0.52);
	background: rgba(224, 122, 62, 0.14);
	color: #ffe7d7;
}
.turn-badge.my-turn::before { content: '✔️'; }
.turn-badge.waiting-turn {
	border-color: rgba(92, 154, 236, 0.5);
	background: rgba(92, 154, 236, 0.12);
	color: #deecff;
}

/* Player color badge (orange for p1, blue for p2) */
.color-badge {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	border-radius: 999px;
	font-family: 'Cinzel', serif;
	font-size: .85rem;
	border: 1px solid var(--border);
	background: rgba(255,255,255,0.04);
}
.color-badge .dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	box-shadow: 0 0 0 2px rgba(255,255,255,0.1) inset;
}
.color-badge.p1 .dot { background: rgb(224, 122, 62); }
.color-badge.p2 .dot { background: rgb(92, 154, 236); }
.color-badge .label { color: var(--muted); }
.color-badge.p1 .label { color: #ffe7d7; }
.color-badge.p2 .label { color: #deecff; }

.dropdown.options button { display: flex; align-items: center; justify-content: space-between; }
.dropdown.options button svg { margin-right: 0; }
/* Scoreboard player name coloring */
.score-board { display:flex; gap:6px; }
.score-board .entry { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; font-family: 'Cinzel', serif; font-size: .82rem; border: 1px solid var(--border); background: rgba(255,255,255,0.03); }
.score-board .entry {
	position: relative;
	padding-left: 14px;
	overflow: hidden;
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.score-board .entry::before {
	content: "";
	position: absolute;
	left: 6px;
	top: 6px;
	bottom: 6px;
	width: 3px;
	border-radius: 2px;
	background: rgba(255,255,255,0.12);
}
.score-board .entry.p1::before { background: rgba(224, 122, 62, 0.82); }
.score-board .entry.p2::before { background: rgba(92, 154, 236, 0.82); }
.score-board .entry .icon { display:inline-flex; align-items:center; justify-content:center; }
.score-board .entry .name { font-weight: 600; color: var(--muted); }
.score-board .entry.p1 { border-color: rgba(224, 122, 62, 0.52); background: rgba(224, 122, 62, 0.14); color: #ffe7d7; }
.score-board .entry.p1 .name { color: #ffe7d7; }
.score-board .entry.p1 .icon svg { color: rgba(224,122,62,0.92); }
.score-board .entry.p2 { border-color: rgba(92, 154, 236, 0.5); background: rgba(92, 154, 236, 0.12); color: #deecff; }
.score-board .entry.p2 .name { color: #deecff; }
.score-board .entry.p2 .icon svg { color: rgba(92,154,236,0.92); }
/* Active player check (now used for the compact turn badge) */
.score-board .entry .check { display: none; margin-right: 6px; font-size: 0.82rem; }
.score-board .entry.active .check { display: inline-flex; align-items: center; }
.score-board .entry.p1 .check { color: #ffe7d7; }
.score-board .entry.p2 .check { color: #deecff; }

/* Make the turn badge more compact inside the scoreboard */
.score-board .entry .turn-badge { padding: 2px 6px; font-size: 0.75rem; margin-right: 6px; }
.score-board .entry.p1 .turn-badge { background: rgb(224, 122, 62); color: #fff; border-color: rgba(224, 122, 62, 0.75); }
.score-board .entry.p2 .turn-badge { background: rgb(92, 154, 236); color: #fff; border-color: rgba(92, 154, 236, 0.72); }

@media (max-width: 480px) {
	.turn-badge, .color-badge { font-size: .8rem; padding: 4px 8px; }
	.color-badge .label { display: none; }
	.start-game button { min-height: 30px; padding: 6px 10px; font-size: .85rem; }
	.score-board { flex-wrap: wrap; justify-content: center; gap: 8px; }
	.score-board .entry { max-width: 100%; overflow: visible; }
	.score-board .entry .name { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Keep player names visible in historical board legend on small screens. */
@media (max-width: 480px) {
	.historical-scale .historical-color-legend {
		flex-direction: column;
		align-items: stretch;
		gap: 6px;
	}
	.historical-scale .historical-color-legend .color-badge {
		justify-content: center;
	}
	.historical-scale .historical-color-legend .color-badge .label {
		display: inline;
		white-space: normal;
	}
}

/* Dim build toggle when disabled */
.btn-small[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
	filter: grayscale(0.3) brightness(0.9);
}

.finished-games td a.btn-small { display:inline-block; padding:6px 8px; background: rgba(255,255,255,0.04); color: var(--text); border-radius:6px; text-decoration:none; border:1px solid rgba(255,255,255,0.03); }
.finished-games td a.btn-small:hover { background: rgba(255,255,255,0.06); }
.finished-games th .btn-small { display:inline-block; padding:6px 8px; background: rgba(255,255,255,0.04); color: var(--text); border-radius:6px; text-decoration:none; border:1px solid rgba(255,255,255,0.03); }
.finished-games th .btn-small:hover { background: rgba(255,255,255,0.06); }

/* Build toolbar above the city */
.build-toolbar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin: 8px auto 8px;
}


/* Placement message shown above the grid: keep horizontally centered and styled */
#place-msg.hint {
	display: block;
	margin: 12px auto;
	text-align: center;
	max-width: 720px;
	padding: 8px 14px;
	background-color: rgba(0, 0, 0, 0);
	background-image: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
	border: 1px solid rgba(255,255,255,0.04);
	color: var(--muted);
	border-radius: 10px;
	font-size: 1.05rem;
	line-height: 1.3;
	box-shadow: 0 8px 20px rgba(0,0,0,0.45);
	animation: hint-in 200ms ease;
}

#place-msg.hint.hint-flash {
	animation: hint-flash 900ms ease;
}

/* small decorative icon before the place message text */
#place-msg.hint:not(:empty)::before {
	content: "ℹ";
	display: inline-block;
	margin-right: 8px;
	color: var(--gold);
	font-weight: 700;
	vertical-align: middle;
}

#place-msg.hint:empty {
	display: none;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
}

@keyframes hint-in {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes hint-flash {
	0% { background-color: rgba(255, 229, 120, 0); border-color: rgba(255,255,255,0.04); }
	35% { background-color: rgba(255, 229, 120, 0.18); border-color: rgba(255, 229, 120, 0.45); }
	100% { background-color: rgba(255, 229, 120, 0); border-color: rgba(255,255,255,0.04); }
}

@media (max-width: 640px) {
  #place-msg.hint { padding: 6px 10px; margin: 10px 8px; font-size: 1.00rem; }
}

/* Finished games table on welcome page */
.finished-games {
	width: 100%;
	border-collapse: collapse;
	margin-top: 12px;
}
.finished-games { table-layout: fixed; }
.finished-games { border-spacing: 0; }
.finished-games th, .finished-games td {
	padding: 8px 10px;
	border-bottom: 1px solid rgba(255,255,255,0.04);
	text-align: left;
	font-size: 0.95rem;
	color: var(--muted);
}
.finished-games thead th { color: var(--text); font-weight: 600; }
.finished-games tbody tr:hover td { background: rgba(255,255,255,0.02); }

@media (max-width: 640px) {
	.finished-games th, .finished-games td {
		padding: 5px 6px;
		font-size: 0.88rem;
		line-height: 1.1;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	/* Keep date compact */
	.finished-games td:nth-child(1), .finished-games th:nth-child(1) {
		width: 90px;
		white-space: nowrap;
	}
	/* Opponent name may overflow; truncate */
	.finished-games td:nth-child(2) {
		max-width: 120px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	/* Score column */
	.finished-games td:nth-child(3) {
		width: 84px;
		text-align: center;
		white-space: nowrap;
	}
	/* Actions column: keep link visible by allowing it to wrap and become block */
	.finished-games th:nth-child(5), .finished-games td:nth-child(5) {
		width: 90px;
	}
	.finished-games td:nth-child(5) a.btn-small {
		display: inline-block;
		width: 100%;
		box-sizing: border-box;
		padding: 6px 4px;
		font-size: 0.85rem;
		white-space: normal;
		text-align: center;
	}
}

@media (max-width: 380px) {
	.finished-games th, .finished-games td {
		padding: 4px 5px;
		font-size: 0.82rem;
		line-height: 1.05;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.finished-games td:nth-child(2) { max-width: 90px; }
	.finished-games td:nth-child(3) { width: 70px; }
	.finished-games td:nth-child(5) a.btn-small { padding: 5px 6px; font-size: 0.8rem; display:inline-block; width:100%; box-sizing: border-box; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}

/* Result styling for finished-games */
.finished-games .result { display:inline-flex; align-items:center; gap:8px; padding:4px 8px; border-radius:6px; font-weight:600; }
.finished-games .result.won { background: rgba(16,185,129,0.12); color: #10b981; }
.finished-games .result.lost { background: rgba(239,68,68,0.12); color: #ef4444; }
.finished-games .result.draw { background: rgba(160,160,160,0.06); color: var(--muted); }

.finished-games .result.cancelled { background: rgba(250,204,21,0.08); color: #b45309; }
.finished-games .result.active-game { background: rgba(96,165,250,0.12); color: #60a5fa; }
.finished-games .result.active-game.my-turn { background: rgba(34,197,94,0.16); color: #34d399; }

.finished-games tr.won td { border-left: 4px solid rgba(16,185,129,0.28); }
.finished-games tr.lost td { border-left: 4px solid rgba(239,68,68,0.28); }
.finished-games tr.draw td { border-left: 4px solid rgba(160,160,160,0.08); }
.finished-games tr.cancelled td { border-left: 4px solid rgba(250,204,21,0.16); }
.finished-games tr.active-game td { border-left: 4px solid rgba(96,165,250,0.28); }
.finished-games tr.active-game.my-turn td { border-left: 4px solid rgba(34,197,94,0.28); }

/* Add small icons before result text */
.finished-games .result.won::before { content: "✔"; display:inline-block; font-size:0.95em; }
.finished-games .result.lost::before { content: "✖"; display:inline-block; font-size:0.95em; }
.finished-games .result.draw::before { content: "—"; display:inline-block; font-size:0.95em; }

.finished-games .result.cancelled::before { content: "⚑"; display:inline-block; font-size:0.95em; }
.finished-games .result.active-game.waiting::before { content: "⏳"; display:inline-block; font-size:0.95em; }
.finished-games .result.active-game.my-turn::before { content: "▶"; display:inline-block; font-size:0.95em; }

.finished-games tr.active-game .score-badge { background: rgba(96,165,250,0.12); color: #60a5fa; border: 1px solid rgba(96,165,250,0.2); }

/* Pager styles for finished games list */
#finished-games-pager {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 12px;
	width: 100%;
	box-sizing: border-box;
}
#finished-games-pager .pager-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px 8px;
	font-size: 0.85rem;
	min-width: 56px;
	height: 30px;
	border-radius: 6px;
	background: rgba(255,255,255,0.04);
	color: var(--text);
	border: 1px solid rgba(255,255,255,0.03);
}
#finished-games-pager .pager-btn[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
}
#finished-games-pager .pager-btn.disabled,
#finished-games-pager .pager-btn.disabled svg {
  opacity: 0.55;
  pointer-events: none;
}
#finished-games-pager .pager-btn--compact {
	padding: 2px 6px;
	min-width: 34px;
	height: 26px;
	font-size: 0.78rem;
}

#finished-games-pager .pager-btn svg {
	display: block;
	width: 14px;
	height: 14px;
	margin: 0;
	padding: 0;
	fill: currentColor;
}
#finished-games-pager .pager-info {
	color: var(--muted);
	flex: 1 1 auto;
	min-width: 0; /* allow ellipsis */
	text-align: center;
	margin: 0 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.95rem;
}
.finished-games tr.active-game.my-turn .score-badge { background: rgba(34,197,94,0.16); color: #22c55e; border: 1px solid rgba(34,197,94,0.24); }

/* Leaderboard uses the same visual language as finished games */
.leaderboard-table tr.my-rank-row td { border-left: 4px solid rgba(212,175,55,0.32); }
.leaderboard-table tr.my-rank-row .score-badge {
	background: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14));
	border: 1px solid rgba(212,175,55,0.28);
	color: #fff;
}

/* When space is limited, hide the textual result label but keep the icon visible */
.finished-games .result .result-label { display: inline; }
.finished-games .result .result-icon { display: none; }

@media (max-width: 600px) {
	.finished-games .result { gap: 6px; padding: 3px 6px; }
	.finished-games .result .result-label { display: none; }
	.finished-games .result .result-icon { display: inline-block; font-size: 1em; }
}

/* Score badge styling (compact: keep text size, reduce pill size) */
.score-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 2px 6px; /* reduced vertical/horizontal padding for a smaller pill */
	border-radius: 999px;
	font-weight: 700;
	background: rgba(255,255,255,0.03);
	color: var(--text);
	min-width: 36px; /* smaller minimum width */
	height: 26px; /* give a compact, consistent height */
	line-height: 1; /* keep text vertically centered */
	font-size: inherit; /* keep the surrounding font-size unchanged */
	text-align: center;
}

@media (max-width: 480px) {
	.score-badge { padding: 1px 6px; height: 22px; min-width: 32px; }
}

/* Score color variations based on row result */
.finished-games tr.won .score-badge { background: linear-gradient(180deg, rgba(16,185,129,0.18), rgba(16,185,129,0.12)); color: #ffffff; box-shadow: 0 2px 6px rgba(6,95,70,0.08); border: 1px solid rgba(6,95,70,0.12); }
.finished-games tr.lost .score-badge { background: linear-gradient(180deg, rgba(239,68,68,0.16), rgba(239,68,68,0.10)); color: #ffffff; box-shadow: 0 2px 6px rgba(127,29,29,0.08); border: 1px solid rgba(127,29,29,0.12); }
.finished-games tr.draw .score-badge { background: rgba(255,255,255,0.04); color: var(--text); box-shadow: none; border: 1px solid rgba(255,255,255,0.03); }

#leaderboard-pager {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 12px;
	width: 100%;
	box-sizing: border-box;
}
#leaderboard-pager .pager-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px 8px;
	font-size: 0.85rem;
	min-width: 56px;
	height: 30px;
	border-radius: 6px;
	background: rgba(255,255,255,0.04);
	color: var(--text);
	border: 1px solid rgba(255,255,255,0.03);
}
#leaderboard-pager .pager-btn.disabled,
#leaderboard-pager .pager-btn.disabled svg {
	opacity: 0.55;
	pointer-events: none;
}
#leaderboard-pager .pager-btn--compact {
	padding: 2px 6px;
	min-width: 34px;
	height: 26px;
	font-size: 0.78rem;
}
#leaderboard-pager .pager-btn svg {
	display: block;
	width: 14px;
	height: 14px;
	margin: 0;
	padding: 0;
	fill: currentColor;
}
#leaderboard-pager .pager-info {
	color: var(--muted);
	flex: 1 1 auto;
	min-width: 0;
	text-align: center;
	margin: 0 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.95rem;
}

.manage-section {
	margin-bottom: 8px;
}

.manage-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.manage-table {
	min-width: 100%;
	width: max-content;
	table-layout: auto;
}

.manage-table th,
.manage-table td {
	white-space: nowrap !important;
	overflow: visible !important;
	text-overflow: clip !important;
	max-width: none !important;
	width: auto !important;
}

.manage-pager {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-top: 12px;
	width: 100%;
	box-sizing: border-box;
}

.manage-pager .pager-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px 8px;
	font-size: 0.85rem;
	min-width: 56px;
	height: 30px;
	border-radius: 6px;
	background: rgba(255,255,255,0.04);
	color: var(--text);
	border: 1px solid rgba(255,255,255,0.03);
}

.manage-pager .pager-btn.disabled,
.manage-pager .pager-btn.disabled svg {
	opacity: 0.55;
	pointer-events: none;
}

.manage-pager .pager-btn--compact {
	padding: 2px 6px;
	min-width: 34px;
	height: 26px;
	font-size: 0.78rem;
}

.manage-pager .pager-btn svg {
	display: block;
	width: 14px;
	height: 14px;
	margin: 0;
	padding: 0;
	fill: currentColor;
}

.manage-pager .pager-info {
	color: var(--muted);
	flex: 1 1 auto;
	min-width: 0;
	text-align: center;
	margin: 0 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.95rem;
}

.build-toolbar { position: relative; }
.build-toolbar .menu { position: static; }
/* Rectangular action/build toggles styled like other buttons but compact */
.build-toolbar .menu #build-toggle,
.build-toolbar .menu #action-toggle {
	width: auto;
	min-height: 32px;
	padding: 6px 12px 6px 10px;
	font-size: .9rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-top: 0; /* override global button top margin for header toggle */
}
.build-toolbar .menu #build-toggle::after,
.build-toolbar .menu #action-toggle::after {
	content: "▾";
	font-size: 1.4em; /* match Options arrow size */
	line-height: 1;
	margin-left: 6px;
	transition: transform 150ms ease;
}
.build-toolbar .menu #build-toggle[aria-expanded="true"]::after,
.build-toolbar .menu #action-toggle[aria-expanded="true"]::after {
	transform: rotate(180deg);
}
.build-toolbar .menu #build-toggle[disabled],
.build-toolbar .menu #action-toggle[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}
.build-toolbar .menu #worker-toggle {
	width: auto;
	min-height: 32px;
	padding: 6px 10px;
	font-size: .9rem;
}
.build-toolbar .menu #worker-toggle[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}
.build-toolbar .menu #pass-turn {
	width: auto;
	min-height: 32px;
	padding: 6px 10px;
	font-size: .9rem;
}
.build-toolbar .menu #pass-turn[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}
.build-toolbar .dropdown {
	position: absolute;
	top: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%) translateY(0);
	list-style: none;
	margin: 0;
	padding: 4px; /* tighter padding */
	min-width: 300px; /* keep dropdown width consistent across viewports */
	max-width: 420px;
	background: var(--panel-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	box-shadow: 0 10px 22px rgba(0,0,0,.35);
	z-index: 20;
	opacity: 1;
	transition: opacity 120ms ease, transform 120ms ease;
	will-change: opacity, transform;
}
.build-toolbar .dropdown[hidden] {
	display: block;
	opacity: 0;
	pointer-events: none;
	transform: translateX(-50%) translateY(-6px);
}
.dropdown li { margin: 2px 0; }
.dropdown button {
	width: 100%;
	box-sizing: border-box;
	text-align: left;
	padding: 6px 8px; /* smaller button padding */
	background: transparent;
	border: none;
	color: var(--text);
	min-height: 30px;
	display: flex;
	align-items: center;
	gap: 8px;
}
.dropdown button .item-main {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 1 1 auto;
	min-width: 0;
}
.dropdown button .item-label { display: inline-flex; align-items: center; }
.dropdown button .item-meta {
	display: block;
	margin-left: 26px;
	margin-top: 2px;
	font-size: 0.78rem;
	color: var(--muted);
	font-weight: 500;
}
.dropdown button .item-cost {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-left: auto;
	flex: 0 0 auto;
.dropdown button .item-cost {
	display: flex;
	gap: 2px;
	align-items: center;
}
.dropdown button .cost-item {
	display: inline-flex;
	align-items: center;
	gap: 2px;
}
.dropdown button .cost-sep {
	margin: 3px 4px;
	opacity: .6;
}
	white-space: nowrap;
}
.dropdown button .cost-item { display: inline-flex; align-items: center; gap: 3px; }
.dropdown button .cost-sep { margin: 0 3px; opacity: 0.6; }
.dropdown button { background: rgba(255,255,255,0.06); border-radius:6px; border: 1px solid rgba(255,255,255,0.03); }
.dropdown button { position: relative; overflow: hidden; transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease; }
.dropdown button::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: linear-gradient(180deg, rgba(212,175,55,0.0), rgba(212,175,55,0.55), rgba(212,175,55,0.0));
	opacity: 0.25;
}
.dropdown button:hover { background: rgba(255,255,255,0.12); border-color: rgba(212,175,55,0.25); }
.dropdown button:hover::before { opacity: 0.7; }
.dropdown button:active { background: rgba(255,255,255,0.16); box-shadow: inset 0 1px 0 rgba(0,0,0,0.25); }
.dropdown button[disabled] { background: rgba(255,255,255,0.02); color: rgba(255,255,255,0.45); cursor: not-allowed; border: 1px solid rgba(255,255,255,0.01); }

h1 {
	margin: 0 0 16px;
	font-size: 1.8rem;
	font-family: 'Cinzel', serif;
	color: var(--gold);
	text-align: center;
}

label { display: block; margin: 12px 0; font-weight: 600; color: var(--muted); }

input[type="text"], input[type="password"] {
	width: 100%;
	padding: 10px 12px;
	background: #0f1424;
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	font-size: 1rem;
	outline: none;
	box-shadow: inset 0 1px 3px rgba(0,0,0,.6);
	transition: border-color 120ms ease, box-shadow 120ms ease;
}

input[type="text"]:focus, input[type="password"]:focus {
	border-color: var(--gold);
	box-shadow: 0 0 0 3px rgba(212,175,55,.15), inset 0 1px 3px rgba(0,0,0,.7);
}

input[type="text"]:focus-visible, input[type="password"]:focus-visible {
	outline: none;
}

button {
	width: 100%;
	padding: 10px 12px;
	background: linear-gradient(180deg, #2b203d, #231a33);
	color: #fef7e6;
	border: 1px solid var(--gold);
	border-radius: 8px;
	font-size: 1rem;
	cursor: pointer;
	box-shadow: 0 8px 16px rgba(0,0,0,.5), inset 0 0 10px rgba(212,175,55,.15);
	text-transform: uppercase;
	letter-spacing: .5px;
	font-family: 'Cinzel', serif;
	min-height: 44px; /* touch target */
	transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover {
	filter: brightness(1.1);
	box-shadow: 0 10px 22px rgba(0,0,0,.6), inset 0 0 14px rgba(212,175,55,.25);
}

button:active { transform: translateY(1px); }

button:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(212,175,55,0.2), 0 10px 22px rgba(0,0,0,.6), inset 0 0 14px rgba(212,175,55,.25);
}

.btn, a.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 12px;
	background: linear-gradient(180deg, #2b203d, #231a33);
	color: #fef7e6;
	border: 1px solid var(--gold);
	border-radius: 8px;
	text-decoration: none;
	font-family: 'Cinzel', serif;
	text-transform: uppercase;
	letter-spacing: .4px;
	min-height: 36px;
	transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}
.btn:hover, a.btn:hover { filter: brightness(1.1); box-shadow: 0 8px 18px rgba(0,0,0,.5), inset 0 0 12px rgba(212,175,55,.2); text-decoration: none; }
.btn:active, a.btn:active { transform: translateY(1px); }
.btn:focus-visible, a.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(212,175,55,0.2), 0 8px 18px rgba(0,0,0,.5), inset 0 0 12px rgba(212,175,55,.2); }

.btn-secondary, a.btn-secondary {
	background: linear-gradient(180deg, #1a2036, #151a2b);
	border-color: var(--border);
	color: var(--text);
	text-transform: none;
}
.btn-ghost, a.btn-ghost {
	background: transparent;
	border-color: rgba(255,255,255,0.08);
	color: var(--text);
	text-transform: none;
}

button.btn-status,
.btn.btn-status,
a.btn.btn-status {
	background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
	border-color: rgba(255,255,255,0.12);
	color: var(--muted);
	text-transform: none;
	letter-spacing: 0;
	box-shadow: none;
	cursor: default;
}
button.btn-status:hover,
.btn.btn-status:hover,
a.btn.btn-status:hover {
	filter: none;
	box-shadow: none;
}

.status-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	min-height: 32px;
	border-radius: 999px;
	border: 1px solid rgba(255,255,255,0.12);
	background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
	color: var(--muted);
	font-family: 'Cinzel', serif;
	font-size: 0.85rem;
}
@keyframes spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

.btn-inline, a.btn-inline {
	padding: 4px 8px;
	min-height: 0;
	font-size: 0.9rem;
	text-transform: none;
	letter-spacing: 0;
}

.error {
	background: var(--danger-bg);
	color: #fecaca;
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid rgba(185,28,28,.35);
}

.success {
	background: rgba(16,185,129,0.14);
	color: #bbf7d0;
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid rgba(16,185,129,0.35);
}

.profile-current-user {
	margin-bottom: 12px;
	padding: 10px 12px;
	border-radius: 8px;
	background: rgba(255,255,255,0.03);
	border: 1px solid rgba(255,255,255,0.08);
	color: var(--muted);
}

.profile-section h2 {
	margin: 0 0 10px;
	font-family: 'Cinzel', serif;
	font-size: 1.15rem;
	color: var(--text);
}

.container p { margin-top: 16px; color: var(--muted); }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.hr { height: 1px; background: linear-gradient(90deg, transparent, rgba(212,175,55,.4), transparent); margin: 16px 0; }

/* Stats bar */
.stats-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	justify-content: center;
	margin: 6px auto 12px;
	padding: 6px 8px;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: 0 8px 16px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.02);
	width: auto;
	max-width: 900px;
	margin-left: auto;
	margin-right: auto;
}
.stats-bar.trade-stocks {
	margin: 0 0 12px 0;
	max-width: 100%;
	justify-content: flex-start;
}
.stats-bar.trade-stocks .stat { min-width: 72px; }
.stats-compare {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	justify-content: center;
	align-items: flex-start;
	margin: 8px auto 16px;
}
.game-stats-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	justify-content: center;
	align-items: stretch;
	margin: 8px auto 16px;
}

.player-compare-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	align-items: start;
}

.player-compare-grid .game-stats-card {
	min-width: 0;
	flex: initial;
}
.game-stats-card {
	flex: 1 1 320px;
	min-width: 280px;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	border-radius: 10px;
	box-shadow: 0 8px 16px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.02);
	padding: 12px 12px 10px;
}
.game-stats-card.overview-card { border-top: 2px solid rgba(250, 204, 21, 0.7); }
.game-stats-card.actions-card { border-top: 2px solid rgba(96, 165, 250, 0.7); }
.game-stats-card.player-card { border-top: 2px solid rgba(34, 197, 94, 0.7); }
.game-stats-card.resources-card { border-top: 2px solid rgba(234, 179, 8, 0.7); }
.game-stat-list {
	display: grid;
	gap: 6px;
}
.game-stat-item {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 6px 8px;
	border-radius: 8px;
	background: rgba(255,255,255,0.02);
}
.game-stat-item.stat-inline .game-stat-label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.stats-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.stats-title-icon {
	width: 18px;
	height: 18px;
	display: inline-flex;
	color: var(--cap);
}
.stats-title-icon svg {
	width: 18px;
	height: 18px;
}
.stat-icon {
	width: 16px;
	height: 16px;
	display: inline-flex;
}
.stat-icon svg {
	width: 16px;
	height: 16px;
	stroke: currentColor;
	fill: none;
	stroke-width: 2px;
}
.stat-icon.wood { color: var(--wood); }
.stat-icon.stone { color: var(--stone); }
.stat-icon.iron { color: var(--iron); }
.stat-icon.food { color: var(--food); }
.stat-icon.pop { color: var(--pop); }
.game-stat-label {
	color: var(--muted);
	font-weight: 600;
}
.game-stat-value {
	color: var(--text);
	font-weight: 700;
	text-align: right;
}

.player-action-chart {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: 12px;
	align-items: center;
	padding: 8px;
	margin-bottom: 8px;
	border-radius: 10px;
	background: rgba(255,255,255,0.02);
	border: 1px solid rgba(255,255,255,0.04);
}

.chart-section-title {
	margin: 6px 2px 6px;
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--muted);
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.player-action-pie {
	width: 110px;
	height: 110px;
	border-radius: 50%;
	background: var(--pie-gradient, conic-gradient(#2a3447 0deg 360deg));
	position: relative;
	border: 1px solid rgba(255,255,255,0.1);
	box-shadow: inset 0 1px 2px rgba(0,0,0,0.4), 0 6px 12px rgba(0,0,0,0.25);
}

.player-action-pie::after {
	content: "";
	position: absolute;
	inset: 23%;
	border-radius: 50%;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid rgba(255,255,255,0.06);
	box-shadow: inset 0 1px 2px rgba(0,0,0,0.45);
}

.player-action-legend {
	display: grid;
	gap: 5px;
}

.action-legend-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 4px 6px;
	border-radius: 6px;
	background: rgba(255,255,255,0.02);
}

.action-legend-label {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	color: var(--muted);
	font-weight: 600;
}

.action-legend-icon {
	width: 18px;
	height: 18px;
	display: inline-flex;
	color: var(--text);
	opacity: 0.95;
	flex: 0 0 auto;
}

.action-legend-icon svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
	stroke: currentColor;
}

.action-legend-value {
	color: var(--text);
	font-weight: 700;
	font-size: 0.92rem;
}

@media (max-width: 700px) {
	.player-action-chart {
		grid-template-columns: 1fr;
		justify-items: center;
	}
	.player-action-legend {
		width: 100%;
	}
}

@media (max-width: 900px) {
	.player-compare-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
	}
	.player-compare-grid .game-stats-card {
		padding: 10px 8px;
	}
	.player-compare-grid .stats-title {
		font-size: 0.95rem;
	}
	.player-compare-grid .game-stat-item {
		padding: 5px 6px;
		gap: 8px;
	}
	.player-compare-grid .game-stat-label,
	.player-compare-grid .game-stat-value {
		font-size: 0.84rem;
	}
	.player-compare-grid .chart-section-title {
		font-size: 0.75rem;
		margin: 4px 2px;
	}
	.player-compare-grid .player-action-chart {
		grid-template-columns: 1fr;
		justify-items: center;
		padding: 6px;
		gap: 8px;
	}
	.player-compare-grid .player-action-pie {
		width: 72px;
		height: 72px;
	}
	.player-compare-grid .player-action-legend {
		width: 100%;
		gap: 4px;
	}
	.player-compare-grid .action-legend-item {
		padding: 3px 4px;
		gap: 6px;
	}
	.player-compare-grid .action-legend-label,
	.player-compare-grid .action-legend-value {
		font-size: 0.74rem;
	}
	.player-compare-grid .action-legend-icon,
	.player-compare-grid .action-legend-icon svg {
		width: 14px;
		height: 14px;
	}
}
.stats-card {
	min-width: 280px;
	flex: 1 1 320px;
}
.stats-title {
	text-align: center;
	font-weight: 700;
	color: var(--text);
	margin-bottom: 6px;
}
.stat {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	padding: 4px 10px;
	min-width: 88px;
	border-radius: 8px;
	background: rgba(255,255,255,0.02);
}
.stat + .stat { border-left: none; padding-left: 0; }
.stat.opp-resources {
	min-width: 1px;
	min-height: 1px;
	padding: 1px 1px;
	align-items: center;
	justify-content: center;
}
.stat.opp-resources .stat-row { gap: 0; width: 100%; justify-content: center; }
.stat.opp-resources #opp-resources-btn { padding: 0; width: 36px; height: 36px; min-height: 36px; }
.stat-row { display: flex; align-items: center; gap: 6px; }
.stat .icon { width: 18px; height: 18px; display: inline-flex; color: var(--muted); }
.stat .icon svg { width: 18px; height: 18px; }
/* Resource stats: use outline stroke style for consistency with resource markers */
.stat.wood .icon svg,
.stat.stone .icon svg,
.stat.iron .icon svg,
.stat.food .icon svg { stroke: currentColor; fill: none; stroke-width: 2px; }
.stat .label { color: var(--muted); font-weight: 600; }
.stat .value { color: var(--text); font-family: 'Cinzel', serif; display: inline-flex; align-items: baseline; gap: 1px; }
.stat .value .cur { font-weight: 700; }
.stat .value .sep { color: var(--muted); font-size: 0.9em; }
.stat .value .max { color: var(--muted); font-size: 0.85em; opacity: 0.95; }
.stat .value .yield { color: var(--yield); font-size: 0.85em; font-weight: 700; margin-left: 6px; }
.stat .value .yield.neg { color: var(--danger); }

/* mini progress bar */
.bar {
	width: 120px;
	height: 6px;
	background: #0f1424;
	border: 1px solid var(--border);
	border-radius: 6px;
	overflow: hidden;
}
.bar-fill {
	height: 100%;
	background: var(--muted);
}
.bar-fill.wood { background: var(--wood); }
.bar-fill.stone { background: var(--stone); }
.bar-fill.iron { background: var(--iron); }
.bar-fill.food { background: var(--food); }
.bar-fill.pop { background: var(--pop); }
.bar-fill.score { background: var(--cap); }

/* Inline logout button in brand */
.logout-brand button {
	width: auto;
	min-height: 32px;
	padding: 6px 10px;
	font-size: .9rem;
}

/* Start game button in header/top panel */
.container.wide > .start-game {
	display: flex;
	justify-content: center;
	margin: 10px auto 4px;
}

.start-game button {
	width: auto;
	min-height: 36px;
	padding: 8px 14px;
	font-size: .95rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	border-radius: 999px;
	border: 1px solid rgba(212,175,55,0.85);
	background: #d4af37;
	color: #1f1300;
	box-shadow: 0 8px 18px rgba(212,175,55,0.30), inset 0 1px 0 rgba(255,255,255,0.30);
	transition: transform 0.14s ease, filter 0.18s ease, box-shadow 0.2s ease;
}

.start-game button:hover {
	transform: translateY(-1px);
	filter: brightness(1.05);
	box-shadow: 0 10px 20px rgba(212,175,55,0.36), inset 0 1px 0 rgba(255,255,255,0.34);
}

.start-game button:focus-visible {
	outline: 2px solid rgba(212,175,55,0.95);
	outline-offset: 2px;
}

/* Global logout bar outside container */
/* remove global logout bar styles (not used) */

/* accents per resource: icon colors only */
.stat.wood .icon { color: var(--wood); }
.stat.stone .icon { color: var(--stone); }
.stat.iron .icon { color: var(--iron); }
.stat.food .icon { color: var(--food); }
.stat.pop .icon { color: var(--pop); }
.stat.score .icon { color: #fff; }
.stat.wood { background: linear-gradient(180deg, rgba(127,191,79,0.10), rgba(127,191,79,0.02)); }
.stat.stone { background: linear-gradient(180deg, rgba(107,114,128,0.10), rgba(107,114,128,0.02)); }
.stat.iron { background: linear-gradient(180deg, rgba(154,164,178,0.10), rgba(154,164,178,0.02)); }
.stat.food { background: linear-gradient(180deg, rgba(212,175,55,0.10), rgba(212,175,55,0.02)); }
.stat.pop { background: linear-gradient(180deg, rgba(192,132,252,0.10), rgba(192,132,252,0.02)); }
.stat.score { background: linear-gradient(180deg, rgba(96,165,250,0.10), rgba(96,165,250,0.02)); }

@media (max-width: 420px) {
	.stats-bar { gap: 6px; padding: 6px 8px; }
	.stat { padding: 4px 8px; min-width: 72px; }
	.stat .icon { width: 16px; height: 16px; }
	.stat .icon svg { width: 16px; height: 16px; }
	.bar { width: 100%; }
}

@media (max-width: 540px) {
	.build-toolbar { flex-direction: row; align-items: center; }
	.build-toolbar .menu { width: auto; }
	.build-toolbar .menu #build-toggle,
	.build-toolbar .menu #worker-toggle { width: auto; }
	.dropdown {
		position: absolute;
		top: 38px;
		left: 50%;
		transform: translateX(-50%) translateY(0);
		width: auto;
		max-width: 420px;
		margin: 0;
		box-shadow: 0 10px 22px rgba(0,0,0,.35);
	}
}

/* Wider dropdown on larger screens for better readability */
@media (min-width: 540px) {
	.dropdown { min-width: 300px; max-width: 420px; }
}

/* Grass field (big green square) */
.grass-field {
	width: min(100%, 85vh, 900px);
	max-width: 900px;
	aspect-ratio: 1 / 1;
	margin: 16px auto 24px;
	border-radius: 12px;
	border: 1px solid #1f3a2e;
	box-shadow: 0 20px 40px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
	/* keep the field green across the full area */
	background: linear-gradient(180deg, #184028 0%, #143621 100%);
	position: relative;
}
/* Keep the field textured by layering a grass pseudo-element beneath the grid and walls. */
.grass-field::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	border-radius: 12px;
	pointer-events: none;
	background:
		radial-gradient(1200px 600px at 10% 0%, rgba(127,191,79,.08), rgba(0,0,0,0) 70%),
		repeating-radial-gradient(circle, rgba(255,255,255,.03) 0 1px, rgba(0,0,0,0) 1px 6px),
		repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 1px, rgba(0,0,0,0) 1px 7px),
		linear-gradient(180deg, #184028 0%, #143621 100%);
	background-size: auto, 18px 18px, 24px 24px, auto;
	background-blend-mode: normal, overlay, overlay, normal;
	z-index: 2; /* below grid (z-index:10) and walls (z-index:5) */
}

/* Scoreboard for both players */
.score-board {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin: 8px auto 16px;
	padding: 8px 12px;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	border-radius: 12px;
	box-shadow: 0 12px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.03);
	max-width: 900px;
	width: auto;
}
.score-board .entry { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.score-board .entry span#my-score, .score-board .entry span#opp-score { color: var(--text); font-family: 'Cinzel', serif; }

/* --- All Cities Map --- */
.cities-map {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 16px;
	margin: 16px auto;
}
.city-card {
	border: 1px solid var(--border);
	border-radius: 10px;
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	box-shadow: 0 12px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.03);
	padding: 10px;
}
.city-header {
	font-family: 'Cinzel', serif;
	color: var(--gold);
	font-size: 1rem;
	margin-bottom: 6px;
	text-align: center;
}
.city-grid {
	position: relative;
	width: 100%;
	aspect-ratio: 1/1;
	display: grid;
	gap: 0;
}
.city-grid .grid-cell {
	border: 1px solid rgba(0,0,0,0.15);
	box-sizing: border-box;
	background-color: rgba(0, 128, 0, 0.03);
	position: relative;
}
.city-grid .grid-cell .building {
	position: absolute;
	inset: 2px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	background: rgba(0,0,0,0.18);
	border: 1px solid rgba(255,255,255,0.08);
	box-shadow: 0 6px 12px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.06);
}
/* Walled city overlay */
.city-walls {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	border: 6px solid #2a3e35;
	border-radius: 12px;
	background: linear-gradient(180deg, rgba(20, 30, 24, .25), rgba(20, 30, 24, .05));
	box-shadow: 0 10px 22px rgba(0,0,0,.35), inset 0 2px 6px rgba(255,255,255,.06);
}

@media (max-width: 600px) {
	.grass-field { width: min(100%, 75vh); border-radius: 10px; }
}

/* Mobile adjustments */
@media (max-width: 420px) {
	.brand { margin: 12px auto 0; gap: 8px; }
	.site-brand-logo { width: min(220px, 72vw); }
	.brand .mark { width: 28px; height: 28px; font-size: 14px; }
	.brand .title { font-size: 22px; }

	.container { max-width: calc(100% - 24px); margin: 12px auto; padding: 16px; border-radius: 10px; box-shadow: 0 12px 24px rgba(0,0,0,.45); }
	h1 { font-size: 1.4rem; }
	label { margin: 10px 0; }

	input[type="text"], input[type="password"] { font-size: 16px; padding: 12px 12px; }
	button { font-size: 16px; padding: 12px; letter-spacing: .4px; }
}

/* Safe area for devices with notches */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }

/* ------------------------------------------------------------------
   R1 HUD hierarchy pass (game pages)
   Scope to pages with an active game id to avoid touching auth screens.
------------------------------------------------------------------ */
body[data-game-id] .brand {
	max-width: 900px;
	margin: 14px auto 4px;
	padding: 6px 10px;
}

body[data-game-id] #score-board {
	max-width: 900px;
	margin: 6px auto 8px;
	padding: 10px;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	background: linear-gradient(180deg, rgba(16, 22, 34, 0.92), rgba(14, 20, 30, 0.88));
	border: 1px solid rgba(93, 113, 147, 0.28);
	border-radius: 12px;
	box-shadow: 0 10px 22px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.03);
}

body[data-game-id] #score-board .entry {
	width: 100%;
	min-height: 38px;
	padding: 6px 10px;
	justify-content: center;
	gap: 8px;
	font-size: .86rem;
}

body[data-game-id] #score-board .entry .name {
	max-width: 46%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

body[data-game-id] #score-board .entry .icon {
	opacity: 0.9;
}

body[data-game-id] #score-board .entry span#my-score,
body[data-game-id] #score-board .entry span#opp-score {
	font-size: 1.02rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}

body[data-game-id] #stats-bar {
	max-width: 900px;
	margin: 0 auto 10px;
	padding: 8px 10px;
	gap: 8px;
	background: linear-gradient(180deg, rgba(18, 24, 38, 0.95), rgba(14, 20, 30, 0.9));
	border-color: rgba(93, 113, 147, 0.30);
	box-shadow: 0 10px 20px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.03);
}

body[data-game-id] #stats-bar .stat {
	min-width: 128px;
	padding: 6px 8px;
	border: 1px solid rgba(255,255,255,0.05);
	border-radius: 8px;
}

body[data-game-id] #stats-bar .stat.opp-resources {
	min-width: auto;
	padding: 4px 6px;
	background: transparent;
	border-color: transparent;
}

body[data-game-id] .build-toolbar {
	max-width: 900px;
	margin: 8px auto 10px;
	gap: 12px;
	position: relative;
	z-index: 30;
}

body[data-game-id] .build-toolbar .menu > #action-toggle,
body[data-game-id] .build-toolbar .menu > #build-toggle {
	min-height: 36px;
	padding: 7px 12px;
	font-size: .92rem;
	letter-spacing: .02em;
	font-weight: 800;
	border-radius: 999px;
	border: 1px solid rgba(212,175,55,0.85);
	background: #d4af37;
	color: #1f1300;
	box-shadow: 0 8px 16px rgba(0,0,0,0.42);
	transition: transform 0.14s ease, filter 0.18s ease, box-shadow 0.2s ease;
}

body[data-game-id] .build-toolbar .menu > #action-toggle:hover,
body[data-game-id] .build-toolbar .menu > #build-toggle:hover {
	transform: translateY(-1px);
	filter: brightness(1.05);
	box-shadow: 0 10px 20px rgba(0,0,0,0.50);
}

body[data-game-id] .build-toolbar .menu > #action-toggle:focus-visible,
body[data-game-id] .build-toolbar .menu > #build-toggle:focus-visible {
	outline: 2px solid rgba(212,175,55,0.95);
	outline-offset: 2px;
}

body[data-game-id] .build-toolbar .menu > #action-toggle:disabled,
body[data-game-id] .build-toolbar .menu > #action-toggle[disabled],
body[data-game-id] .build-toolbar .menu > #build-toggle:disabled,
body[data-game-id] .build-toolbar .menu > #build-toggle[disabled] {
	opacity: 0.55;
	filter: grayscale(0.25) brightness(0.95);
	box-shadow: 0 4px 10px rgba(0,0,0,0.22);
	cursor: not-allowed;
}

.brand-right .options-menu #options-toggle {
	min-height: 36px;
	padding: 8px 14px;
	font-size: .95rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	border-radius: 999px;
	border: 1px solid rgba(212,175,55,0.85);
	background: #d4af37;
	color: #1f1300;
	box-shadow: 0 8px 16px rgba(0,0,0,0.42);
	transition: transform 0.14s ease, filter 0.18s ease, box-shadow 0.2s ease;
}

.brand-right .options-menu #options-toggle svg {
	color: #1f1300;
}

.brand-right .options-menu #options-toggle:hover {
	transform: translateY(-1px);
	filter: brightness(1.05);
	box-shadow: 0 10px 20px rgba(0,0,0,0.50);
}

.brand-right .options-menu #options-toggle:focus-visible {
	outline: 2px solid rgba(212,175,55,0.95);
	outline-offset: 2px;
}

body[data-game-id] #place-msg.hint {
	max-width: 900px;
	margin: 10px auto 12px;
	padding: 8px 12px;
	font-size: 1rem;
	background-image: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.012));
	border-color: rgba(255,255,255,0.08);
}

body[data-game-id] .grass-field {
	margin-top: 10px;
}

@media (max-width: 860px) {
	body[data-game-id] #score-board {
		grid-template-columns: 1fr;
		gap: 8px;
	}

	body[data-game-id] #score-board .entry .name {
		max-width: 56%;
	}
}

@media (max-width: 640px) {
	body[data-game-id] .brand {
		margin-top: 10px;
	}

	body[data-game-id] #score-board {
		padding: 8px;
		margin: 6px 8px 8px;
	}

	body[data-game-id] #score-board .entry {
		min-height: 34px;
		padding: 6px 8px;
		font-size: .82rem;
	}

	body[data-game-id] #stats-bar {
		margin: 0 8px 8px;
		padding: 7px;
		gap: 6px;
	}

	body[data-game-id] #stats-bar .stat {
		min-width: 108px;
		padding: 5px 7px;
	}

	body[data-game-id] .build-toolbar {
		margin: 8px auto 8px;
		gap: 8px;
	}

	body[data-game-id] #place-msg.hint {
		margin: 8px 8px 10px;
		padding: 7px 10px;
	}
}

/* ------------------------------------------------------------------
   Dialog components (R1)
------------------------------------------------------------------ */
.blocked { pointer-events: none !important; opacity: 0.6; }

.fc-dialog-overlay {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0,0,0,0.75);
	backdrop-filter: blur(2px);
	padding: 14px;
}

.fc-dialog-overlay--soft {
	background: rgba(0,0,0,0.72);
}

.fc-dialog-overlay--finish {
	background: rgba(0,0,0,0.85);
	color: #fff;
	touch-action: auto;
	-webkit-overflow-scrolling: touch;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
}

.fc-dialog-panel {
	width: min(94vw, 520px);
	padding: 18px;
	border-radius: 10px;
	background: linear-gradient(180deg, rgba(12,12,12,0.95), rgba(24,24,24,0.95));
	text-align: left;
	color: #f3f4f6;
	box-shadow: 0 10px 30px rgba(0,0,0,0.62), inset 0 1px 0 rgba(255,255,255,0.03);
	border: 1px solid rgba(255,255,255,0.08);
}

.fc-dialog-panel--xs { width: min(94vw, 480px); }
.fc-dialog-panel--sm { width: min(94vw, 520px); }
.fc-dialog-panel--md { width: min(94vw, 560px); }
.fc-dialog-panel--center { text-align: center; }

.fc-dialog-title {
	margin: 0 0 8px 0;
	color: #fff;
	font-size: 1.1rem;
	font-family: 'Cinzel', serif;
}

.fc-dialog-subtitle {
	margin: 0 0 12px 0;
	color: rgba(230,230,230,0.86);
	font-size: 0.96rem;
	line-height: 1.35;
}

.fc-dialog-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 12px;
	flex-wrap: wrap;
}

.fc-dialog-actions--center {
	justify-content: center;
}

.fc-btn-muted {
	background: transparent;
	color: #e5e7eb;
	border: 1px solid rgba(255,255,255,0.10);
}

.fc-btn-danger {
	background: #ef4444;
	color: #fff;
	border: 1px solid rgba(0,0,0,0.12);
}

.fc-btn-success {
	background: #22c55e;
	color: #0b0f18;
	border: 1px solid rgba(0,0,0,0.12);
}

#finish-overlay .btn {
	display: inline-block;
	padding: 8px 12px;
	background: var(--accent);
	color: #fff;
	border-radius: 6px;
	text-decoration: none;
}

.finish-panel .fc-dialog-title {
	margin-bottom: 10px;
	font-size: 1.25rem;
}

.finish-cancelled {
	margin: 0 0 12px 0;
	padding: 10px;
	border-radius: 6px;
	background: linear-gradient(180deg, rgba(250,204,21,0.12), rgba(250,204,21,0.06));
	color: #b45309;
	font-weight: 700;
}

.finish-cancelled-title {
	font-size: 1.05rem;
}

.finish-cancelled-by {
	font-size: 0.9rem;
	margin-top: 6px;
	color: rgba(180,83,9,0.9);
}

.start-mode-panel {
	position: relative;
}

.start-mode-close {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 24px;
	height: 24px;
	padding: 0;
	border-radius: 6px;
	border: 1px solid rgba(255,255,255,0.15);
	background: rgba(255,255,255,0.03);
	color: #d1d5db;
	font-size: 13px;
	line-height: 1;
	cursor: pointer;
	min-height: 0;
}

.start-mode-stack {
	display: grid;
	gap: 12px;
}

.start-mode-group-title {
	margin: 0 0 6px 2px;
	font-size: 0.88rem;
	font-weight: 700;
	letter-spacing: 0.01em;
}

.start-mode-group-title.human { color: #fef3c7; }
.start-mode-group-title.ai { color: #bfdbfe; }

.start-mode-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}

.mode-btn {
	font-weight: 700;
	text-transform: none;
	letter-spacing: 0;
}

.mode-btn-ranked {
	background: #d4af37;
	color: #1f1300;
	border: 1px solid rgba(212,175,55,0.92);
	font-weight: 800;
	box-shadow: 0 6px 14px rgba(212,175,55,0.32);
}

.mode-btn-practice {
	background: linear-gradient(180deg, #d1d5db, #9ca3af);
	color: #111827;
	border: 1px solid rgba(148,163,184,0.65);
}

.mode-btn-ai-easy {
	background: linear-gradient(180deg, #bfdbfe, #93c5fd);
	color: #0b1b33;
	border: 1px solid rgba(96,165,250,0.55);
}

.mode-btn-ai-medium {
	background: linear-gradient(180deg, #c4b5fd, #a78bfa);
	color: #1f1147;
	border: 1px solid rgba(139,92,246,0.55);
}

.trade-content-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
}

.trade-block {
	display: grid;
	gap: 6px;
}

.trade-opt-list {
	display: flex;
	gap: 8px;
	flex-wrap: nowrap;
}

.trade-opt {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 8px;
	border: 1px solid rgba(255,255,255,0.10);
	background: rgba(15,23,42,0.9);
	min-height: 0;
}

.trade-opt[data-value="wood"] { color: var(--wood); }
.trade-opt[data-value="stone"] { color: var(--stone); }
.trade-opt[data-value="iron"] { color: var(--iron); }
.trade-opt[data-value="food"] { color: var(--food); }

.trade-opt.selected {
	outline: 2px solid rgba(34,197,94,0.7);
	box-shadow: 0 0 0 2px rgba(34,197,94,0.3) inset;
}

.trade-strong {
	color: #f8fafc;
}

.trade-range {
	width: 100%;
}

.trade-limit {
	font-size: 0.85rem;
	color: var(--muted);
}

.trade-error {
	color: #fca5a5;
	font-weight: 600;
}

.opp-resources-name {
	margin-bottom: 8px;
}

.opp-resources-status {
	font-size: 0.9rem;
	color: #fca5a5;
	margin-bottom: 8px;
}

.opp-resources-list {
	margin-top: 6px;
}

@media (max-width: 640px) {
	.fc-dialog-panel {
		padding: 14px;
	}

	.start-mode-grid {
		grid-template-columns: 1fr;
	}

	.trade-opt-list {
		gap: 6px;
	}

	.fc-dialog-actions {
		justify-content: stretch;
	}

	.fc-dialog-actions .btn {
		flex: 1 1 auto;
	}
}

/* ------------------------------------------------------------------
   Welcome dashboard hierarchy pass (R1)
------------------------------------------------------------------ */
.welcome-dashboard {
	max-width: 1060px;
	padding: 20px 20px 18px;
}

.welcome-dashboard h1 {
	margin-bottom: 12px;
}

.welcome-dashboard-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 14px;
	align-items: start;
}

.welcome-dashboard-grid .welcome-list-section {
	margin-top: 0;
}

.welcome-dashboard-grid .welcome-list-section--active-games {
	grid-column: 1 / -1;
}

.welcome-dashboard-grid .welcome-list-section--games {
	grid-column: 1;
}

.welcome-dashboard-grid .welcome-list-section--leaderboard {
	grid-column: 2;
}

.welcome-dashboard-grid .welcome-list-title {
	justify-content: flex-start;
	font-size: 23px;
	padding-left: 2px;
}

.welcome-dashboard-grid .welcome-list-section--active-games .welcome-list-title {
	font-size: 25px;
}

.welcome-dashboard-grid .welcome-list-surface {
	margin-top: 8px;
	padding: 12px;
	border-radius: 12px;
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 10px 22px rgba(0,0,0,0.24);
	height: 100%;
}

.welcome-dashboard-grid .welcome-list-section--active-games .welcome-list-surface {
	padding: 14px;
	border-width: 1px;
}

.welcome-loading {
	margin-top: 16px;
	text-align: center;
	color: var(--muted);
}

.welcome-loading--tight {
	margin-top: 8px;
}

.welcome-loading-cell {
	text-align: center;
	color: var(--muted);
}

.welcome-pager {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	margin-top: 12px;
	width: 100%;
	box-sizing: border-box;
}

.welcome-dashboard-grid .finished-games {
	table-layout: auto;
	font-size: 0.92rem;
}

.welcome-dashboard-grid .finished-games th,
.welcome-dashboard-grid .finished-games td {
	padding: 7px 8px;
	font-size: 0.9rem;
}

.welcome-dashboard-grid #active-games-root .finished-games th,
.welcome-dashboard-grid #active-games-root .finished-games td {
	padding-top: 9px;
	padding-bottom: 9px;
}

.welcome-dashboard-grid #active-games-root .finished-games td:nth-child(2),
.welcome-dashboard-grid #finished-games-root .finished-games td:nth-child(2),
.welcome-dashboard-grid #leaderboard-root .leaderboard-table td:nth-child(2) {
	white-space: normal;
	overflow: visible;
	text-overflow: clip;
	line-height: 1.25;
}

.welcome-dashboard-grid #finished-games-root .finished-games td:nth-child(5) .btn-small {
	padding: 5px 8px;
	font-size: 0.84rem;
}

.welcome-dashboard-grid .score-badge {
	padding: 3px 7px;
	font-size: 0.84rem;
}

@media (max-width: 960px) {
	.welcome-dashboard {
		padding: 16px;
	}

	.welcome-dashboard-grid {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.welcome-dashboard-grid .welcome-list-section--games,
	.welcome-dashboard-grid .welcome-list-section--leaderboard {
		grid-column: 1 / -1;
	}
}

@media (max-width: 640px) {
	.welcome-dashboard {
		padding: 14px 12px;
	}

	.welcome-dashboard-grid .welcome-list-title {
		font-size: 21px;
	}

	.welcome-dashboard-grid .welcome-list-section--active-games .welcome-list-title {
		font-size: 22px;
	}

	.welcome-dashboard-grid .welcome-list-surface {
		padding: 10px;
	}

	.welcome-dashboard-grid .finished-games th,
	.welcome-dashboard-grid .finished-games td {
		padding: 7px 6px;
		font-size: 0.86rem;
	}

	.welcome-dashboard-grid .welcome-pager {
		gap: 6px;
	}

	.welcome-dashboard-grid .welcome-pager .pager-info {
		font-size: 0.82rem;
		text-align: center;
	}
}

/* ------------------------------------------------------------------
   Historical page parity pass (R1)
------------------------------------------------------------------ */
.historical-page .historical-header-card {
	max-width: 900px;
}

.historical-page .historical-score-wrap {
	text-align: center;
	margin-top: 10px;
	margin-bottom: 14px;
}

.historical-page .historical-score-grid {
	display: inline-flex;
	align-items: flex-end;
	gap: 24px;
	padding: 10px 14px;
	border-radius: 12px;
	background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
	border: 1px solid rgba(255,255,255,0.08);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 10px 20px rgba(0,0,0,0.25);
}

.historical-page .historical-score-player {
	text-align: center;
	min-width: 170px;
}

.historical-page .historical-score-name {
	font-size: 14px;
	color: var(--muted);
	margin-bottom: 6px;
}

.historical-page .historical-score-link {
	color: inherit;
	text-decoration: underline;
}

.historical-page .historical-score-value {
	font-size: 48px;
	font-weight: 800;
	line-height: 1;
	font-family: 'Cinzel', serif;
}

.historical-page .historical-score-elo {
	font-size: 14px;
	color: var(--muted);
	margin-top: 6px;
}

.historical-page .historical-score-divider {
	font-size: 28px;
	color: var(--muted);
	align-self: center;
}

.historical-page .historical-result-line {
	text-align: center;
	font-size: 1.15rem;
	font-weight: 700;
	margin: 6px 0;
}

.historical-page .historical-cancel-note {
	text-align: center;
	color: var(--muted);
	margin: 4px 0;
}

.historical-page .historical-back-link {
	text-align: center;
	margin-top: 8px;
}

.historical-page .historical-color-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	justify-content: center;
	margin: 8px 0 12px;
}

@media (max-width: 760px) {
	.historical-page .historical-score-grid {
		display: grid;
		grid-template-columns: 1fr;
		gap: 12px;
		padding: 10px;
		width: min(100%, 420px);
	}

	.historical-page .historical-score-divider {
		display: none;
	}

	.historical-page .historical-score-player {
		min-width: 0;
	}

	.historical-page .historical-score-value {
		font-size: 40px;
	}
}

/* ------------------------------------------------------------------
   Auth pages redesign (middeleeuwse hero + branding)
------------------------------------------------------------------ */
body.auth-page {
	--auth-parchment: #f3e7cb;
	--auth-ink: #2b2016;
	--auth-accent: #d2a24a;
	--auth-accent-dark: #936b27;
	--auth-panel: rgba(14, 20, 30, 0.9);
	--auth-panel-edge: rgba(219, 180, 102, 0.34);
	background:
		radial-gradient(1300px 620px at 10% -6%, rgba(229, 193, 116, 0.22), rgba(0,0,0,0) 62%),
		radial-gradient(1000px 520px at 96% 0%, rgba(120, 149, 194, 0.2), rgba(0,0,0,0) 58%),
		linear-gradient(170deg, #131c29 0%, #0c141f 52%, #0a121c 100%);
	overflow-x: hidden;
}

body.auth-page.auth-page--login,
body.auth-page.auth-page--register {
	background: #0c141f;
}

body.welcome-page {
	background:
		radial-gradient(1300px 620px at 10% -6%, rgba(229, 193, 116, 0.22), rgba(0,0,0,0) 62%),
		radial-gradient(1000px 520px at 96% 0%, rgba(120, 149, 194, 0.2), rgba(0,0,0,0) 58%),
		linear-gradient(170deg, #131c29 0%, #0c141f 52%, #0a121c 100%);
	overflow-x: hidden;
}

body.welcome-page .welcome-dashboard {
	background:
		linear-gradient(178deg, rgba(13,20,31,0.94), rgba(10,16,25,0.95)),
		linear-gradient(135deg, rgba(209,163,73,0.08), rgba(0,0,0,0));
	border: 1px solid rgba(219, 180, 102, 0.3);
	box-shadow: 0 24px 44px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
	border-radius: 16px;
}

@media (max-width: 760px) {
	body.welcome-page .welcome-dashboard {
		border-radius: 12px;
	}
}

body.auth-page .auth-shell {
	max-width: 1080px;
	margin: 0 auto;
	padding: 22px 18px 30px;
	animation: auth-fade-in 420ms ease-out;
}

body.auth-page .auth-hero {
	position: relative;
	padding: 16px;
	border-radius: 18px;
	border: 1px solid rgba(194, 152, 70, 0.32);
	background: linear-gradient(145deg, rgba(10,15,23,0.94), rgba(17,25,37,0.88));
	box-shadow: 0 18px 30px rgba(0,0,0,0.34), inset 0 1px 0 rgba(255,255,255,0.05);
	overflow: hidden;
	margin-bottom: 20px;
}

body.auth-page .auth-hero::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(90deg, rgba(246, 218, 148, 0.16), rgba(246,218,148,0) 40%);
	mix-blend-mode: screen;
}

body.auth-page .auth-brand {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 6px 4px 12px;
}

body.auth-page .auth-brand-logo {
	width: clamp(180px, 34vw, 300px);
	height: auto;
	filter: drop-shadow(0 10px 16px rgba(0,0,0,0.45));
	flex: 0 0 auto;
}

body.auth-page .auth-brand-copy {
	min-width: 0;
}

body.auth-page .auth-overline {
	margin: 0;
	font-family: 'Cinzel', serif;
	font-size: clamp(1rem, 2.3vw, 1.45rem);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: #f2d79a;
	text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

body.auth-page .auth-subline {
	margin: 6px 0 0;
	font-size: clamp(1rem, 1.85vw, 1.18rem);
	line-height: 1.3;
	color: #d5dfef;
	max-width: 52ch;
}

body.auth-page .auth-hero-art {
	display: block;
	width: 100%;
	height: clamp(116px, 22vw, 190px);
	object-fit: cover;
	border-radius: 12px;
	border: 1px solid rgba(214, 178, 103, 0.24);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
	opacity: 0.86;
	position: relative;
	z-index: 1;
}

body.auth-page .container.auth-card {
	max-width: 560px;
	margin: 0 auto;
	padding: 26px;
	background:
		linear-gradient(178deg, rgba(13,20,31,0.95), rgba(10,16,25,0.96)),
		linear-gradient(135deg, rgba(209,163,73,0.08), rgba(0,0,0,0));
	border: 1px solid var(--auth-panel-edge);
	border-radius: 16px;
	box-shadow: 0 24px 44px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
	position: relative;
}

body.auth-page .container.auth-card::before {
	content: "";
	position: absolute;
	inset: 10px;
	border-radius: 12px;
	border: 1px solid rgba(255,255,255,0.06);
	pointer-events: none;
}

body.auth-page h1 {
	margin: 0 0 14px;
	font-size: clamp(1.65rem, 4vw, 2.05rem);
	letter-spacing: 0.04em;
	color: var(--auth-parchment);
	text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

body.auth-page label {
	margin: 12px 0 10px;
	font-size: 1.05rem;
	font-weight: 600;
	color: #d8dff0;
}

body.auth-page input[type="text"],
body.auth-page input[type="password"] {
	padding: 12px 13px;
	background: linear-gradient(180deg, #0f1624, #0d1421);
	border: 1px solid rgba(135, 154, 182, 0.34);
	border-radius: 10px;
	color: #ecf2ff;
	box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

body.auth-page input[type="text"]:focus,
body.auth-page input[type="password"]:focus {
	border-color: rgba(235, 190, 96, 0.92);
	box-shadow: 0 0 0 3px rgba(235, 190, 96, 0.16), inset 0 1px 2px rgba(0,0,0,0.65);
}

body.auth-page button {
	margin-top: 8px;
	background: linear-gradient(180deg, #d7ae58, #b38332);
	border: 1px solid rgba(255,231,180,0.42);
	color: var(--auth-ink);
	font-weight: 700;
	letter-spacing: 0.06em;
	box-shadow: 0 12px 20px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
}

body.auth-page button:hover {
	filter: brightness(1.04);
	box-shadow: 0 14px 24px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.45);
}

body.auth-page .error {
	margin-bottom: 12px;
	background: rgba(139, 26, 26, 0.48);
	border-color: rgba(245, 148, 148, 0.34);
	color: #ffd4d4;
}

body.auth-page .auth-switch {
	margin-top: 14px;
	font-size: 1.05rem;
	text-align: center;
	color: #cfdaef;
}

body.auth-page .auth-switch .btn-ghost {
	border-color: rgba(222, 188, 111, 0.3);
	color: #f2d79c;
	background: rgba(213, 165, 67, 0.08);
}

body.auth-page .auth-switch .btn-ghost:hover {
	background: rgba(213, 165, 67, 0.14);
	text-decoration: none;
}

/* Login/Register: merge hero + form into one visual panel */
body.auth-page--login .auth-shell,
body.auth-page--register .auth-shell {
	max-width: 620px;
}

body.auth-page--login .auth-panel,
body.auth-page--register .auth-panel {
	position: relative;
	border: 1px solid rgba(194, 152, 70, 0.32);
	border-radius: 16px;
	background:
		linear-gradient(178deg, rgba(13,20,31,0.95), rgba(10,16,25,0.96)),
		linear-gradient(135deg, rgba(209,163,73,0.08), rgba(0,0,0,0));
	box-shadow: 0 24px 44px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
	overflow: hidden;
}

body.auth-page--login .auth-panel::after,
body.auth-page--register .auth-panel::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(90deg, rgba(246, 218, 148, 0.16), rgba(246,218,148,0) 40%);
	mix-blend-mode: screen;
	z-index: 0;
}

body.auth-page--login .auth-panel::before,
body.auth-page--register .auth-panel::before {
	display: none;
}

body.auth-page--login .auth-hero,
body.auth-page--register .auth-hero {
	margin-bottom: 0;
	border-radius: 0;
	border: none;
	box-shadow: none;
	background: transparent;
	z-index: 1;
}

body.auth-page--login .auth-hero::after,
body.auth-page--register .auth-hero::after {
	display: none;
}

body.auth-page--login .auth-hero-art,
body.auth-page--register .auth-hero-art {
	border-radius: 12px;
}

body.auth-page--login .container.auth-card,
body.auth-page--register .container.auth-card {
	max-width: 100%;
	margin: 0;
	border-radius: 0;
	border: none;
	background: transparent;
	box-shadow: none;
	z-index: 1;
}

body.auth-page--login h1,
body.auth-page--register h1 {
	font-family: 'Cinzel', serif;
	color: #f2d79a;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	text-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

body.auth-page--login .container.auth-card::before,
body.auth-page--register .container.auth-card::before {
	display: none;
}

body.auth-page--login input[type="text"],
body.auth-page--login input[type="password"],
body.auth-page--register input[type="text"],
body.auth-page--register input[type="password"] {
	background: transparent;
	border-color: rgba(133, 154, 185, 0.42);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

body.auth-page--login input[type="text"]::placeholder,
body.auth-page--login input[type="password"]::placeholder,
body.auth-page--register input[type="text"]::placeholder,
body.auth-page--register input[type="password"]::placeholder {
	color: rgba(213, 224, 244, 0.58);
}

body.auth-page--login input[type="text"]:focus,
body.auth-page--login input[type="password"]:focus,
body.auth-page--register input[type="text"]:focus,
body.auth-page--register input[type="password"]:focus {
	background: transparent;
	border-color: rgba(235, 190, 96, 0.92);
	box-shadow: 0 0 0 3px rgba(235, 190, 96, 0.14), inset 0 1px 0 rgba(255,255,255,0.06);
}

@keyframes auth-fade-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (max-width: 760px) {
	body.auth-page .auth-shell {
		padding: 14px 12px 20px;
	}

	body.auth-page .auth-hero {
		padding: 12px;
		margin-bottom: 14px;
	}

	body.auth-page .auth-brand {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	body.auth-page .auth-brand-logo {
		width: min(250px, 74vw);
	}

	body.auth-page .auth-subline {
		max-width: none;
	}

	body.auth-page .container.auth-card {
		max-width: 100%;
		padding: 18px 16px;
		border-radius: 12px;
	}

	body.auth-page .container.auth-card::before {
		inset: 8px;
	}

	body.auth-page--login .auth-shell,
	body.auth-page--register .auth-shell {
		max-width: 100%;
	}

	body.auth-page--login .auth-panel,
	body.auth-page--register .auth-panel {
		border-radius: 12px;
	}

	body.auth-page--login .auth-panel::before,
	body.auth-page--register .auth-panel::before {
		inset: 8px;
		border-radius: 8px;
	}

	body.auth-page--login .auth-hero,
	body.auth-page--register .auth-hero {
		margin-bottom: 0;
	}

	body.auth-page--login .container.auth-card,
	body.auth-page--register .container.auth-card {
		border-radius: 0;
	}
}
