.pg-root {
	--pg-ink: #0b1a21;
	--pg-deep: #16303b;
	--pg-blue: #244857;
	--pg-teal: #60959c;
	--pg-glow: #8fc0c4;
	--pg-pale: #d7e9ea;
	--pg-alert: #e4585c;
	--pg-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Courier New", monospace;

	max-width: 1040px;
	margin: 0 auto;
	color: var(--pg-pale);
	font-family: var(--pg-mono);
	-webkit-font-smoothing: antialiased;
}

.pg-root *,
.pg-root *::before,
.pg-root *::after {
	box-sizing: border-box;
}

.pg-frame {
	position: relative;
	aspect-ratio: 16 / 10;
	border: 2px solid var(--pg-blue);
	border-radius: 10px;
	background: radial-gradient(circle at 50% 45%, #16303b 0%, #0b1a21 70%);
	box-shadow: 0 0 0 1px rgba(143, 192, 196, 0.18), 0 24px 60px -30px rgba(0, 0, 0, 0.9);
	overflow: hidden;
	touch-action: manipulation;
}

.pg-frame::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: repeating-linear-gradient(
		to bottom,
		rgba(0, 0, 0, 0) 0,
		rgba(0, 0, 0, 0) 2px,
		rgba(0, 0, 0, 0.22) 3px,
		rgba(0, 0, 0, 0.22) 4px
	);
	mix-blend-mode: multiply;
	opacity: 0.55;
}

.pg-canvas {
	display: block;
	width: 100%;
	height: 100%;
	cursor: crosshair;
}

/* HUD: visibile solo a partita in corso. */

.pg-hud {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	gap: 18px;
	padding: 12px 16px;
	background: linear-gradient(to bottom, rgba(11, 26, 33, 0.92), rgba(11, 26, 33, 0));
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.pg-root.is-live .pg-hud {
	opacity: 1;
}

.pg-hud__cell {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 70px;
}

.pg-hud__cell--wide {
	flex: 1;
}

.pg-hud__cell--right {
	align-items: flex-end;
}

.pg-hud__label {
	font-size: 9px;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--pg-teal);
}

.pg-hud__value {
	font-size: 20px;
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--pg-pale);
	font-variant-numeric: tabular-nums;
}

.pg-time.is-low {
	color: var(--pg-alert);
}

.pg-bar {
	display: block;
	height: 10px;
	border: 1px solid var(--pg-blue);
	background: rgba(36, 72, 87, 0.35);
}

.pg-bar__fill {
	display: block;
	height: 100%;
	width: 100%;
	background: linear-gradient(90deg, var(--pg-teal), var(--pg-glow));
	transition: width 0.18s linear, background 0.18s linear;
}

.pg-bar__fill.is-low {
	background: var(--pg-alert);
}

/* Audio */

.pg-audio {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 10px;
}

.pg-audio__sep {
	width: 1px;
	height: 18px;
	background: var(--pg-blue);
	margin: 0 2px;
}

.pg-toggle[disabled] {
	opacity: 0.32;
	cursor: default;
}

.pg-toggle[disabled]:hover {
	opacity: 0.32;
	border-color: var(--pg-blue);
	color: var(--pg-teal);
}

.pg-toggle {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 6px 11px;
	border: 1px solid var(--pg-blue);
	border-radius: 4px;
	background: rgba(11, 26, 33, 0.72);
	color: var(--pg-teal);
	font-family: var(--pg-mono);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	cursor: pointer;
	opacity: 0.72;
}

.pg-toggle:hover {
	opacity: 1;
	border-color: var(--pg-teal);
	color: var(--pg-glow);
}

.pg-toggle__state {
	color: inherit;
}

.pg-toggle__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--pg-blue);
}

.pg-toggle[aria-pressed="true"] {
	opacity: 1;
	color: var(--pg-glow);
}

.pg-toggle[aria-pressed="true"] .pg-toggle__dot {
	background: var(--pg-glow);
	box-shadow: 0 0 8px var(--pg-glow);
}

/* Schermate */

.pg-screen {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: none;
	align-items: center;
	justify-content: center;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 24px;
	text-align: center;
	background: radial-gradient(circle at 50% 40%, rgba(22, 48, 59, 0.94), rgba(11, 26, 33, 0.97));
	backdrop-filter: blur(2px);
}

/* Attract screen: nessun riquadro, solo testo luminoso sopra la demo. */
.pg-screen--intro {
	align-items: center;
	background: radial-gradient(
		ellipse at 50% 46%,
		rgba(11, 26, 33, 0.92) 0%,
		rgba(11, 26, 33, 0.84) 46%,
		rgba(11, 26, 33, 0.4) 100%
	);
	backdrop-filter: none;
}

.pg-screen--intro .pg-screen__inner {
	max-width: 720px;
}

/* Istruzioni: testo in alto, campo di gioco vivo sotto. */
.pg-screen--howto {
	align-items: flex-start;
	padding-top: 52px;
	background: linear-gradient(
		to bottom,
		rgba(11, 26, 33, 0.9) 0%,
		rgba(11, 26, 33, 0.72) 40%,
		rgba(11, 26, 33, 0.18) 100%
	);
	backdrop-filter: none;
}

.pg-screen--howto .pg-screen__inner {
	padding: 22px 24px 24px;
	border: 1px solid var(--pg-blue);
	border-radius: 8px;
	background: rgba(11, 26, 33, 0.82);
	box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.95);
}

/* Briefing: la scena resta in vista, il testo scende in basso. */
.pg-screen--briefing {
	align-items: flex-end;
	padding: 20px;
	background: linear-gradient(
		to bottom,
		rgba(11, 26, 33, 0) 0%,
		rgba(11, 26, 33, 0.12) 40%,
		rgba(11, 26, 33, 0.82) 76%,
		rgba(11, 26, 33, 0.94) 100%
	);
	backdrop-filter: none;
}

.pg-screen--briefing .pg-screen__inner {
	max-width: 560px;
	padding: 18px 22px 20px;
	border: 1px solid var(--pg-blue);
	border-radius: 8px;
	background: rgba(11, 26, 33, 0.86);
	box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.95);
}

/* Altezza fissa: il riquadro non salta mentre il testo viene scritto. */
.pg-brief {
	min-height: 4.5em;
	margin-bottom: 16px;
}

.pg-screen.is-open {
	display: flex;
	animation: pg-fade 0.25s ease-out;
}

@keyframes pg-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.pg-screen__inner {
	max-width: 460px;
}

.pg-eyebrow {
	margin: 0 0 10px;
	font-size: 10px;
	letter-spacing: 0.32em;
	text-transform: uppercase;
	color: var(--pg-teal);
}

.pg-eyebrow--danger {
	color: var(--pg-alert);
}

.pg-title {
	margin: 0 0 14px;
	font-family: var(--pg-mono);
	font-size: clamp(22px, 4.2vw, 38px);
	line-height: 1.15;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--pg-pale);
	text-shadow: 0 0 18px rgba(96, 149, 156, 0.55);
}

.pg-title--sm {
	font-size: clamp(18px, 3vw, 26px);
}

.pg-title--brand {
	margin-bottom: 10px;
	font-size: clamp(30px, 9vw, 82px);
	line-height: 1;
	letter-spacing: 0.12em;
	color: #eaf6f7;
	text-shadow: 0 0 6px rgba(234, 246, 247, 0.75), 0 0 40px rgba(96, 149, 156, 0.9);
}

/* Riga di credito fra due filetti, come sui cabinati. */
.pg-brandline {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0 0 16px;
	font-size: clamp(10px, 1.1vw, 14px);
	font-weight: 700;
	letter-spacing: 0.42em;
	text-transform: uppercase;
	color: var(--pg-pale);
	text-shadow: 0 0 14px rgba(143, 192, 196, 0.5);
}

.pg-brandline::before,
.pg-brandline::after {
	content: "";
	flex: 1;
	height: 1px;
	background: linear-gradient(90deg, transparent, var(--pg-blue), transparent);
}

.pg-subtitle {
	margin: 0 0 14px;
	font-family: var(--pg-mono);
	font-size: clamp(18px, 3.4vw, 30px);
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--pg-glow);
	text-shadow: 0 0 18px rgba(143, 192, 196, 0.6);
}

.pg-subtitle::before {
	content: "[ ";
	color: var(--pg-teal);
}

.pg-subtitle::after {
	content: " ]";
	color: var(--pg-teal);
}

.pg-logo--intro {
	width: 92px;
	margin-bottom: 18px;
}

.pg-text {
	margin: 0 0 20px;
	font-size: 13px;
	line-height: 1.7;
	color: rgba(215, 233, 234, 0.82);
}

.pg-text--tag {
	margin-bottom: 30px;
	color: var(--pg-teal);
	letter-spacing: 0.04em;
}

.pg-brand {
	display: inline-block;
	font-weight: 700;
	font-size: 1.15em;
	letter-spacing: 0.06em;
	color: var(--pg-glow);
	text-shadow: 0 0 14px rgba(143, 192, 196, 0.7);
	white-space: nowrap;
}

.pg-text--quiet {
	color: var(--pg-teal);
	font-size: 12px;
}

.pg-rules {
	margin: 0 0 22px;
	padding: 0 0 0 20px;
	text-align: left;
	font-size: 13px;
	line-height: 1.7;
	color: rgba(215, 233, 234, 0.86);
}

.pg-rules li {
	margin-bottom: 10px;
}

.pg-rules b {
	color: var(--pg-glow);
}

.pg-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: center;
	margin-top: 4px;
}

.pg-btn {
	display: inline-block;
	padding: 13px 26px;
	border: 1px solid var(--pg-teal);
	border-radius: 4px;
	background: transparent;
	color: var(--pg-pale);
	font-family: var(--pg-mono);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.pg-btn--primary {
	background: var(--pg-blue);
	box-shadow: 0 0 0 0 rgba(143, 192, 196, 0.6);
}

.pg-btn--primary:hover {
	background: var(--pg-teal);
	color: var(--pg-ink);
	transform: translateY(-1px);
	box-shadow: 0 0 22px -4px rgba(143, 192, 196, 0.8);
}

.pg-btn--ghost:hover {
	border-color: var(--pg-glow);
	color: var(--pg-glow);
}

/* Start: lampeggio a scatto secco, fermo appena ci passi sopra. */
.pg-btn--start {
	padding: 18px 54px;
	font-size: clamp(14px, 2.2vw, 18px);
	letter-spacing: 0.32em;
	animation: pg-blink 1.1s step-end infinite;
}

.pg-btn--start:hover,
.pg-btn--start:focus-visible {
	animation: none;
	opacity: 1;
}

@keyframes pg-blink {
	0%   { opacity: 1; }
	55%  { opacity: 0.15; }
	100% { opacity: 0.15; }
}

.pg-contacts {
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid rgba(36, 72, 87, 0.9);
}

.pg-contacts__label {
	margin: 0 0 10px;
	font-size: 9px;
	letter-spacing: 0.28em;
	text-transform: uppercase;
	color: var(--pg-teal);
}

.pg-contacts__row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.pg-btn--contact {
	padding: 10px 18px;
	border-color: var(--pg-teal);
	background: rgba(36, 72, 87, 0.55);
	letter-spacing: 0.12em;
}

.pg-btn--contact:hover {
	background: var(--pg-teal);
	color: var(--pg-ink);
}

.pg-btn:focus-visible,
.pg-sound:focus-visible {
	outline: 2px solid var(--pg-glow);
	outline-offset: 3px;
}

.pg-logo {
	width: 76px;
	height: auto;
	margin: 0 auto 16px;
	display: block;
	filter: drop-shadow(0 0 22px rgba(96, 149, 156, 0.55));
}

.pg-logo--win {
	animation: pg-logo-in 0.6s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

@keyframes pg-logo-in {
	from { opacity: 0; transform: scale(0.6) translateY(14px); }
	to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pg-root .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

@media (max-width: 640px) {
	.pg-frame {
		aspect-ratio: 3 / 4;
	}

	.pg-screen {
		padding: 18px 16px;
		align-items: flex-start;
	}

	.pg-screen--howto {
		padding-top: 44px;
	}

	.pg-screen--intro {
		align-items: center;
		padding: 18px;
	}

	.pg-logo--intro {
		width: 56px;
		margin-bottom: 12px;
	}

	.pg-title--brand {
		margin-bottom: 8px;
	}

	.pg-brandline {
		margin-bottom: 12px;
		gap: 8px;
		font-size: 9px;
		letter-spacing: 0.32em;
	}

	.pg-subtitle {
		margin-bottom: 18px;
	}

	/* La durata la ripete il briefing subito dopo: qui serve spazio. */
	.pg-screen--intro .pg-text--tag {
		display: none;
	}

	.pg-btn--start {
		padding: 18px 20px;
		letter-spacing: 0.24em;
	}

	.pg-screen--briefing {
		align-items: flex-end;
		padding: 14px 12px;
	}

	.pg-screen--briefing .pg-screen__inner {
		padding: 16px 16px 18px;
	}

	.pg-brief {
		min-height: 6.2em;
		margin-bottom: 14px;
	}

	.pg-screen__inner {
		width: 100%;
	}

	.pg-actions {
		flex-direction: column;
		align-items: stretch;
		gap: 12px;
	}

	/* I contatti restano in riga: in colonna finivano fuori dal campo. */
	.pg-contacts {
		margin-top: 14px;
		padding-top: 12px;
	}

	.pg-contacts__label {
		margin-bottom: 8px;
	}

	.pg-contacts__row {
		flex-direction: row;
		flex-wrap: nowrap;
		gap: 6px;
	}

	.pg-contacts__row .pg-btn {
		flex: 1 1 0;
		width: auto;
		min-width: 0;
		padding: 12px 4px;
		font-size: 10px;
		letter-spacing: 0.04em;
	}

	/* Spazio recuperato nella schermata di vittoria. */
	.pg-logo {
		width: 52px;
		margin-bottom: 10px;
	}

	.pg-text--quiet {
		display: none;
	}

	.pg-screen--win .pg-text,
	.pg-screen--over .pg-text {
		margin-bottom: 14px;
		font-size: 12px;
		line-height: 1.5;
	}

	.pg-screen--win .pg-title,
	.pg-screen--over .pg-title {
		margin-bottom: 10px;
	}

	.pg-btn {
		width: 100%;
		padding: 15px 18px;
	}

	.pg-text,
	.pg-rules {
		margin-bottom: 18px;
	}

	.pg-audio {
		flex-wrap: nowrap;
		justify-content: stretch;
		gap: 5px;
	}

	.pg-audio__sep {
		display: none;
	}

	.pg-toggle {
		flex: 1 1 0;
		justify-content: center;
		padding: 9px 4px;
		font-size: 9px;
		letter-spacing: 0.06em;
		gap: 5px;
	}

	.pg-toggle__state {
		display: none;
	}

	.pg-hud {
		gap: 10px;
		padding: 10px;
	}

	.pg-hud__value {
		font-size: 16px;
	}

	.pg-hud__cell {
		min-width: 52px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pg-screen.is-open,
	.pg-logo--win,
	.pg-btn--start {
		animation: none;
		opacity: 1;
	}

	.pg-btn,
	.pg-hud {
		transition: none;
	}
}