/* ==================== VARIABLES ==================== */
:root {
	/* Основная палитра (из логотипа) */
	--primary: #0aa7c7;
	--primary-hover: #0783a1;
	--primary-light: #38d7f2;
	--secondary: #16344a;
	--secondary-light: #1f5f86;
	--accent: #d8b884;
	--accent-hover: #c49a5e;
	--success: #10b981;
	--danger: #ef4444;
	--warning: #f59e0b;

	/* Фоны */
	--bg-dark: #07131c;
	--bg-medium: #0b1d2a;
	--bg-card: #0f2533;
	--bg-card-hover: #143142;

	/* Текст */
	--text-primary: #f5f7fb;
	--text-secondary: #a7b7c8;
	--text-muted: #7d8ea3;

	/* Границы и тени */
	--border: #1a3a4a;
	--border-light: #22485b;
	--shadow: 0 10px 30px rgba(3, 12, 20, 0.55);
	--shadow-glow: 0 0 30px rgba(10, 167, 199, 0.35);
	--shadow-gold: 0 0 25px rgba(216, 184, 132, 0.35);

	/* Размеры */
	--radius: 12px;
	--radius-lg: 16px;
	--radius-sm: 8px;

	/* Градиенты */
	--gradient-primary: linear-gradient(135deg, #0aa7c7 0%, #0a7ea3 100%);
	--gradient-gold: linear-gradient(135deg, #d8b884 0%, #b98d4b 100%);
	--gradient-bg: radial-gradient(1200px circle at 15% -10%, rgba(12, 164, 196, 0.18), transparent 55%),
		radial-gradient(900px circle at 85% 10%, rgba(216, 184, 132, 0.12), transparent 60%),
		linear-gradient(180deg, #07131c 0%, #0b1d2a 50%, #0f2533 100%);
	--gradient-card: linear-gradient(145deg, #0f2533 0%, #0a1a25 100%);

	/* Background image */
	--bg-image: none;
}

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

html {
	scroll-behavior: smooth;
}

body {
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background-image: var(--bg-image), var(--gradient-bg);
	background-size: cover, auto;
	background-position: center, center;
	background-repeat: no-repeat, no-repeat;
	background-attachment: fixed;
	color: var(--text-primary);
	min-height: 100vh;
	line-height: 1.6;
	position: relative;
}

body::before,
body::after {
	content: '';
	position: fixed;
	inset: -20%;
	pointer-events: none;
	z-index: -1;
}

body::before {
	background: radial-gradient(900px circle at 10% 0%, rgba(216, 184, 132, 0.08), transparent 60%);
}

body::after {
	background: radial-gradient(800px circle at 90% 10%, rgba(12, 164, 196, 0.1), transparent 60%);
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

::-webkit-scrollbar-track {
	background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
	background: var(--secondary);
	border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
	background: var(--primary);
}

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3, h4, h5, h6 {
	font-weight: 600;
	line-height: 1.3;
}

.section-title {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--text-primary);
	margin-bottom: 20px;
	text-align: center;
	background: var(--gradient-gold);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	text-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

a {
	color: var(--primary-light);
	text-decoration: none;
	transition: color 0.2s;
}

a:hover {
	color: var(--primary);
}

/* ==================== CONTAINER ==================== */
.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 20px;
}

.app-container {
	max-width: 1400px;
	margin: 0 auto;
	padding: 24px;
	width: 100%;
}

.admin-container {
	max-width: 1400px;
	margin: 0 auto;
	padding: 24px;
	width: 100%;
}

.app-main {
	max-width: 1200px;
	margin: 0 auto;
	width: 100%;
}

.game-section {
	max-width: 100%;
	margin: 0 auto;
}

.image-selection {
	max-width: 1200px;
	margin: 0 auto;
}

/* ==================== HEADER ==================== */
header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 30px;
	padding: 20px 0;
	border-bottom: 1px solid var(--border);
}

.app-header {
	align-items: center;
}

header h1,
.app-title {
	font-size: 1.8rem;
	font-weight: 700;
	background: var(--gradient-primary);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
}

.app-title-container {
	display: flex;
	align-items: center;
	gap: 12px;
	max-height: 60px;
}

.app-title-container img {
	width: clamp(24px, 3.2vw, 32px);
	height: clamp(24px, 3.2vw, 32px);
}

.app-title-icon {
	width: clamp(24px, 3.2vw, 32px);
	height: clamp(24px, 3.2vw, 32px);
	object-fit: contain;
	filter: drop-shadow(0 0 8px rgba(10, 167, 199, 0.5));
}

.app-header .app-title-icon {
	width: 32px;
	height: 32px;
}

.app-title-icon,
header h1 .logo-icon,
header img {
	max-width: 48px;
	max-height: 48px;
}

.app-title {
	font-size: clamp(1.3rem, 2.1vw, 1.8rem);
}

header h1 .logo-icon {
	width: 40px;
	height: 40px;
}

#user-info {
	display: flex;
	align-items: center;
	gap: 15px;
}

#username {
	font-weight: 500;
	color: var(--accent);
}

/* ==================== BUTTONS ==================== */
.btn {
	padding: 12px 24px;
	border: none;
	border-radius: var(--radius-sm);
	font-size: 1rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-family: inherit;
	box-shadow: var(--shadow);
	border: 1px solid transparent;
	position: relative;
	overflow: hidden;
}

.btn::after {
	content: '';
	position: absolute;
	inset: -1px;
	background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.35) 35%, transparent 65%);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.btn-primary:hover::after,
.btn-gold:hover::after {
	opacity: 0.35;
}

.btn-primary {
	background: var(--gradient-primary);
	color: white;
	box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(10, 167, 199, 0.5);
}

.btn-secondary {
	background: var(--bg-card);
	color: var(--text-primary);
	border: 1px solid var(--border);
}

.btn-secondary:hover {
	background: var(--bg-card-hover);
	border-color: var(--primary);
}

.btn-gold {
	background: var(--gradient-gold);
	color: var(--bg-dark);
	font-weight: 600;
	box-shadow: var(--shadow-gold);
	border: 1px solid rgba(216, 184, 132, 0.4);
}

.btn-gold:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 25px rgba(216, 184, 132, 0.5);
}

.btn-danger {
	background: var(--danger);
	color: white;
	box-shadow: 0 8px 22px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
	background: #dc2626;
	transform: translateY(-1px);
}

.btn-success {
	background: var(--success);
	color: white;
	box-shadow: 0 8px 22px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
	background: #059669;
}

.btn-sm {
	padding: 8px 16px;
	font-size: 0.875rem;
}

.btn-lg {
	padding: 14px 32px;
	font-size: 1.1rem;
}

.btn-block {
	width: 100%;
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none !important;
}

.btn-icon {
	width: 40px;
	height: 40px;
	padding: 0;
	border-radius: 50%;
}

.btn:focus-visible,
.grid-size-btn:focus-visible,
.tab-btn:focus-visible,
.admin-tab:focus-visible {
	outline: 2px solid var(--primary-light);
	outline-offset: 2px;
}

/* ==================== SCREENS & ANIMATIONS ==================== */
.screen {
	animation: fadeIn 0.3s ease;
}

.hidden {
	display: none !important;
}

@keyframes fadeIn {
	from { 
		opacity: 0; 
		transform: translateY(10px); 
	}
	to { 
		opacity: 1; 
		transform: translateY(0); 
	}
}

@keyframes slideIn {
	from {
		opacity: 0;
		transform: translateX(-20px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

@keyframes slideInRight {
	from {
		opacity: 0;
		transform: translateX(20px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

@keyframes pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.05); }
}

@keyframes glow {
	0%, 100% { box-shadow: 0 0 20px rgba(10, 167, 199, 0.3); }
	50% { box-shadow: 0 0 40px rgba(10, 167, 199, 0.6); }
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

@keyframes fadeOut {
	from {
		opacity: 1;
		transform: translateX(0);
	}
	to {
		opacity: 0;
		transform: translateX(100px);
	}
}

@keyframes bounce {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-10px); }
}

/* ==================== PUZZLE SELECT ==================== */
#puzzle-select h2 {
	font-size: 1.5rem;
	margin-bottom: 20px;
	color: var(--text-primary);
}

.controls-row {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	margin-bottom: 25px;
	align-items: center;
}

.difficulty-selector {
	display: flex;
	align-items: center;
	gap: 10px;
}

.difficulty-selector label {
	color: var(--text-secondary);
	font-weight: 500;
}

/* ==================== FORM ELEMENTS ==================== */
.form-select,
.difficulty-selector select {
	padding: 10px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 1rem;
	background: var(--bg-card);
	color: var(--text-primary);
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
	min-width: 120px;
}

.form-select:hover,
.difficulty-selector select:hover {
	border-color: var(--primary);
}

.form-select:focus,
.difficulty-selector select:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(10, 167, 199, 0.2);
}

.form-group {
	margin-bottom: 20px;
}

.form-group label {
	display: block;
	margin-bottom: 8px;
	color: var(--text-secondary);
	font-weight: 500;
	font-size: 0.875rem;
}

.form-group input,
.form-group textarea {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	font-size: 1rem;
	background: var(--bg-dark);
	color: var(--text-primary);
	transition: all 0.2s;
	font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
	outline: none;
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(10, 167, 199, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
	color: var(--text-muted);
}

.form-group input[type="file"] {
	padding: 10px;
	cursor: pointer;
}

.form-group input[type="file"]::-webkit-file-upload-button {
	padding: 8px 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg-card);
	color: var(--text-primary);
	cursor: pointer;
	margin-right: 10px;
	transition: all 0.2s;
}

.form-group input[type="file"]::-webkit-file-upload-button:hover {
	background: var(--bg-card-hover);
	border-color: var(--primary);
}

.form-hint {
	display: block;
	margin-top: 6px;
	font-size: 0.75rem;
	color: var(--text-muted);
	transition: all 0.2s;
}

.form-hint.error {
	color: var(--danger);
}

.form-hint.success {
	color: var(--success);
}

.form-row {
	display: flex;
	gap: 15px;
	align-items: flex-end;
	flex-wrap: wrap;
}

.form-row .form-group {
	flex: 1;
	min-width: 150px;
	margin-bottom: 0;
}

.form-checkboxes {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	margin-top: 8px;
}

.checkbox-label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	padding: 8px 12px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	transition: all 0.2s;
}

.checkbox-label:hover {
	border-color: var(--primary);
	background: var(--bg-card-hover);
}

.form-checkbox {
	width: 18px;
	height: 18px;
	cursor: pointer;
	accent-color: var(--primary);
}

.image-card-sizes {
	margin: 10px 0;
	padding: 12px;
	background: linear-gradient(145deg, var(--bg-dark) 0%, var(--bg-card) 100%);
	border-radius: var(--radius);
	font-size: 0.875rem;
	color: var(--text-secondary);
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	border: 1px solid var(--border);
}

.image-card-sizes strong {
	color: var(--text-primary);
	margin-right: 5px;
	width: 100%;
	margin-bottom: 6px;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	font-weight: 600;
}

.grid-size-btn {
	padding: 8px 14px;
	background: linear-gradient(180deg, rgba(13, 34, 46, 0.95), rgba(9, 24, 34, 0.9));
	color: var(--text-primary);
	border: 1px solid var(--border-light);
	border-radius: var(--radius-sm);
	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;
	transition: all 0.25s ease;
	box-shadow: var(--shadow);
	font-family: inherit;
	position: relative;
	overflow: hidden;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	min-width: 56px;
}

.grid-size-btn::before {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, rgba(216, 184, 132, 0.18) 0%, transparent 100%);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.grid-size-btn::after {
	content: '';
	position: absolute;
	inset: -1px;
	background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.2) 35%, transparent 65%);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.grid-size-btn:hover {
	transform: translateY(-2px);
	background: var(--gradient-primary);
	color: white;
	border-color: rgba(10, 167, 199, 0.5);
	box-shadow: var(--shadow-glow);
}

.grid-size-btn:hover::before {
	opacity: 1;
}

.grid-size-btn:hover::after {
	opacity: 0.35;
}

.grid-size-btn:active {
	transform: translateY(-1px);
	box-shadow: var(--shadow);
}

.grid-size-btn[disabled],
.grid-size-btn.is-completed {
	cursor: not-allowed;
	opacity: 0.6;
	background: var(--bg-dark);
	color: var(--text-muted);
	border-color: var(--border);
	box-shadow: none;
	transform: none;
}

.grid-size-btn[disabled]::before,
.grid-size-btn[disabled]::after,
.grid-size-btn.is-completed::before,
.grid-size-btn.is-completed::after {
	opacity: 0;
}

.grid-size-btn[disabled]:hover,
.grid-size-btn.is-completed:hover {
	transform: none;
	background: var(--bg-dark);
	color: var(--text-muted);
	box-shadow: none;
}

.card-sizes {
	margin: 10px 0;
	padding: 8px;
	background: var(--bg-dark);
	border-radius: var(--radius-sm);
	font-size: 0.875rem;
	color: var(--text-secondary);
}

.modal-actions {
	display: flex;
	gap: 10px;
	justify-content: flex-end;
	margin-top: 20px;
}

/* ==================== IMAGES GRID ==================== */
.images-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 20px;
	margin-bottom: 30px;
	max-width: 1200px;
	margin-left: auto;
	margin-right: auto;
}

.image-card-preview img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.image-card-info {
	padding: 15px;
}

.image-card-title {
	font-weight: 600;
	margin-bottom: 10px;
	color: var(--text-primary);
}


.image-card-stats {
	color: var(--text-muted);
	font-size: 0.85rem;
}

.image-card {
	background: var(--gradient-card);
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: var(--shadow);
	cursor: pointer;
	transition: all 0.3s ease;
	border: 1px solid var(--border);
	position: relative;
}

.image-card::before,
.admin-image-card::before,
.auth-card::before,
.auth-box::before,
.modal-content::before,
.stats-card::before,
.settings-card::before,
.upload-card::before,
.upload-form::before,
.win-stats::before,
.stats-detail::before,
.analytics-card::before,
.stat::before,
.stat-item::before,
.leaderboard-table-wrapper::before,
.logs-table-wrapper::before,
.table-wrapper::before {
	content: '';
	position: absolute;
	inset: -1px;
	background: radial-gradient(900px circle at 5% -20%, rgba(216, 184, 132, 0.18), transparent 55%),
		radial-gradient(700px circle at 110% 0%, rgba(12, 164, 196, 0.18), transparent 55%);
	opacity: 0.6;
	pointer-events: none;
}

.admin-image-card,
.auth-card,
.auth-box,
.modal-content,
.stats-card,
.settings-card,
.upload-card,
.upload-form,
.win-stats,
.stats-detail,
.analytics-card,
.stat,
.stat-item,
.leaderboard-table-wrapper,
.logs-table-wrapper,
.table-wrapper {
	position: relative;
	overflow: hidden;
}

.image-card:hover {
	transform: translateY(-8px);
	box-shadow: var(--shadow-glow);
	border-color: var(--primary);
}

.image-card .card-image {
	position: relative;
	overflow: hidden;
}

.image-card img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.image-card:hover img {
	transform: scale(1.05);
}

.image-card .difficulty-badge {
	position: absolute;
	top: 10px;
	right: 10px;
	padding: 4px 10px;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
}

.difficulty-badge.easy {
	background: var(--success);
	color: white;
}

.difficulty-badge.medium {
	background: var(--warning);
	color: var(--bg-dark);
}

.difficulty-badge.hard {
	background: var(--danger);
	color: white;
}

.image-card .card-info {
	padding: 15px;
}

.image-card .card-title {
	font-weight: 600;
	margin-bottom: 5px;
	color: var(--text-primary);
}

.image-card .card-meta {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.image-card .card-plays {
	color: var(--text-muted);
	font-size: 0.875rem;
}

.image-card .card-grid {
	color: var(--primary-light);
	font-size: 0.875rem;
	font-weight: 500;
}

/* ==================== GAME SCREEN ==================== */
.game-section {
	max-width: 1000px;
	margin: 0 auto;
	padding: 0 20px;
}

.game-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
	flex-wrap: wrap;
	gap: 15px;
	max-width: 100%;
}

.game-stats {
	display: flex;
	gap: 30px;
}

.stat,
.stat-item {
	text-align: center;
	background: var(--bg-card);
	padding: 12px 20px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
}

.stat-label {
	color: var(--text-muted);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	display: block;
	margin-bottom: 4px;
}

.stat-value {
	font-size: 1.5rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	color: var(--primary-light);
}

.stat-value.warning {
	color: var(--warning);
}

.game-controls {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: center;
	max-width: 100%;
}

.game-controls .btn {
	flex: 1;
	min-width: 120px;
	max-width: 200px;
}

.god-mode-panel {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin: 10px 0 25px;
	padding: 10px 14px;
	border: 1px dashed var(--border-light);
	border-radius: var(--radius);
	background: rgba(7, 19, 28, 0.6);
}

.god-mode-panel.hidden {
	display: none;
}

.god-mode-label {
	color: var(--text-muted);
	font-size: 0.9rem;
}

/* ==================== PUZZLE BOARD ==================== */
.puzzle-wrapper {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	--puzzle-size: clamp(260px, 70vmin, 520px);
	max-width: var(--puzzle-size);
	margin: 0 auto 25px;
	position: relative;
}

#puzzle-container {
	display: grid;
	gap: 4px;
	justify-content: center;
	align-items: center;
	position: relative;
	padding: 8px;
	background: linear-gradient(145deg, var(--secondary) 0%, var(--bg-medium) 100%);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow), inset 0 2px 10px rgba(0, 0, 0, 0.3);
	border: 2px solid var(--border);
	width: 100%;
	width: var(--puzzle-size);
	max-width: var(--puzzle-size);
	aspect-ratio: 1;
	touch-action: none;
}

#puzzle-container.size-3 {
	grid-template-columns: repeat(3, 1fr);
	grid-template-rows: repeat(3, 1fr);
}

#puzzle-container.size-4 {
	grid-template-columns: repeat(4, 1fr);
	grid-template-rows: repeat(4, 1fr);
}

#puzzle-container.size-5 {
	grid-template-columns: repeat(5, 1fr);
	grid-template-rows: repeat(5, 1fr);
}

#puzzle-container.size-6 {
	grid-template-columns: repeat(6, 1fr);
	grid-template-rows: repeat(6, 1fr);
}

#puzzle-container.size-7 {
	grid-template-columns: repeat(7, 1fr);
	grid-template-rows: repeat(7, 1fr);
}

#puzzle-container.size-8 {
	grid-template-columns: repeat(8, 1fr);
	grid-template-rows: repeat(8, 1fr);
}

#puzzle-board {
	display: grid;
	gap: 4px;
	background: linear-gradient(145deg, var(--secondary) 0%, var(--bg-medium) 100%);
	padding: 8px;
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow), inset 0 2px 10px rgba(0, 0, 0, 0.3);
	border: 2px solid var(--border);
	position: relative;
	touch-action: none;
}

#puzzle-board.size-3 {
	grid-template-columns: repeat(3, 1fr);
}

#puzzle-board.size-4 {
	grid-template-columns: repeat(4, 1fr);
}

#puzzle-board.size-5 {
	grid-template-columns: repeat(5, 1fr);
}

#puzzle-board.size-6 {
	grid-template-columns: repeat(6, 1fr);
}

#puzzle-board.completed {
	animation: glow 1s ease infinite;
}

#puzzle-board.completed .puzzle-tile {
	cursor: default;
}

/* ==================== PUZZLE TILES ==================== */
.puzzle-tile {
	width: 100%;
	height: 100%;
	aspect-ratio: 1;
	background-size: cover;
	background-position: center;
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
	position: relative;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	border: 1px solid rgba(255, 255, 255, 0.1);
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	min-width: 0;
	min-height: 0;
}

.puzzle-tile.empty {
	background: transparent !important;
	cursor: default;
	box-shadow: none;
	border: none;
}

.puzzle-tile:not(.empty):hover {
	transform: scale(1.03);
	box-shadow: 0 4px 15px rgba(10, 167, 199, 0.4);
	z-index: 5;
}

.puzzle-tile:not(.empty):active {
	transform: scale(0.97);
}

.puzzle-tile.movable {
	cursor: pointer;
}

.puzzle-tile.movable::after {
	content: '';
	position: absolute;
	inset: -2px;
	border: 2px solid var(--primary-light);
	border-radius: var(--radius-sm);
	opacity: 0;
	transition: opacity 0.2s;
}

.puzzle-tile.movable:hover::after {
	opacity: 1;
}

.puzzle-tile.moving {
	z-index: 10;
	transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.puzzle-tile .tile-number {
	position: absolute;
	bottom: 4px;
	right: 4px;
	background: rgba(0, 0, 0, 0.7);
	color: white;
	font-size: 0.625rem;
	padding: 2px 5px;
	border-radius: 4px;
	font-weight: 600;
}

.puzzle-tile.animating {
	z-index: 10;
	will-change: transform;
}

.puzzle-tile.hint-highlight {
	animation: hintPulse 1s ease;
	box-shadow: 0 0 20px rgba(10, 167, 199, 0.8);
	z-index: 15;
}

@keyframes hintPulse {
	0%, 100% {
		transform: scale(1);
		box-shadow: 0 0 20px rgba(10, 167, 199, 0.8);
	}
	50% {
		transform: scale(1.1);
		box-shadow: 0 0 30px rgba(10, 167, 199, 1);
	}
}

.btn.paused {
	background: var(--success);
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* ==================== PAUSE OVERLAY ==================== */
#pause-overlay {
	position: absolute;
	inset: 0;
	background: rgba(7, 19, 28, 0.75);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-lg);
	z-index: 20;
	backdrop-filter: blur(10px);
	animation: fadeIn 0.2s ease;
}

#pause-overlay.hidden {
	display: none;
}

#pause-overlay h3 {
	font-size: 2.5rem;
	margin-bottom: 10px;
	color: var(--accent);
}

#pause-overlay p {
	color: var(--text-secondary);
	margin-bottom: 25px;
	font-size: 1.1rem;
}

/* ==================== GAME ACTIONS ==================== */
.game-actions {
	display: flex;
	justify-content: center;
	gap: 15px;
	flex-wrap: wrap;
}

/* ==================== MODALS ==================== */
.modal {
	position: fixed;
	inset: 0;
	background: rgba(10, 22, 40, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	animation: fadeIn 0.2s ease;
	backdrop-filter: blur(5px);
	padding: 20px;
}

.modal-content {
	background: var(--gradient-card);
	padding: 35px;
	border-radius: var(--radius-lg);
	text-align: center;
	max-width: 450px;
	width: 100%;
	border: 1px solid var(--border);
	box-shadow: var(--shadow-glow);
	animation: slideIn 0.3s ease;
	position: relative;
	max-height: 90vh;
	overflow-y: auto;
}

.modal-large {
	max-width: 750px;
}

.preview-modal {
	max-width: min(90vw, 560px);
}

.preview-puzzle-container {
	display: grid;
	width: min(80vmin, 420px);
	height: min(80vmin, 420px);
	max-width: 80vw;
	max-height: 70vh;
	margin: 20px auto;
	border: 2px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--bg-dark);
	box-shadow: var(--shadow);
}

.modal h2 {
	margin-bottom: 15px;
	font-size: 1.75rem;
	background: var(--gradient-gold);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.modal p {
	margin-bottom: 20px;
	color: var(--text-secondary);
}

.modal-close {
	position: absolute;
	top: 15px;
	right: 15px;
	background: none;
	border: none;
	color: var(--text-muted);
	font-size: 1.5rem;
	cursor: pointer;
	transition: color 0.2s;
	padding: 5px;
	line-height: 1;
}

.modal-close:hover {
	color: var(--text-primary);
}

/* ==================== PREVIEW MODAL ==================== */
#preview-image {
	max-width: 100%;
	max-height: min(60vh, 420px);
	border-radius: var(--radius);
	margin-bottom: 15px;
	box-shadow: var(--shadow);
}

.preview-penalty {
	background: rgba(245, 158, 11, 0.2);
	color: var(--warning);
	padding: 10px 20px;
	border-radius: 25px;
	font-size: 0.875rem;
	font-weight: 600;
	display: inline-block;
	margin-bottom: 20px;
	border: 1px solid var(--warning);
}

/* ==================== WIN MODAL ==================== */
.win-icon {
	font-size: 5rem;
	margin-bottom: 15px;
	animation: bounce 1s ease infinite;
}

.win-stats {
	background: var(--bg-dark);
	padding: 25px;
	border-radius: var(--radius);
	margin-bottom: 25px;
	border: 1px solid var(--border);
}

.win-stats-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 20px;
}

.win-stat {
	text-align: center;
}

.win-stat-label {
	color: var(--text-muted);
	font-size: 0.875rem;
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.win-stat-value {
	font-size: 2rem;
	font-weight: 700;
	color: var(--primary-light);
}

.win-stat-value.gold {
	color: var(--accent);
}

.win-actions {
	display: flex;
	gap: 12px;
	justify-content: center;
	flex-wrap: wrap;
}

/* Win leaderboard */
.win-leaderboard {
	margin-top: 25px;
	text-align: left;
}

.win-leaderboard h3 {
	text-align: center;
	margin-bottom: 15px;
	font-size: 1.1rem;
	color: var(--text-primary);
}

.win-leaderboard .leaderboard-table-wrapper {
	max-height: 250px;
}

/* ==================== LEADERBOARD ==================== */
.leaderboards-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 20px;
	max-width: 1200px;
	margin: 0 auto;
}

.leaderboard-section-item {
	margin-bottom: 40px;
}

.leaderboard-size-title {
	font-size: 1.3rem;
	color: var(--primary-light);
	margin-bottom: 15px;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--border);
	text-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.leaderboard-filters {
	display: flex;
	gap: 10px;
	margin-bottom: 20px;
	justify-content: center;
	flex-wrap: wrap;
}

.leaderboard-table-wrapper {
	max-height: 400px;
	overflow-y: auto;
	margin-bottom: 20px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--bg-card);
	box-shadow: var(--shadow);
}

.leaderboard-table th,
.leaderboard-table td {
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.leaderboard-section .empty-state p,
.leaderboard-section .error-message {
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.table-wrapper {
	max-width: 100%;
	overflow: auto;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--bg-card);
	box-shadow: var(--shadow);
}

#leaderboard-table,
#win-leaderboard-table,
.leaderboard-table,
.admin-table {
	width: 100%;
	border-collapse: collapse;
}

#leaderboard-table th,
#leaderboard-table td,
#win-leaderboard-table th,
#win-leaderboard-table td,
.leaderboard-table th,
.leaderboard-table td,
.admin-table th,
.admin-table td {
	padding: 12px 15px;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

#leaderboard-table th,
#win-leaderboard-table th,
.leaderboard-table th,
.admin-table th {
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	font-size: 0.7rem;
	letter-spacing: 0.5px;
	background: var(--bg-dark);
	position: sticky;
	top: 0;
	z-index: 1;
}

#leaderboard-table tbody tr,
#win-leaderboard-table tbody tr,
.leaderboard-table tbody tr,
.admin-table tbody tr {
	transition: background 0.2s;
}

#leaderboard-table tbody tr:hover,
#win-leaderboard-table tbody tr:hover,
.leaderboard-table tbody tr:hover,
.admin-table tbody tr:hover {
	background: var(--bg-card-hover);
}

#leaderboard-table tbody tr:last-child td,
#win-leaderboard-table tbody tr:last-child td,
.leaderboard-table tbody tr:last-child td,
.admin-table tbody tr:last-child td {
	border-bottom: none;
}

.rank-cell {
	font-weight: 700;
	font-size: 1.1rem;
}

.rank-cell.top-1 {
	color: #ffd700;
	text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.rank-cell.top-2 {
	color: #c0c0c0;
	text-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.rank-cell.top-3 {
	color: #cd7f32;
	text-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

.current-user {
	background: rgba(10, 167, 199, 0.15) !important;
}

.current-user td {
	color: var(--primary-light);
	font-weight: 500;
}

.you-badge {
	background: var(--primary);
	color: white;
	padding: 2px 6px;
	border-radius: 10px;
	font-size: 0.7rem;
	margin-left: 5px;
	font-weight: 600;
}

.loading-cell,
.empty-cell,
.error-text {
	text-align: center;
	padding: 40px !important;
	color: var(--text-muted);
}

.loading-cell .spinner {
	margin: 0 auto;
}

.error-text {
	color: var(--danger);
}

/* ==================== AUTH PAGES ==================== */
.auth-container {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	padding: 20px;
}

.auth-card {
	background: var(--gradient-card);
	border-radius: var(--radius-lg);
	padding: 40px;
	box-shadow: var(--shadow);
	border: 1px solid var(--border);
	max-width: 450px;
	width: 100%;
}

.auth-header {
	text-align: center;
	margin-bottom: 30px;
}

.auth-logo-container {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-bottom: 10px;
}

.auth-logo-img {
	width: clamp(32px, 5vw, 44px);
	height: clamp(32px, 5vw, 44px);
	object-fit: contain;
	filter: drop-shadow(0 0 10px rgba(10, 167, 199, 0.5));
}

.auth-title {
	font-size: 2rem;
	font-weight: 700;
	background: var(--gradient-primary);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	margin: 0;
}

.auth-subtitle {
	text-align: center;
	color: var(--text-muted);
	margin-bottom: 30px;
	font-size: 0.95rem;
}

.auth-box {
	background: var(--gradient-card);
	padding: 40px;
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-glow);
	width: 100%;
	max-width: 420px;
	border: 1px solid var(--border);
}

.auth-box h1 {
	text-align: center;
	margin-bottom: 10px;
	font-size: 2rem;
	background: var(--gradient-gold);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

.auth-subtitle {
	text-align: center;
	color: var(--text-muted);
	margin-bottom: 30px;
}

.tabs {
	display: inline-flex;
	margin: 0 auto 30px;
	background: var(--bg-dark);
	border-radius: var(--radius);
	padding: 4px;
	gap: 4px;
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
	width: fit-content;
	max-width: 100%;
}

.tab-btn {
	flex: 1;
	padding: 10px 18px;
	background: var(--bg-card);
	border: 1px solid var(--border);
	font-size: 0.95rem;
	cursor: pointer;
	color: var(--text-muted);
	border-radius: var(--radius-sm);
	transition: all 0.3s ease;
	font-weight: 600;
	font-family: inherit;
	position: relative;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-shadow: var(--shadow);
	min-width: 130px;
}

.tab-btn::before {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--gradient-primary);
	opacity: 0;
	transition: opacity 0.3s ease;
	z-index: -1;
}

.tab-btn.active {
	background: var(--gradient-primary);
	color: white;
	box-shadow: var(--shadow-glow);
	border-color: rgba(10, 167, 199, 0.5);
}

.tab-btn.active::before {
	opacity: 1;
}

.tab-btn:hover:not(.active) {
	color: var(--text-primary);
	background: var(--bg-card-hover);
	border-color: var(--border-light);
}

.auth-form {
	animation: fadeIn 0.3s ease;
}

.auth-divider {
	display: flex;
	align-items: center;
	margin: 25px 0;
	color: var(--text-muted);
}

.auth-divider::before,
.auth-divider::after {
	content: '';
	flex: 1;
	height: 1px;
	background: var(--border);
}

.auth-divider span {
	padding: 0 15px;
	font-size: 0.875rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.error-message,
.form-error {
	background: rgba(239, 68, 68, 0.1);
	border: 1px solid var(--danger);
	color: var(--danger);
	padding: 12px;
	border-radius: var(--radius-sm);
	margin-top: 15px;
	font-size: 0.875rem;
}

.success-message {
	background: rgba(16, 185, 129, 0.1);
	border: 1px solid var(--success);
	color: var(--success);
	padding: 12px;
	border-radius: var(--radius-sm);
	margin-top: 15px;
	font-size: 0.875rem;
}

/* ==================== SPINNER ==================== */
.spinner {
	width: 40px;
	height: 40px;
	border: 3px solid var(--border);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

.spinner-sm {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: white;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	vertical-align: middle;
	margin-right: 8px;
}

.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px;
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
	position: fixed;
	inset: 0;
	background: rgba(7, 19, 28, 0.85);
	backdrop-filter: blur(6px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1500;
	padding: 20px;
}

.loading-overlay.hidden {
	display: none;
}

.loading-content {
	background: var(--gradient-card);
	border-radius: var(--radius-lg);
	padding: 30px 35px;
	border: 1px solid var(--border);
	box-shadow: var(--shadow-glow);
	text-align: center;
	min-width: 220px;
}

.loading-message {
	margin-top: 12px;
	color: var(--text-secondary);
	font-size: 0.95rem;
}

/* ==================== ALREADY PLAYED SCREEN ==================== */
.already-played-screen {
	text-align: center;
	padding: 60px 20px;
	max-width: 500px;
	margin: 0 auto;
	animation: fadeIn 0.5s ease;
}

.already-played-screen .played-icon {
	font-size: 5rem;
	margin-bottom: 20px;
	animation: pulse 2s ease infinite;
}

.already-played-screen h2 {
	font-size: 2rem;
	background: var(--gradient-gold);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	margin-bottom: 15px;
}

.already-played-screen p {
	color: var(--text-secondary);
	margin-bottom: 10px;
	font-size: 1.1rem;
	line-height: 1.6;
}

.already-played-screen .your-result {
	background: var(--bg-card);
	padding: 25px;
	border-radius: var(--radius);
	margin: 30px 0;
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
}

.already-played-screen .your-result h3 {
	color: var(--text-primary);
	margin-bottom: 0;
	font-size: 1.1rem;
}

.already-played-screen .btn {
	margin-top: 20px;
}

.already-played-message {
	text-align: center;
	padding: 20px 0;
}

.already-played-message .played-icon {
	font-size: 4rem;
	margin-bottom: 15px;
}

.already-played-message h2 {
	color: var(--accent);
	margin-bottom: 15px;
}

.already-played-message p {
	color: var(--text-secondary);
	margin-bottom: 10px;
}

.already-played-message .btn {
	margin-top: 20px;
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
	text-align: center;
	padding: 60px 20px;
	grid-column: 1 / -1;
}

.empty-state .empty-icon {
	font-size: 4rem;
	margin-bottom: 20px;
	opacity: 0.5;
}

.empty-state p {
	color: var(--text-secondary);
	font-size: 1.1rem;
	margin-bottom: 5px;
}

.empty-state .empty-hint {
	color: var(--text-muted);
	font-size: 0.875rem;
}

/* ==================== ADMIN PAGES ==================== */
.admin-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 30px;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--border);
}

.admin-header h1 {
	font-size: 1.8rem;
	background: var(--gradient-gold);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	text-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.admin-header-actions {
	display: flex;
	align-items: center;
	gap: 15px;
}

#admin-name {
	color: var(--text-secondary);
	font-size: 0.875rem;
}

.admin-nav,
.admin-tabs {
	display: flex;
	gap: 10px;
	margin-bottom: 30px;
	flex-wrap: wrap;
}

.admin-tab {
	padding: 12px 24px;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text-secondary);
	cursor: pointer;
	transition: all 0.2s;
	font-size: 1rem;
	font-weight: 500;
	font-family: inherit;
	box-shadow: var(--shadow);
}

.admin-tab:hover {
	border-color: var(--primary);
	color: var(--text-primary);
}

.admin-tab.active {
	background: var(--gradient-primary);
	border-color: rgba(10, 167, 199, 0.5);
	color: white;
	box-shadow: var(--shadow-glow);
}

.admin-section {
	animation: fadeIn 0.3s ease;
}

.section-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 25px;
	flex-wrap: wrap;
	gap: 15px;
}

.section-header h2 {
	font-size: 1.5rem;
	color: var(--text-primary);
	text-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.section-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.section-header-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

/* Back link */
.admin-back-link {
	margin-top: 25px;
	text-align: center;
}

.admin-back-link a {
	color: var(--text-muted);
	text-decoration: none;
	font-size: 0.875rem;
	transition: color 0.2s;
}

.admin-back-link a:hover {
	color: var(--primary-light);
}

/* ==================== UPLOAD FORM ==================== */
.upload-card {
	background: var(--gradient-card);
	padding: 25px;
	border-radius: var(--radius);
	margin-bottom: 30px;
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
}

.upload-card h3,
.stats-card h3,
.stats-detail h3,
.analytics-card h4 {
	text-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.upload-form {
	background: var(--bg-card);
	padding: 25px;
	border-radius: var(--radius);
	margin-bottom: 30px;
	border: 1px solid var(--border);
}

/* ==================== ADMIN IMAGES GRID ==================== */
.images-admin-grid {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 20px;
	max-width: 1200px;
	margin: 0 auto;
}

.admin-image-card {
	background: var(--bg-card);
	border-radius: var(--radius);
	overflow: hidden;
	border: 1px solid var(--border);
	transition: all 0.3s ease;
	box-shadow: var(--shadow);
}

.admin-image-card:hover {
	border-color: var(--primary);
	transform: translateY(-4px);
	box-shadow: var(--shadow-glow);
}

.admin-image-card img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	cursor: pointer;
	transition: transform 0.3s ease;
}

.admin-image-card:hover img {
	transform: scale(1.05);
}

.admin-image-card .card-body {
	padding: 15px;
}

.admin-image-card .card-title {
	font-weight: 600;
	margin-bottom: 10px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
}

.admin-image-card .card-title span:first-child {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.admin-image-card .card-stats {
	display: flex;
	gap: 15px;
	margin-bottom: 15px;
	font-size: 0.8rem;
	color: var(--text-muted);
	flex-wrap: wrap;
}

.admin-image-card .card-stats span {
	display: flex;
	align-items: center;
	gap: 4px;
}

.admin-image-card .card-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.admin-image-card .card-actions .btn {
	flex: 1;
	min-width: 100px;
}

.status-badge {
	padding: 4px 10px;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 600;
	white-space: nowrap;
}

.status-badge.active {
	background: rgba(16, 185, 129, 0.2);
	color: var(--success);
}

.status-badge.inactive {
	background: rgba(239, 68, 68, 0.2);
	color: var(--danger);
}

/* ==================== STATS CARDS ==================== */
.stats-cards,
.stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 20px;
	margin-bottom: 30px;
}

.stat-card {
	background: var(--gradient-card);
	padding: 25px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	text-align: center;
	transition: all 0.2s;
}

.stat-card:hover {
	border-color: var(--primary);
	box-shadow: var(--shadow-glow);
}

.stat-card .stat-value,
.stat-card-value {
	font-size: 2.5rem;
	font-weight: 700;
	color: var(--primary-light);
	margin-bottom: 5px;
}

.stat-card .stat-label,
.stat-card-label {
	color: var(--text-muted);
	font-size: 0.875rem;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.stats-detail {
	background: var(--bg-card);
	padding: 25px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
}

.stats-detail h3 {
	margin-bottom: 15px;
	color: var(--text-primary);
	font-size: 1.1rem;
}

.stats-detail ul {
	list-style: none;
}

.stats-detail li {
	padding: 10px 0;
	border-bottom: 1px solid var(--border);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.stats-detail li:last-child {
	border-bottom: none;
}

.stats-detail li .top-rank {
	color: var(--accent);
	font-weight: 600;
	margin-right: 5px;
}

.stats-detail li .top-count {
	color: var(--primary-light);
}

.stats-detail li.empty-item {
	color: var(--text-muted);
	font-style: italic;
	justify-content: center;
}

/* ==================== LOGS TABLE ==================== */
.logs-table-wrapper {
	max-height: 500px;
	overflow-y: auto;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
}

#logs-table .details-cell {
	max-width: 300px;
	font-size: 0.8rem;
	color: var(--text-secondary);
	line-height: 1.4;
}

#logs-table .date-cell {
	white-space: nowrap;
	font-size: 0.8rem;
}

#logs-table .ip-cell {
	font-family: 'Monaco', 'Consolas', monospace;
	font-size: 0.75rem;
	color: var(--text-muted);
}

.action-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 8px;
	background: var(--bg-dark);
	border-radius: var(--radius-sm);
	font-size: 0.8rem;
	white-space: nowrap;
}

/* Admin leaderboard */
.admin-leaderboards-grid {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.admin-leaderboard-section {
	padding: 16px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg-card);
	box-shadow: var(--shadow);
}

.admin-leaderboard-title {
	font-weight: 700;
	color: var(--primary-light);
	margin-bottom: 12px;
}

.admin-leaderboard-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.admin-leaderboard-entry {
	display: grid;
	grid-template-columns: 70px 1fr 2fr;
	gap: 12px;
	align-items: start;
	padding: 12px;
	border-radius: var(--radius-sm);
	background: var(--bg-dark);
	border: 1px solid var(--border);
}

.admin-leaderboard-entry .entry-rank {
	font-weight: 700;
	color: var(--accent);
}

.admin-leaderboard-entry .entry-meta {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.admin-leaderboard-entry .entry-name {
	font-weight: 600;
}

.admin-leaderboard-entry .entry-email {
	font-size: 0.85rem;
	color: var(--text-muted);
	word-break: break-all;
}

.admin-leaderboard-entry .entry-info {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 6px 12px;
	font-size: 0.9rem;
}

.admin-leaderboard-entry .entry-label {
	color: var(--text-muted);
	margin-right: 6px;
}

.admin-leaderboard-empty {
	color: var(--text-muted);
	font-size: 0.9rem;
}

.admin-leaderboards-grid .email-cell {
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.8rem;
	color: var(--text-muted);
}

.admin-leaderboards-grid .time-cell {
	font-weight: 600;
	color: var(--primary-light);
}

#admin-leaderboard tr.rank-0 {
	background: rgba(255, 215, 0, 0.1);
}

#admin-leaderboard tr.rank-1 {
	background: rgba(192, 192, 192, 0.1);
}

#admin-leaderboard tr.rank-2 {
	background: rgba(205, 127, 50, 0.1);
}

/* ==================== CONFIRM MODAL ==================== */
.confirm-actions {
	display: flex;
	gap: 15px;
	justify-content: center;
	margin-top: 25px;
}

#confirm-modal .modal-content {
	max-width: 400px;
}

#confirm-modal h2 {
	color: var(--danger);
	-webkit-text-fill-color: var(--danger);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 2000;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: calc(100vw - 40px);
}

.toast {
	background: var(--bg-card);
	padding: 15px 20px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
	display: flex;
	align-items: center;
	gap: 10px;
	animation: slideInRight 0.3s ease;
	max-width: 350px;
}

.toast.success {
	border-color: var(--success);
}

.toast.error {
	border-color: var(--danger);
}

.toast.warning {
	border-color: var(--warning);
}

.toast.info {
	border-color: var(--primary);
}

.toast-icon {
	font-size: 1.25rem;
	flex-shrink: 0;
}

.toast-message {
	flex: 1;
	font-size: 0.875rem;
	line-height: 1.4;
}

.toast-close {
	background: none;
	border: none;
	color: var(--text-muted);
	cursor: pointer;
	padding: 5px;
	font-size: 1.25rem;
	line-height: 1;
	flex-shrink: 0;
	transition: color 0.2s;
}

.toast-close:hover {
	color: var(--text-primary);
}

/* ==================== RESPONSIVE ==================== */

/* Desktop */
@media (min-width: 768px) {
	.puzzle-tile {
		width: 100%;
		height: 100%;
	}
}

/* Tablet */
@media (max-width: 768px) {
	.container {
		padding: 15px;
	}

	.app-container {
		padding: 15px;
	}

	.app-main {
		padding: 0;
	}

	.tabs {
		width: 100%;
		justify-content: center;
	}

	.game-section {
		padding: 0 10px;
	}

	.puzzle-wrapper {
		--puzzle-size: clamp(240px, 82vmin, 520px);
	}

	#puzzle-container {
		width: var(--puzzle-size);
		max-width: var(--puzzle-size);
	}

	header {
		flex-direction: column;
		gap: 15px;
		text-align: center;
	}

	header h1 {
		font-size: 1.5rem;
	}

	.game-header {
		flex-direction: column;
		gap: 15px;
	}

	.game-stats {
		width: 100%;
		justify-content: center;
	}

	.game-controls {
		width: 100%;
		justify-content: center;
	}

	.puzzle-tile {
		width: 100%;
		height: 100%;
	}

	.images-grid {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		gap: 15px;
	}

	.modal-content {
		padding: 25px;
		margin: 10px;
	}

	.win-stats-grid {
		grid-template-columns: 1fr 1fr;
	}

	.win-stats-grid .win-stat:nth-child(3) {
		grid-column: span 2;
	}

	.form-row {
		flex-direction: column;
	}

	.form-row .form-group {
		width: 100%;
	}

	.admin-nav,
	.admin-tabs {
		flex-direction: column;
	}

	.admin-tab {
		width: 100%;
		text-align: center;
	}

	.section-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.section-header-actions {
		width: 100%;
		flex-direction: column;
	}

	.section-header-actions .btn {
		width: 100%;
	}

	#leaderboard-table th:nth-child(3),
	#leaderboard-table td:nth-child(3),
	.leaderboard-table th:nth-child(3),
	.leaderboard-table td:nth-child(3) {
		display: none;
	}

	.logs-table-wrapper {
		max-height: 400px;
	}

	#logs-table th:nth-child(5),
	#logs-table td:nth-child(5),
	#logs-table th:nth-child(6),
	#logs-table td:nth-child(6) {
		display: none;
	}

	#admin-leaderboard th:nth-child(3),
	#admin-leaderboard td:nth-child(3) {
		display: none;
	}

	.confirm-actions {
		flex-direction: column;
	}

	.confirm-actions .btn {
		width: 100%;
	}

	.images-admin-grid,
	.admin-images-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 1200px) {
	.images-admin-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (max-width: 980px) {
	.images-admin-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 720px) {
	.images-admin-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* Mobile */
@media (max-width: 480px) {
	.container {
		padding: 10px;
	}

	.app-container {
		padding: 10px;
	}

	.game-section {
		padding: 0 5px;
	}

	.puzzle-wrapper {
		--puzzle-size: clamp(220px, 92vmin, 520px);
	}

	#puzzle-container {
		width: var(--puzzle-size);
		max-width: var(--puzzle-size);
		padding: 6px;
		gap: 3px;
	}

	.puzzle-tile {
		width: 100%;
		height: 100%;
	}

	#puzzle-board {
		padding: 5px;
		gap: 3px;
	}

	.stat {
		padding: 10px 15px;
	}

	.stat-value {
		font-size: 1.25rem;
	}

	.game-stats {
		gap: 15px;
	}

	.btn {
		padding: 10px 16px;
		font-size: 0.875rem;
	}

	.btn-sm {
		padding: 6px 12px;
		font-size: 0.8rem;
	}

	.already-played-screen {
		padding: 40px 15px;
	}

	.already-played-screen .played-icon {
		font-size: 4rem;
	}

	.already-played-screen h2 {
		font-size: 1.5rem;
	}

	.already-played-screen p {
		font-size: 1rem;
	}

	.already-played-screen .your-result {
		padding: 20px 15px;
	}

	.win-stat-value {
		font-size: 1.5rem;
	}

	.win-actions {
		flex-direction: column;
	}

	.win-actions .btn {
		width: 100%;
	}

	#pause-overlay h3 {
		font-size: 2rem;
	}

	.auth-box {
		padding: 30px 20px;
	}

	.auth-box h1 {
		font-size: 1.5rem;
	}

	#leaderboard-table th,
	#leaderboard-table td,
	#win-leaderboard-table th,
	#win-leaderboard-table td,
	.leaderboard-table th,
	.leaderboard-table td {
		padding: 10px 8px;
		font-size: 0.8rem;
	}

	.stats-cards,
	.stats-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 10px;
	}

	.stat-card {
		padding: 15px;
	}

	.stat-card .stat-value {
		font-size: 1.75rem;
	}

	.upload-form {
		padding: 15px;
	}

	.toast-container {
		bottom: 10px;
		right: 10px;
		left: 10px;
		max-width: none;
	}

	.toast {
		max-width: none;
	}

	.win-icon {
		font-size: 4rem;
	}

	.modal h2 {
		font-size: 1.5rem;
	}

	.controls-row {
		flex-direction: column;
		align-items: stretch;
	}

	.difficulty-selector {
		flex-direction: column;
		align-items: stretch;
	}

	.difficulty-selector select {
		width: 100%;
	}

	.admin-header {
		flex-direction: column;
		gap: 15px;
		text-align: center;
	}

	.admin-header-actions {
		flex-direction: column;
		width: 100%;
	}
}

/* Very small screens */
@media (max-width: 360px) {
	.puzzle-tile {
		width: 100%;
		height: 100%;
	}

	.win-stats-grid {
		grid-template-columns: 1fr;
	}

	.stats-cards,
	.stats-grid {
		grid-template-columns: 1fr;
	}
}

/* Touch devices */
@media (hover: none) {
	.puzzle-tile:not(.empty):hover {
		transform: none;
	}

	.puzzle-tile.movable::after {
		opacity: 0.5;
	}

	.puzzle-tile:active {
		transform: scale(0.95);
	}

	.image-card:hover {
		transform: none;
	}

	.image-card:hover img {
		transform: none;
	}

	.btn:hover {
		transform: none;
	}

	.btn-primary:hover,
	.btn-gold:hover {
		box-shadow: none;
	}
}

/* Analytics */
.analytics-section {
	margin-top: 30px;
}

.analytics-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 20px;
	margin-top: 20px;
}

.analytics-card {
	background: var(--bg-card);
	padding: 20px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
}

.analytics-card h4 {
	margin-bottom: 15px;
	color: var(--primary-light);
}

.stats-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.stat-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px;
	background: var(--bg-dark);
	border-radius: var(--radius-sm);
}

.stat-label {
	font-weight: 600;
	color: var(--text-primary);
}

.stat-value {
	color: var(--primary-light);
}

/* ==================== SETTINGS ==================== */
.settings-card {
	background: var(--bg-card);
	border-radius: var(--radius);
	padding: 24px;
	margin-bottom: 20px;
	border: 1px solid var(--border);
}

.settings-card h3 {
	margin-bottom: 20px;
	color: var(--primary-light);
	font-size: 1.2rem;
	text-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.settings-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 0;
	border-bottom: 1px solid var(--border);
}

.settings-item:last-child {
	border-bottom: none;
}

.settings-info {
	flex: 1;
}

.settings-label {
	display: block;
	font-weight: 600;
	color: var(--text-primary);
	margin-bottom: 4px;
}

.settings-description {
	font-size: 0.9rem;
	color: var(--text-secondary);
	margin: 0;
}

.settings-controls {
	margin-left: 20px;
}

.settings-actions {
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid var(--border);
}

/* Toggle Switch */
.toggle-switch {
	position: relative;
	display: inline-block;
	width: 50px;
	height: 26px;
}

.toggle-input {
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: var(--secondary);
	transition: 0.3s;
	border-radius: 26px;
}

.toggle-slider:before {
	position: absolute;
	content: "";
	height: 20px;
	width: 20px;
	left: 3px;
	bottom: 3px;
	background-color: var(--text-primary);
	transition: 0.3s;
	border-radius: 50%;
}

.toggle-input:checked + .toggle-slider {
	background-color: var(--primary);
}

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

.toggle-input:focus + .toggle-slider {
	box-shadow: 0 0 0 3px rgba(10, 167, 199, 0.3);
}

.stat-detail {
	font-size: 0.875rem;
	color: var(--text-muted);
}

.daily-chart {
	display: flex;
	align-items: flex-end;
	gap: 4px;
	height: 200px;
	margin-top: 15px;
}

.chart-bar {
	flex: 1;
	background: var(--primary);
	border-radius: var(--radius-sm) var(--radius-sm) 0 0;
	position: relative;
	min-height: 20px;
	transition: background 0.2s;
}

.chart-bar:hover {
	background: var(--primary-light);
}

.bar-value {
	position: absolute;
	bottom: -20px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.75rem;
	color: var(--text-muted);
	white-space: nowrap;
}

.category-badge {
	display: inline-block;
	padding: 4px 8px;
	background: var(--bg-dark);
	border-radius: var(--radius-sm);
	font-size: 0.75rem;
	color: var(--text-secondary);
	margin-left: 8px;
}

.preview-grid {
	display: grid;
	gap: 2px;
	margin: 20px 0;
	max-width: 500px;
	margin-left: auto;
	margin-right: auto;
}

.preview-tile {
	aspect-ratio: 1;
	border-radius: 4px;
	border: 1px solid var(--border);
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
	.auth-container {
		padding: 10px;
		align-items: flex-start;
	}

	.auth-box {
		padding: 20px;
	}

	.modal-content {
		max-height: 95vh;
		padding: 20px;
	}

	.win-icon {
		font-size: 3rem;
		margin-bottom: 10px;
	}

	.win-stats {
		padding: 15px;
		margin-bottom: 15px;
	}
}

/* Print styles */
@media print {
	body {
		background: white;
		color: black;
	}

	.btn,
	.admin-nav,
	.toast-container,
	.modal {
		display: none !important;
	}

	.admin-table,
	#leaderboard-table,
	.leaderboard-table {
		border: 1px solid #ccc;
	}

	.admin-table th,
	.admin-table td,
	#leaderboard-table th,
	#leaderboard-table td,
	.leaderboard-table th,
	.leaderboard-table td {
		border: 1px solid #ccc;
	}
}

/* High contrast mode */
@media (prefers-contrast: high) {
	:root {
		--border: #4a5568;
		--text-muted: #a0aec0;
	}

	.btn {
		border: 2px solid currentColor;
	}

	.puzzle-tile {
		border: 2px solid rgba(255, 255, 255, 0.3);
	}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	html {
		scroll-behavior: auto;
	}
}

/* ==================== ORIGINAL PREVIEW ==================== */
.original-preview {
	position: fixed;
	inset: 0;
	background: rgba(10, 22, 40, 0.95);
	backdrop-filter: blur(10px);
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	animation: fadeIn 0.3s ease;
	flex-direction: column;
}

.original-preview.hidden {
	display: none;
}

.original-preview .modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(7, 19, 28, 0.6);
}

.original-preview img {
	max-width: min(90vw, 680px);
	max-height: min(80vh, 520px);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-glow);
	border: 2px solid var(--primary);
	z-index: 1;
}

.close-preview-btn {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--danger);
	color: white;
	border: none;
	font-size: 24px;
	font-weight: bold;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	box-shadow: var(--shadow);
	z-index: 1001;
}

.close-preview-btn:hover {
	background: #dc2626;
	transform: scale(1.1);
}
