body { margin: 0; overflow: hidden; }
#score {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    font-family: 'Vazir', Arial, sans-serif;
    font-size: 24px;
    background: linear-gradient(to bottom, rgba(50, 50, 50, 0.8), rgba(20, 20, 20, 0.9));
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.2);
}
#speedometer {
    position: fixed;
    bottom: 20px;
    left: 20px;
    color: white;
    font-family: 'Vazir', Arial, sans-serif;
    font-size: 24px;
    background: linear-gradient(to bottom, rgba(50, 50, 50, 0.8), rgba(20, 20, 20, 0.9));
    padding: 10px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.2);
}
#instructions {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-family: 'Vazir', Arial, sans-serif;
    background: linear-gradient(to bottom, rgba(50, 50, 50, 0.8), rgba(20, 20, 20, 0.9));
    padding: 10px;
    border-radius: 5px;
    direction: rtl;
    border: 1px solid rgba(255,255,255,0.2);
}
#gameOver {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-family: 'Vazir', Arial, sans-serif;
    font-size: 42px;
    text-align: center;
    background: radial-gradient(circle at top, rgba(220, 80, 80, 0.95), rgba(20, 0, 0, 0.98));
    padding: 32px 32px 26px;
    border-radius: 16px;
    direction: rtl;
    border: 2px solid #ff7777;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.6);
}
#retryButton {
    margin-top: 18px;
    padding: 14px 32px;
    font-size: 22px;
    font-family: 'Vazir', Arial, sans-serif;
    color: #111;
    background: conic-gradient(from 180deg, #ffeb3b, #ffc107, #ff9800, #ffc107, #ffeb3b);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
    box-shadow: 0 6px 14px rgba(0,0,0,0.35);
}
#retryButton::before {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: inherit;
    background: linear-gradient(135deg, #fffde7, #ffe082);
    transition: clip-path 0.4s ease;
    clip-path: inset(0 100% 0 0);
    z-index: 0;
}
#retryButton::after {
    content: "↻";
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    opacity: 0.9;
}
#retryButton span {
    position: relative;
    z-index: 1;
}
#retryButton:hover {
    filter: brightness(1.05);
}
#retryButton:hover::before {
    clip-path: inset(0 0 0 0);
}
#retryButton:focus-visible {
    outline: 2px solid #fff59d;
    outline-offset: 3px;
}
#retryButton.pressed {
    transform: translateY(3px) scale(0.97);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    border: 1px solid #555;
}
#loadingText {
    color: white;
    font-family: 'Vazir', Arial, sans-serif;
    font-size: 24px;
    margin-bottom: 20px;
}
#loadingBar {
    width: 200px;
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #555;
}
#loadingProgress {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #4CAF50, #81C784);
    transition: width 0.3s ease;
}
#startButton {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    font-size: 24px;
    background: linear-gradient(to bottom, #67c26a, #4CAF50);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: none;
    z-index: 900;
    font-family: 'Vazir', Arial, sans-serif;
    border-bottom: 4px solid #388E3C;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}
#startButton:hover {
    background: linear-gradient(to bottom, #79d47d, #5cb85c);
}

/* Settings / calibration */
#settingsButton {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: radial-gradient(circle at 30% 30%, #ffffff, #b0bec5);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 950;
}
#settingsButton::before,
#settingsButton::after {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    border: 2px solid rgba(55,71,79,0.9);
}
#settingsButton::after {
    inset: 6px;
    border-style: solid;
    border-width: 0 2px 0 2px;
    border-radius: 0;
}
#settingsPanel {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    width: min(360px, 92vw);
    background: rgba(15, 15, 20, 0.96);
    border-radius: 16px;
    padding: 12px 16px 14px;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 24px rgba(0,0,0,0.7);
    font-family: 'Vazir', Arial, sans-serif;
    color: white;
    z-index: 960;
    transition: transform 0.25s ease-out;
}
#settingsPanel.open {
    transform: translateX(-50%) translateY(0%);
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 6px 0;
}
.settings-row label {
    font-size: 14px;
}
.settings-row input[type="range"] {
    flex: 1;
}
#closeSettings {
    margin-top: 8px;
    width: 100%;
    padding: 6px 0;
    border-radius: 10px;
    border: none;
    background: linear-gradient(180deg, #455a64, #263238);
    color: white;
    font-family: 'Vazir', Arial, sans-serif;
    cursor: pointer;
}

/* Screen fade */
#screenFade {
    position: fixed;
    inset: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 2000;
}
#screenFade.fade-out {
    opacity: 1;
}
.mobile-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 20px;
    z-index: 1000;
}

.control-button {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.control-button:active {
    background: rgba(255, 255, 255, 0.5);
}

.arrow {
    width: 0;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
}

.arrow-left {
    border-right: 25px solid white;
}

.arrow-right {
    border-left: 25px solid white;
}

/* Gas and Brake pedal UI */
#pedals {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 1000;
}
#pedals button {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: none;
    font-size: 24px;
    color: white;
    background: linear-gradient(180deg, #4CAF50, #2E7D32);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
#pedals button:active { transform: translateY(2px); }
#brakeButton {
    background: linear-gradient(180deg, #E53935, #C62828);
}

