:root {
	--amber: #ffc93c;
	--amber-deep: #f0a500;
	--ink: #eef3ea;
	--glass: linear-gradient(180deg, rgba(22, 28, 21, .82), rgba(8, 11, 8, .88));
	--glass-border: rgba(255, 255, 255, .16);
	--glass-shadow: 0 12px 30px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .1);
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background-color: #2f6b1f; /* запасной фон, пока грузится трава */
	color: var(--ink);
	font-family: "Rajdhani", "Segoe UI", system-ui, sans-serif;
	overscroll-behavior: none;
	touch-action: none; /* свайпы управляют машиной, а не скроллом страницы */
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

/* ---------- трава по краям ---------- */
.grass {
	position: fixed;
	inset: 0;
	z-index: 0;
	overflow: hidden;
}
.grass__tex {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	display: block;
	background-image: url("green-grass-tile.jpg");
	background-repeat: repeat;
	will-change: transform;
}

/* ---------- трасса ---------- */
.fon {
	position: fixed;
	inset: 0;
	z-index: 1;
}
.road {
	position: absolute;
	inset: 0;
	display: flex;
	justify-content: center;
	box-shadow: 0 0 26px 4px rgba(0, 0, 0, .45);
}
.colon {
	position: relative;
	flex: 0 0 30%;
	height: 100%;
	overflow: hidden;
}
.colon__tex {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	display: block;
	background-image: url("trassa.jpg");
	background-repeat: repeat;
	will-change: transform;
}

/* ---------- спрайты ---------- */
.car,
.stone {
	position: absolute;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
}
.car {
	background-image: url("car2.png");
	transform-origin: 50% 80%;
	filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5));
	transition: left .13s cubic-bezier(.2, .7, .3, 1), transform .13s ease-out;
	z-index: 2;
}
/* WebP — основной вариант, PNG остаётся запасным для старых браузеров:
   если image-set() не поддерживается, применяется предыдущее объявление */
.stone {
	background-image: url("stone.png");
	background-image: image-set(url("stone.webp") type("image/webp"), url("stone.png") type("image/png"));
	filter: drop-shadow(0 5px 7px rgba(0, 0, 0, .45));
	will-change: transform;
	z-index: 2;
}
.car.is-boom {
	background-image: url("explode.png");
	background-image: image-set(url("explode.webp") type("image/webp"), url("explode.png") type("image/png"));
}
/* в бесконечном режиме машина проезжает поверх камня, а не под ним */
body.is-endless .car {
	z-index: 3;
}

/* ---------- панель прогресса ---------- */
.rasst {
	position: fixed;
	top: calc(env(safe-area-inset-top, 0px) + 14px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 5;
	display: flex;
	align-items: baseline;
	gap: 10px;
	padding: 9px 20px 9px 20px;
	border: 1px solid var(--glass-border);
	border-radius: 14px;
	background: var(--glass);
	box-shadow: var(--glass-shadow);
	-webkit-backdrop-filter: blur(10px) saturate(130%);
	backdrop-filter: blur(10px) saturate(130%);
	white-space: nowrap;
}
/* раллийный «шашечный» акцент слева */
.rasst::before {
	content: "";
	position: absolute;
	left: 0;
	top: 9px;
	bottom: 9px;
	width: 5px;
	border-radius: 6px 0 0 6px;
	background: repeating-linear-gradient(180deg, var(--amber) 0 6px, #1b1f18 6px 12px);
}
.n1 {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .17em;
	text-transform: uppercase;
	color: rgba(238, 243, 234, .6);
}
.n2 {
	min-width: 3.5ch;   /* стартовое значение; дальше точный резерв ставит script.js */
	font-family: "Orbitron", "Segoe UI", ui-monospace, monospace;
	font-size: 28px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	text-align: right;
	color: var(--amber);
	text-shadow: 0 0 16px rgba(255, 201, 60, .35);
}
.n3 {
	font-size: 14px;
	font-weight: 600;
	color: rgba(238, 243, 234, .65);
}

/* ---------- кнопка «Пауза» ---------- */
.pause-btn {
	position: fixed;
	top: calc(env(safe-area-inset-top, 0px) + 14px);
	right: calc(env(safe-area-inset-right, 0px) + 14px);
	z-index: 6;
	display: grid;
	place-items: center;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 1px solid var(--glass-border);
	border-radius: 14px;
	background: var(--glass);
	box-shadow: var(--glass-shadow);
	-webkit-backdrop-filter: blur(10px) saturate(130%);
	backdrop-filter: blur(10px) saturate(130%);
	color: var(--amber);
	cursor: pointer;
	touch-action: manipulation;
	transition: transform .12s ease, border-color .12s ease;
}
.pause-btn:hover {
	border-color: rgba(255, 201, 60, .5);
}
.pause-btn:active {
	transform: scale(.93);
}
.pause-btn:focus-visible {
	outline: 2px solid var(--amber);
	outline-offset: 3px;
}
.pause-btn__icon {
	width: 21px;
	height: 21px;
	fill: currentColor;
}
.pause-btn__icon--play {
	display: none;
}
body.is-paused .pause-btn__icon--pause {
	display: none;
}
body.is-paused .pause-btn__icon--play {
	display: block;
}
body.is-over .pause-btn {
	display: none;
}

/* ---------- оверлей паузы / финала ---------- */
.overlay {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: grid;
	place-items: center;
	padding: 20px;
	background: rgba(6, 10, 6, .6);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}
.overlay[hidden] {
	display: none;
}
.overlay__card {
	width: min(86vw, 360px);
	padding: 24px 24px 20px;
	text-align: center;
	border: 1px solid var(--glass-border);
	border-radius: 20px;
	background: var(--glass);
	box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .1);
}
.overlay__flag {
	height: 12px;
	margin-bottom: 18px;
	border-radius: 4px;
	background: repeating-conic-gradient(#e9ede6 0 25%, #14170f 0 50%) 0 0 / 12px 12px;
}
.overlay__title {
	margin: 0 0 8px;
	font-family: "Orbitron", "Segoe UI", sans-serif;
	font-size: 24px;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
}
.overlay__text {
	margin: 0 0 20px;
	font-size: 15px;
	font-weight: 500;
	color: rgba(238, 243, 234, .68);
}
.overlay__actions {
	display: flex;
	gap: 10px;
	justify-content: center;
}
.btn {
	flex: 1 1 auto;
	padding: 11px 16px;
	border: 1px solid var(--glass-border);
	border-radius: 12px;
	background: rgba(255, 255, 255, .06);
	color: var(--ink);
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .04em;
	cursor: pointer;
	touch-action: manipulation;
	transition: transform .12s ease, background-color .12s ease;
}
.btn:hover {
	background: rgba(255, 255, 255, .12);
}
.btn:active {
	transform: scale(.97);
}
.btn:focus-visible {
	outline: 2px solid var(--amber);
	outline-offset: 3px;
}
.btn--primary {
	border-color: rgba(0, 0, 0, .25);
	background: linear-gradient(180deg, #ffd45e, var(--amber-deep));
	color: #1c1505;
}
.btn--primary:hover {
	background: linear-gradient(180deg, #ffdd7d, #ffb412);
}
.btn[hidden] {
	display: none;
}

/* ---------- телефоны ---------- */
@media (max-width: 560px) {
	.rasst {
		gap: 8px;
		padding: 7px 15px;
		border-radius: 12px;
	}
	.n1 {
		font-size: 10px;
		letter-spacing: .14em;
	}
	.n2 {
		font-size: 22px;
	}
	.n3 {
		font-size: 12px;
	}
	.pause-btn {
		width: 42px;
		height: 42px;
		border-radius: 12px;
	}
	.pause-btn__icon {
		width: 19px;
		height: 19px;
	}
}
