.race-root { font-family: Arial, Helvetica, sans-serif; color: #fff; }
/* center game vertically and horizontally */
.html, body { height: 100%; margin: 0; }
/* center the game in the overlay window */
body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.race-root { width: 100%; display: flex; align-items: center; justify-content: center; }
.race-track { position: relative; width: 100%; max-width: 1400px; margin: 0 auto; padding: 40px 24px; background: var(--race-track-bg, transparent); }
.lane { position: relative; height: 90px; margin-bottom: 18px; border-radius: 12px; background: var(--lane-bg, rgba(255,255,255,0.02)); overflow: hidden; }
.car { position: absolute; left: 6px; top: 12px; width: 84px; height: 66px; transition: left 0.25s ease; background: transparent; box-shadow: none; border-radius: 0; }
.car img.car-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.name { position: absolute; right: 8px; top: 8px; font-size: 14px; opacity: 0.9; }
.finish-line { position: absolute; right: 120px; top: 0; bottom: 0; width: 6px; background: linear-gradient(45deg,#fff 25%, transparent 25%, transparent 75%, #fff 75%); background-size: 12px 12px; opacity: 0.14; }

/* meta label to the left of the finish line: vertical stacked boxes with letters */
.finish-meta-ctr { position: absolute; right: 0; top: 0; bottom: 0; width: 120px; pointer-events: none; }
.finish-meta { width: 40px; height: 160px; display: block; }
.finish-checker { position: absolute; right: 24px; top: 0; bottom: 0; width: 120px; z-index: 1; }
/* checkerboard using two 45deg gradients offset to create squares */
.finish-checker {
	background-image:
		linear-gradient(45deg, #000 25%, transparent 25%, transparent 75%, #000 75%, #000),
		linear-gradient(45deg, #000 25%, transparent 25%, transparent 75%, #000 75%, #000);
	background-size: 40px 40px;
	background-position: 0 0, 20px 20px;
}

.finish-meta-box { position: absolute; right: 64px; top: 50%; transform: translateY(-50%); width: 64px; height: 192px; background: #ffffff; border-radius: 6px; display:flex; align-items:center; justify-content:center; z-index:3; box-shadow: 0 8px 22px rgba(0,0,0,0.25); }
.meta-letters { display:flex; flex-direction:column; align-items:center; justify-content:space-around; height:90%; width:100%; }
.meta-letter { font-family: 'Bebas Neue', Arial, Helvetica, sans-serif; font-size:30px; letter-spacing:2px; font-weight:700; color:#000; transform: rotate(90deg); transform-origin:center; }
.finish-line { position: absolute; right: 144px; top: 0; bottom: 0; width: 6px; background: linear-gradient(45deg,#fff 25%, transparent 25%, transparent 75%, #fff 75%); background-size: 12px 12px; opacity: 0.14; z-index:4; }

/* white rectangle behind checker squares */
.finish-checker-bg { position: absolute; right: 24px; top: 0; bottom: 0; width: 120px; background: #ffffff; z-index: 0; opacity: 1; }
.race-timer { position: fixed !important; left: 50% !important; bottom: 24px !important; top: auto !important; transform: translateX(-50%) scale(var(--race-timer-scale,1)) !important; transform-origin: center bottom !important; background: rgba(0,0,0,0.6); padding: 10px 14px; border-radius: 10px; font-weight: 800; font-size: 20px; backdrop-filter: blur(4px); display: none; z-index: 9999; }

/* Pre-start big countdown (3..2..1) */
.pre-countdown { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 10000; pointer-events: none; display:flex; align-items:center; justify-content:center; }
.pre-countdown .num { font-family: 'Bebas Neue', Arial, Helvetica, sans-serif; color: #fff; font-size: 240px; line-height: 1; text-align:center; text-shadow: 0 12px 40px rgba(0,0,0,0.6); opacity: 0; transform: scale(0.6); }
.pre-countdown .num.pop { animation: pop-in 800ms cubic-bezier(.2,.9,.3,1) both; }

@keyframes pop-in {
	0% { opacity: 0; transform: scale(0.5); }
	40% { opacity: 1; transform: scale(1.14); }
	100% { opacity: 1; transform: scale(1); }
}
.race-win { position: fixed; left: 50%; top: 20%; transform: translateX(-50%); z-index: 9999; }
.race-win__card { background: rgba(15,23,42,0.95); padding: 18px; border-radius: 12px; box-shadow: 0 16px 60px rgba(0,0,0,0.6); text-align: center; }
.race-win__card { transform-origin: center; transition: transform 180ms ease, padding 180ms ease; }
.race-win__text { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.race-win__name { font-size: 16px; opacity: 0.9; }
.race-win img { width: 100px; height: 100px; object-fit: contain; margin-top: 8px; }
.race-win__car { width: 120px; height: 90px; margin: 6px auto 8px auto; display:none; }
.race-win__car svg { width: 100%; height: 100%; display:block; }
.race-win__gift { width: 48px; height: 48px; object-fit: contain; display:none; margin: 6px auto 8px auto; }
.race-win--hidden { display: none; }

/* Winner animations */
.win-anim-zoom { --win-anim-duration: 1200ms; animation: rc-zoom var(--win-anim-duration) cubic-bezier(.2,.9,.3,1) 1 both; }
.win-anim-pulse { --win-anim-duration: 1400ms; animation: rc-pulse var(--win-anim-duration) ease-in-out infinite; }
.win-anim-shake { --win-anim-duration: 900ms; animation: rc-shake var(--win-anim-duration) ease-in-out 1; }
.win-anim-glow { --win-anim-duration: 1800ms; animation: rc-glow var(--win-anim-duration) ease-in-out infinite; }

@keyframes rc-zoom {
	0% { transform: scale(0.8); opacity: 0; }
	50% { transform: scale(1.18); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}

@keyframes rc-pulse {
	0% { box-shadow: 0 6px 18px rgba(0,0,0,0.45); transform: translateY(0); }
	50% { box-shadow: 0 22px 48px rgba(0,0,0,0.6); transform: translateY(-6px); }
	100% { box-shadow: 0 6px 18px rgba(0,0,0,0.45); transform: translateY(0); }
}

@keyframes rc-shake {
	0% { transform: translateX(0); }
	20% { transform: translateX(-8px); }
	40% { transform: translateX(6px); }
	60% { transform: translateX(-4px); }
	80% { transform: translateX(2px); }
	100% { transform: translateX(0); }
}

@keyframes rc-glow {
	0% { box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 0 rgba(255,255,255,0); }
	40% { box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 24px rgba(255,255,255,0.06); }
	100% { box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 0 rgba(255,255,255,0); }
}

/* controls box */
#race-controls { position: fixed; right: 12px; top: 12px; background: rgba(0,0,0,0.5); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 13px; z-index: 9999; }
#race-controls label { display: block; margin-bottom: 6px; }
#race-controls input[type="range"] { width: 160px; }
#race-controls input[type="color"] { vertical-align: middle; margin-left: 6px; }

/* gift legend at top center */
.gift-legend { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9998; pointer-events: none; }
.gift-legend-list { display: flex; gap: 12px; align-items: center; }
.gift-legend-item { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.35); padding: 6px 8px; border-radius: 8px; backdrop-filter: blur(4px); }
.gift-legend-img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.gift-legend-swatch { width: 20px; height: 20px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.12); }
.gift-legend-name { color: #fff; font-size: 13px; opacity: 0.95; }
