/* Design tokens + theme variables */
:root {
	--space-2: 2px;
	--space-4: 4px;
	--space-6: 6px;
	--space-8: 8px;
	--space-12: 12px;
	--space-16: 16px;
	--space-20: 20px;
	--space-24: 24px;
	--radius-sm: 8px;
	--radius-md: 12px;
	--radius-lg: 16px;
	--radius-xl: 20px;
	--radius-2xl: 24px;
	--radius-3xl: 36px;
	--radius-4xl: 48px;
	--touch-min: 44px;
	--ease: cubic-bezier(0.25, 0.1, 0.25, 1);

	--bg-color: linear-gradient(135deg, #bfa2fc 0%, #a78bfa 100%);
	--container-bg: #ffffff;
	--container-border: #bfa2fc;
	--game-border: #bfa2fc;
	--text-color: #2c3e50;
	--found-color: #a78bfa;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #c4b5fd;
	--selection-color: #ddd6fe;
	--button-bg: #ffffff;
	--button-text: #7c3aed;
	--button-border: #bfa2fc;
	--hint-line-color: #ef4444;
	--hint-display-color: #ef4444;
	--timer-text-color: #2c3e50;
	--shadow-light: #bfa2fc33;
	--shadow-medium: #bfa2fc4d;
	--gradient-start: #bfa2fc;
	--gradient-end: #a78bfa;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

/* Ocean Breeze Theme */
.ocean-theme {
	--bg-color: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
	--container-bg: #ffffff;
	--container-border: #0ea5e9;
	--game-border: #0ea5e9;
	--text-color: #1e3a8a;
	--found-color: #06b6d4;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #7dd3fc;
	--selection-color: #bae6fd;
	--button-bg: #ffffff;
	--button-text: #0ea5e9;
	--button-border: #0ea5e9;
	--hint-line-color: #f97316;
	--hint-display-color: #f97316;
	--timer-text-color: #1e3a8a;
	--shadow-light: #0ea5e926;
	--shadow-medium: #0ea5e940;
	--gradient-start: #0ea5e9;
	--gradient-end: #06b6d4;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

/* Sunset Glow Theme */
.sunset-theme {
	--bg-color: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
	--text-color: #7c2d12;
	--container-bg: #ffffff;
	--container-border: #f97415;
	--game-border: #f97415;
	--found-color: #a34900;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #fdba74;
	--selection-color: #fed7aa;
	--button-bg: #ffffff;
	--button-text: #f97316;
	--button-border: #f97316;
	--hint-line-color: #dc2626;
	--hint-display-color: #dc2626;
	--timer-text-color: #7c2d12;
	--shadow-light: #ffceab26 --shadow-medium: #f9731640;
	--gradient-start: #f97316;
	--gradient-end: #974400;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

/* Forest Dream Theme */
.forest-theme {
	--bg-color: linear-gradient(135deg, #059669 0%, #10b981 100%);
	--text-color: #064e3b;
	--container-bg: #ffffff;
	--container-border: #059669;
	--game-border: #059669;
	--found-color: #10b981;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #6ee7b7;
	--selection-color: #a7f3d0;
	--button-bg: #ffffff;
	--button-text: #059669;
	--button-border: #059669;
	--hint-line-color: #f59e0b;
	--hint-display-color: #f59e0b;
	--timer-text-color: #064e3b;
	--shadow-light: #05966926;
	--shadow-medium: #05966940;
	--gradient-start: #059669;
	--gradient-end: #10b981;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

/* Royal Purple Theme */
.royal-theme {
	--bg-color: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
	--text-color: #4c1d95;
	--container-bg: #ffffff;
	--container-border: #7c3aed;
	--game-border: #7c3aed;
	--found-color: #a78bfa;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #c4b5fd;
	--selection-color: #ddd6fe;
	--button-bg: #ffffff;
	--button-text: #7c3aed;
	--button-border: #7c3aed;
	--hint-line-color: #f59e0b;
	--hint-display-color: #f59e0b;
	--timer-text-color: #4c1d95;
	--shadow-light: #7c3aed26;
	--shadow-medium: #7c3aed40;
	--gradient-start: #7c3aed;
	--gradient-end: #a78bfa;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

/* Midnight Dark Theme */
.midnight-theme {
	--bg-color: linear-gradient(135deg, #030303 0%, #000000 100%);
	--text-color: #2b2b2b;
	--container-bg: #0f172a;
	--game-border: #0f172a;
	--container-border: #475569;
	--found-color: #64748b;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #475569;
	--selection-color: #334155;
	--button-bg: #1e293b;
	--button-text: #e2e8f0;
	--button-border: #475569;
	--hint-line-color: #f59e0b;
	--hint-display-color: #f59e0b;
	--timer-text-color: #2b2b2b;
	--shadow-light: #0000004d;
	--shadow-medium: #00000080;
	--gradient-start: #1e293b;
	--gradient-end: #334155;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

.neon-theme {
	--bg-color: linear-gradient(135deg, #000000 0%, #230046 100%);
	--text-color: #00ff88;
	--container-bg: #000000;
	--container-border: #c8a3ef;
	--game-border: #089bcd;
	--found-color: #39ff14;
	--found-text-color: #ffffff;
	--hint-color: #21df00;
	--line-color: #a1ee94;
	--selection-color: #ddd6fe;
	--button-bg: #000000;
	--button-text: #21df00;
	--button-border: #a1ee94;
	--hint-line-color: #f59e0b;
	--hint-display-color: #f59e0b;
	--timer-text-color: #1bb100;
	--shadow-light: #279613;
	--shadow-medium: #0e4704;
	--gradient-start: #2be60a;
	--gradient-end: #1bad02;
	--focus-ring: 0 0 0 3px #bfa2fc66;
	--text-muted: #64748b;
}

.light-theme {
	--bg-color: linear-gradient(135deg, #464646 0%, #7e7e7e 100%);
	--container-bg: #ffffff;
	--container-border: #4d4d4d;
	--game-border: #4d4d4d;
	--text-color: #2c3e50;
	--found-color: #585858;
	--found-text-color: #ffffff;
	--hint-color: #10b981;
	--line-color: #b4b4b4;
	--selection-color: #ddd6fe;
	--button-bg: #ffffff;
	--button-text: #414141;
	--button-border: #757575;
	--hint-line-color: #ef4444;
	--hint-display-color: #ef4444;
	--timer-text-color: #2c3e50;
	--shadow-light: #adadad33;
	--shadow-medium: #8f8f8f4d;
	--gradient-start: #707070;
	--gradient-end: #333333;
	--focus-ring: 0 0 0 3px #c9c9c966;
	--text-muted: #868686;
}

@font-face {
	font-family: RakeslyRG;
	src: url(assets/fonts/font.otf);
}

/* Smooth animations */
@keyframes blink {
	0%,
	100% {
		opacity: 0.3;
	}

	50% {
		opacity: 1;
	}
}

@keyframes pulse {
	0%,
	100% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.05);
	}
}

@keyframes shimmer {
	0% {
		background-position: -1000px 0;
	}
	100% {
		background-position: 1000px 0;
	}
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

@keyframes slideUp {
	from {
		transform: translateY(30px);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

* {
	font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
	box-sizing: border-box;
	user-select: none;
}

button,
.nav-btn,
.close-btn,
.theme-button,
.puzzle-item,
.theme-card,
.leaderboard-item,
.submit-score-btn,
.skip-score-btn,
#reset-timer-btn,
#pause-btn,
#hint-button,
#new-puzzle-button {
	font-weight: 700;
}

h1,
h2,
h3,
#theme-text,
.theme-name {
	font-weight: 800;
}

html {
	touch-action: manipulation;
}

body {
	margin: 0;
	padding: 0;
	min-height: 100dvh;
	overflow-x: hidden;
	overflow-y: auto;
	transition: background 0.3s ease;
	background: var(--bg-color);
	background-attachment: fixed;
}

#full-bg-overlay {
	z-index: 1;
	height: 100dvh;
	position: fixed;
	top: 0;
	left: 0;
	width: 100dvw;
	height: 100dvh;
	overflow: hidden;
	background: url(/assets/bg.png) center/cover no-repeat;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

.neon-theme #full-bg-overlay {
	background: #000000;
}

#ad-slot {
	position: absolute;
	height: 50px;
	min-width: 50px;
	display: flex;
}

#ad-slot.left {
	top: -5px;
	left: 0;
}

#ad-slot.right {
	top: -5px;
	right: 0;
}

#ad-slot > div {
	width: 100%;
	padding: 12px;
	font-size: 12px;
	text-align: center;
	color: #6b7280;
	background: #f3f4f6;
	border-radius: 8px;
	text-align: center;
	display: flex;
	align-items: center;
	justify-content: center;
}

#loader {
	display: flex;
	position: absolute;
	top: 50%;
	left: 50%;
	align-items: center;
	justify-content: center;
	height: auto;
	background: none;
	transform: translate(-50%, -50%);
}

#loadingImage {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 150px;
	animation: blink 2s infinite ease-in-out;
}

/* Theme box: gauge/dashboard style, dimensional border */
#theme-box {
	margin: 10px auto;
	padding: 16px;
	width: calc(100% - var(--space-16));
	max-width: min(480px, calc(100dvw - 24px));
	height: calc(100dvh - 20px);
	max-height: min(925px, calc(100dvh - 20px));
	display: flex;
	gap: var(--space-8);
	flex-direction: column;
	text-align: center;
	color: var(--text-color);
	position: relative;
	overflow: hidden;
	background:
		rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1), radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.1) 50%, transparent 70%),
		linear-gradient(165deg, rgba(255, 255, 255, 0.25) 0%, rgba(250, 250, 255, 0.15) 50%, rgba(245, 243, 255, 0.1) 100%);
	border: 3px solid rgba(255, 255, 255, 0.6);
	border-radius: var(--radius-3xl);
	outline: 3px solid rgba(255, 255, 255, 0.8);
	outline-offset: 3px;
	box-shadow:
		0 8px 32px rgba(27, 68, 102, 0.3),
		inset 0 1px 0 rgba(19, 52, 160, 0.4),
		inset 0 -1px 0 rgba(9, 37, 165, 0.2);
	backdrop-filter: blur(25px);
	-webkit-backdrop-filter: blur(25px);
}

.theme-header {
	gap: 12px;
	position: relative;
	display: flex;
	justify-content: space-between;
	flex-wrap: wrap;
}

#theme-text {
	flex: 1;
	margin: 0;
	background-clip: text;
	font-size: 1.75rem;
	letter-spacing: 0.02em;
	line-height: 1.2;
	text-align: center;
	color: var(--text-color);
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}
.timer-icon svg,
.rounded-cross-btn {
	width: 44px;
	height: 44px;
	flex-shrink: 0;
}

.rounded-cross-btn {
	position: relative;
	border: 3px solid white;
	border-radius: 50%;
	background: radial-gradient(circle, color-mix(in srgb, var(--gradient-start), white 20%) 0%, var(--gradient-end) 30%);
	color: white;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow:
		inset 0 2px 4px rgba(255, 255, 255, 0.6),
		inset 0 -2px 4px rgba(0, 0, 0, 0.2),
		0 4px 12px rgba(0, 0, 0, 0.3),
		0 2px 4px rgba(0, 0, 0, 0.2),
		0 8px 20px var(--shadow-medium);
	transition: all 0.3s var(--ease);
	font-weight: 800;
}

.rounded-cross-btn svg {
	stroke: white;
	stroke-width: 3;
	filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.rounded-cross-btn:hover {
	box-shadow: 0 4px 12px var(--shadow-medium);
	transform: scale(1.05);
}

.rounded-cross-btn:active {
	transform: scale(0.95);
}

.rounded-cross-btn:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.timer-controls {
	margin-bottom: 8px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
}

.timer-controls .inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	background: #ffffff;
	border-radius: var(--radius-sm);
}

#timer-display {
	font-size: 1.25rem;
	font-weight: 700;
	text-align: center;
	padding: 4px 20px;
	border-radius: 6px;
	color: var(--timer-text-color);
	font-variant-numeric: tabular-nums;
}

/* Reset/Pause: match .theme-button and nav style (outline buttons) */
#reset-timer-btn,
#pause-btn {
	background: var(--button-bg);
	color: var(--button-text);
	border: 2px solid var(--button-border);
	border-radius: var(--radius-sm);
	padding: var(--space-8) var(--space-12);
	font-size: 0.8125rem;
	cursor: pointer;
	transition:
		transform 0.2s var(--ease),
		box-shadow 0.2s var(--ease);
	box-shadow: 0 2px 8px var(--shadow-light);
	touch-action: manipulation;
	min-height: var(--touch-min);
}

#reset-timer-btn:hover,
#pause-btn:hover {
	box-shadow: 0 4px 12px var(--shadow-medium);
}

#reset-timer-btn:active,
#pause-btn:active {
	transform: scale(0.97);
}

#reset-timer-btn:focus-visible,
#pause-btn:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

/* Puzzle frame: clear "picture frame" around the entire puzzle */
.puzzle-frame {
	width: 100%;
	height: calc(100% - 165px) !important;
	max-height: calc(100% - 165px) !important;
	border: 5px solid var(--container-border);
	border-radius: var(--radius-2xl);
	box-shadow:
		inset 0 2px 0 rgba(255, 255, 255, 0.1),
		inset 0 2px 0 rgba(0, 0, 0, 0.3),
		0 0 0 1px rgba(107, 91, 138, 0.3),
		0 8px 32px rgba(0, 0, 0, 0.25),
		0 16px 48px var(--shadow-medium);
	position: relative;
	overflow: visible;
}

.puzzle-frame::before {
	content: "";
	position: absolute;
	inset: 2px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: var(--radius-lg);
	pointer-events: none;
}

.puzzle-frame::after {
	content: "";
	position: absolute;
	inset: 4px 2px 2px;
	border: 5px solid rgba(0, 0, 0, 0.2);
	border-radius: 18px;
	pointer-events: none;
}

#game-container {
	padding: 16px;
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	border: none;
	border-radius: var(--radius-lg);
	text-align: center;
	color: var(--text-color);
	position: relative;
	overflow: visible;
}

#game {
	margin: 0;
	width: 100%;
	overflow: visible;
	display: flex;
	align-items: center;
	justify-content: center;
	height: calc(100% - 140px) !important;
	max-height: calc(100% - 140px) !important;
}

#game canvas {
	margin: auto !important;
	max-width: 100% !important;
	max-height: 100% !important;
	border: 5px solid var(--game-border);
	border-radius: 10px;
}

#show-selected {
	margin: 0;
	font-size: 1.2rem;
	font-weight: 600;
	color: var(--text-color);
	text-align: center;
	margin-bottom: 12px;
}

/* Compact Navigation Buttons – desktop: top-right */
.nav-buttons {
	width: 100%;
	display: flex;
	z-index: 1000;
	gap: 16px;
	justify-content: space-evenly;
	margin-top: 8px;
}

.nav-btn {
	border: 3px solid color-mix(in srgb, var(--button-border) 30%, transparent);
	border-radius: 20px;
	padding: 10px 15px;
	font-size: 22px;
	cursor: pointer;
	transition: all 0.3s ease;
	display: flex;
	align-items: center;
	flex-direction: column;
	gap: 2px;
	min-width: 112px;
	touch-action: manipulation;
	background: radial-gradient(circle at left top, color-mix(in srgb, var(--gradient-start), transparent 40%) 0%, color-mix(in srgb, var(--gradient-end), transparent 40%) 100%);
	box-shadow:
		inset 0 2px 4px rgba(255, 255, 255, 0.6),
		inset 0 -2px 4px rgba(0, 0, 0, 0.2),
		0 4px 12px var(--shadow-medium),
		0 8px 20px var(--shadow-medium);
}

.nav-btn-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	color: white;
}

.nav-btn-icon svg {
	width: 100%;
	height: 100%;
}

.nav-btn-label {
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.3px;
	text-transform: uppercase;
	color: white;
}

.nav-btn:active {
	transform: scale(0.97);
}

.nav-btn:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

p,
label,
.username-hint,
.loading-leaderboard {
	font-weight: 500;
}

/* Modal Base Styles */
.modal-base {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(15, 23, 42, 0.85);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	z-index: 2000;
	justify-content: center;
	align-items: center;
	animation: fadeIn 0.25s var(--ease);
	padding: var(--space-16);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.modal-content-base {
	background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
	border: none;
	border-radius: 20px;
	padding: 24px;
	width: 100%;
	max-width: 500px;
	max-height: calc(100dvh - 32px);
	overflow-y: auto;
	box-shadow:
		0 20px 60px rgba(102, 126, 234, 0.4),
		0 8px 24px rgba(0, 0, 0, 0.2);
	position: relative;
	animation: slideUp 0.4s ease;
}

.close-btn {
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	border: none;
	font-size: 22px;
	cursor: pointer;
	color: #ffffff;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
	flex-shrink: 0;
}

.close-btn:active {
	transform: scale(0.97);
}

.close-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

/* Username Prompt Modal */
.username-modal {
	display: none;
	position: fixed;
	inset: 0;
	background-color: rgba(15, 23, 42, 0.9);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	z-index: 2500;
	align-items: center;
	justify-content: center;
	padding: var(--space-16);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.username-content {
	padding: 24px;
	width: 100%;
	max-width: 450px;
	border: none;
	border-radius: 20px;
	background: linear-gradient(165deg, rgba(255, 255, 255, 95) 0%, rgba(233, 233, 233, 0.65) 50%, rgba(255, 255, 255, 1) 100%);
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.4),
		inset 0 -1px 0 rgba(0, 0, 0, 0.2);
	position: relative;
	animation: slideUp 0.4s ease;
}

.neon-theme .username-content {
	background: linear-gradient(165deg, rgba(22, 22, 22, 0.65) 0%, rgba(71, 71, 71, 0.45) 50%, rgba(44, 44, 44, 0.25) 100%);
}

.username-body {
	position: relative;
	z-index: 1;
}

.congrats-text {
	text-align: center;
	font-size: 18px;
	color: var(--text-color);
	margin: 12px 0;
}

.score-display {
	text-align: center;
	font-size: 24px;
	font-weight: 900;
	color: #10b981;
	margin: 16px 0;
	padding: 10px;
	background: #d1fae5;
	border-radius: 12px;
}

.username-body label {
	display: block;
	margin: 16px 0 8px;
	font-size: 15px;
	color: var(--text-color);
	font-weight: 700;
}

#username-input,
#email-input {
	width: 100%;
	padding: 12px 14px;
	font-size: 15px;
	border: 2px solid #a7f3d0;
	border-radius: 12px;
	background: #ffffff;
	color: #064e3b;
	font-weight: 600;
	transition: all 0.3s ease;
}

#username-input:focus,
#email-input:focus {
	outline: none;
	border-color: #10b981;
	box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.username-buttons {
	display: flex;
	gap: 10px;
	margin-top: 16px;
}

.submit-score-btn,
.skip-score-btn {
	flex: 1;
	padding: 12px 16px;
	font-size: 15px;
	font-weight: 700;
	border: none;
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.3s ease;
	touch-action: manipulation;
}

.submit-score-btn {
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: #ffffff;
	box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.submit-score-btn:hover {
	box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.submit-score-btn:active {
	transform: scale(0.97);
}

.submit-score-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.4);
}

.skip-score-btn {
	background: #f8fafc;
	color: var(--text-muted);
	border: 2px solid #e2e8f0;
}

.skip-score-btn:hover {
	background: #f1f5f9;
	border-color: #cbd5e1;
}

.skip-score-btn:active {
	transform: scale(0.97);
}

.skip-score-btn:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.username-hint {
	text-align: center;
	font-size: 14px;
	color: var(--hint-color);
	margin: 12px 0 0;
}

/* Puzzle Menu Modal */
.puzzle-menu-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 2000;
	align-items: center;
	justify-content: center;
	padding: var(--space-16);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: transparent;
}

.puzzle-menu-content {
	padding: var(--space-24) var(--space-24);
	width: 100%;
	max-width: min(480px, calc(100dvw - 24px));
	border: 3px solid rgba(255, 255, 255, 0.5);
	border-radius: var(--radius-3xl);
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.4),
		inset 0 -1px 0 rgba(0, 0, 0, 0.2);
	background: linear-gradient(165deg, rgba(255, 255, 255, 0.65) 0%, rgba(250, 250, 255, 0.45) 50%, rgba(245, 243, 255, 0.25) 100%);
	border: 3px solid rgba(255, 255, 255, 0.6);
	outline: 3px solid rgba(255, 255, 255, 0.8);
	outline-offset: 3px;
	backdrop-filter: blur(25px);
	-webkit-backdrop-filter: blur(25px);
	text-align: center;
	color: var(--text-color);
	position: relative;
	overflow: hidden;
	min-height: 140px;
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	max-height: calc(100dvh - 32px);
	animation: slideUp 0.35s var(--ease);
}

.neon-theme .puzzle-menu-content {
	background: linear-gradient(165deg, rgba(22, 22, 22, 0.65) 0%, rgba(71, 71, 71, 0.45) 50%, rgba(44, 44, 44, 0.25) 100%);
}

.puzzle-menu-header {
	z-index: 1;
	display: flex;
	align-items: center;
	position: relative;
	justify-content: space-between;
}

.puzzle-menu-header h2 {
	margin: 0;
	font-size: 1.5rem;
	letter-spacing: 0.02em;
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}

.puzzle-item {
	padding: 16px;
	margin: 10px 0;
	background: linear-gradient(135deg, #ffffff 0%, #fafaff 100%);
	border: 2px solid #e0e7ff;
	border-radius: 14px;
	cursor: pointer;
	transition: all 0.3s ease;
	position: relative;
	box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
	touch-action: manipulation;
}

.puzzle-item:active {
	transform: scale(0.98);
}

.puzzle-item h3 {
	margin: 0 0 6px 0;
	color: var(--text-color);
	font-size: 18px;
	font-weight: 800;
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}

.puzzle-category-title {
	margin: 0 0 8px 0;
	color: var(--text-color);
	font-size: 18px;
	font-weight: 800;
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}

.puzzle-item p {
	margin: 0;
	font-size: 13px;
	color: var(--text-color);
	opacity: 0.7;
	font-weight: 500;
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.leaderboard-title {
	z-index: 1;
	position: relative;
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
}

.leaderboard-title h2 {
	margin: 0;
	font-size: 1.5rem;
	letter-spacing: 0.02em;
	background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}

/* Theme Selector Modal */
.theme-selector-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 2000;
	align-items: center;
	justify-content: center;
	padding: var(--space-16);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: transparent;
}

.theme-selector-content {
	padding: var(--space-24) var(--space-24);
	width: calc(100% - var(--space-16));
	max-width: min(480px, calc(100dvw - 24px));
	border: 3px solid rgba(255, 255, 255, 0.5);
	border-radius: var(--radius-3xl);
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.4),
		inset 0 -1px 0 rgba(0, 0, 0, 0.2);
	background: linear-gradient(165deg, rgba(255, 255, 255, 0.65) 0%, rgba(250, 250, 255, 0.45) 50%, rgba(245, 243, 255, 0.25) 100%);
	border: 3px solid rgba(255, 255, 255, 0.6);
	outline: 3px solid rgba(255, 255, 255, 0.8);
	outline-offset: 3px;
	backdrop-filter: blur(25px);
	-webkit-backdrop-filter: blur(25px);
	text-align: center;
	color: var(--text-color);
	position: relative;
	overflow: hidden;
	min-height: 140px;
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	max-height: calc(100dvh - 32px);
	animation: slideUp 0.35s var(--ease);
}

.neon-theme .theme-selector-content {
	background: linear-gradient(165deg, rgba(22, 22, 22, 0.65) 0%, rgba(71, 71, 71, 0.45) 50%, rgba(44, 44, 44, 0.25) 100%);
}

.theme-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
	margin-top: 16px;
	position: relative;
	z-index: 1;
}

.theme-card {
	padding: var(--space-16);
	border-radius: var(--radius-md);
	cursor: pointer;
	transition:
		transform 0.2s var(--ease),
		box-shadow 0.2s var(--ease),
		border-color 0.2s var(--ease);
	position: relative;
	text-align: center;
	border: 2px solid rgba(0, 0, 0, 0.08);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	background: #ffffff;
	touch-action: manipulation;
	min-height: var(--touch-min);
}

.theme-card:hover {
	border-color: rgba(102, 126, 234, 0.3);
	box-shadow: 0 4px 16px var(--shadow-light);
}

.theme-card:active {
	transform: scale(0.98);
}

.theme-card:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.theme-card.active {
	border-color: #10b981;
	box-shadow:
		0 0 0 2px #10b981,
		0 4px 16px rgba(16, 185, 129, 0.25);
}

.theme-card.active::after {
	content: "✓";
	position: absolute;
	top: 6px;
	right: 6px;
	background: #10b981;
	color: white;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: bold;
}

.theme-preview {
	width: 50px;
	height: 50px;
	border-radius: 10px;
	margin: 0 auto 10px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-name {
	font-weight: 800;
	font-size: 13px;
	margin: 0;
	color: #334155;
}

/* Leaderboard Modal */
.leaderboard-modal {
	display: none;
	position: fixed;
	padding: 10px;
	inset: 0;
	z-index: 2000;
	align-items: center;
	justify-content: center;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: transparent;
}

.leaderboard-content {
	padding: 24px;
	width: 100%;
	max-width: min(480px, calc(100dvw - 24px));
	min-height: 140px;
	max-height: calc(100dvh - 24px);
	border: 3px solid rgba(255, 255, 255, 0.6);
	outline: 3px solid rgba(255, 255, 255, 0.8);
	outline-offset: 3px;
	backdrop-filter: blur(25px);
	-webkit-backdrop-filter: blur(25px);
	text-align: center;
	color: var(--text-color);
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	animation: slideUp 0.35s var(--ease);
	border: 3px solid rgba(255, 255, 255, 0.5);
	border-radius: var(--radius-3xl);
	background: linear-gradient(165deg, rgba(255, 255, 255, 0.65) 0%, rgba(250, 250, 255, 0.45) 50%, rgba(245, 243, 255, 0.25) 100%);
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.4),
		inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.neon-theme .leaderboard-content {
	background: linear-gradient(165deg, rgba(22, 22, 22, 0.65) 0%, rgba(71, 71, 71, 0.45) 50%, rgba(44, 44, 44, 0.25) 100%);
}

#leaderboard-list {
	width: 100%;
	position: relative;
	z-index: 1;
	padding: 0 10px;
	overflow-y: auto;
	overflow-x: hidden;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.5) transparent;
}

*::-webkit-scrollbar {
	width: 8px;
}

*::-webkit-scrollbar-track {
	background: transparent;
}

*::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.5);
	border-radius: 4px;
	border: 2px solid transparent;
	background-clip: content-box;
	transition: background 0.2s ease;
}

*::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.7);
}

.loading-leaderboard {
	text-align: center;
	padding: 20px;
	color: var(--button-text);
	font-size: 16px;
}

/* .leaderboard-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	margin: 8px 0;
	background: #ffffff;
	border-radius: 12px;
	border: 2px solid #e0e7ff;
	transition: all 0.3s ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	touch-action: manipulation;
}

.leaderboard-item:active {
	transform: scale(0.98);
}

.leaderboard-item.top-rank {
	background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
	border-color: #f59e0b;
} */

.leaderboard-username {
	flex: 1;
	margin: 0 10px;
	font-size: 15px;
	font-weight: 700;
	color: #334155;
}

.leaderboard-score {
	font-size: 16px;
	font-weight: 900;
	color: var(--button-text);
	background: #ede9fe;
	padding: 4px 12px;
	border-radius: 8px;
}

.top-rank .leaderboard-score {
	background: #f59e0b;
	color: #ffffff;
}

.theme-button {
	background-color: var(--button-text);
	color: #fff;
	border: 2px solid var(--button-border);
	box-shadow:
		inset 0 0 0 2px rgba(255, 255, 255, 0.2),
		0 0 0 0px var(--button-border),
		inset 0 0 0 4px transparent;
	border-radius: var(--radius-xl);
	cursor: pointer;
	padding: 3px;
	transition:
		transform 0.2s var(--ease),
		box-shadow 0.2s var(--ease),
		border-color 0.2s var(--ease);
	box-shadow: 0 2px 8px var(--shadow-light);
	touch-action: manipulation;
	position: relative;
}

.theme-button::before {
	content: "";
	position: absolute;
	inset: 4px;
	border: 2px solid var(--button-border);
	border-radius: inherit;
	background: transparent;
	pointer-events: none;
}

.theme-button:hover {
	box-shadow: 0 4px 12px var(--shadow-medium);
}

.theme-button:active {
	transform: scale(0.97);
}

.theme-button:focus-visible {
	outline: none;
	box-shadow: var(--focus-ring);
}

.progress-block {
	gap: 3px;
	margin-top: 12px;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

#found-words-text {
	color: var(--text-color);
	font-weight: 700;
	text-align: center;
	font-size: 1rem;
	min-height: 1.4rem;
	line-height: 1.4;
}

#hint-display {
	display: none;
	text-align: center;
	margin: 4px 0 4px 12px;
	color: var(--hint-display-color);
	font-size: 1rem;
	font-weight: 700;
	min-height: 1.25rem;
	line-height: 1.3;
}

.game-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	position: relative;
	margin-top: var(--space-12);
}

.game-actions .theme-button {
	position: relative;
	border: 3px solid white;
	border-radius: var(--radius-xl);
	background: radial-gradient(circle at left top, color-mix(in srgb, var(--gradient-start), white 20%) 0%, var(--gradient-end) 30%);
	color: white;
	box-shadow:
		inset 0 2px 4px rgba(255, 255, 255, 0.6),
		inset 0 -2px 4px rgba(0, 0, 0, 0.2),
		0 4px 12px rgba(0, 0, 0, 0.3),
		0 8px 20px var(--shadow-medium);
	transition: all 0.3s var(--ease);
	font-weight: 800;
	padding: 12px 24px;
	min-height: 52px;
}

.neon-theme .theme-button {
	border: 3px solid black;
}

.game-actions .theme-button:hover {
	transform: translateY(-2px);
	box-shadow:
		inset 0 2px 4px rgba(255, 255, 255, 0.6),
		inset 0 -2px 4px rgba(0, 0, 0, 0.2),
		0 6px 16px rgba(0, 0, 0, 0.4),
		0 12px 24px var(--shadow-medium);
}

.game-actions .theme-button:active {
	transform: translateY(0);
}

#hint-button,
#new-puzzle-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: var(--space-8) var(--space-16);
	font-size: 0.875rem;
	min-height: var(--touch-min);
}

/* Leaderboard */
.leaderboard {
	width: 350px;
}

.leaderboard-row {
	width: 100%;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	margin: 12px 0;
	border-radius: 22px;

	/* Transparent glass background */
	background: rgba(255, 255, 255, 0.25);
	backdrop-filter: blur(12px);

	/* Border */
	border: 2px solid rgba(255, 255, 255, 0.5);

	/* Soft inner + outer glow */
	box-shadow:
		inset 0 2px 6px rgba(255, 255, 255, 0.7),
		inset 0 -3px 8px rgba(0, 0, 0, 0.1),
		0 4px 12px rgba(0, 0, 0, 0.2);

	overflow: hidden;
}

.leaderboard-row::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 22px;
	padding: 2px;

	background: linear-gradient(120deg, rgba(255, 255, 255, 0.9), rgba(200, 150, 255, 0.6), rgba(255, 255, 255, 0.9));

	-webkit-mask:
		linear-gradient(#000 0 0) content-box,
		linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;

	pointer-events: none;
}

.leaderboard-row::after {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.4), transparent 40%);
	opacity: 0.6;
	pointer-events: none;
}

/* Left section */
.leaderboard-left {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* Rank circle */
.leaderboard-rank {
	position: relative;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;

	font-weight: bold;
	color: white;
	z-index: 1;

	/* Gradient fill */
	background: linear-gradient(180deg, #c77dff, #7a3cff);

	/* Border */
	border: 2px solid rgba(255, 255, 255, 0.8);

	/* Glow + depth */
	box-shadow:
		inset 0 2px 5px rgba(255, 255, 255, 0.7),
		inset 0 -3px 6px rgba(0, 0, 0, 0.25),
		0 0 10px rgba(160, 100, 255, 0.7),
		0 3px 6px rgba(0, 0, 0, 0.3);
}

.leaderboard-rank::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	padding: 2px;

	background: linear-gradient(120deg, rgba(255, 255, 255, 1), rgba(200, 150, 255, 0.9), rgba(255, 255, 255, 1));

	-webkit-mask:
		linear-gradient(#000 0 0) content-box,
		linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;

	pointer-events: none;
}

.leaderboard-rank::after {
	content: "";
	position: absolute;
	top: 15%;
	left: 20%;
	width: 60%;
	height: 40%;
	border-radius: 50%;

	background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);

	opacity: 0.7;
}

/* Name */
.leaderboard-name {
	font-weight: bold;
	color: #333;
}

/* Time pill */
.leaderboard-time {
	position: relative;
	padding: 6px 16px;
	border-radius: 999px;
	font-weight: bold;
	color: white;
	z-index: 1;

	/* Inner gradient */
	background: linear-gradient(180deg, #d58cff, #8f4dff);

	/* Border */
	border: 2px solid rgba(255, 255, 255, 0.7);

	/* Glow + depth */
	box-shadow:
		inset 0 2px 4px rgba(255, 255, 255, 0.7),
		inset 0 -3px 6px rgba(0, 0, 0, 0.2),
		0 0 10px rgba(180, 100, 255, 0.6),
		0 3px 8px rgba(0, 0, 0, 0.25);

	backdrop-filter: blur(6px);
}

.leaderboard-time::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 999px;
	padding: 2px;

	background: linear-gradient(120deg, rgba(255, 255, 255, 1), rgba(200, 150, 255, 0.9), rgba(255, 255, 255, 1));

	-webkit-mask:
		linear-gradient(#000 0 0) content-box,
		linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;

	pointer-events: none;
}

.leaderboard-time::after {
	content: "";
	position: absolute;
	top: 10%;
	left: 15%;
	width: 70%;
	height: 40%;
	border-radius: 999px;

	background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7), transparent);

	opacity: 0.6;
}

/* TOP 3 styles */
.leaderboard-row.gold {
	background: linear-gradient(#ffd86b, #ff9f1c);
	color: #5a3b00;
}

.leaderboard-row.silver {
	background: linear-gradient(#e0e0e0, #bdbdbd);
}

.leaderboard-row.bronze {
	background: linear-gradient(#ffb47b, #ff7b2f);
}

/* Highlight glow */
.leaderboard-rank.top {
	background: none;
	border: none;
	box-shadow: none;
	width: auto;
	height: auto;
	font-size: 28px;
}

.leaderboard-rank.top::before {
	background: none;
	border: none;
	box-shadow: none;
}

.leaderboard-rank.top::after {
	background: none;
	border: none;
	box-shadow: none;
}
/* Mobile: app-like layout – one screen, aligned, minimal gaps */
@media (max-width: 768px) {
	html,
	body {
		height: 100%;
		overflow: hidden;
	}

	body {
		display: flex;
		flex-direction: column;
		height: 100dvh;
		height: 100dvh;
		padding-bottom: 0;
	}

	/* Theme bar: compact, centered timer between buttons */
	/* #theme-box {
		gap: 6px;
		padding: 12px;
		height: calc(100dvh - 20px);
		max-height: min(925px, calc(100dvh - 20px));
	} */

	/* #theme-text {
		flex: 1;
		font-size: 1.75rem; 
		line-height: 1.2;
	} */

	/* #reset-timer-btn,
	#pause-btn {
		padding: 6px 12px;
		font-size: 1rem;
		min-height: 32px;
		line-height: 1.2;
		flex: 0 0 auto;
		border-radius: 8px;
	} */

	/* #timer-display {
		font-size: 1.2rem;
		min-width: 82px;
		min-height: 32px;
		line-height: 1.2;
		font-weight: 800;
		text-align: center;
		flex: 0 0 auto;
		color: #000000;
		background: rgba(255, 255, 255, 0.9);
		padding: 4px 0px;
		border-radius: 4px;
	} */

	/* .puzzle-frame {
		flex: 1;
		min-height: 0;
		width: 100%;
		max-width: none;
		height: calc(100% - 165px) !important;
		max-height: calc(100% - 165px) !important;
		border-width: 3px;
		border-radius: 18px;
		box-shadow:
			0 6px 20px rgba(0, 0, 0, 0.3),
			inset 0 1px 0 rgba(255, 255, 255, 0.08);
	} */

	/* .puzzle-frame::before {
		content: "";
		position: absolute;
		inset: 6px;
		border: 1px solid rgba(255, 255, 255, 0.06);
		border-radius: 12px;
		pointer-events: none;
	} */

	/* #game-container {
		padding: 16px;
	}

	#show-selected {
		margin-bottom: 12px;
	} */

	/* #game {
		margin: 0;
		padding: 0;
		height: calc(100% - 140px) !important;
		max-height: calc(100% - 140px) !important;
	} */

	/* #game canvas {
		width: auto !important;
		height: auto !important;
		max-width: 100% !important;
		max-height: 100% !important;
		object-fit: contain;
		display: block;
		margin: 0 auto;
	} */

	/* #found-words-text {
		margin: 0;
		padding: 0;
		font-size: 1rem;
		font-weight: 700;
		min-height: 0;
		line-height: 1.3;
		text-align: center;
	} */

	/* #hint-display {
		margin: 4px 0 0;
		font-size: 1rem;
		font-weight: 700;
		line-height: 1.3;
		text-align: center;
	} */

	/* .game-actions { 
		display: flex;
		justify-content: center;
	} */

	.nav-buttons {
		gap: 10px;
		justify-content: space-evenly;
	}

	/* .nav-btn {
		padding: 8px 4px;
		min-width: 100px;
	} */

	/* .nav-btn-icon {
		width: 26px;
		height: 26px;
	} */

	/* .nav-btn-label {
		font-size: 0.8rem;
		font-weight: 600;
	} */

	.leaderboard-content {
		padding: 12px;
		max-width: min(480px, calc(100dvw - 12px));
		max-height: calc(100dvh - 12px);
	}
}

/* Small mobile: same app alignment, tighter text */
@media (max-width: 480px) {
	/* #theme-box {
		gap: 6px;
		padding: 10px;
	} */

	/* #theme-text {
		font-size: 1.25rem;
	} */

	/* #reset-timer-btn,
	#pause-btn {
		padding: 4px 6px;
		font-size: 0.85rem;
		min-height: 30px;
		line-height: 1.2;
	} */

	/* #game-container {
		padding: 8px;
	} */

	/* #show-selected {
		margin-bottom: 8px;
	} */

	/* #game {
		height: calc(100% - 140px) !important;
		max-height: calc(100% - 140px) !important;
	} */

	/* 
	#found-words-text {
		margin: 0;
		font-size: 0.85rem;
		line-height: 1.2;
	} */

	/* #hint-display {
		margin: 4px 0 0;
		font-size: 0.85rem;
		font-weight: 700;
		line-height: 1.3;
		text-align: center;
	} */

	/* .game-actions {
		gap: 4px;
		margin: 0;
	} */

	/* #hint-button,
	#new-puzzle-button {
		padding: 6px 8px;
		font-size: 0.85rem;
		min-height: 38px;
	} */

	.nav-btn {
		width: 100%;
		min-width: auto;
	}

	/* .nav-btn-icon {
		width: 22px;
		height: 22px;
	} */

	/* .nav-btn-label {
		font-size: 0.75rem;
		font-weight: 600;
	} */
}

@media (max-width: 380px) {
	#game {
		height: calc(100% - 160px) !important;
		max-height: calc(100% - 160px) !important;
	}
}
