
/* Layout & responsiveness (no frameworks). */

.app {
	min-height: 100vh;
	display: grid;
	grid-template-rows: auto 1fr;
	position: relative;
}

.topbar {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 16px;
	padding: 16px 20px;
	background: rgba(8, 20, 14, 0.9);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid rgba(236, 240, 241, 0.1);
	box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
	position: relative;
	z-index: 10;
}

.topbar > :first-child {
	justify-self: start;
}

.topbar > :nth-child(2) {
	justify-self: center;
}

.topbar > :last-child {
	justify-self: end;
}

.topbar__center {
	display: flex;
	align-items: center;
	gap: 16px;
}

.logo {
	height: 65px;
	width: auto;
	filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
.topbar__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}
.stage {
	display: grid;
	grid-template-rows: 1fr auto auto;
	gap: 20px;
	padding: 20px;
	max-width: 1200px;
	margin: 0 auto;
}

/* Shared MainUI uses fixed header/actions/footer.
   Add mobile padding so the board never sits underneath them. */
#game-container {
	width: 100%;
	max-width: 100vw;
}

	body:not(.aps-use-renderer) .boardWrap {
		display: grid;
		place-items: center;
		margin-top: 120px; /* Default/mobile: keep current size and position */
		width: 100%;
		max-width: 100vw;
		margin-left: 0;
		margin-right: 0;
	}

	@media (min-width: 1024px) {
	  body:not(.aps-use-renderer) .boardWrap {
	    max-width: 520px; /* Desktop: adjust as needed */
	    width: 100%;
	    margin-left: auto;
	    margin-right: auto;
	    /* You can add more desktop-specific adjustments here */
	  }
	}

body:not(.aps-use-renderer) .boardContainer {
	position: relative;
	width: min(96vw, 500px);
	display: grid;
	place-items: center;

	/*
		Grid alignment inside the container SVG.
		If you tweak the container art later, adjust these 3 knobs only.
	*/
	--grid-left: 50%;
	--grid-top: 60.8%;
	--grid-width: 60.5%;
	--grid-row-gap: 4px;
	--grid-column-gap: 4px;
	--grid-col-gap: var(--grid-column-gap);
}

.boardContainer__bg {
	width: 100%;
	height: auto;
	display: block;
	pointer-events: none;
}

.controls {
	display: grid;
	place-items: center;
	padding: 16px 0 24px;
}

.control-buttons {
	display: flex;
	gap: 16px;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
}

/* Mobile control buttons */
@media (max-width: 679px) {
	.control-buttons {
		flex-direction: column;
		gap: 12px;
		width: 100%;
		max-width: 280px;
	}

	.control-buttons .btn {
		width: 100%;
		justify-content: center;
	}
}

body:not(.aps-use-renderer) .grid {
	position: absolute;
	left: var(--grid-left);
	top: var(--grid-top);
	transform: translate(-50%, -50%);

	width: var(--grid-width);
	height: var(--grid-height, auto);
	aspect-ratio: 1.25 / 1;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	grid-template-rows: repeat(4, 1fr);
	row-gap: var(--grid-row-gap);
	column-gap: var(--grid-col-gap, var(--grid-column-gap));
}

@media (min-width: 680px) {
	.topbar {
		padding: 20px 24px;
	}

	.stage {
		padding: 24px;
		gap: 24px;
	}


}

/* Mobile tile optimizations */
@media (max-width: 679px) {
	#game-container {
		padding-top: 110px;
		padding-bottom: 170px;
	}

	body:not(.aps-use-renderer) .boardWrap {
		margin-top: 0;
		min-height: calc(100dvh - 110px - 170px);
	}

	.app {
		min-height: 100dvh; /* Use dynamic viewport height for mobile */
	}
	
	.topbar {
		padding: 10px 12px;
		gap: 6px;
		grid-template-columns: auto 1fr auto; /* Better distribution for mobile */
		min-height: 60px; /* Ensure minimum height for touch */
	}
	
	.stage {
		padding: 12px 8px;
		gap: 12px;
	}
	
	body:not(.aps-use-renderer) .boardContainer {
		width: min(98vw, 720px); /* Slightly wider on mobile for better fit */
		margin-bottom: 150px; /* Add bottom margin to prevent overlap with controls */
	}
	
	.tile {
		background: url("../assets/images/ui/game-tiles/game-tile-main.svg") center center / 100% 100% no-repeat !important;
		min-height: 0;
		min-width: 0;
	}
	
	.topbar__center {
		flex-direction: column;
		gap: 2px;
		justify-content: center;
		min-width: 0; /* Allow flex shrinking */
	}
	
	.logo {
		height: 26px;
		flex-shrink: 0;
	}
	
	.multiplier {
		font-size: 16px;
		font-weight: bold;
		flex-shrink: 0;
	}
	
	.topbar__actions {
		flex-direction: column;
		gap: 2px;
		justify-content: center;
	}
	
	/* Mobile control buttons */
	.controls {
		padding: 12px 0 16px;
	}
	
	.control-buttons {
		flex-direction: column;
		gap: 10px;
		width: 100%;
		max-width: 300px;
	}

	.control-buttons .btn {
		width: 100%;
		justify-content: center;
		min-height: 48px;
		font-size: 16px;
		padding: 12px 20px;
	}
	
	/* Hide "How to Play" button on very small screens to save space */
	@media (max-width: 480px) {
		.topbar {
			padding: 8px 10px;
			grid-template-columns: 1fr auto; /* Center content and actions only */
			min-height: 50px;
		}
		
		.topbar > :first-child {
			display: none;
		}
		
		.topbar__center {
			order: 1;
			align-items: center;
		}
		
		.topbar__actions {
			order: 2;
			align-items: center;
		}
		
		.stage {
			padding: 8px 6px;
			gap: 8px;
		}
		
		.logo {
			height: 22px;
		}
		
		.multiplier {
			font-size: 14px;
		}
		
		.tile {
			min-height: 0;
			min-width: 0;
		}
		
		.control-buttons {
			max-width: 280px;
			gap: 8px;
		}
		
		.control-buttons .btn {
			min-height: 44px;
			font-size: 15px;
			padding: 10px 16px;
		}
		
		.controls {
			padding: 8px 0 12px;
		}
	}
	
	/* Extra small screens */
	@media (max-width: 360px) {
		.topbar {
			padding: 6px 8px;
		}
		
		.logo {
			height: 20px;
		}
		
		.multiplier {
			font-size: 13px;
		}
		
		.tile {
			min-height: 0;
			min-width: 0;
		}
		
		.control-buttons {
			max-width: 260px;
		}
		
		.control-buttons .btn {
			min-height: 42px;
			font-size: 14px;
			padding: 8px 12px;
		}
	}
	
	/* Ensure good touch targets for buttons */
	.btn {
		min-height: 44px;
		touch-action: manipulation;
		-webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
	}
}

.footer {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	display: grid;
	place-items: center;
	padding: 12px 20px;
	opacity: 0.6;
	background: rgba(0, 0, 0, 0.8);
	z-index: 10;
}

.footer__text {
	color: rgba(236, 240, 241, 0.8);
	font-size: 12px;
	text-align: center;
	margin: 0;
	line-height: 1.4;
}

/* Mobile footer adjustments */
@media (max-width: 679px) {
	.footer {
		padding: 6px 12px;
		margin-top: 4px;
	}
	
	.footer__text {
		font-size: 10px;
		line-height: 1.3;
	}
}

/* Extra small footer adjustments */
@media (max-width: 480px) {
	.footer {
		padding: 4px 8px;
	}
	
	.footer__text {
		font-size: 9px;
	}
}

