* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	font-family: 'Roboto', sans-serif;
}

#map {
	height: 100vh;
	width: 100vw;
}

#toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%) translateY(12px);
	z-index: 20;
	background: #2563eb;
	color: white;
	padding: 12px 20px;
	border-radius: 8px;
	font-size: 14px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
	white-space: nowrap;
}

#toast.visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

#toast.toast-error {
	background: #dc2626;
}

#overlay {
	position: absolute;
	inset: 0;
	z-index: 5;
	background: rgba(0, 0, 0, 0.35);
	opacity: 1;
	transition: opacity 0.3s ease;
}

#overlay.hidden {
	opacity: 0;
	pointer-events: none;
}

#menu {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 10;
	background: white;
	border-radius: 12px;
	overflow: hidden;
	width: 300px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
}

.menu-header {
	position: relative;
	overflow: hidden;
	padding: 28px 28px 8px;
}

.menu-header::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to bottom,
		transparent 0%,
		rgba(255, 255, 255, 0) 50%,
		white 100%
	);
	pointer-events: none;
}

.menu-section,
.menu-actions {
	padding: 0 28px;
}

.menu-actions {
	padding-bottom: 12px;
}

.menu-footer {
	padding: 12px 28px 20px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	border-top: 1px solid #eee;
}

.flags-ticker {
	position: absolute;
	inset: -60px -80px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 6px;
	transform: rotate(-15deg);
	opacity: 0.4;
	pointer-events: none;
	z-index: 0;
}

.flags-row {
	display: flex;
	overflow: hidden;
}

.flags-track {
	display: inline-block;
	white-space: nowrap;
	font-size: 64px;
	line-height: 50px;
	padding-right: 15px;
	animation: scroll-flags 90s linear infinite;
	will-change: transform;
	flex-shrink: 0;
}

.flags-row--slow .flags-track {
	animation-duration: 130s;
}

.flags-row--fast .flags-track {
	animation-duration: 60s;
}

@keyframes scroll-flags {
	from { transform: translateX(0); }
	to { transform: translateX(-100%); }
}

#menu h1 {
	position: relative;
	z-index: 1;
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 30px;
	font-weight: 700;
	text-align: center;
	color: white;
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8), 0 0 32px rgba(0, 0, 0, 0.6);
	padding: 24px 0 20px;
}

.menu-step {
	display: flex;
	flex-direction: column;
	border-top: 1px solid #eee;
}

.menu-step-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 28px;
	font-size: 13px;
	font-family: 'Roboto Condensed', sans-serif;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #888;
}

.menu-step.done .menu-step-header {
	cursor: pointer;
}

.step-check {
	display: flex;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid #e2e8f0;
	color: transparent;
	font-size: 11px;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.menu-step.done .step-check {
	background: #2563eb;
	border-color: #2563eb;
	color: white;
}

.menu-step-body {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.3s ease;
}

.menu-step-body-inner {
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.menu-step.active .menu-step-body,
.menu-step.done.open .menu-step-body {
	grid-template-rows: 1fr;
}

.menu-section {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 0 28px 16px;
}

.option-label {
	font-size: 13px;
	font-weight: 400;
	color: #555;
}

.slider-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.slider-value {
	font-size: 13px;
	font-weight: 600;
	color: #2563eb;
}

.slider {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 4px;
	border-radius: 2px;
	background: #e2e8f0;
	outline: none;
	cursor: pointer;
}

.slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: white;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.slider::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: white;
	cursor: pointer;
	border: none;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.segmented {
	display: flex;
	width: 100%;
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid #e2e8f0;
}

.seg-btn {
	flex: 1;
	padding: 9px 0;
	border: none;
	border-left: 1px solid #e2e8f0;
	background: white;
	font-size: 13px;
	font-weight: 600;
	color: #64748b;
	cursor: pointer;
}

.seg-btn:first-child {
	border-left: none;
}

.seg-btn.active {
	background: #2563eb;
	color: white;
	border-left-color: #2563eb;
}

.section-label {
	font-size: 13px;
	font-family: 'Roboto Condensed', sans-serif;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #888;
}

.checkbox-row {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

.toggle {
	position: relative;
	width: 36px;
	height: 20px;
	flex-shrink: 0;
}

.toggle input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-track {
	position: absolute;
	inset: 0;
	background: #ccc;
	border-radius: 10px;
	transition: background 0.2s ease;
	cursor: pointer;
}

.toggle-track::before {
	content: '';
	position: absolute;
	width: 16px;
	height: 16px;
	top: 2px;
	left: 2px;
	background: white;
	border-radius: 50%;
	transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-track {
	background: #2563eb;
}

.toggle input:checked + .toggle-track::before {
	transform: translateX(16px);
}

.menu-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-top: 16px;
	border-top: 1px solid #eee;
}

.btn {
	padding: 10px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	border: none;
	width: 100%;
}

.btn-primary {
	background: #2563eb;
	color: white;
}

.btn-secondary {
	background: #f1f5f9;
	color: #1e293b;
}

.btn-ghost {
	background: none;
	color: #888;
	font-size: 12px;
	font-weight: 400;
	padding: 4px;
}

#lobby,
#game-start {
	display: none;
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 10;
	align-items: flex-end;
	justify-content: center;
	padding-bottom: 24px;
}

#lobby.visible,
#game-start.visible {
	display: flex;
}

#lobby.visible {
	top: 0;
	align-items: center;
	padding-bottom: 0;
}

#lobby-popup {
	background: white;
	border-radius: 12px;
	padding: 28px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	width: 280px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

#lobby-code-section {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

#lobby-copy-buttons {
	display: flex;
	gap: 6px;
	width: 100%;
	margin-top: 4px;
}

#lobby-copy-buttons .btn {
	flex: 1;
	font-size: 12px;
	padding: 7px;
	border: 1.5px solid #e2e8f0;
	background: white;
	color: #1e293b;
	transition: border-color 0.15s, color 0.15s, background 0.15s;
}

#lobby-copy-buttons .btn.btn-copied {
	border-color: #16a34a;
	color: #16a34a;
	background: #f0fdf4;
}

.lobby-section-label {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: #888;
}

.lobby-section-header {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: #888;
	margin: 0;
	border-top: 1px solid #eee;
	padding-top: 8px;
}

#lobby-player-count {
	font-weight: 400;
	letter-spacing: 0;
}

#lobby-code {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 40px;
	font-weight: 700;
	color: #1e293b;
	letter-spacing: 0.1em;
}

.lobby-copy-hint {
	font-size: 11px;
	color: #bbb;
}

#lobby-players {
	display: flex;
	flex-direction: column;
	gap: 6px;
	max-height: 160px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: #ddd transparent;
	padding-right: 8px;
	padding-bottom: 16px;
}

#lobby-players.has-overflow {
	-webkit-mask-image: linear-gradient(to bottom, black calc(100% - 28px), transparent 100%);
	mask-image: linear-gradient(to bottom, black calc(100% - 28px), transparent 100%);
}

#lobby-players::-webkit-scrollbar {
	width: 4px;
}

#lobby-players::-webkit-scrollbar-track {
	background: transparent;
}

#lobby-players::-webkit-scrollbar-thumb {
	background: #ddd;
	border-radius: 2px;
}

.lobby-player {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	font-size: 14px;
	color: #1e293b;
	font-weight: 500;
	min-width: 0;
}

.lobby-player-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}

.lobby-player-badges {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.lobby-crown {
	width: 14px;
	height: 10px;
}

.lobby-player-you {
	font-size: 11px;
	font-family: 'Roboto Condensed', sans-serif;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #888;
	flex-shrink: 0;
}

#lobby-waiting,
#game-start-waiting {
	font-size: 13px;
	color: #888;
	text-align: center;
	margin: 0;
}

#game-start-popup {
	background: white;
	border-radius: 12px;
	padding: 32px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	min-width: 160px;
}

#game-start-points:empty {
	display: none;
}

#name-popup,
#join-popup,
#about-popup {
	display: none;
	position: absolute;
	inset: 0;
	z-index: 20;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.5);
}

#name-popup.visible,
#join-popup.visible,
#about-popup.visible {
	display: flex;
}

#name-popup-inner,
#join-popup-inner,
#about-popup-inner {
	background: white;
	border-radius: 12px;
	padding: 28px;
	width: 280px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

#name-popup-inner h2,
#join-popup-inner h2,
#about-popup-inner h2 {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 20px;
	font-weight: 700;
	color: #1e293b;
	text-align: center;
}

.lang-picker {
	display: flex;
	gap: 6px;
}

.lang-picker input[type="radio"] {
	display: none;
}

.lang-picker label {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 7px 12px;
	border: 1.5px solid #e2e8f0;
	border-radius: 8px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	color: #64748b;
}

.lang-picker input[type="radio"]:checked + label {
	border-color: #2563eb;
	background: #eff6ff;
	color: #2563eb;
}

.lang-picker label img {
	height: 14px;
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.popup-info {
	font-size: 13px;
	color: #888;
	text-align: center;
	line-height: 1.5;
}

.popup-info a,
.about-credits a {
	color: #2563eb;
	text-decoration: none;
}

.popup-info a:hover,
.about-credits a:hover {
	text-decoration: underline;
}

.about-credits {
	font-size: 11px;
	color: #64748b;
	text-align: center;
	line-height: 1.8;
	border-top: 1px solid #e2e8f0;
	padding-top: 10px;
}

#player-name-input,
.popup-input {
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	font-size: 14px;
	font-family: 'Roboto', sans-serif;
	outline: none;
	width: 100%;
	box-sizing: border-box;
}

#player-name-input:focus,
.popup-input:focus {
	border-color: #2563eb;
}

#game-over {
	display: none;
	position: absolute;
	inset: 0;
	z-index: 10;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.35);
}

#game-over.visible {
	display: flex;
}

#game-over-popup {
	background: white;
	border-radius: 12px;
	padding: 28px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
	width: 300px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

#game-over-title {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 20px;
	font-weight: 700;
	color: #1e293b;
	text-align: center;
}

#game-over-leaderboard {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.leaderboard-row {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 14px;
	color: #1e293b;
}

.lb-rank {
	font-family: 'Roboto Condensed', sans-serif;
	font-weight: 700;
	font-size: 12px;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	background: white;
	border: 2px solid #e2e8f0;
	color: #94a3b8;
}

.lb-rank-1 {
	background: #F59E0B;
	border-color: #F59E0B;
	color: white;
}

.lb-rank-2 {
	background: #94A3B8;
	border-color: #94A3B8;
	color: white;
}

.lb-rank-3 {
	background: #92622A;
	border-color: #92622A;
	color: white;
}

.lb-name {
	flex: 1;
	font-weight: 600;
}

.lb-score {
	font-family: 'Roboto Condensed', sans-serif;
	font-weight: 700;
	font-size: 16px;
	color: #2563eb;
}

.lb-time {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 12px;
	color: #94a3b8;
	flex-shrink: 0;
}

#game-info .item {
	display: none;
	position: fixed;
	top: 0;
	background: white;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	font-family: 'Roboto Condensed', sans-serif;
	white-space: nowrap;
	z-index: 10;
}

#game-info.visible .item {
	display: flex;
	align-items: center;
}

#game-info-round {
	right: 50%;
	height: 28px;
	padding: 0 40px 0 20px;
	border-radius: 0 0 0 12px;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #888;
}

#game-info-score {
	left: 50%;
	height: 28px;
	padding: 0 20px 0 40px;
	border-radius: 0 0 12px 0;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #888;
}

@keyframes score-pop {
	0% { transform: scale(1); color: #888; }
	30% { transform: scale(1.25); color: #2563eb; }
	100% { transform: scale(1); color: #888; }
}

.score-pop {
	display: inline-block;
	animation: score-pop 0.6s ease-out forwards;
}

#game-info-timer {
	display: none;
	position: fixed;
	top: 3px;
	left: 50%;
	transform: translateX(-50%);
	width: 48px;
	height: 22px;
	border-radius: 6px;
	background: #2563eb;
	color: white;
	font-size: 16px;
	font-weight: 700;
	font-family: 'Roboto Condensed', sans-serif;
	align-items: center;
	justify-content: center;
	z-index: 11;
}

#game-info.visible #game-info-timer {
	display: flex;
}

#btn-confirm-guess {
	display: none;
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 20;
	background: #2563eb;
	color: white;
	border: none;
	border-radius: 24px;
	padding: 12px 32px;
	font-size: 15px;
	font-weight: 700;
	font-family: 'Roboto Condensed', sans-serif;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

#btn-confirm-guess.visible {
	display: block;
}

#game-hud {
	position: fixed;
	left: 0;
	right: 0;
	margin: 0 auto;
	width: fit-content;
	z-index: 10;
	background: white;
	border-radius: 12px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	flex-direction: column;
	align-items: center;
	gap: 8px;
	display: none;
	transition: top 0.5s ease, transform 0.5s ease, padding 0.5s ease;
}

#game-hud.intro {
	display: flex;
	top: 50%;
	transform: translateY(-50%);
	padding: 32px;
	gap: 20px;
}

#game-hud.hud {
	display: flex;
	top: 38px;
	transform: translateY(0);
	padding: 12px;
	cursor: pointer;
}

#game-hud.expanded {
	display: flex;
	top: 50%;
	transform: translateY(-50%);
	padding: 32px;
	gap: 20px;
	cursor: pointer;
}

#game-hud-label,
#game-start-label {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 16px;
	color: #888;
}

#game-hud-count,
#game-start-points {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 80px;
	font-weight: 700;
	color: #1e293b;
	line-height: 1;
}

#game-start-points {
	min-width: 200px;
	text-align: center;
	font-size: 36px;
}

#game-start-flags {
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: auto 60px auto;
	column-gap: 28px;
	row-gap: 6px;
	width: 100%;
	justify-items: center;
	align-items: start;
}

.game-start-flag-heading {
	font-family: 'Roboto Condensed', sans-serif;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: #888;
}

.game-start-flag-img {
	height: 60px;
	border-radius: 3px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.10);
}

.game-start-flag-name {
	font-size: 13px;
	font-weight: 600;
	color: #1e293b;
	text-align: center;
}


#round-result-leaderboard {
	display: none;
	flex-direction: column;
	gap: 6px;
	width: 100%;
	margin-top: 4px;
	padding-top: 12px;
	border-top: 1px solid #eee;
}

#round-result-leaderboard.visible {
	display: flex;
}

#game-hud-flag {
	display: none;
	width: auto;
	border-radius: 3px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
	transition: height 0.5s ease;
}

#game-hud.intro #game-hud-flag,
#game-hud.expanded #game-hud-flag {
	height: 120px;
}

#game-hud.hud #game-hud-flag {
	height: 48px;
}

#game-hud-name {
	display: none;
	font-family: 'Roboto Condensed', sans-serif;
	font-weight: 700;
	color: #1e293b;
	text-align: center;
	transition: font-size 0.5s ease;
}

#game-hud.intro #game-hud-name,
#game-hud.expanded #game-hud-name {
	font-size: 22px;
}

#game-hud.hud #game-hud-name {
	font-size: 13px;
}


#lobby-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

#lobby-rules {
	display: flex;
	flex-direction: column;
	gap: 5px;
}

#lobby-rules:empty {
	display: none;
}

.lobby-rule-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 8px 12px;
}

.lobby-rule-cell {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	font-size: 12px;
	align-items: center;
	text-align: center;
	margin-bottom: 5px;
}

.lobby-rule-cell span {
	color: #888;
	font-size: 11px;
}

.lobby-rule-cell strong {
	color: #1e293b;
	font-weight: 600;
}

.lobby-check-on {
	color: #2563eb;
}

.lobby-check-off {
	color: #ccc;
}