/*
 * games-v2-common.css
 * Wspolne style wtyczki Gry Logiczne v2.
 * WSZYSTKO scope'owane do .gl2-game - plugin nie nadpisuje motywu ani v1.
 * Mobile-first, w pelni grywalne na ekranie 360 px.
 */

.gl2-game {
	--gl2-bg: #1e2530;
	--gl2-panel: #2b3442;
	--gl2-accent: #4aa3ff;
	--gl2-accent-2: #ffb648;
	--gl2-text: #eef2f7;
	--gl2-muted: #9aa7b6;
	--gl2-cell: 34px;
	--gl2-radius: 8px;

	max-width: 480px;
	margin: 0 auto;
	padding: 12px;
	background: var(--gl2-bg);
	color: var(--gl2-text);
	border-radius: 12px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	box-sizing: border-box;
	-webkit-user-select: none;
	user-select: none;
}

.gl2-game *,
.gl2-game *::before,
.gl2-game *::after {
	box-sizing: border-box;
}

/* --- Przyciski --- */
.gl2-game .gl2-btn {
	appearance: none;
	border: none;
	border-radius: var(--gl2-radius);
	background: var(--gl2-accent);
	color: #06121f;
	font-weight: 700;
	font-size: 15px;
	padding: 10px 14px;
	cursor: pointer;
	transition: transform .08s ease, filter .12s ease;
	min-height: 44px;
	touch-action: manipulation;
}
.gl2-game .gl2-btn:hover { filter: brightness(1.08); }
.gl2-game .gl2-btn:active { transform: scale(.96); }
.gl2-game .gl2-btn-secondary { background: var(--gl2-panel); color: var(--gl2-text); }

/* --- Ekran wyboru poziomu --- */
.gl2-game .gl2-title,
.gl2-game .gl2-modal-title { margin: 0 0 12px; font-size: 18px; text-align: center; }
.gl2-game .gl2-level-buttons {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
}
.gl2-game .gl2-level-btn { padding: 16px; font-size: 16px; }

/* --- Pasek statusu --- */
.gl2-game .gl2-statusbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 14px;
	justify-content: center;
	margin-bottom: 12px;
	font-variant-numeric: tabular-nums;
}
.gl2-game .gl2-status-label { color: var(--gl2-muted); }
.gl2-game .gl2-status-value { font-weight: 700; }

.gl2-game .gl2-controls {
	display: flex;
	gap: 8px;
	justify-content: center;
	margin-top: 12px;
	flex-wrap: wrap;
}

/* --- Modal konca gry --- */
.gl2-game .gl2-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	border-radius: 12px;
}
.gl2-game { position: relative; }
.gl2-game .gl2-modal {
	background: var(--gl2-panel);
	padding: 20px;
	border-radius: 12px;
	text-align: center;
	max-width: 90%;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.gl2-game .gl2-modal-line { margin: 4px 0; }
.gl2-game .gl2-modal-record { margin: 8px 0; color: var(--gl2-accent-2); font-weight: 700; }
.gl2-game .gl2-modal-buttons { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* ======================= LIGHTS OUT ======================= */
.gl2-game .gl2-lights-board {
	display: grid;
	gap: 6px;
	max-width: 320px;
	margin: 0 auto;
}
.gl2-game .gl2-cell {
	aspect-ratio: 1;
	border: none;
	border-radius: var(--gl2-radius);
	background: #3a4657;
	cursor: pointer;
	transition: background .12s ease, box-shadow .12s ease;
	min-height: 40px;
}
.gl2-game .gl2-cell.gl2-on {
	background: var(--gl2-accent-2);
	box-shadow: 0 0 12px rgba(255, 182, 72, .7);
}
.gl2-game .gl2-cell.gl2-hint { outline: 3px solid var(--gl2-accent); outline-offset: -3px; }

/* ======================= SAPER ======================= */
.gl2-game .gl2-saper-toggle { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.gl2-game .gl2-toggle-btn { flex: 1; max-width: 120px; }
.gl2-game .gl2-toggle-btn.gl2-active { background: var(--gl2-accent-2); color: #06121f; }
.gl2-game .gl2-saper-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gl2-game .gl2-saper-board {
	display: grid;
	gap: 2px;
	margin: 0 auto;
	width: max-content;
}
.gl2-game .gl2-saper-board.gl2-zoom { --gl2-cell: 44px; }
.gl2-game .gl2-mcell {
	width: var(--gl2-cell);
	height: var(--gl2-cell);
	border: none;
	background: #4a5768;
	border-radius: 3px;
	font-weight: 700;
	font-size: 14px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	color: var(--gl2-text);
	touch-action: manipulation;
}
.gl2-game .gl2-mcell.gl2-revealed { background: #2b3442; cursor: default; }
.gl2-game .gl2-mcell.gl2-flag { background: #4a5768; color: var(--gl2-accent-2); }
.gl2-game .gl2-mcell.gl2-mine { background: #c0392b; }
.gl2-game .gl2-n1 { color: #4aa3ff; }
.gl2-game .gl2-n2 { color: #2ecc71; }
.gl2-game .gl2-n3 { color: #e74c3c; }
.gl2-game .gl2-n4 { color: #9b59b6; }
.gl2-game .gl2-n5 { color: #e67e22; }
.gl2-game .gl2-n6 { color: #1abc9c; }
.gl2-game .gl2-n7 { color: #ecf0f1; }
.gl2-game .gl2-n8 { color: #95a5a6; }

/* ======================= 2048 ======================= */
.gl2-game .gl2-2048-board {
	position: relative;
	display: grid;
	grid-template-columns: repeat(var(--gl2-size), 1fr);
	grid-template-rows: repeat(var(--gl2-size), 1fr);
	gap: 8px;
	background: var(--gl2-panel);
	padding: 8px;
	border-radius: var(--gl2-radius);
	max-width: 360px;
	margin: 0 auto;
	aspect-ratio: 1;
	touch-action: none; /* swipe przesuwa kafelki - scroll strony poza plansza dziala */
}
.gl2-game .gl2-2048-bg { background: #3a4657; border-radius: 6px; }
.gl2-game .gl2-2048-tiles {
	position: absolute;
	inset: 8px;
	display: grid;
	grid-template-columns: repeat(var(--gl2-size), 1fr);
	grid-template-rows: repeat(var(--gl2-size), 1fr);
	gap: 8px;
	pointer-events: none;
}
.gl2-game .gl2-2048-tile {
	/* pozycja ustawiana przez grid-column/grid-row - brak transform/top/left */
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	font-size: clamp(14px, 6vw, 28px);
	line-height: 1;
	border-radius: 6px;
	background: #ede0c8;
	color: #06121f;
	overflow: hidden;
}
.gl2-game .gl2-2048-tile.gl2-merged { animation: gl2-pop .16s ease; }
@keyframes gl2-pop {
	0% { transform: scale(.7); }
	60% { transform: scale(1.12); }
	100% { transform: scale(1); }
}
.gl2-game .gl2-t2 { background: #eee4da; }
.gl2-game .gl2-t4 { background: #ede0c8; }
.gl2-game .gl2-t8 { background: #f2b179; color: #fff; }
.gl2-game .gl2-t16 { background: #f59563; color: #fff; }
.gl2-game .gl2-t32 { background: #f67c5f; color: #fff; }
.gl2-game .gl2-t64 { background: #f65e3b; color: #fff; }
.gl2-game .gl2-t128,
.gl2-game .gl2-t256,
.gl2-game .gl2-t512 { background: #edcf72; color: #fff; }
.gl2-game .gl2-t1024,
.gl2-game .gl2-t2048,
.gl2-game .gl2-t4096,
.gl2-game .gl2-t8192 { background: #edc22e; color: #fff; }

.gl2-game .gl2-dpad {
	display: grid;
	grid-template-columns: repeat(3, 44px);
	grid-template-rows: repeat(3, 44px);
	gap: 4px;
	justify-content: center;
	margin: 12px auto 0;
	width: max-content;
}
.gl2-game .gl2-dpad-btn { padding: 0; font-size: 20px; }
.gl2-game .gl2-dpad-up { grid-column: 2; grid-row: 1; }
.gl2-game .gl2-dpad-left { grid-column: 1; grid-row: 2; }
.gl2-game .gl2-dpad-right { grid-column: 3; grid-row: 2; }
.gl2-game .gl2-dpad-down { grid-column: 2; grid-row: 3; }

/* ======================= BUBBLE SHOOTER ======================= */
.gl2-game .gl2-bubble-canvas {
	display: block;
	margin: 0 auto;
	background: #141a22;
	border-radius: var(--gl2-radius);
	touch-action: none; /* celowanie/strzal - blokada scrolla TYLKO na canvasie */
}

@media (max-width: 380px) {
	.gl2-game { --gl2-cell: 30px; padding: 8px; }
}
