/**
 * Pizza Hut Slice Game – עיצוב ומיתוג.
 *
 * צבעי מותג:
 *   #F32735 אדום | #2D2A26 שחור | #F0EFDD קרם | #B58967 קראפט
 *   נמנעים מ-#6BA43A (ירוק) אלא אם הקמפיין נטול גלוטן.
 */

.phsg-app {
	--phsg-red: #F32735;
	--phsg-black: #2D2A26;
	--phsg-cream: #F0EFDD;
	--phsg-kraft: #B58967;
	--phsg-kraft-dark: #9a6f4f;

	position: relative;
	box-sizing: border-box;
	max-width: 720px;
	margin: 0 auto;
	padding: 20px;
	min-height: 560px;
	/* רקע קופסת פיצה בגוון קראפט */
	background-color: var(--phsg-kraft);
	background-image:
		linear-gradient(135deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%),
		linear-gradient(225deg, rgba(0, 0, 0, 0.05) 25%, transparent 25%);
	background-size: 22px 22px;
	border: 6px solid var(--phsg-black);
	border-radius: 18px;
	box-shadow: 0 18px 40px rgba(45, 42, 38, 0.35);
	overflow: hidden;
	font-family: "Machmorat Rounded", "Rubik", "Assistant", -apple-system, "Segoe UI", sans-serif;
	color: var(--phsg-black);
	text-align: center;
}

.phsg-app *,
.phsg-app *::before,
.phsg-app *::after {
	box-sizing: border-box;
}

/* ===== רקע תבנית טיפוגרפיה ===== */
.phsg-pattern {
	position: absolute;
	inset: 0;
	z-index: 0;
	opacity: 0.10;
	pointer-events: none;
	overflow: hidden;
	transform: rotate(-8deg) scale(1.4);
	transform-origin: center;
}

.phsg-pattern__row {
	display: block;
	white-space: nowrap;
	font-family: "HWT Artz", "Rubik", sans-serif;
	font-weight: 800;
	font-size: 26px;
	line-height: 1.7;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: var(--phsg-black);
}

/* ===== במה ומסכים ===== */
.phsg-stage {
	position: relative;
	z-index: 1;
}

.phsg-screen {
	position: relative; /* עוגן לשכבת הקונפטי במסך הסיום. */
	display: none;
	animation: phsg-fade 0.35s ease;
}

.phsg-screen.is-active {
	display: block;
}

@keyframes phsg-fade {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ===== כרטיס ===== */
.phsg-card {
	background: var(--phsg-cream);
	border: 4px solid var(--phsg-black);
	border-radius: 16px;
	padding: 28px 22px;
	margin: 0 auto 16px;
	box-shadow: 0 8px 0 var(--phsg-black);
}

.phsg-card--board {
	padding: 18px;
}

/* ===== לוגו/משולש ===== */
.phsg-logo {
	width: 96px;
	margin: 0 auto 12px;
}

.phsg-logo--sm {
	width: 64px;
}

.phsg-slice-svg {
	display: block;
	width: 100%;
	height: auto;
}

/* ===== טיפוגרפיה ===== */
.phsg-title {
	font-family: "HWT Artz", "Rubik", "Assistant", sans-serif;
	font-weight: 800;
	font-size: clamp(30px, 7vw, 48px);
	line-height: 1.05;
	margin: 0 0 6px;
	color: var(--phsg-red);
	text-transform: uppercase;
	-webkit-text-stroke: 1.5px var(--phsg-black);
	text-shadow: 3px 3px 0 var(--phsg-black);
}

.phsg-title--sm {
	font-size: clamp(24px, 5vw, 34px);
}

.phsg-subtitle {
	font-weight: 700;
	font-size: 18px;
	margin: 0 0 14px;
	color: var(--phsg-black);
}

.phsg-lead {
	font-size: 16px;
	line-height: 1.5;
	margin: 0 0 20px;
	color: var(--phsg-black);
}

/* ===== כפתורים ===== */
.phsg-btn {
	display: inline-block;
	font-family: inherit;
	font-weight: 800;
	font-size: 18px;
	padding: 14px 34px;
	border: 3px solid var(--phsg-black);
	border-radius: 40px;
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.12s ease;
	text-decoration: none;
}

.phsg-btn--primary {
	background: var(--phsg-red);
	color: #fff;
	box-shadow: 0 5px 0 var(--phsg-black);
}

.phsg-btn--primary:hover {
	transform: translateY(-2px);
	box-shadow: 0 7px 0 var(--phsg-black);
}

.phsg-btn--primary:active {
	transform: translateY(3px);
	box-shadow: 0 2px 0 var(--phsg-black);
}

.phsg-btn:focus-visible {
	outline: 3px dashed var(--phsg-black);
	outline-offset: 3px;
}

/* ===== טופס ===== */
.phsg-form {
	text-align: right;
	max-width: 380px;
	margin: 0 auto;
}

.phsg-field {
	margin-bottom: 16px;
}

.phsg-field label {
	display: block;
	font-weight: 700;
	margin-bottom: 6px;
}

.phsg-field input[type="text"],
.phsg-field input[type="tel"],
.phsg-field input[type="email"] {
	width: 100%;
	font-family: inherit;
	font-size: 16px;
	padding: 12px 14px;
	border: 3px solid var(--phsg-black);
	border-radius: 10px;
	background: #fff;
	color: var(--phsg-black);
}

.phsg-field input:focus {
	outline: none;
	border-color: var(--phsg-red);
	box-shadow: 0 0 0 3px rgba(243, 39, 53, 0.25);
}

.phsg-field--check label {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-weight: 500;
	font-size: 14px;
	cursor: pointer;
}

.phsg-field--check input {
	margin-top: 3px;
	width: 20px;
	height: 20px;
	accent-color: var(--phsg-red);
	flex: 0 0 auto;
}

.phsg-field__error {
	display: block;
	color: var(--phsg-red);
	font-size: 13px;
	font-weight: 700;
	margin-top: 5px;
	min-height: 16px;
}

.phsg-field.has-error input {
	border-color: var(--phsg-red);
	background: #fff4f5;
}

/* ===== HUD ===== */
.phsg-hud {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.phsg-hud__item {
	flex: 1;
	background: var(--phsg-cream);
	border: 3px solid var(--phsg-black);
	border-radius: 12px;
	padding: 8px 10px;
	box-shadow: 0 4px 0 var(--phsg-black);
}

.phsg-hud__label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
}

.phsg-hud__value {
	display: block;
	font-family: "HWT Artz", "Rubik", sans-serif;
	font-weight: 800;
	font-size: 30px;
	color: var(--phsg-red);
	line-height: 1;
}

/* ===== זירת משחק ===== */
.phsg-arena {
	position: relative;
	width: 100%;
	height: 420px;
	background:
		radial-gradient(ellipse at center, transparent 55%, rgba(181, 137, 103, 0.22) 100%),
		var(--phsg-cream);
	border: 4px solid var(--phsg-black);
	border-radius: 16px;
	box-shadow: inset 0 0 0 4px rgba(181, 137, 103, 0.35);
	overflow: hidden;
	/* סמן-מטרה (reticle) מעוצב – משחקי. */
	cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 38 38"><circle cx="19" cy="19" r="12" fill="none" stroke="%23F0EFDD" stroke-width="7"/><circle cx="19" cy="19" r="12" fill="none" stroke="%23F32735" stroke-width="3.5"/><circle cx="19" cy="19" r="3.5" fill="%23F32735"/><path d="M19 1.5v6M19 30.5v6M1.5 19h6M30.5 19h6" stroke="%232D2A26" stroke-width="3.5" stroke-linecap="round"/></svg>') 19 19, crosshair;
	touch-action: manipulation;
}

.phsg-arena:focus-visible {
	outline: 3px dashed var(--phsg-red);
	outline-offset: 3px;
}

/* מצב "לחוץ" – 10 שניות אחרונות. */
.phsg-arena.is-urgent {
	animation: phsg-urgent-border 1s ease-in-out infinite;
}

@keyframes phsg-urgent-border {
	0%, 100% { border-color: var(--phsg-black); }
	50%      { border-color: var(--phsg-red); }
}

.phsg-hud__item--time.is-urgent .phsg-hud__value {
	color: var(--phsg-red);
	animation: phsg-urgent-pulse 1s ease-in-out infinite;
}

@keyframes phsg-urgent-pulse {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.22); }
}

/* ===== משולש הפיצה (מטרה) ===== */
.phsg-slice {
	position: absolute;
	width: 74px;
	height: 74px;
	padding: 0;
	margin: 0;
	border: none;
	background: transparent;
	cursor: inherit;
	transform: translate(-50%, -50%) scale(1);
	transition: transform 0.08s ease;
	animation: phsg-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
	filter: drop-shadow(2px 4px 3px rgba(45, 42, 38, 0.4));
	z-index: 2;
}

.phsg-slice .phsg-slice-svg {
	animation: phsg-wobble 1.6s ease-in-out infinite;
}

@keyframes phsg-wobble {
	0%, 100% { transform: rotate(-6deg); }
	50%      { transform: rotate(6deg); }
}

.phsg-slice:active {
	transform: translate(-50%, -50%) scale(0.86);
}

@keyframes phsg-pop {
	from { transform: translate(-50%, -50%) scale(0.2) rotate(-40deg); }
	to   { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
}

/* ===== שכבת אפקטים ===== */
.phsg-fx {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 3;
}

.phsg-particle {
	position: absolute;
	border-radius: 50%;
	transform: translate(-50%, -50%);
	pointer-events: none;
	border: 1px solid rgba(45, 42, 38, 0.35);
}

.phsg-ring {
	position: absolute;
	width: 16px;
	height: 16px;
	border: 3px solid var(--phsg-red);
	border-radius: 50%;
	transform: translate(-50%, -50%);
	pointer-events: none;
	animation: phsg-ring 0.45s ease-out forwards;
}

.phsg-ring--miss {
	border-color: rgba(45, 42, 38, 0.4);
}

@keyframes phsg-ring {
	from { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
	to   { transform: translate(-50%, -50%) scale(4);   opacity: 0; }
}

.phsg-float {
	position: absolute;
	transform: translate(-50%, -50%);
	pointer-events: none;
	direction: ltr; /* "+1" ולא "1+" בהקשר RTL. */
	unicode-bidi: isolate;
	font-weight: 900;
	font-size: 26px;
	color: var(--phsg-red);
	text-shadow: 2px 2px 0 var(--phsg-cream), -1px -1px 0 var(--phsg-cream);
	animation: phsg-float 0.75s ease-out forwards;
	white-space: nowrap;
	z-index: 4;
}

.phsg-float--miss {
	font-size: 16px;
	color: var(--phsg-black);
}

@keyframes phsg-float {
	from { transform: translate(-50%, -50%) scale(0.6); opacity: 1; }
	60%  { opacity: 1; }
	to   { transform: translate(-50%, -160%) scale(1.25); opacity: 0; }
}

/* רעידת מסך עדינה בפגיעה. */
.phsg-stage.is-shaking {
	animation: phsg-shake 0.24s ease-in-out;
}

@keyframes phsg-shake {
	0%, 100% { transform: translate(0, 0); }
	25%      { transform: translate(2px, -2px); }
	50%      { transform: translate(-2px, 2px); }
	75%      { transform: translate(1px, -1px); }
}

/* ===== תג קומבו ===== */
.phsg-combo {
	position: absolute;
	top: 12px;
	inset-inline-start: 50%;
	transform: translateX(50%);
	background: var(--phsg-black);
	color: var(--phsg-cream);
	font-weight: 900;
	font-size: 18px;
	padding: 6px 18px;
	border-radius: 999px;
	border: 3px solid var(--phsg-cream);
	box-shadow: 0 4px 0 rgba(45, 42, 38, 0.35);
	pointer-events: none;
	animation: phsg-combo-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
	z-index: 4;
}

.phsg-combo.is-hot {
	background: var(--phsg-red);
	border-color: #FFDD87;
}

@keyframes phsg-combo-pop {
	from { transform: translateX(50%) scale(0.5); }
	60%  { transform: translateX(50%) scale(1.2); }
	to   { transform: translateX(50%) scale(1); }
}

/* ===== ספירה לאחור ===== */
.phsg-countdown {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(45, 42, 38, 0.55);
	z-index: 5;
}

.phsg-countdown[hidden] {
	display: none;
}

.phsg-countdown__num {
	font-size: 110px;
	font-weight: 900;
	color: var(--phsg-cream);
	text-shadow: 4px 4px 0 var(--phsg-red), 8px 8px 0 rgba(45, 42, 38, 0.4);
	animation: phsg-count-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.phsg-countdown__num.is-go {
	color: #FFDD87;
}

@keyframes phsg-count-pop {
	from { transform: scale(2.4); opacity: 0; }
	to   { transform: scale(1);   opacity: 1; }
}

/* ===== כפתור סאונד ===== */
.phsg-sound {
	border: 3px solid var(--phsg-black);
	background: var(--phsg-cream);
	border-radius: 12px;
	font-size: 20px;
	line-height: 1;
	padding: 8px 10px;
	cursor: pointer;
	box-shadow: 0 3px 0 var(--phsg-black);
	transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.phsg-sound:active {
	transform: translateY(3px);
	box-shadow: 0 0 0 var(--phsg-black);
}

/* ===== קונפטי ===== */
.phsg-confetti {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 6;
}

.phsg-confetti__piece {
	position: absolute;
	top: -14px;
	width: 10px;
	height: 14px;
	border-radius: 3px;
	animation: phsg-confetti-fall linear forwards;
}

@keyframes phsg-confetti-fall {
	to {
		transform: translateY(620px) rotate(540deg);
		opacity: 0.4;
	}
}

@media (prefers-reduced-motion: reduce) {
	.phsg-slice,
	.phsg-screen,
	.phsg-slice .phsg-slice-svg,
	.phsg-arena.is-urgent,
	.phsg-hud__item--time.is-urgent .phsg-hud__value,
	.phsg-stage.is-shaking,
	.phsg-combo,
	.phsg-countdown__num {
		animation: none;
	}
}

/* ===== מסך סיום – תוצאה ===== */
.phsg-result {
	display: flex;
	justify-content: center;
	gap: 14px;
	margin: 18px 0;
}

.phsg-result__item {
	flex: 1;
	max-width: 130px;
	background: #fff;
	border: 3px solid var(--phsg-black);
	border-radius: 12px;
	padding: 12px 6px;
}

.phsg-result__value {
	display: block;
	font-family: "HWT Artz", "Rubik", sans-serif;
	font-weight: 800;
	font-size: 34px;
	color: var(--phsg-red);
	line-height: 1;
}

.phsg-result__label {
	display: block;
	font-size: 13px;
	font-weight: 700;
	margin-top: 4px;
}

.phsg-result__msg {
	font-size: 16px;
	font-weight: 700;
	margin: 6px 0 18px;
	min-height: 22px;
}

/* ===== טבלת מובילים ===== */
.phsg-board__title {
	font-family: "HWT Artz", "Rubik", sans-serif;
	font-weight: 800;
	font-size: 22px;
	color: var(--phsg-red);
	margin: 0 0 12px;
	text-transform: uppercase;
}

.phsg-board__head,
.phsg-board__row {
	display: grid;
	grid-template-columns: 60px 1fr 70px 60px;
	align-items: center;
	gap: 6px;
	padding: 8px 10px;
	text-align: center;
}

.phsg-board__head {
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border-bottom: 3px solid var(--phsg-black);
	color: var(--phsg-black);
}

.phsg-board__row {
	background: #fff;
	border: 2px solid var(--phsg-black);
	border-radius: 10px;
	margin-top: 6px;
	font-weight: 600;
}

.phsg-board__row .phsg-board__name {
	text-align: right;
}

.phsg-board__rank {
	font-family: "HWT Artz", "Rubik", sans-serif;
	font-weight: 800;
	color: var(--phsg-red);
}

.phsg-board__row--gold   { background: #fff7d6; border-color: #d9a300; }
.phsg-board__row--silver { background: #f2f2f2; border-color: #9a9a9a; }
.phsg-board__row--bronze { background: #f7e6d4; border-color: var(--phsg-kraft-dark); }

.phsg-board__empty {
	padding: 16px;
	font-weight: 700;
}

.phsg-board__row.is-you {
	outline: 3px solid var(--phsg-red);
	outline-offset: 1px;
}

/* ===== לואודר ===== */
.phsg-loader {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(240, 239, 221, 0.7);
}

/* display:flex דורס את ברירת המחדל של hidden – מחזירים את ההסתרה במפורש. */
.phsg-loader[hidden] {
	display: none;
}

.phsg-loader__spinner {
	width: 46px;
	height: 46px;
	border: 5px solid var(--phsg-kraft);
	border-top-color: var(--phsg-red);
	border-radius: 50%;
	animation: phsg-spin 0.8s linear infinite;
}

@keyframes phsg-spin {
	to { transform: rotate(360deg); }
}

/* ===== רספונסיביות ===== */
@media (max-width: 600px) {
	.phsg-app {
		padding: 14px;
		border-width: 4px;
		min-height: 500px;
	}

	.phsg-card {
		padding: 20px 16px;
	}

	.phsg-arena {
		height: 340px;
	}

	.phsg-slice {
		width: 64px;
		height: 64px;
	}

	.phsg-result__value {
		font-size: 28px;
	}

	.phsg-board__head,
	.phsg-board__row {
		grid-template-columns: 44px 1fr 56px 50px;
		font-size: 14px;
		padding: 7px 6px;
	}
}

@media (max-width: 360px) {
	.phsg-arena {
		height: 300px;
	}
	.phsg-slice {
		width: 56px;
		height: 56px;
	}
}
