@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

#game-wrapper {
	position: relative;
	width: 100%;
	max-width: 1920px;
	margin: 0 auto;
	aspect-ratio: 16 / 9;
	background: #0a0a2e;
	overflow: hidden;
	border: 3px solid #6b21a8;
	border-radius: 8px;
	box-shadow: 0 0 40px rgba(107, 33, 168, 0.4), inset 0 0 60px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
	display: block;
	width: 100%;
	height: 100%;
	image-rendering: pixelated;
}

#game-ui {
	position: absolute;
	top: 0; left: 0;
	width: 100%; height: 100%;
	font-family: 'Press Start 2P', monospace;
}

#game-ui.playing { pointer-events: none; }
#game-ui.playing > * { pointer-events: auto; }

/* ── HUD ── */
.game-hud {
	position: absolute;
	top: 8px; left: 8px; right: 8px;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	font-size: 10px;
	color: #fbbf24;
	text-shadow: 1px 1px 0 #000, 2px 2px 0 rgba(0,0,0,0.5);
	z-index: 10;
}

.hud-left, .hud-center, .hud-right { display: flex; flex-direction: column; }
.hud-left { align-items: flex-start; }
.hud-center { align-items: center; }
.hud-right { align-items: flex-end; }

.game-hud .score { font-size: clamp(12px, 1.5vw, 22px); }
.game-hud .lives { font-size: clamp(12px, 1.5vw, 22px); letter-spacing: -1px; }
.game-hud .level { font-size: clamp(9px, 1vw, 16px); color: #a78bfa; margin-top: 2px; }
#hud-objective { font-size: clamp(10px, 1.2vw, 18px); color: #60a5fa; }
#hud-powerups { font-size: clamp(8px, 0.9vw, 14px); color: #34d399; margin-top: 3px; }
#hud-suit { font-size: clamp(8px, 0.9vw, 14px); margin-top: 3px; }
#hud-coffee { font-size: clamp(8px, 0.9vw, 14px); margin-top: 2px; color: #c2854a; }

/* ── Menu ── */
.menu-screen {
	position: absolute;
	top: 0; left: 0;
	width: 100%; height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: radial-gradient(ellipse at center, rgba(107, 33, 168, 0.3) 0%, rgba(10, 10, 46, 0.95) 70%);
	z-index: 100;
	overflow-y: auto;
}

.menu-screen h1 {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(16px, 3vw, 28px);
	color: #fbbf24;
	text-shadow: 3px 3px 0 #f97316, 6px 6px 0 rgba(0, 0, 0, 0.5);
	margin-bottom: 8px;
	text-align: center;
	line-height: 1.4;
}

.menu-screen .subtitle {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(7px, 1.2vw, 10px);
	color: #a78bfa;
	margin-bottom: 20px;
	text-align: center;
	line-height: 1.6;
}

.cat-selection {
	display: flex;
	gap: 15px;
	margin-bottom: 20px;
	flex-wrap: wrap;
	justify-content: center;
	padding: 0 15px;
}

.cat-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 12px;
	border: 3px solid #374151;
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.2s;
	background: rgba(0, 0, 0, 0.4);
	min-width: 110px;
}

.cat-option:hover {
	border-color: #fbbf24;
	background: rgba(251, 191, 36, 0.1);
	transform: translateY(-4px);
	box-shadow: 0 8px 20px rgba(251, 191, 36, 0.2);
}

.cat-option.selected {
	border-color: #fbbf24;
	background: rgba(251, 191, 36, 0.15);
	box-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

.cat-option .cat-preview-img {
	width: 90px;
	height: 90px;
	border-radius: 12px;
}

.cat-option .cat-name {
	font-family: 'Press Start 2P', monospace;
	font-size: 8px;
	color: #e5e7eb;
	margin-bottom: 4px;
	margin-top: 6px;
}

.cat-option .cat-stats {
	font-family: 'Press Start 2P', monospace;
	font-size: 6px;
	color: #9ca3af;
	text-align: center;
	line-height: 1.8;
}

.start-btn {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(10px, 1.5vw, 14px);
	padding: 14px 36px;
	background: linear-gradient(180deg, #f97316, #ea580c);
	color: #fff;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
	box-shadow: 0 4px 0 #9a3412, 0 8px 20px rgba(249, 115, 22, 0.3);
	transition: all 0.1s;
}

.start-btn:hover {
	background: linear-gradient(180deg, #fb923c, #f97316);
	transform: translateY(-2px);
	box-shadow: 0 6px 0 #9a3412, 0 12px 25px rgba(249, 115, 22, 0.4);
}

.start-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #9a3412; }
.start-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Game over ── */
.gameover-screen {
	position: absolute;
	top: 0; left: 0;
	width: 100%; height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: rgba(10, 10, 46, 0.9);
	z-index: 100;
}

.gameover-screen h2 {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(18px, 3vw, 32px);
	color: #ef4444;
	text-shadow: 3px 3px 0 #000;
	margin-bottom: 20px;
}

.gameover-screen .final-score {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(11px, 1.8vw, 16px);
	color: #fbbf24;
	margin-bottom: 8px;
}

.gameover-screen .final-mice {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(7px, 1.1vw, 11px);
	color: #a78bfa;
	margin-bottom: 15px;
}

/* ── Pause ── */
.pause-overlay {
	position: absolute;
	top: 0; left: 0;
	width: 100%; height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 10, 46, 0.7);
	z-index: 50;
}

.pause-overlay span {
	font-family: 'Press Start 2P', monospace;
	font-size: clamp(16px, 3vw, 28px);
	color: #fbbf24;
	text-shadow: 3px 3px 0 #000;
	animation: blink 1s infinite;
}

@keyframes blink {
	0%, 50% { opacity: 1; }
	51%, 100% { opacity: 0; }
}

/* ── Mobile ── */
.mobile-controls {
	display: none;
	position: absolute;
	bottom: 10px; left: 0; right: 0;
	justify-content: space-between;
	padding: 0 15px;
	z-index: 20;
}

@media (max-width: 768px) {
	.mobile-controls { display: flex; }
}

.mobile-controls button {
	font-family: 'Press Start 2P', monospace;
	font-size: 18px;
	width: 50px; height: 50px;
	border: 2px solid rgba(251, 191, 36, 0.5);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	color: #fbbf24;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
}

.ctrl-group { display: flex; gap: 8px; }

/* ── Fullscreen ── */
.fullscreen-btn {
	font-family: 'Press Start 2P', monospace;
	font-size: 9px;
	margin-top: 12px;
	padding: 8px 20px;
	background: rgba(107, 33, 168, 0.4);
	color: #a78bfa;
	border: 2px solid rgba(167, 139, 250, 0.4);
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.15s;
}

.fullscreen-btn:hover {
	background: rgba(107, 33, 168, 0.6);
	border-color: #a78bfa;
	color: #fff;
}

.fs-btn-ingame {
	position: absolute;
	bottom: 8px;
	right: 8px;
	font-size: 18px;
	width: 36px;
	height: 36px;
	background: rgba(0, 0, 0, 0.4);
	color: rgba(255, 255, 255, 0.5);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 6px;
	cursor: pointer;
	z-index: 20;
	pointer-events: auto;
	line-height: 36px;
	text-align: center;
	padding: 0;
}

.fs-btn-ingame:hover {
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	border-color: rgba(255, 255, 255, 0.4);
}

/* Fullscreen mode */
#game-wrapper:fullscreen {
	max-width: 100%;
	border: none;
	border-radius: 0;
}

#game-wrapper:-webkit-full-screen {
	max-width: 100%;
	border: none;
	border-radius: 0;
}

/* ── Nickname ── */
.nickname-section {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
	font-family: 'Press Start 2P', monospace;
}
.nickname-label { font-size: 7px; color: #9ca3af; }
.nickname-display { font-size: 10px; color: #fbbf24; text-shadow: 1px 1px 0 #000; }
.nick-edit-btn {
	font-size: 10px; background: none; border: 1px solid rgba(251,191,36,0.3);
	border-radius: 4px; color: #fbbf24; cursor: pointer; padding: 2px 6px; transition: all 0.15s;
}
.nick-edit-btn:hover { background: rgba(251,191,36,0.15); border-color: #fbbf24; }
.nick-input {
	font-family: 'Press Start 2P', monospace; font-size: 10px;
	background: rgba(0,0,0,0.6); border: 2px solid #fbbf24; border-radius: 4px;
	color: #fbbf24; padding: 4px 8px; outline: none; width: 180px;
}

/* ── Leaderboard ── */
.leaderboard { margin: 12px 0; width: 100%; max-width: 380px; }
.leaderboard h3 {
	font-family: 'Press Start 2P', monospace; font-size: clamp(9px,1.4vw,13px);
	color: #fbbf24; text-shadow: 2px 2px 0 #000; margin-bottom: 8px; text-align: center;
}
.lb-loading, .lb-empty { font-family: 'Press Start 2P', monospace; font-size: 8px; color: #6b7280; text-align: center; }
.lb-table { width: 100%; border-collapse: collapse; font-family: 'Press Start 2P', monospace; font-size: clamp(6px,1vw,8px); }
.lb-table th { color: #6b7280; padding: 4px 6px; border-bottom: 1px solid rgba(107,33,168,0.5); text-align: left; }
.lb-table td { padding: 4px 6px; color: #e5e7eb; border-bottom: 1px solid rgba(107,33,168,0.2); }
.lb-rank { text-align: center; width: 30px; }
.lb-nick { color: #a78bfa; }
.lb-score { color: #fbbf24; text-align: right; }
.lb-level { color: #6b7280; text-align: center; }
.lb-me td { color: #fbbf24 !important; background: rgba(251,191,36,0.08); }
.lb-me .lb-nick { color: #fbbf24; }

/* Game over scroll fix */
.gameover-screen { overflow-y: auto; padding: 20px 0; }

/* Menu leaderboard */
.menu-leaderboard { margin-bottom: 14px; }
.menu-screen { overflow-y: auto; padding: 20px 0; }

/* ── Debug panel ── */
#debug-panel {
	max-width: 1920px;
	margin: 8px auto 0;
	font-family: 'Courier New', monospace;
	font-size: 11px;
	color: #9ca3af;
	background: #0a0a1a;
	border: 1px solid #1e1e3a;
	border-radius: 6px;
	padding: 8px 12px;
	line-height: 1.6;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 2px 16px;
}
#debug-panel .db-label { color: #6b7280; }
#debug-panel .db-val { color: #a78bfa; }
#debug-panel .db-warn { color: #fbbf24; }
#debug-panel .db-bad { color: #ef4444; }
#debug-panel .db-good { color: #4ade80; }
#debug-panel .db-section {
	grid-column: 1 / -1;
	color: #6b21a8;
	border-bottom: 1px solid #1e1e3a;
	margin-top: 4px;
	padding-bottom: 2px;
	font-weight: bold;
}
