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

@font-face {
	font-family: 'Press Start 2P';
	src: url('fonts/PressStart2P.woff2') format('woff2'),
		url('fonts/PressStart2P.woff') format('woff');
	font-weight: normal;
	font-style: normal;
	font-display: block;
}

@font-face {
	font-family: 'pizza';
	src: url('fonts/pizza.woff2') format('woff2'),
		url('fonts/pizza.woff') format('woff');
	font-weight: normal;
	font-style: normal;
	font-display: block;
}

[class^="icon-"]:before,
[class*=" icon-"]:before {
	font-family: "pizza";
	font-style: normal;
	font-weight: normal;
	display: inline-block;
	width: 1em;
	text-align: center;
	line-height: 1em;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.icon-pause:before { content: '\e800'; }
.icon-reload:before { content: '\e801'; }
.icon-infinity:before { content: '\e802'; }
.icon-play:before { content: '\e803'; }

/*
 * --u é o tamanho de uma célula do tabuleiro (240px no desktop),
 * reduzido para caber na largura e na altura da tela.
 */
:root {
	--u: 240px;
	--u: max(80px, min(240px, calc((100vw - 32px) / 3)));
	--u: max(80px, min(240px, calc((100vw - 32px) / 3), calc((100dvh - 48px) / 3)));
	--p: calc(var(--u) * 5 / 6);
	--fs: calc(var(--u) / 20);

	--bg: #000;
	--fg: #FFF;
	--muted: #8C8C8C;
	--ok: #4CD964;
	--warn: #FFCC00;
	--danger: #FF3B30;
}

* {
	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;
	padding: 0 16px 16px;
	-webkit-tap-highlight-color: transparent;
	-webkit-user-select: none;
	user-select: none;
	touch-action: manipulation;
}

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

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

/* Tela do jogo: tabuleiro centralizado na vertical */
.game {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: calc(100dvh - 16px);
	padding-top: 16px;
}

/* Tabuleiro: 3 colunas x 6 meias-linhas */

.board {
	position: relative;
	display: grid;
	grid-template-columns: repeat(3, var(--u));
	grid-template-rows: repeat(6, calc(var(--u) / 2));
	width: calc(var(--u) * 3);
	margin: 0 auto;
}

.hud-time   { grid-area: 1 / 1 / 2 / 2; }
#pizza-6    { grid-area: 2 / 1 / 4 / 2; }
#pizza-5    { grid-area: 4 / 1 / 6 / 2; }
.actions    { grid-area: 6 / 1 / 7 / 2; }
#pizza-1    { grid-area: 1 / 2 / 3 / 3; }
.center     { grid-area: 3 / 2 / 5 / 3; }
#pizza-4    { grid-area: 5 / 2 / 7 / 3; }
.hud-score  { grid-area: 1 / 3 / 2 / 4; }
#pizza-2    { grid-area: 2 / 3 / 4 / 4; }
#pizza-3    { grid-area: 4 / 3 / 6 / 4; }
.hud-lives  { grid-area: 6 / 3 / 7 / 4; }

/* Pizzas */

.plate {
	position: relative;
	width: var(--p);
	height: var(--p);
	background: url("../img/fundo.png") center / contain no-repeat;
	transition: filter 0.2s;
}

.pizza {
	place-self: center;
	transition: transform 0.1s, opacity 0.15s;
}

.pizza:active {
	transform: scale(0.97);
}

@media (hover: hover) {
	.pizza:hover {
		opacity: 0.85;
	}
}

.slice {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: none;
	pointer-events: none;
}

.slice.on,
.slice.ghost {
	display: block;
}

.slice.ghost {
	animation: pulsate 0.8s linear forwards;
}

.key {
	position: absolute;
	top: 0;
	left: 0;
	font-size: var(--fs);
	color: var(--muted);
}

@media (hover: none) {
	.key {
		display: none;
	}
}

.pop {
	position: absolute;
	inset: 0;
	z-index: 8;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	font-size: calc(var(--u) / 5);
	text-shadow: 6px 5px 6px rgba(0, 0, 0, 0.56);
	pointer-events: none;
	animation: pop 1.4s ease-out forwards;
}

.pop small {
	margin-top: 10px;
	font-size: var(--fs);
	color: var(--warn);
}

.shake {
	animation: shake 0.4s;
	filter: drop-shadow(0 0 10px var(--danger));
}

/* Fatia sorteada (centro) */

.center {
	position: relative;
	display: grid;
	place-items: center;
	z-index: 1;
}

.center.flying {
	z-index: 10;
}

.rand {
	position: absolute;
	inset: 0;
}

.rand.appear {
	animation: appear 0.25s ease-out;
}

.timer {
	position: absolute;
	left: calc(var(--u) / 12);
	right: calc(var(--u) / 12);
	bottom: calc(var(--u) / 48);
	height: max(4px, calc(var(--u) / 40));
	background-color: #222;
	border-radius: 3px;
	overflow: hidden;
}

.timer-fill {
	height: 100%;
	background-color: var(--ok);
	transform-origin: left center;
	transform: scaleX(0);
}

.timer-fill.warn {
	background-color: var(--warn);
}

.timer-fill.danger {
	background-color: var(--danger);
}

.pause-label {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: none;
	place-items: center;
	font-size: calc(var(--u) / 12);
}

.board.paused .pause-label {
	display: grid;
}

.board.paused .plate {
	filter: blur(6px) brightness(0.4);
}

/* Painéis */

.hud {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: calc(var(--u) / 30);
	text-align: center;
}

.label {
	font-size: var(--fs);
}

.clock {
	font-size: calc(var(--u) / 12);
}

.score-line {
	display: flex;
	align-items: center;
	gap: calc(var(--u) / 30);
	font-size: calc(var(--u) / 12);
}

.score-line img {
	width: calc(var(--u) / 4);
	height: auto;
}

#score {
	font-size: calc(var(--u) / 10);
}

.hearts {
	display: flex;
	gap: calc(var(--u) / 24);
}

.hearts img {
	width: calc(var(--u) / 5);
	height: auto;
}

.hearts img.lost {
	animation: lose-life 1.2s linear forwards;
}

.actions {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: calc(var(--u) / 20);
	font-size: calc(var(--u) / 9);
}

.actions button {
	display: grid;
	place-items: center;
	width: calc(var(--u) / 5);
	height: calc(var(--u) / 5);
	transition: opacity 0.25s;
}

@media (hover: hover) {
	.actions button:hover {
		opacity: 0.85;
	}
}

.actions svg {
	width: 1.25em;
	height: 1.1em;
}

/* Ícone em pixel art: sem suavização, como a fonte */
.actions svg.pixel {
	width: 0.95em;
	height: 0.95em;
	shape-rendering: crispEdges;
}

/* Tela inicial */

.home {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: clamp(10px, 2.4dvh, 22px);
	min-height: calc(100dvh - 16px);
	padding: 24px 0;
	text-align: center;
}

.home > :not(.rain) {
	position: relative;
	z-index: 1;
}

.rain {
	position: fixed;
	inset: 0;
	z-index: 0;
	overflow: hidden;
	pointer-events: none;
}

.rain img {
	position: absolute;
	top: 0;
	height: auto;
	opacity: 0.12;
	animation: fall linear infinite;
}

.home-hero {
	width: min(220px, 52vw, 30dvh);
	aspect-ratio: 1;
	background: radial-gradient(circle, rgba(255, 204, 0, 0.22), transparent 68%);
	border-radius: 50%;
}

.hero-pizza {
	position: relative;
	width: 100%;
	height: 100%;
	background: url('../img/fundo.png') center / contain no-repeat;
	animation: bob 3s ease-in-out infinite;
}

.hero-pizza img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	animation: hero-slice 7s ease-in infinite;
	animation-delay: calc(var(--i) * 0.35s);
}

.home-title {
	margin: 0;
	font-size: clamp(30px, 9vw, 64px);
	font-weight: normal;
	line-height: 1.1;
	text-shadow: 4px 4px 0 #B3261E, 8px 8px 0 rgba(255, 204, 0, 0.3);
}

.home-title span:last-child {
	color: var(--warn);
}

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

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

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

#menu-play {
	font-size: clamp(18px, 5.4vw, 26px);
	color: var(--warn);
	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(--warn);
	opacity: 0;
}

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

.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: 8px 0 0;
	font-size: clamp(9px, 2.4vw, 11px);
	color: var(--muted);
	text-transform: uppercase;
}

/* Janela de mensagens */

.modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	flex-direction: column;
	align-items: center;
	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;
	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;
	text-shadow: 0 0 90px rgba(200, 200, 200, 0.8);
}

.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);
}

/* 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(--warn);
	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(--warn);
}

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

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

.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(--warn);
}

.ranking tr.mine td,
.ranking tr.mine td:first-child {
	background-color: var(--warn);
	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(--warn);
	outline-offset: -2px;
}

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

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

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

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

.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(--warn);
	background-color: var(--warn);
	color: var(--bg);
}

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

/* Animações */

@keyframes pulsate {
	0%, 40%, 80% { opacity: 1; }
	20%, 60% { opacity: 0.1; }
	100% { opacity: 0; }
}

@keyframes lose-life {
	0%, 40%, 80% { opacity: 1; }
	20%, 60% { opacity: 0.1; }
	100% { opacity: 0.15; filter: grayscale(1); }
}

@keyframes pop {
	0% { opacity: 0; transform: scale(0.5); }
	20% { opacity: 1; transform: scale(1.1); }
	70% { opacity: 1; transform: translateY(-10%); }
	100% { opacity: 0; transform: translateY(-30%); }
}

@keyframes shake {
	0%, 100% { transform: translateX(0); }
	20%, 60% { transform: translateX(-8px); }
	40%, 80% { transform: translateX(8px); }
}

@keyframes appear {
	from { opacity: 0; transform: scale(0.6); }
}

@keyframes fall {
	from { transform: translateY(-120px) rotate(0); }
	to { transform: translateY(calc(100dvh + 40px)) rotate(var(--spin)); }
}

@keyframes hero-slice {
	0% { opacity: 0; transform: translateY(-160%) scale(1.3); }
	6% { opacity: 1; transform: translateY(0) scale(1); }
	8% { transform: scale(1.05); }
	10%, 72% { opacity: 1; transform: none; }
	82%, 100% { opacity: 0; transform: scale(0.85); }
}

@keyframes bob {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-8px); }
}

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

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

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

@media (prefers-reduced-motion: reduce) {
	.shake,
	.rand.appear,
	.hero-pizza,
	#menu-play {
		animation: none;
	}

	.rain {
		display: none;
	}
}
