@charset "utf-8";
/*
 * CSS Document
 */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
 
:root {
	--bg: #000;
	--fg: #FFF;
	--muted: #8C8C8C;
	--accent: #FFC100;
	--blue: #1E85EE;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html, body {
	margin: 0;
	background-color: var(--bg);
	color: var(--fg);
}

body {
	font-family: 'Press Start 2P', monospace;
	font-weight: 500;
	font-style: normal;
	overscroll-behavior: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

button:focus-visible {
	outline: 2px dashed var(--accent);
	outline-offset: 4px;
}

.highlight {
	color: var(--accent);
}

/* Tela do jogo: centralizada e sem rolagem/zoom por toque (celular) */
.screen-game {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	touch-action: none;
}

/* Largura/altura fixas; o main.js aplica zoom para caber em telas menores */
.game {
	flex: none;
	width: 570px;
	height: 730px;
}

.pause-btn {
	display: inline-grid;
	place-items: center;
	width: 30px;
	height: 30px;
	vertical-align: top;
	transition: opacity 0.2s;
}

.pause-btn svg {
	width: 18px;
	height: 18px;
	shape-rendering: crispEdges;
}

@media (hover: hover) {
	.pause-btn:hover {
		opacity: 0.7;
	}
}

/* Pausado: congela as animações dos sprites e do labirinto */
.main.paused div,
.main.paused div:before {
	animation-play-state: paused !important;
}

.score {
	margin: 0 auto;
	width: 570px;
	height: 60px;
	display: grid;
	grid-template-columns: 1fr 2fr 1fr;
}
	
.score > div {
	text-align: center;
	line-height: 30px;
	font-size: 18px;
}

.main {
	position: relative;
	overflow: hidden;
	margin: 0 auto;
	width: 570px;
	height: 630px;
	display: grid;
	grid-template-columns: repeat(19, 30px);
	grid-template-rows: repeat(21, 30px);
}

.cell {
	box-sizing: border-box;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
}

.T { border-top: 3px solid #1E85EE; }
.R { border-right: 3px solid #1E85EE; }
.B { border-bottom: 3px solid #1E85EE; }
.L { border-left: 3px solid #1E85EE; }

.TW { border-top: 5px solid #CCCCCC; }

/* Labirinto piscando ao terminar a fase */
.main.flash > .cell {
	animation: mazeflash 0.4s steps(1) infinite;
}

@keyframes mazeflash {
	50% {
		border-color: #FFFFFF;
	}
}

.P:before {
	content: '';
	display: block;
	width: 6px;
	height: 6px;
	background-color: #CCCCCC;
	margin: auto;
	margin-top: 12px;
	border-radius: 50%;
}

.W:before {
	content: '';
	display: block;
	width: 10px;
	height: 10px;
	background-color: #FFFFFF;
	margin: auto;
	margin-top: 10px;
	border-radius: 50%;
	animation: powerup 2s infinite linear;
}

@keyframes powerup {
	0% {
		opacity: 1;
	}
	50% {
		opacity: 0;
	}
	100% {
		opacity: 1;
	}
}

/* READY! / GAME OVER */
.message {
	position: absolute;
	left: 0;
	right: 0;
	top: 330px;
	height: 30px;
	line-height: 30px;
	font-size: 24px;
	text-align: center;
	color: yellow;
}

.message.gameover {
	font-size: 20px;
	color: red;
}

/* Rodapé: vidas | habilidade (modo inverso) | fase */
.footer {
	margin: 0 auto;
	width: 570px;
	height: 40px;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	font-size: 12px;
}

#level {
	grid-column: 3;
	text-align: right;
}

/*
 * Habilidade do fantasma (modo inverso): ícone dentro de um anel que enche com
 * a recarga (--charge de 0 a 1) e esvazia enquanto o efeito dura
 */
.ability {
	--ability-color: #FFF;
	--charge: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	grid-column: 2;
	color: var(--ability-color);
	font-size: 9px;
}

.ability.blinky { --ability-color: #FE0002; }
.ability.pinky  { --ability-color: #FFA0A1; }
.ability.inky   { --ability-color: #1BD8DA; }
.ability.clyde  { --ability-color: #FF9000; }

.ability-ring {
	position: relative;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: conic-gradient(var(--ability-color) calc(var(--charge) * 1turn), #2A2A2A 0);
}

/* Miolo do anel */
.ability-ring::before {
	content: '';
	position: absolute;
	inset: 4px;
	border-radius: 50%;
	background-color: var(--bg);
}

.ability-icon {
	position: relative;
	width: 16px;
	height: 16px;
	shape-rendering: crispEdges;
}

.ability.charging,
.ability.passive {
	cursor: default;
}

.ability.charging .ability-icon,
.ability.charging .ability-name {
	opacity: 0.45;
}

/* Pronta: o anel brilha chamando o clique */
.ability.ready .ability-ring {
	animation: ability-ready 0.8s ease-in-out infinite alternate;
}

@keyframes ability-ready {
	to {
		box-shadow: 0 0 12px 2px var(--ability-color);
	}
}

/* Em uso: miolo tingido e ícone piscando */
.ability.active .ability-ring::before {
	background-color: color-mix(in srgb, var(--ability-color) 35%, var(--bg));
}

.ability.active .ability-icon {
	animation: ability-active 0.3s steps(1) infinite;
}

@keyframes ability-active {
	50% {
		opacity: 0.4;
	}
}

@media (hover: hover) {
	.ability.ready:hover .ability-ring {
		transform: scale(1.08);
	}
}

/* Destino do teletransporte do Pinky */
.teleport-marker {
	position: absolute;
	width: 30px;
	height: 30px;
	border: 3px dashed #FFA0A1;
	border-radius: 50%;
	pointer-events: none;
	animation: marker 0.25s steps(1) infinite;
}

@keyframes marker {
	50% {
		opacity: 0.2;
	}
}

#lives {
	display: flex;
	gap: 8px;
}


/*
 * Tela inicial
 */
.home {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: clamp(12px, 3dvh, 28px);
	min-height: 100vh;
	min-height: 100dvh;
	padding: 24px 16px;
	text-align: center;
}

.home-title {
	margin: 0;
	font-size: clamp(34px, 11vw, 72px);
	font-weight: normal;
	line-height: 1.1;
	color: var(--accent);
	text-shadow: 4px 4px 0 var(--blue), 8px 8px 0 rgba(30, 133, 238, 0.35);
}

.home-tagline {
	margin: 0;
	font-size: clamp(9px, 2.6vw, 12px);
	line-height: 1.6;
	color: var(--muted);
}

/* Título: no modo inverso ganha o selo "INVERSO" */
.home-heading {
	position: relative;
}

.home-badge {
	position: absolute;
	right: -0.4em;
	bottom: -0.9em;
	padding: 6px 10px;
	border: 3px solid var(--fg);
	background-color: #FE0002;
	color: var(--fg);
	font-size: clamp(11px, 3.4vw, 18px);
	transform: rotate(-8deg);
	box-shadow: 4px 4px 0 var(--blue);
}

/* Faixa animada (posição e sprites controlados pelo screens.js) */
.hero {
	position: relative;
	width: min(520px, 100%);
	height: 48px;
	overflow: hidden;
	background: radial-gradient(circle, #CCCCCC 3px, transparent 3.5px) 0 center / 30px 30px repeat-x;
}

.hero-track {
	position: absolute;
	top: 3px;
	left: 0;
}

.hero-sprites {
	display: flex;
	gap: 6px;
	zoom: 1.5;
}

.hero-sprites .pacman,
.hero-sprites .ghost {
	position: relative;
	margin-right: 4px;
}

.hero-sprites .pacman {
	margin-left: 26px;
}


.menu {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.menu-item {
	position: relative;
	padding: 12px 34px;
	font-size: clamp(13px, 3.8vw, 18px);
	letter-spacing: 1px;
	transition: color 0.1s;
}

#menu-play {
	font-size: clamp(18px, 5.4vw, 26px);
	color: var(--accent);
	animation: pulse 1.6s ease-in-out infinite;
}

/* Setinha de fliperama no item selecionado */
.menu-item::before {
	content: '';
	position: absolute;
	left: 8px;
	top: 50%;
	margin-top: -0.4em;
	border-top: 0.4em solid transparent;
	border-bottom: 0.4em solid transparent;
	border-left: 0.6em solid var(--accent);
	opacity: 0;
}

.menu-item:hover,
.menu-item:focus {
	outline: none;
	color: var(--accent);
}

.menu-item:hover::before,
.menu-item:focus::before {
	opacity: 1;
	animation: blink 0.8s steps(2, jump-none) infinite;
}

.home-footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px 24px;
	margin: 0;
	font-size: clamp(9px, 2.4vw, 11px);
	color: var(--muted);
	text-transform: uppercase;
}

@keyframes pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.08); }
}

@keyframes blink {
	0% { opacity: 1; }
	100% { opacity: 0.2; }
}

/*
 * Janela de mensagens
 */
.modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	padding: 16px;
	background-color: rgba(0, 0, 0, 0.88);
	animation: fade 0.2s ease-out;
}

.modal-box {
	width: 100%;
	max-width: 760px;
	margin: auto;
	text-align: center;
	line-height: 1.8;
}

.modal h2 {
	margin: 0 0 24px;
	text-transform: uppercase;
	font-size: clamp(22px, 7vw, 44px);
	font-weight: normal;
	color: var(--accent);
	text-shadow: 3px 3px 0 var(--blue);
}

.modal-body {
	max-width: 560px;
	margin: 0 auto;
	font-size: clamp(10px, 2.6vw, 13px);
}

.modal-body ul {
	margin: 0;
	padding-left: 1.4em;
	text-align: left;
}

.modal-body li {
	margin-bottom: 10px;
}

.modal-body p {
	margin: 8px 0;
}

.modal-body .stats {
	margin-top: 20px;
	color: var(--muted);
}

.modal-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 16px;
	margin-top: 28px;
}

.modal-btn {
	padding: 14px 22px;
	border: 2px solid var(--fg);
	font-size: clamp(12px, 3vw, 16px);
	transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.modal-btn:hover,
.modal-btn:not(.primary):focus-visible {
	background-color: var(--fg);
	color: var(--bg);
}

.modal-btn.primary {
	border-color: var(--accent);
	background-color: var(--accent);
	color: var(--bg);
}

.modal-btn.primary:hover {
	border-color: var(--fg);
	background-color: var(--fg);
}

@keyframes fade {
	from { opacity: 0; }
}

/*
 * Ranking
 */
.rank-form {
	margin-top: 24px;
}

.rank-form label {
	display: block;
	margin-bottom: 10px;
}

.rank-form input {
	width: min(100%, 360px);
	padding: 12px 14px;
	border: 2px solid var(--fg);
	background-color: var(--bg);
	color: var(--accent);
	font: inherit;
	font-size: clamp(12px, 3vw, 16px);
	text-align: center;
	text-transform: uppercase;
	-webkit-user-select: text;
	user-select: text;
}

.rank-form input:focus {
	outline: none;
	border-color: var(--accent);
}

.rank-form input::placeholder {
	color: #555;
}

.rank-msg {
	min-height: 1.8em;
	color: var(--accent);
}

.ranking {
	width: min(100%, 420px);
	margin: 0 auto;
	border-collapse: collapse;
	text-transform: uppercase;
}

.ranking td {
	padding: 6px 8px;
	text-align: left;
}

.ranking td:first-child {
	width: 4em;
	color: var(--muted);
}

.ranking td:last-child {
	text-align: right;
}

.ranking tr:nth-child(-n+3) td:first-child {
	color: var(--accent);
}

.ranking tr.mine td,
.ranking tr.mine td:first-child {
	background-color: var(--accent);
	color: var(--bg);
}

.ranking tr[data-position] {
	cursor: pointer;
}

.ranking tr[data-position]:not(.mine):hover td,
.ranking tr[data-position]:not(.mine):focus td {
	background-color: #222;
}

.ranking tr[data-position]:focus {
	outline: 2px dashed var(--accent);
	outline-offset: -2px;
}

.ranking.detail tr td:first-child {
	width: auto;
	color: var(--muted);
}

.ranking.detail td:last-child {
	color: var(--accent);
}

.ranking tr.gap td {
	text-align: center;
	color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
	#menu-play {
		animation: none;
	}
}

/*
 * Escolha do fantasma (modo inverso)
 */
.ghost-select {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}

.ghost-card {
	--card-color: #FFF;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 14px 10px;
	border: 2px solid #333;
	background-color: var(--bg);
	line-height: 1.5;
	transition: border-color 0.15s, background-color 0.15s;
}

.ghost-card.blinky { --card-color: #FE0002; }
.ghost-card.pinky  { --card-color: #FFA0A1; }
.ghost-card.inky   { --card-color: #1BD8DA; }
.ghost-card.clyde  { --card-color: #FF9000; }

.ghost-card:hover,
.ghost-card:focus-visible {
	outline: none;
	border-color: #777;
}

.ghost-card.selected {
	border-color: var(--card-color);
	background-color: #161616;
}

.ghost-card-sprite {
	display: block;
	width: 42px;
	height: 42px;
}

.ghost-card-sprite .ghost {
	position: relative;
	zoom: 1.5;
}

.ghost-card-name {
	font-size: clamp(11px, 3vw, 14px);
	color: var(--card-color);
}

.ghost-card-nick {
	font-size: clamp(8px, 2.2vw, 10px);
	color: var(--muted);
}

.ghost-card-text {
	flex: 1;
	font-size: clamp(8px, 2.2vw, 10px);
}

.ghost-card-level {
	font-size: clamp(8px, 2.2vw, 10px);
	color: var(--accent);
}

.modal-body h3 {
	margin: 18px 0 10px;
	font-size: clamp(11px, 3vw, 14px);
	font-weight: normal;
	color: var(--accent);
	text-align: left;
}

.modal-body h3:first-child {
	margin-top: 0;
}

/* Modo inverso: vidas do Pacman já capturadas */
.pacman.life.captured {
	opacity: 0.25;
	filter: grayscale(1);
}

/* Ranking do modo inverso: o fantasma de cada jogador */
.ranking .rank-ghost {
	width: 40px;
	padding-top: 2px;
	padding-bottom: 2px;
}

.rank-ghost .ghost {
	position: relative;
}

.ghost-card-ability {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: clamp(8px, 2.2vw, 10px);
	color: var(--card-color);
}

.ghost-card-ability .ability-icon {
	width: 14px;
	height: 14px;
}
