:root {
	--navy: #031a3d;
	--blue: #084c9e;
	--cream: #fff4ce;
	--red: #d92f3d;
	--gold: #f8c52c;
	--ink: #020b18;
	--white: #fffef2
}

* {
	box-sizing: border-box
}

html,
body {
	margin: 0;
	min-height: 100%;
	background: var(--navy);
	color: var(--white);
	font-family: "Courier New", monospace;
	overflow: hidden;
	touch-action: manipulation
}

body {
	display: grid;
	place-items: center
}

button {
	font: inherit
}

.app {
	position: relative;
	width: min(100vw, 480px);
	height: 100vh;
	height: 100dvh;
	min-height: 0;
	overflow: hidden;
	background: var(--navy);
	image-rendering: pixelated
}

.screen {
	position: absolute;
	inset: 0
}

.screen[hidden] {
	display: none
}

.start {
	display: grid;
	place-items: end center;
	padding: 24px 18px calc(28px + env(safe-area-inset-bottom));
	background: linear-gradient(180deg, rgba(3, 26, 61, .06), rgba(3, 26, 61, .2) 48%, rgba(3, 26, 61, .94)), url("assets/centenario-8bit.png") center/cover no-repeat
}

.start-panel {
	width: 100%;
	text-align: center;
	text-shadow: 3px 3px 0 var(--ink)
}

.start h1 {
	margin: 0;
	color: var(--gold);
	font-size: clamp(35px, 11vw, 56px);
	line-height: .9;
	letter-spacing: -3px
}

.start p {
	margin: 12px auto 18px;
	max-width: 350px;
	font-size: 15px;
	font-weight: 900;
	line-height: 1.35;
	text-transform: uppercase
}

.pixel-btn {
	width: 100%;
	min-height: 64px;
	border: 4px solid var(--cream);
	background: var(--red);
	color: white;
	font-weight: 900;
	font-size: clamp(20px, 6.5vw, 29px);
	letter-spacing: 1px;
	text-transform: uppercase;
	box-shadow: 0 7px 0 #84202a, 5px 12px 0 var(--ink);
	cursor: pointer
}

.pixel-btn:active:not(:disabled) {
	transform: translateY(6px);
	box-shadow: 0 1px 0 #84202a, 2px 4px 0 var(--ink)
}

.pixel-btn:disabled {
	background: #596a79;
	color: #c3ccd3;
	box-shadow: 0 7px 0 #33404c, 5px 12px 0 var(--ink)
}

.game {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	background: #77c8ff
}

.topbar {
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	flex-wrap: wrap;
	padding: 12px 14px;
	background: var(--navy);
	border-bottom: 5px solid var(--gold);
	box-shadow: 0 5px 0 var(--ink)
}

.brand {
	color: var(--gold);
	font-size: clamp(17px, 5vw, 23px);
	font-weight: 900;
	letter-spacing: -1px;
	text-shadow: 2px 2px 0 #8c2b27
}

.turns {
	display: flex;
	gap: 6px;
	align-items: center;
	font-size: 12px;
	font-weight: 900
}

.life {
	width: 16px;
	height: 16px;
	border: 3px solid var(--cream);
	background: var(--red);
	box-shadow: 2px 2px 0 var(--ink)
}

.life.used {
	background: #314860
}

.stage {
	position: relative;
	min-height: 0;
	cursor: pointer
}

/* Conserva la proporción original del dibujo sin estirar los jugadores. */
.stage canvas {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	image-rendering: pixelated
}

.hud {
	position: absolute;
	inset: 13px 12px auto;
	display: grid;
	place-items: center;
	pointer-events: none
}

.status {
	max-width: 96%;
	min-height: 42px;
	padding: 9px 12px;
	background: rgba(3, 26, 61, .92);
	border: 3px solid var(--cream);
	box-shadow: 4px 4px 0 var(--ink);
	font-size: clamp(13px, 3.8vw, 17px);
	font-weight: 900;
	line-height: 1.25;
	text-align: center;
	text-transform: uppercase
}

.tap-mark {
	position: absolute;
	left: 50%;
	bottom: 18px;
	transform: translateX(-50%);
	padding: 6px 9px;
	background: var(--gold);
	color: var(--navy);
	font-size: 12px;
	font-weight: 900;
	box-shadow: 3px 3px 0 var(--ink);
	text-transform: uppercase;
	pointer-events: none;
	white-space: nowrap;
	animation: blink 1s steps(2) infinite
}

.stage.busy .tap-mark {
	display: none
}

.controls {
	z-index: 2;
	display: grid;
	gap: 10px;
	padding: 12px 14px calc(15px + env(safe-area-inset-bottom));
	background: var(--cream);
	border-top: 5px solid var(--ink)
}

.hint {
	margin: 5px 0 0;
	color: var(--navy);
	font-size: 12px;
	font-weight: 900;
	text-align: center;
	text-transform: uppercase
}

/* Pantalla final: cartel completo arriba y enlaces fuera de la imagen. */
.end {
	display: grid;
	grid-template-rows: minmax(280px, 1fr) auto;
	overflow-y: auto;
	background: var(--navy);
}

.end-art {
	position: relative;
	min-width: 0;
	min-height: 0;
}

.end-image {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	image-rendering: auto;
}

.end-image[hidden] { display: none; }
.end-image.pixel-art { image-rendering: pixelated; }

.end-actions {
	display: grid;
	justify-items: center;
	gap: 8px;
	padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
	border-top: 1px solid #365071;
	text-align: center;
}

.end-follow {
	margin: 0;
	color: var(--gold);
	font-size: 13px;
	font-weight: 900;
	letter-spacing: 1px;
}

.social-links {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px;
}

.social-links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 8px 12px;
	border: 1px solid #627893;
	color: var(--cream);
	font-size: 13px;
	font-weight: bold;
	text-underline-offset: 4px;
}

.social-links a:hover,
.social-links a:focus-visible {
	background: var(--cream);
	color: var(--navy);
}

.end .again {
	width: auto;
	min-height: 44px;
	padding: 8px 16px;
	border-width: 2px;
	background: transparent;
	font-size: 12px;
	letter-spacing: 0;
	box-shadow: 0 3px 0 #05295b;
}

.end .again:disabled {
	opacity: .4;
	cursor: default;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

@keyframes blink {
	50% {
		opacity: .35
	}
}

@media(min-width:481px) {
	body {
		padding: 18px
	}
	.app {
		height: min(900px, calc(100dvh - 36px));
		border: 5px solid var(--gold);
		box-shadow: 12px 12px 0 #000
	}
}

@media(prefers-reduced-motion:reduce) {
	.tap-mark {
		animation: none
	}
}

/* Mantiene los controles visibles en celulares en horizontal o ventanas bajas. */
@media (max-height: 540px) {
	.topbar {
		padding: 6px 12px;
	}
	.controls {
		gap: 4px;
		padding: 6px 12px calc(12px + env(safe-area-inset-bottom));
	}
	.pixel-btn {
		min-height: 44px;
		font-size: 18px;
	}
	.hint {
		margin: 3px 0 0;
		font-size: 10px;
	}
	.hud {
		inset: 5px 8px auto;
	}
	.status {
		min-height: 0;
		padding: 4px 8px;
		font-size: 11px;
	}
	.tap-mark {
		bottom: 6px;
		font-size: 10px;
	}
	.start h1 {
		font-size: 35px;
	}
	.start p {
		margin: 8px auto 12px;
		font-size: 12px;
	}
}

.pixel-btn:focus-visible,
.stage:focus-visible {
	outline: 3px solid var(--gold);
	outline-offset: -3px;
}
