/* ========================= */
/* RESET */
/* ========================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    font-family: Arial, sans-serif;
    background: radial-gradient(circle at top, #111, #050505);
    overflow: hidden;
    color: #ffffff;
}

/* ========================= */
/* GAME CONTAINER */
/* ========================= */

.game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    isolation: isolate;
}

/* ========================= */
/* BACK BUTTON */
/* ========================= */

.back-btn {
    position: absolute;
    top: clamp(10px, 2vh, 20px);
    left: clamp(10px, 2vw, 20px);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #ffffff;
    padding: clamp(8px, 1.5vw, 12px) clamp(12px, 2vw, 18px);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: clamp(0.75rem, 2vw, 0.95rem);
    transition: 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* ========================= */
/* GAME AREA */
/* ========================= */

.game-area {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ========================= */
/* ROAD */
/* ========================= */

.road {
    position: relative;
    width: clamp(280px, 42vw, 420px);
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(to right,
        #111 0%,
        #1c1c1c 10%,
        #303030 50%,
        #1c1c1c 90%,
        #111 100%);
    border-left: 4px solid #666;
    border-right: 4px solid #666;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
}

/* ========================= */
/* ROAD GLOW */
/* ========================= */

.road::before,
.road::after {
    content: "";
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    background: #00c3ff;
    opacity: 0.3;
    filter: blur(10px);
}

.road::before { left: -3px; }
.road::after  { right: -3px; }

/* ========================= */
/* ROAD LINES */
/* ========================= */

.road-lines {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 200%;
    opacity: 0.9;
    background: repeating-linear-gradient(to bottom,
        #ffffff 0px,
        #ffffff 80px,
        transparent 80px,
        transparent 160px);
}

/* ========================= */
/* PLAYER CAR */
/* ========================= */

.player-car {
    position: absolute;
    width: clamp(70px, 18vw, 110px);
    height: clamp(120px, 30vw, 190px);
    bottom: clamp(80px, 12vh, 120px);
    left: 50%;
    transform: translateX(-50%);
    transition: left 0.08s linear;
    z-index: 10;
}

.player-car img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    filter: drop-shadow(0 0 12px rgba(0, 195, 255, 0.45));
    animation: engineBounce 0.12s infinite linear;
}

/* ========================= */
/* ENEMY CAR */
/* ========================= */

.enemy-car {
    position: absolute;
    width: clamp(70px, 18vw, 110px);
    height: clamp(120px, 30vw, 190px);
    top: -220px;
    left: 50%;
    transform: none;
    z-index: 8;
}

.enemy-car-2 {
    top: -500px;
    left: 25%;
    transform: none;
}

.enemy-police {
    top: -300px;
    left: 20%;
    z-index: 9;
    width: clamp(65px, 16vw, 100px);
    height: clamp(110px, 28vw, 175px);
}

.enemy-car img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    filter: drop-shadow(0 0 12px rgba(255, 0, 0, 0.35));
}

.enemy-police img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    filter: drop-shadow(0 0 18px rgba(0, 150, 255, 0.8));
}

/* ========================= */
/* TOP UI */
/* ========================= */

.top-ui {
    position: absolute;
    top: clamp(10px, 2vh, 20px);
    left: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 clamp(10px, 3vw, 30px);
    z-index: 20;
}

/* ========================= */
/* LOGO */
/* ========================= */

.logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1rem, 3vw, 1.8rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: clamp(2px, 1vw, 5px);
    color: #ffffff;
    text-shadow: 0 0 12px rgba(0, 195, 255, 0.8);
    white-space: nowrap;
}

/* ========================= */
/* GAME HUD */
/* ========================= */

.game-hud {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1.5vw, 12px);
}

/* ========================= */
/* HUD ITEM */
/* ========================= */
.game-hud {
    display: flex;
    gap: 25px;
    background: rgba(0,0,0,0.4);
    padding: 10px 20px;
    border-radius: 12px;
    backdrop-filter: blur(8px);
}

.hud-item {
    text-align: center;
}

.hud-label {
    font-size: 12px;
    color: #aaa;
    display: block;
}

.hud-value {
    font-size: 22px;
    font-weight: bold;
    color: white;
}

/* 🔥 KM SPECIAL STYLE */
.km-display {
    color: #00ffcc;
    text-shadow:
        0 0 8px #00ffcc,
        0 0 15px rgba(0,255,200,0.6);
}

/* 🔥 SPEED COLOR */
.speed-value {
    color: #ffcc00;
}

/* ========================= */
/* LOADING SCREEN            */
/* ========================= */

.loading-screen {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top, #111, #050505);
    z-index: 100;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    padding: 40px;
}

.loading-card h2 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: #ffffff;
    text-shadow:
        0 0 25px #00c3ff,
        0 0 60px rgba(0, 195, 255, 0.4);
    letter-spacing: 4px;
    text-transform: uppercase;
}

.loading-card p {
    font-size: 1rem;
    color: #aaaaaa;
    letter-spacing: 2px;
}

.loading-bar {
    width: clamp(200px, 50vw, 300px);
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00c3ff, #0077ff);
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 195, 255, 0.6);
}

.loading-percent {
    font-size: 0.9rem;
    color: #00c3ff;
    font-weight: 700;
}

/* ========================= */
/* START SCREEN */
/* ========================= */

.start-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 3vh, 20px);
    z-index: 30;
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.92));
    padding: 20px;
    text-align: center;
}

.start-screen h1 {
    font-size: clamp(2.2rem, 8vw, 6rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: clamp(2px, 1vw, 5px);
    color: #ffffff;
    text-shadow:
        0 0 25px #00c3ff,
        0 0 60px rgba(0, 195, 255, 0.5);
}

.start-screen p {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    opacity: 0.8;
    letter-spacing: 1px;
}

/* ========================= */
/* PLAY BUTTON */
/* ========================= */

.play-btn {
    border: none;
    cursor: pointer;
    padding: clamp(14px, 3vw, 18px) clamp(30px, 6vw, 45px);
    border-radius: 60px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #ff6a00, #ff0000);
    transition: 0.3s ease;
    box-shadow: 0 0 25px rgba(255, 80, 0, 0.5);
    /* ✅ bigger tap target on mobile */
    min-width: clamp(160px, 40vw, 200px);
    min-height: 54px;
    touch-action: manipulation;
}

.play-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 40px rgba(255, 80, 0, 0.8);
}

/* ========================= */
/* CONTINUE SCREEN */
/* ========================= */

.continue-screen {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    z-index: 45;
    opacity: 0;
    visibility: hidden;
    transition: 0.35s ease;
    padding: 20px;
}

.show-continue {
    opacity: 1;
    visibility: visible;
}

/* ========================= */
/* CARD */
/* ========================= */

.continue-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(12px, 3vh, 20px);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: clamp(24px, 5vw, 40px) clamp(28px, 6vw, 50px);
    text-align: center;
    width: min(380px, 90vw);
}

.continue-card h2 {
    font-size: clamp(1.8rem, 6vw, 3rem);
    font-weight: 900;
    color: #ff3c3c;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

.continue-sub {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    opacity: 0.7;
    letter-spacing: 1px;
}

/* ========================= */
/* HEARTS */
/* ========================= */

.hearts-display {
    font-size: clamp(2rem, 8vw, 3.5rem);
    letter-spacing: 6px;
    filter: drop-shadow(0 0 8px rgba(255, 80, 80, 0.6));
}

/* ========================= */
/* CONTINUE BUTTON */
/* ========================= */

.continue-btn {
    border: none;
    cursor: pointer;
    padding: clamp(12px, 2.5vw, 16px) clamp(28px, 6vw, 40px);
    border-radius: 50px;
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #00c3ff, #0077ff);
    box-shadow: 0 0 25px rgba(0, 195, 255, 0.5);
    transition: 0.3s ease;
    min-width: clamp(140px, 35vw, 180px);
    min-height: 50px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.continue-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(0, 195, 255, 0.8);
}

/* ========================= */
/* NO CHANCES + FINAL SCORE */
/* ========================= */

.no-chances-text {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: #ff6666;
    font-weight: 600;
    letter-spacing: 1px;
}

.final-score-text {
    font-size: clamp(1rem, 3vw, 1.3rem);
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(0, 195, 255, 0.5);
}

/* ========================= */
/* GAME OVER SCREEN */
/* ========================= */

.game-over-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 3vh, 20px);
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: 0.4s ease;
    padding: 20px;
    text-align: center;
}

.show-game-over {
    opacity: 1;
    visibility: visible;
}

.game-over-screen h2 {
    font-size: clamp(2rem, 7vw, 5rem);
    font-weight: 900;
    letter-spacing: 4px;
    color: #ff3c3c;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.7);
}

.restart-btn {
    border: none;
    padding: clamp(12px, 2.5vw, 16px) clamp(28px, 5vw, 36px);
    border-radius: 50px;
    cursor: pointer;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #ff0000, #ff6600);
    box-shadow: 0 0 25px rgba(255, 60, 0, 0.5);
    transition: 0.3s ease;
    min-width: clamp(140px, 35vw, 180px);
    min-height: 50px;
    touch-action: manipulation;
}

.restart-btn:hover {
    transform: scale(1.05);
}

/* ========================= */
/* MOBILE CONTROLS */
/* ========================= */

.mobile-controls {
    position: fixed;
    bottom: clamp(15px, 3vh, 20px);
    width: 100%;
    display: none;
    justify-content: space-between;
    padding: 0 clamp(15px, 4vw, 20px);
    pointer-events: none;
    z-index: 999;
}

.mobile-btn {
    width: clamp(90px, 22vw, 120px);
    height: clamp(90px, 22vw, 120px);
    border-radius: 50%;
    border: none;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: bold;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    backdrop-filter: blur(10px);
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    /* ✅ proper tap highlight removal on iOS */
    -webkit-tap-highlight-color: transparent;
}

.mobile-btn:active {
    transform: scale(0.92);
}

.brake-btn {
    background: rgba(255, 0, 0, 0.22);
    border: 2px solid rgba(255, 80, 80, 0.45);
}

.accel-btn {
    background: rgba(0, 195, 255, 0.22);
    border: 2px solid rgba(0, 195, 255, 0.45);
}

.finish-text {
    position: absolute;
    top: 40%;
    width: 100%;
    text-align: center;
    font-size: 40px;
    color: yellow;
    font-weight: bold;
    text-shadow: 2px 2px 10px black;
    z-index: 25;
}

.finish-line {
    position: absolute;
    width: 100%;
    height: 50px;
    background: repeating-linear-gradient(
        45deg,
        white 0px,
        white 10px,
        black 10px,
        black 20px
    );
    top: -200px; /* start off screen */
    z-index: 5;
}

/* ========================= */
/* LEVEL MESSAGE             */
/* ========================= */

.level-message {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 35;
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: 900;
    color: #ffffff;
    text-shadow:
        0 0 20px #00c3ff,
        0 0 40px rgba(0, 195, 255, 0.5);
    letter-spacing: 2px;
    text-align: center;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.show-level-message {
    opacity: 1;
}

/* ========================= */
/* SHOW MOBILE CONTROLS */
/* ========================= */

@media (max-width: 900px) {
    .mobile-controls {
        display: flex;
    }
}

/* ========================= */
/* SMALL PHONES (≤380px) */
/* ========================= */

@media (max-width: 380px) {

    .road {
        width: 100%;
        border-left: none;
        border-right: none;
    }

    .logo {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }

    .hud-item {
        min-width: 52px;
        padding: 5px 8px;
    }

    .hud-value {
        font-size: 0.95rem;
    }

    .hud-label {
        font-size: 0.5rem;
    }
}

/* ========================= */
/* LANDSCAPE PHONES */
/* ========================= */

@media (max-height: 500px) and (orientation: landscape) {

    .road {
        width: clamp(200px, 35vw, 300px);
    }

    .top-ui {
        top: 6px;
    }

    .hud-item {
        padding: 4px 8px;
        min-width: 55px;
    }

    .hud-value {
        font-size: 1rem;
    }

    .mobile-controls {
        bottom: 6px;
    }

    .mobile-btn {
        width: 70px;
        height: 70px;
        font-size: 0.75rem;
    }

    .start-screen h1 {
        font-size: 1.8rem;
    }
}

