/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #0a0a0f;
    font-family: 'Rajdhani', sans-serif;
    color: #fff;
    height: 100vh;
    width: 100vw;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    z-index: 1;
}
.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== START SCREEN ===== */
.start-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 30%, #0a1a2e 60%, #0a0a1a 100%);
    z-index: 0;
}
.start-bg::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(0, 200, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 0, 100, 0.08) 0%, transparent 50%);
}

.start-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem;
}

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 5rem;
    margin-bottom: 0.2rem;
    line-height: 1.1;
}
.title-ai {
    display: block;
    font-size: 2.5rem;
    color: #00d4ff;
    text-shadow: 0 0 30px rgba(0, 212, 255, 0.6), 0 0 60px rgba(0, 212, 255, 0.3);
    letter-spacing: 1.2rem;
}
.title-racer {
    display: block;
    background: linear-gradient(90deg, #ff006e, #ff6b00, #ffbe00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(255, 0, 110, 0.4));
}

.tagline {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5rem;
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

/* Menu Options */
.menu-options {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    max-width: 500px;
    margin: 0 auto 2rem;
}
.menu-options label {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.3rem;
    margin-bottom: 0.5rem;
}

.diff-buttons, .track-buttons, .car-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.diff-btn, .track-btn, .car-btn {
    padding: 0.5rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.1rem;
}
.diff-btn:hover, .track-btn:hover, .car-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.diff-btn.active {
    background: rgba(0, 212, 255, 0.15);
    border-color: #00d4ff;
    color: #00d4ff;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}
.track-btn.active {
    background: rgba(255, 0, 110, 0.15);
    border-color: #ff006e;
    color: #ff006e;
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.2);
}
.car-btn.active {
    background: rgba(255, 190, 0, 0.15);
    border-color: #ffbe00;
    color: #ffbe00;
    box-shadow: 0 0 15px rgba(255, 190, 0, 0.2);
}

/* Start Button */
.glow-btn {
    position: relative;
    padding: 1rem 3rem;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #ff006e, #ff6b00);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    letter-spacing: 0.2rem;
    transition: all 0.3s;
    overflow: hidden;
}
.glow-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 0, 110, 0.5), 0 0 60px rgba(255, 107, 0, 0.3);
}
.glow-btn .btn-glow {
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
    animation: btnGlow 3s ease-in-out infinite;
}
@keyframes btnGlow {
    0%, 100% { transform: translate(-30%, -30%); }
    50% { transform: translate(30%, 30%); }
}

.controls-hint {
    margin-top: 1.5rem;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
}

/* ===== GAME SCREEN ===== */
#game-screen {
    background: #000;
}
#game-screen.active {
    display: block;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD */
#hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    z-index: 10;
    pointer-events: none;
}

.hud-left, .hud-right {
    display: flex;
    gap: 1.5rem;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.15rem;
}

.hud-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.speedometer {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.speed-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 0, 110, 0.6);
    line-height: 1;
}
.speed-unit {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.2rem;
}

.boost-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}
.boost-bar {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.boost-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    border-radius: 4px;
    transition: width 0.1s;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

/* Countdown */
#countdown {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}
#countdown-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 50px rgba(255, 0, 110, 0.8), 0 0 100px rgba(0, 212, 255, 0.5);
    animation: countPulse 0.8s ease-out;
}
@keyframes countPulse {
    0% { transform: scale(2); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Lap Notification */
#lap-notification {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
}
#lap-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffbe00;
    text-shadow: 0 0 30px rgba(255, 190, 0, 0.6);
    animation: lapSlide 1.5s ease-out forwards;
}
@keyframes lapSlide {
    0% { opacity: 0; transform: translateY(20px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* Pause */
#pause-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 25;
    gap: 1rem;
}
#pause-overlay h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    color: #00d4ff;
    text-shadow: 0 0 30px rgba(0, 212, 255, 0.5);
}
#pause-overlay p {
    color: rgba(255, 255, 255, 0.5);
}

.menu-btn {
    padding: 0.7rem 2rem;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    cursor: pointer;
    letter-spacing: 0.15rem;
    transition: all 0.2s;
}
.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.hidden {
    display: none !important;
}

/* ===== RESULTS SCREEN ===== */
#results-screen {
    background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 50%, #0a0a1a 100%);
}

.results-content {
    text-align: center;
    padding: 2rem;
}
.results-content h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    margin-bottom: 2rem;
    background: linear-gradient(90deg, #ffbe00, #ff006e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(255, 190, 0, 0.4));
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 500px;
    margin: 0 auto 2.5rem;
}

.result-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.2rem;
}
.result-label {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.2rem;
    margin-bottom: 0.5rem;
}
.result-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #00d4ff;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}
.result-value.big {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #ffbe00, #ff006e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ===== MINI MAP ===== */
#minimap {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    z-index: 10;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
}

/* ===== RULES MODAL ===== */
.action-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    margin-top: 0.5rem;
}

.rules-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.rules-content {
    position: relative;
    max-width: 700px;
    width: 100%;
    background: linear-gradient(135deg, #0f0f25 0%, #1a0f35 50%, #0f1a35 100%);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-shadow:
        0 0 60px rgba(0, 212, 255, 0.15),
        0 0 120px rgba(255, 0, 110, 0.1),
        inset 0 0 40px rgba(255, 255, 255, 0.03);
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.rules-content::-webkit-scrollbar {
    width: 8px;
}
.rules-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.rules-content::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.3);
    border-radius: 4px;
}

.rules-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rules-close:hover {
    background: rgba(255, 0, 110, 0.25);
    border-color: #ff006e;
    transform: rotate(90deg);
}

.rules-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    background: linear-gradient(90deg, #00d4ff, #ff006e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
    letter-spacing: 0.1rem;
}

.rules-subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    color: #ffbe00;
    letter-spacing: 0.25rem;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
}

.rules-intro {
    background: rgba(255, 190, 0, 0.08);
    border-left: 3px solid #ffbe00;
    padding: 1rem 1.2rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    line-height: 1.5;
}

.rules-section {
    margin-bottom: 1.3rem;
    padding: 1rem 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    transition: all 0.2s;
}
.rules-section:hover {
    background: rgba(0, 212, 255, 0.05);
    border-color: rgba(0, 212, 255, 0.2);
}

.rules-section h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    color: #00d4ff;
    margin-bottom: 0.7rem;
    letter-spacing: 0.1rem;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
}

.rules-section ul {
    list-style: none;
    padding: 0;
}

.rules-section li {
    position: relative;
    padding: 0.35rem 0 0.35rem 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.92rem;
    line-height: 1.5;
}
.rules-section li::before {
    content: '▸';
    position: absolute;
    left: 0.3rem;
    color: #ff006e;
    font-weight: bold;
}
.rules-section li strong {
    color: #ffbe00;
    font-weight: 700;
}

#rules-close-bottom {
    display: block;
    margin: 1.5rem auto 0;
    padding: 0.8rem 2.5rem;
    font-size: 1rem;
}

/* In-game rules button */
.ingame-rules-btn {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 212, 255, 0.4);
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 15;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ingame-rules-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    transform: scale(1.1);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .game-title { font-size: 3rem; }
    .title-ai { font-size: 1.5rem; letter-spacing: 0.8rem; }
    .tagline { font-size: 0.9rem; letter-spacing: 0.3rem; }
    .diff-buttons, .track-buttons, .car-buttons { flex-wrap: wrap; }
    .hud-left, .hud-right { gap: 0.8rem; }
    .hud-value { font-size: 1rem; }
    .speed-value { font-size: 1.8rem; }
    .results-grid { grid-template-columns: 1fr; }
    .action-row { flex-direction: column; gap: 0.6rem; }
    .rules-content { padding: 1.5rem 1.2rem; }
    .rules-title { font-size: 1.4rem; }
    .rules-section li { font-size: 0.85rem; }
}
