@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 */
}

/* ------------------------------------------------------------------
   Landing + unified auth page
------------------------------------------------------------------ */
body.landing-page {
	--landing-panel-bg: linear-gradient(178deg, rgba(13, 20, 31, 0.94), rgba(10, 16, 25, 0.97));
	--landing-border: rgba(201, 166, 88, 0.34);
	--landing-text: #e7edf8;
	--landing-muted: #b6c2d8;
	--landing-cta: #d8ad56;
	--landing-cta-dark: #ac7f30;
	background: #0c141f;
	color: var(--landing-text);
	min-height: 100vh;
	overflow-x: hidden;
	overflow-y: auto;
	scroll-snap-type: y proximity;
}

body.landing-page .landing-topbar {
	position: sticky;
	top: 0;
	z-index: 120;
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	padding: 12px calc(20px + env(safe-area-inset-right)) 12px calc(20px + env(safe-area-inset-left));
	background: linear-gradient(180deg, rgba(8, 12, 19, 0.92), rgba(8, 12, 19, 0.35));
	backdrop-filter: blur(8px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

body.landing-page .landing-logo {
	width: clamp(160px, 20vw, 250px);
	height: auto;
	display: block;
	filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.45));
}

body.landing-page .landing-play-now {
	background: linear-gradient(180deg, var(--landing-cta), var(--landing-cta-dark));
	border: 1px solid rgba(255, 235, 184, 0.42);
	color: #2b2016;
	font-weight: 700;
	letter-spacing: 0.05em;
	border-radius: 999px;
	padding: 0.65rem 1.25rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: auto;
	min-width: 200px;
	margin-top: 0;
	box-shadow: 0 10px 22px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

body.landing-page .landing-layout {
	display: block;
	padding: 18px 20px 18px;
	max-width: 1480px;
	margin: 0 auto;
}

body.landing-page .landing-scroll {
	height: auto;
	overflow: visible;
	padding-right: 4px;
	scroll-behavior: smooth;
}

body.landing-page .landing-section {
	min-height: calc(100vh - 108px);
	scroll-snap-align: start;
	scroll-snap-stop: normal;
	display: grid;
	grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr);
	gap: 16px;
	align-items: stretch;
	padding: 12px 8px 22px;
}

body.landing-page .landing-auth-panel {
	border-radius: 16px;
	box-shadow: 0 20px 38px rgba(0, 0, 0, 0.589), inset 0 1px 0 rgba(255, 255, 255, 0.05);
	background: var(--landing-panel-bg);
	border: 1px solid var(--landing-border);
}

body.landing-page .landing-section > .landing-surface,
body.landing-page .landing-section > .landing-media-placeholder {
	border: 0;
	background: transparent;
	box-shadow: none;
	border-radius: 0;
}

body.landing-page .landing-surface {
	padding: clamp(18px, 2vw, 30px);
	position: relative;
}

body.landing-page .landing-surface::after {
	content: none;
}

body.landing-page .landing-eyebrow {
	margin: 0;
	font-family: 'Cinzel', serif;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: #f2d79a;
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75), 0 0 2px rgba(0, 0, 0, 0.85);
}

body.landing-page .landing-section h1,
body.landing-page .landing-section h2,
body.landing-page .landing-section h3 {
	margin-top: 0;
	font-family: 'Cinzel', serif;
	color: #f2d79a;
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

body.landing-page .landing-lead,
body.landing-page .landing-section p,
body.landing-page .landing-section li {
	color: var(--landing-text);
	line-height: 1.45;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.45);
}

body.landing-page .landing-section .landing-surface,
body.landing-page .landing-section .landing-surface *,
body.landing-page .landing-section .landing-media-placeholder {
	font-family: 'Cinzel', serif;
}

body.landing-page .landing-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 14px;
}

body.landing-page .landing-card-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	margin-top: 12px;
}

body.landing-page .landing-mini-card {
	border: 0;
	border-radius: 0;
	padding: 12px;
	background: transparent;
}

body.landing-page .landing-flow {
	margin: 0;
	padding-left: 1.2rem;
	display: grid;
	gap: 8px;
}

body.landing-page .landing-media-placeholder {
	min-height: 300px;
	display: grid;
	place-items: center;
	padding: 16px;
	text-align: center;
	color: var(--landing-muted);
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.45);
}

body.landing-page .landing-media-placeholder img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
	border-radius: 12px;
	display: block;
}

body.landing-page .landing-auth-dock {
	position: fixed;
	top: 25%;
	right: 24px;
	transform: translateY(-50%);
	width: min(390px, calc(100vw - 48px));
	z-index: 130;
	display: none;
}

body.landing-page .landing-auth-panel {
	width: 100%;
	height: auto;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: 18px;
}

body.landing-page .landing-auth-tabs {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
	gap: 8px;
	margin-bottom: 12px;
}

body.landing-page .landing-tab {
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: rgba(255, 255, 255, 0.03);
	color: var(--landing-text);
	padding: 0.45rem 0.55rem;
	border-radius: 10px;
	font-size: 0.9rem;
	font-weight: 600;
}

body.landing-page .landing-tab.is-active {
	background: rgba(215, 173, 88, 0.16);
	border-color: rgba(215, 173, 88, 0.52);
	color: #f8e0ac;
}

body.landing-page .landing-auth-view {
	display: none;
}

body.landing-page .landing-auth-view.is-active {
	display: block;
}

body.landing-page .landing-link-btn {
	padding: 0;
	background: none;
	border: 0;
	font: inherit;
	cursor: pointer;
	color: inherit;
	text-decoration: underline;
	display: inline;
	width: auto;
	margin: 0;
	box-shadow: none;
	letter-spacing: normal;
	text-transform: none;
	vertical-align: baseline;
}

body.landing-page .landing-auth-modal {
	position: fixed;
	inset: 0;
	z-index: 190;
	display: none;
}

body.landing-page .landing-auth-modal.is-open {
	display: block;
}

body.landing-page .landing-auth-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(2, 5, 11, 0.78);
	backdrop-filter: blur(6px);
}

body.landing-page .landing-auth-modal-body {
	position: absolute;
	left: 10px;
	right: 10px;
	bottom: 10px;
	max-height: calc(100vh - 104px);
	border: 0;
	border-radius: 16px;
	background: transparent;
	box-shadow: none;
	overflow: visible;
	display: flex;
	flex-direction: column;
	overflow-y: visible;
	padding: 0;
	min-height: 0;
}

body.landing-page .auth-footer-bar {
	position: static;
	background: linear-gradient(180deg, rgba(8, 12, 19, 0.35), rgba(8, 12, 19, 0.92));
	backdrop-filter: blur(6px);
}

@media (prefers-reduced-motion: reduce) {
	body.landing-page .landing-scroll {
		scroll-behavior: auto;
	}
}

@media (max-width: 1100px) {
	body.landing-page .landing-card-grid {
		grid-template-columns: 1fr;
	}
}

@media (min-width: 961px) {
	body.landing-page .landing-auth-modal-body {
		left: 50%;
		right: auto;
		top: 50%;
		bottom: auto;
		transform: translate(-50%, -50%);
		width: min(390px, calc(100vw - 48px));
		max-height: calc(100vh - 32px);
		padding: 0;
	}

	body.landing-page .landing-auth-modal-body .landing-auth-panel {
		max-height: calc(100vh - 32px);
		overflow-y: auto;
	}

	body.landing-page .landing-section > .landing-surface {
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
}

@media (max-width: 960px) {
	body.landing-page .landing-auth-modal-body {
		left: 50%;
		right: auto;
		top: 50%;
		bottom: auto;
		transform: translate(-50%, -50%);
		width: min(390px, calc(100vw - 20px));
		max-height: calc(100vh - 20px);
		padding: 0;
		overflow-y: visible;
	}

	body.landing-page .landing-auth-modal-body .landing-auth-panel {
		max-height: calc(100vh - 20px);
		overflow-y: auto;
	}

	body.landing-page .landing-layout {
		display: block;
		height: auto;
		padding-top: 14px;
		padding-bottom: 62px;
	}

	body.landing-page .landing-scroll {
		height: auto;
		overflow: visible;
	}

	body.landing-page .landing-section {
		min-height: auto;
		grid-template-columns: 1fr;
		padding: 8px 2px 14px;
	}

	body.landing-page .landing-auth-dock {
		display: none;
	}
}

@media (max-width: 640px) {
	body.landing-page .landing-topbar {
		padding: 10px calc(12px + env(safe-area-inset-right)) 10px calc(12px + env(safe-area-inset-left));
	}

	body.landing-page .landing-logo {
		width: min(180px, 52vw);
	}

	body.landing-page .landing-play-now {
		padding: 0.55rem 1rem;
		font-size: 0.9rem;
	}
}

/* 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.16);
	box-sizing: border-box;
	background-color: transparent;
	position: relative; /* allow building marker positioning */
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.035), inset 0 -1px 0 rgba(0,0,0,0.12);
	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: transparent;
}

/* 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;
}

#city-grid.move-mode .grid-cell .cell-tooltip {
	display: none;
}

/* 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: none;
	box-shadow: none;
	overflow: visible;
	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; overflow: visible; }
/* 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;
}
#city-grid .grid-cell .resource .label img {
	width: 115%;
	height: 115%;
	max-width: 115%;
	max-height: 115%;
	display: block;
	object-fit: contain;
	transform: translateY(-6%);
}
#city-grid .grid-cell .building .label img {
	width: 115%;
	height: 115%;
	max-width: 115%;
	max-height: 115%;
	display: block;
	object-fit: contain;
	transform: translateY(-6%);
}
#city-grid .grid-cell .worker .label img {
	width: 95%;
	height: 95%;
	max-width: 100%;
	max-height: 100%;
	display: block;
	object-fit: contain;
}

/* 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;
}
/* 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 .cell-tooltip {
	position: absolute;
	bottom: calc(100% + 6px);
	right: 0;
	padding: 8px 10px;
	min-width: 170px;
	max-width: min(280px, calc(100vw - 24px));
	font-size: 14px;
	line-height: 1.2;
	border-radius: 6px;
	background: rgba(0,0,0,0.9);
	color: #fff;
	white-space: pre-line;
	overflow-wrap: break-word;
	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: 999;
}
#city-grid .grid-cell .cell-tooltip.cell-tooltip--below {
	top: calc(100% + 6px);
	bottom: auto;
	transform: translateY(-4px);
}
#city-grid .grid-cell:hover .cell-tooltip {
	opacity: 1;
	transform: translateY(0);
}

#city-grid .grid-cell:hover {
	z-index: 60;
}

#city-grid .grid-cell:hover .worker {
	z-index: 70;
}

/* 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,
.build-toolbar .dropdown .icon img {
	width: var(--hud-icon-size, 20px);
	height: var(--hud-icon-size, 20px);
	display: inline-block;
	vertical-align: text-bottom;
}
/* 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;
	--sky-bg-gradient:
		radial-gradient(1300px 640px at 12% -8%, rgba(126, 203, 255, 0.24), rgba(0,0,0,0) 58%),
		radial-gradient(1000px 540px at 96% 0%, rgba(63, 150, 224, 0.22), rgba(0,0,0,0) 60%),
		linear-gradient(180deg, #031c39 0%, #2b5677 45%, #002041 100%);
	--text: #e5e7eb;
	--muted: #a1a5b5;
	--gold: #f1dda7;
	--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: var(--sky-bg-gradient);
	color: var(--text);
	min-height: 100vh;
}

body:not(.auth-page):not(.welcome-page) {
	background: var(--sky-bg-gradient);
}

.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: 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;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	align-self: center;
	height: 36px;
	margin-top: 0;
}
.brand-right .options-menu #options-toggle svg { display:block; color: #1f1300; }
.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); }
.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;
}
.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; }

.auth-footer-bar {
	position: static;
	padding: 8px 2px calc(8px + env(safe-area-inset-bottom));
	text-align: center;
	backdrop-filter: none;
}

.auth-footer-bar p {
	margin: 0;
	font-family: 'Cinzel', serif;
	font-size: 0.82rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.auth-footer-bar a {
	color: inherit;
	text-decoration: underline;
}

/* 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-home-link,
.auth-brand-link {
	display: inline-flex;
	text-decoration: none;
}
.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-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);
}

.welcome-list-section {
	margin-top: 24px;
}

.welcome-list-title {
	margin: 0;
	text-align: center;
	font-size: 24px;
	letter-spacing: 0.3px;
	font-family: 'Cinzel', serif;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.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: 0;
	padding: 14px;
	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);
}

.welcome-list-surface .welcome-list-title {
	margin: 0 auto 12px;
	padding: 10px 28px;
	width: min(100%, 332px);
	min-height: 56px;
	border-radius: 0;
	border: 0;
	background: url('assets/titel_background.png') center / 100% 100% no-repeat;
	box-shadow: none;
	line-height: 1.2;
	font-size: 20px;
}

.welcome-list-surface--active-games .welcome-list-title {
	border: 0;
	background: url('assets/titel_background.png') center / 100% 100% no-repeat;
}

.welcome-list-surface--games .welcome-list-title {
	border: 0;
	background: url('assets/titel_background.png') center / 100% 100% no-repeat;
}

.welcome-list-surface--leaderboard .welcome-list-title {
	border: 0;
	background: url('assets/titel_background.png') center / 100% 100% no-repeat;
}

.welcome-list-surface--games {
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	box-shadow: 0 20px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.03);
}

.welcome-list-surface--active-games {
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	box-shadow: 0 20px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.03);
}

.welcome-list-surface--queued-games {
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	box-shadow: 0 20px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.03);
}

.welcome-list-surface--leaderboard {
	background: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	box-shadow: 0 20px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.03);
}

#active-games-root,
#queued-games-root,
#finished-games-root,
#leaderboard-root {
	min-height: 48px;
}

#queued-games-root .finished-games tbody tr:hover td {
	background: rgba(212,175,55,0.12);
}

#queued-games-root .finished-games {
	table-layout: auto;
}

#queued-games-root .finished-games th:nth-child(1),
#queued-games-root .finished-games td:nth-child(1),
#queued-games-root .finished-games th:nth-child(2),
#queued-games-root .finished-games td:nth-child(2),
#queued-games-root .finished-games th:nth-child(3),
#queued-games-root .finished-games td:nth-child(3) {
	width: 1%;
	white-space: nowrap;
}

#queued-games-root .finished-games td:nth-child(3) .btn-small {
	white-space: nowrap;
}

.queued-status-cell {
	text-align: left;
}

.queued-status-pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	color: rgba(243,248,255,0.92);
}

.matchmaking-countdown {
	font-variant-numeric: tabular-nums;
	color: #b9fff5;
}

.countdown-expired {
	color: #ffb4a8;
}

.queued-status-pill::before {
	content: "";
	flex: 0 0 12px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 2px solid rgba(255,255,255,0.35);
	border-top-color: rgba(255,255,255,0.98);
	will-change: transform;
	animation: spin 1s linear infinite;
}

#active-games-root .finished-games tbody tr:hover td {
	background: rgba(212,175,55,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;
}


#finished-games-root .finished-games tbody tr:hover td {
	background: rgba(212,175,55,0.12);
}

#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) {
	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: #f3f8ff;
	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(96,165,250,0.12);
	color: #60a5fa;
}

#active-games-root .finished-games tr.active-game td {
	border-left: none;
}

#active-games-root .finished-games tr.active-game .score-badge {
	background: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14));
	color: #fff;
	border: 1px solid rgba(212,175,55,0.28);
}

#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(249, 115, 22, 0.56);
	background: rgba(249, 115, 22, 0.18);
	color: #fff2e8;
}
.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: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
	max-width: 640px;
	margin: 0 auto;
	width: min(100%, 640px);
}
.score-board .entry {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	align-items: center;
	gap: 6px;
	min-width: 0;
	padding: 20px 10px 6px;
	border-radius: 7px;
	font-family: 'Cinzel', serif;
	font-size: .78rem;
	line-height: 1;
	border: 1px solid var(--border);
	background: rgba(255,255,255,0.03);
	box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
	overflow: hidden;
}
.score-board .entry::before {
	content: 'WAITING';
	position: absolute;
	left: 0;
	top: 0;
	height: 16px;
	padding: 0 8px;
	display: inline-flex;
	align-items: center;
	font-size: .62rem;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: #dbeafe;
	background: rgba(92, 154, 236, 0.95);
	border-right: 1px solid rgba(255,255,255,0.15);
	border-bottom: 1px solid rgba(255,255,255,0.12);
	border-bottom-right-radius: 6px;
	z-index: 2;
}
.score-board .entry.active::before {
	content: 'PLAYER\'S TURN';
}
.score-board .entry.p1::before {
	color: #fff7ed;
	background: rgba(249, 115, 22, 0.96);
}
.score-board .entry.p2::before {
	color: #dbeafe;
	background: rgba(92, 154, 236, 0.95);
}
.score-board .entry .check { display: none !important; }
.score-board .entry .name {
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-weight: 700;
	letter-spacing: .02em;
	color: var(--muted);
}
.score-board .entry .icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 15px;
	height: 15px;
	color: #f5c962;
}
.score-board .entry .icon svg,
.score-board .entry .icon img {
	width: 14px;
	height: 14px;
	display: block;
}
.score-board .entry #my-score,
.score-board .entry #opp-score {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 18px;
	padding: 0 6px;
	border-radius: 999px;
	font-size: .76rem;
	font-weight: 700;
	color: #ffffff;
	background: rgba(255,255,255,0.1);
	border: 1px solid rgba(255,255,255,0.18);
}
.score-board .entry.p1 {
	border-color: rgba(249, 115, 22, 0.56);
	background: linear-gradient(180deg, rgba(249, 115, 22, 0.24), rgba(249, 115, 22, 0.12));
	color: #fff2e8;
}
.score-board .entry.p1 .name { color: #fff2e8; }
.score-board .entry.p1 .icon { color: rgba(249,115,22,0.96); }
.score-board .entry.p1 #my-score,
.score-board .entry.p1 #opp-score {
	background: rgba(130, 58, 18, 0.45);
	border-color: rgba(249, 115, 22, 0.45);
}
.score-board .entry.p2 {
	border-color: rgba(92, 154, 236, 0.52);
	background: linear-gradient(180deg, rgba(92, 154, 236, 0.22), rgba(92, 154, 236, 0.1));
	color: #deecff;
}
.score-board .entry.p2 .name { color: #deecff; }
.score-board .entry.p2 .icon { color: rgba(92,154,236,0.92); }
.score-board .entry.p2 #my-score,
.score-board .entry.p2 #opp-score {
	background: rgba(32, 68, 120, 0.46);
	border-color: rgba(92, 154, 236, 0.42);
}

@media (max-width: 480px) {
	.turn-badge, .color-badge { font-size: .8rem; padding: 4px 8px; }
	.color-badge .label { display: none; }
	.score-board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
	.score-board .entry { min-height: 44px; padding: 18px 8px 5px; font-size: .7rem; gap: 5px; }
	.score-board .entry::before { height: 15px; padding: 0 6px; font-size: .56rem; }
	.score-board .entry .icon { width: var(--hud-icon-size, 16px); height: var(--hud-icon-size, 16px); }
	.score-board .entry .icon svg,
	.score-board .entry .icon img { width: var(--hud-icon-size, 16px); height: var(--hud-icon-size, 16px); }
	.score-board .entry #my-score,
	.score-board .entry #opp-score { min-width: 18px; height: 16px; padding: 0 5px; font-size: .68rem; }
}

/* 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,
.finished-games td button.btn-small {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--overview-action-height, 32px);
	padding: 0 10px;
	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);
	line-height: 1;
	font: inherit;
	cursor: pointer;
}

.finished-games td a.btn-small:hover,
.finished-games td button.btn-small:hover {
	background: rgba(255,255,255,0.06);
}

#queued-games-root .finished-games td button.matchmaking-action-btn,
#invitations-root .finished-games td button.matchmaking-action-btn {
	text-transform: none;
	letter-spacing: normal;
	font-family: inherit;
	box-shadow: none;
	filter: none;
	background: rgba(255,255,255,0.04);
	border-color: rgba(255,255,255,0.03);
}

#queued-games-root .finished-games td button.matchmaking-action-btn:hover,
#queued-games-root .finished-games td button.matchmaking-action-btn:focus-visible,
#queued-games-root .finished-games td button.matchmaking-action-btn:active,
#invitations-root .finished-games td button.matchmaking-action-btn:hover,
#invitations-root .finished-games td button.matchmaking-action-btn:focus-visible,
#invitations-root .finished-games td button.matchmaking-action-btn:active {
	background: rgba(255,255,255,0.06);
	box-shadow: none;
	filter: none;
	transform: none;
	outline: none;
}
.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: linear-gradient(180deg, var(--panel), var(--panel-2));
	border: 1px solid var(--border);
	color: var(--muted);
	border-radius: 10px;
	font-size: 1.05rem;
	line-height: 1.3;
	box-shadow: 0 8px 16px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.02);
	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;
	font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}
.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: #dbe5f2;
}
.finished-games thead th { color: #f3f8ff; font-weight: 600; }
.finished-games tbody tr:hover td { background: rgba(255,255,255,0.02); }

.leaderboard-table,
.leaderboard-table th,
.leaderboard-table td {
	font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

.leaderboard-table td {
	color: #dbe5f2;
}

.leaderboard-table thead th {
	color: #f3f8ff;
}

@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 */
	/* Opponent name may overflow; truncate */
	#finished-games-root .finished-games td:nth-child(2) {
		max-width: 120px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	/* Score column */
	#finished-games-root .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-root .finished-games th:nth-child(4),
	#finished-games-root .finished-games td:nth-child(4) {
		width: 90px;
	}
	#finished-games-root .finished-games td:nth-child(4) 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-root .finished-games td:nth-child(2) { max-width: 90px; }
	#finished-games-root .finished-games td:nth-child(3) { width: 70px; }
	#finished-games-root .finished-games td:nth-child(4) 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: none; }
.finished-games tr.lost td { border-left: none; }
.finished-games tr.draw td { border-left: none; }
.finished-games tr.cancelled td { border-left: none; }
.finished-games tr.active-game td { border-left: none; }
.finished-games tr.active-game.my-turn td { border-left: none; }

/* 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: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14)); color: #fff; border: 1px solid rgba(212,175,55,0.28); box-shadow: 0 2px 6px rgba(0,0,0,0.16); }

/* 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: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14)); color: #fff; border: 1px solid rgba(212,175,55,0.28); box-shadow: 0 2px 6px rgba(0,0,0,0.16); }

/* Leaderboard uses the same visual language as finished games */
.leaderboard-table tr.my-rank-row td { border-left: none; }
.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;
}

/* Finished games result column: always icon-only (no text labels) */
#finished-games-root .finished-games .result { gap: 0; }
#finished-games-root .finished-games .result .result-label { display: none; }
#finished-games-root .finished-games .result .result-icon { display: none; }

/* 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: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14));
	color: #fff;
	border: 1px solid rgba(212,175,55,0.28);
	box-shadow: 0 2px 6px rgba(0,0,0,0.16);
	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(212,175,55,0.24), rgba(212,175,55,0.14)); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.16); border: 1px solid rgba(212,175,55,0.28); }
.finished-games tr.lost .score-badge { background: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14)); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.16); border: 1px solid rgba(212,175,55,0.28); }
.finished-games tr.draw .score-badge { background: linear-gradient(180deg, rgba(212,175,55,0.24), rgba(212,175,55,0.14)); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.16); border: 1px solid rgba(212,175,55,0.28); }

#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;
}


.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;
	gap: 2px;
	align-items: center;
	margin-left: auto;
	flex: 0 0 auto;
	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="email"], 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="email"]: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="email"]: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);
}

.notification-intro,
.notification-security-note {
	font-size: .9rem;
	margin: 0 0 12px;
}
.notification-security-note { margin: 12px 0 0; }
.notification-preferences { display: grid; gap: 2px; }
.notification-preference {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 5px 0;
    margin: 0px;
	cursor: pointer;
}
.notification-preference-copy { display: grid; gap: 2px; flex: 1; min-width: 0; }
.notification-preference-label { color: var(--text); font-weight: 600; }
.notification-preference-description { color: var(--muted); font-size: .82rem; }
.notification-preference-status { min-height: 1em; color: var(--gold); font-size: .75rem; }
.notification-toggle-input { position: absolute; opacity: 0; pointer-events: none; }
.notification-toggle {
	width: 42px;
	height: 24px;
	flex: 0 0 42px;
	padding: 3px;
	border-radius: 999px;
	background: rgba(148,163,184,.35);
	transition: background .18s ease;
}
.notification-toggle span {
	display: block;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #f8fafc;
	transition: transform .18s ease;
}
.notification-toggle-input:checked + .notification-toggle { background: #b88a35; }
.notification-toggle-input:checked + .notification-toggle span { transform: translateX(18px); }
.notification-toggle-input:focus-visible + .notification-toggle { outline: 2px solid #facc15; outline-offset: 2px; }

.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-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;
}
.status-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 8px;
	border: 1px solid currentColor;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 700;
	line-height: 1.2;
}
.status-badge-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}
.player-online-dot {
	display: inline-block;
	flex: 0 0 6px;
	width: 6px;
	height: 6px;
	margin-left: 4px;
	border-radius: 50%;
	background: #86efac;
	box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.14);
	vertical-align: middle;
}
.status-badge--online { color: #86efac; background: rgba(34, 197, 94, 0.12); }
.status-badge--offline { color: #cbd5e1; background: rgba(148, 163, 184, 0.12); }

.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;
	overflow: hidden;
	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,
.stat .icon img { width: 18px; height: 18px; }
.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;
}

/* 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: var(--hud-icon-size, 16px); height: var(--hud-icon-size, 16px); }
	.stat .icon svg,
	.stat .icon img { width: var(--hud-icon-size, 16px); height: var(--hud-icon-size, 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-image:
		radial-gradient(1200px 600px at 10% 0%, rgba(127,191,79,.10), rgba(0,0,0,0) 70%),
		url('assets/grass_background.png'),
		linear-gradient(180deg, #184028 0%, #143621 100%);
	background-size: auto, cover, auto;
	background-position: center, center, center;
	background-repeat: no-repeat, no-repeat, no-repeat;
	background-blend-mode: normal, normal, 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; }
.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: 3px 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="email"], 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); }

/* ------------------------------------------------------------------
   Mobile edge-to-edge pass (all Settlercity pages)
------------------------------------------------------------------ */
@media (max-width: 640px) {
	body {
		padding-left: max(5px, env(safe-area-inset-left));
		padding-right: max(5px, env(safe-area-inset-right));
	}

	.historical-scale .container {
		transform: none;
	}

	.container,
	.container.wide {
		max-width: none;
		width: 100%;
		margin-left: 0;
		margin-right: 0;
		border-radius: 12px;
	}

	body.auth-page .auth-shell,
	body.auth-page--login .auth-shell,
	body.auth-page--register .auth-shell {
		max-width: none;
		padding-left: 0;
		padding-right: 0;
	}

	body.auth-page--login .auth-panel,
	body.auth-page--register .auth-panel {
		border-radius: 12px;
	}

	body.auth-page .container.auth-card,
	body.auth-page--login .container.auth-card,
	body.auth-page--register .container.auth-card {
		max-width: none;
		margin-left: 0;
		margin-right: 0;
		border-radius: 12px;
	}
}

