/* trap. PAC-MAN */

@font-face {
	font-family: 'Press Start 2P';
	font-style: normal;
	font-weight: 400;
	src: url('../fonts/PressStart2Play.eot');
	src: url('../fonts/PressStart2Play.eot?iefix') format('eot'),
	     url('../fonts/PressStart2Play.woff') format('woff'),
	     url('../fonts/PressStart2Play.ttf') format('truetype');
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	background: #000;
	color: #fff;
	font-family: 'Press Start 2P', cursive;
	font-size: 15px;
	-webkit-tap-highlight-color: transparent;
	/* app-like feel on mobile: no rubber-band bounce, no double-tap zoom */
	overscroll-behavior: none;
	touch-action: manipulation;
	-webkit-touch-callout: none;
}

.container { text-align: center; margin: 0; padding: 0; }
.main { width: 100%; max-width: 660px; margin: 0 auto; }
.content { width: 100%; max-width: 540px; text-align: left; margin: 0 auto; padding: 0 10px; }
.content[id*=-content]:not(#game-content) {
	display: none;
	overflow-y: auto;
	overflow-x: hidden;
	padding-top: 40px;
	padding-bottom: 40px;
}
.content img { max-width: 100%; }
.pull-right { float: right; width: 30px; height: 30px; }

h1, h2, h3 { font-weight: normal; text-transform: uppercase; }
h1 { font-size: 1.4em; }
h2 { font-size: 1.1em; margin-top: 2em; }
h3 { font-size: 0.9em; }
p { font-size: 0.75em; line-height: 1.8; }
#instructions-content div { font-size: 0.8em; line-height: 1.8; }
#instructions-content div div { font-size: inherit; }

/* ---------- header / footer logos ---------- */

.site-header { padding: 22px 10px 6px 10px; }
.header-logo { height: 42px; width: auto; }

.site-footer { padding: 30px 10px 26px 10px; opacity: 0.35; }
.footer-logo { height: 20px; width: auto; }

/* ---------- game ---------- */

.game { max-width: 540px; margin: auto; }
.wrapper { padding: 0; }

.score, .lives, .level { display: inline-block; font-size: 0.75em; padding: 8px 0; }
.score { width: 160px; text-align: left; }
.lives img { height: 12px; }

.controlSound {
	background: url('../img/audio-icon.png');
	background-size: 100%;
	width: 36px;
	height: 25px;
	float: right;
	position: relative;
	bottom: 5px;
	cursor: pointer;
}
/* mute icon hidden by default (sound on); JS shows it if sound is off */
#mute { display: none; width: 36px; height: 25px; }

#myCanvas { border: none; display: block; background: #000; width: 100%; height: auto; }
#canvas-container { position: relative; }
#canvas-overlay-container {
	position: absolute;
	background: rgba(0,0,0,0.75);
	height: 100%;
	width: 100%;
	padding: 1em;
	z-index: 5;
}
#canvas-overlay-content {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	width: 100%;
	padding: 1em;
}
.overlay-logo { height: 40px; width: auto; display: block; margin: 0 auto 18px auto; }
#canvas-overlay-content #title {
	text-transform: uppercase;
	font-size: 150%;
	color: #ffe600;
	text-shadow: 0 0 12px rgba(255,230,0,0.4);
}
#canvas-overlay-content #text { font-size: 0.75em; line-height: 1.8; }

/* ---------- buttons / menu ---------- */

.button {
	background: rgba(255,255,255,0.08);
	cursor: pointer;
	padding: 8px;
	font-size: 0.85em;
	user-select: none;
}
.button:hover { background: rgba(255,255,255,0.22); }
.button#back { position: relative; display: inline-block; margin-bottom: 12px; }

#menu-buttons ul, #menu-buttons ul li { list-style: none; padding: 0; }
#menu-buttons ul li {
	height: 40px;
	line-height: 40px;
	font-size: 100%;
	margin-bottom: 8px;
}

.controls { text-align: center; margin-top: 15px; }

/* ---------- D-pad ---------- */

#game-buttons { display: none; padding-bottom: 10px; }

.dpad {
	display: grid;
	grid-template-columns: 64px 64px 64px;
	grid-template-rows: 64px 64px;
	gap: 6px;
	justify-content: center;
}
.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 2; }

.controlButton {
	display: inline-block;
	width: 64px;
	height: 64px;
	line-height: 64px;
	background: rgba(255,255,255,0.07);
	border: 1px solid rgba(255,255,255,0.15);
	border-radius: 12px;
	color: #ffe600;
	font-size: 22px;
	cursor: pointer;
	user-select: none;
	touch-action: none;
	transition: transform 0.06s, background 0.06s;
}
.controlButton:hover { background: rgba(255,255,255,0.18); }
.controlButton:active,
.controlButton.pressed { background: rgba(255,230,0,0.3); transform: scale(0.92); }

/* ---------- responsive ---------- */

.mobile { display: none; }
@media (pointer: coarse) {
	.mobile { display: block; }
	.nomobile { display: none; }

	/* app-like: snug layout, safe areas for notches, no footer */
	.site-footer { display: none; }
	.site-header { padding: calc(12px + env(safe-area-inset-top, 0px)) 10px 4px 10px; }
	.main { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
	body { position: relative; min-height: 100dvh; }
}

/* landscape phones: let the maze use the full height, float the d-pad
   in the right thumb zone */
@media (pointer: coarse) and (orientation: landscape) {
	.site-header { display: none; }
	.game {
		max-width: calc((100dvh - 70px) * 540 / 390);
	}
	#game-buttons {
		position: fixed;
		right: calc(12px + env(safe-area-inset-right, 0px));
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
		margin: 0;
		z-index: 40;
		opacity: 0.9;
	}
	#game-buttons .dpad {
		grid-template-columns: 58px 58px 58px;
		grid-template-rows: 58px 58px;
		gap: 5px;
	}
	#game-buttons .controlButton { width: 58px; height: 58px; line-height: 58px; font-size: 20px; }
}

@media screen and (max-width: 650px) {
	.game { width: 100%; padding: 0 4px; }
	.content { max-width: none; }
	.header-logo { height: 30px; }
	.dpad {
		grid-template-columns: 76px 76px 76px;
		grid-template-rows: 76px 76px;
	}
	.controlButton { width: 76px; height: 76px; line-height: 76px; font-size: 26px; }
}

/* ---------- admin: floating button ---------- */

#admin-fab {
	position: fixed;
	right: 14px;
	bottom: 14px;
	width: 34px;
	height: 34px;
	line-height: 34px;
	text-align: center;
	border-radius: 50%;
	background: rgba(255,255,255,0.04);
	color: rgba(255,255,255,0.14);
	font-size: 13px;
	cursor: pointer;
	z-index: 50;
	user-select: none;
	transition: color 0.3s, background 0.3s;
}
#admin-fab:hover {
	background: rgba(255,255,255,0.1);
	color: rgba(255,255,255,0.6);
}

/* ---------- admin: modals ---------- */

.trap-modal-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.85);
	z-index: 100;
	overflow-y: auto;
	padding: 30px 10px;
}
.trap-modal-backdrop.open { display: block; }

.trap-modal {
	position: relative;
	margin: 0 auto;
	background: #0d0d0d;
	border: 1px solid rgba(255,255,255,0.2);
	border-radius: 10px;
	padding: 26px;
	text-align: center;
}
.trap-modal-small { max-width: 340px; margin-top: 12vh; }
.trap-modal-large { max-width: 560px; text-align: left; }
.trap-modal-large h2 { text-align: left; font-size: 1em; }
.trap-modal h2 { margin-top: 0; font-size: 1em; }

.trap-modal-close {
	position: absolute;
	top: 8px;
	right: 14px;
	font-size: 22px;
	color: rgba(255,255,255,0.5);
	cursor: pointer;
	font-family: sans-serif;
}
.trap-modal-close:hover { color: #fff; }

.trap-modal input[type=password] {
	width: 100%;
	padding: 10px;
	margin: 12px 0;
	background: #000;
	border: 1px solid rgba(255,255,255,0.3);
	color: #fff;
	font-family: 'Press Start 2P', cursive;
	font-size: 12px;
	border-radius: 6px;
	outline: none;
}
.trap-modal input[type=password]:focus { border-color: #ffe600; }

.trap-btn {
	display: inline-block;
	background: #c80a0a;
	color: #fff;
	padding: 12px 18px;
	margin-top: 6px;
	cursor: pointer;
	font-size: 0.8em;
	border-radius: 6px;
	user-select: none;
}
.trap-btn:hover { background: #e51212; }
.trap-btn.disabled { opacity: 0.4; pointer-events: none; }

.admin-error { color: #ff5555; font-size: 0.65em; min-height: 1em; }

/* ---------- admin: sprite manager ---------- */

.sprite-hint { font-size: 0.6em; color: rgba(255,255,255,0.6); }

.sprite-row {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 0;
	border-bottom: 1px solid rgba(255,255,255,0.1);
	flex-wrap: wrap;
}
.sprite-row-name { width: 110px; font-size: 0.65em; text-transform: uppercase; }
.sprite-row-size { display: block; color: rgba(255,255,255,0.45); font-size: 0.85em; margin-top: 5px; text-transform: none; }

.sprite-tile {
	width: 64px;
	height: 64px;
	flex: 0 0 64px;
	border: 1px dashed rgba(255,255,255,0.25);
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	background:
		repeating-conic-gradient(rgba(255,255,255,0.06) 0% 25%, transparent 0% 50%)
		0 / 16px 16px;
}
.sprite-tile canvas, .sprite-tile img { image-rendering: auto; max-width: 100%; max-height: 100%; }
.sprite-arrow { color: rgba(255,255,255,0.4); font-size: 16px; }

.sprite-row-controls { display: flex; flex-direction: column; gap: 6px; margin-left: auto; }
.sprite-file-btn, .sprite-clear-btn {
	font-size: 0.55em;
	padding: 7px 10px;
	background: rgba(255,255,255,0.1);
	border-radius: 5px;
	cursor: pointer;
	text-align: center;
	user-select: none;
}
.sprite-file-btn:hover, .sprite-clear-btn:hover { background: rgba(255,255,255,0.25); }
.sprite-clear-btn { color: #ff8888; }
.sprite-row input[type=file] { display: none; }

.sprite-actions { margin-top: 18px; display: flex; align-items: center; gap: 14px; }
#sprite-save-status { font-size: 0.6em; color: #7fdc7f; }
