/* Base Styles - Fully updated for realism overlay */
:root {
    --color-bg: #050508;
    --color-primary: #ffaa00; 
    --color-primary-glow: rgba(255, 170, 0, 0.4);
    --color-secondary: #00e5ff; 
    --color-secondary-glow: rgba(0, 229, 255, 0.4);
    --color-danger: #ea0038; 
    --color-danger-glow: rgba(234, 0, 56, 0.5);
    --color-text: #ffffff;
    --color-text-dim: #9aa0a6;
    --color-panel: rgba(10, 15, 25, 0.85);

    --font-heading: 'Teko', sans-serif;
    --font-body: 'Orbitron', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body, html { width: 100%; height: 100%; background-color: var(--color-bg); color: var(--color-text); font-family: var(--font-body); overflow: hidden; touch-action: none; }

#bg-effects { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; background: radial-gradient(circle at center, #101018 0%, #050508 100%); }
.neon-line { position: absolute; width: 150%; height: 1px; background: linear-gradient(90deg, transparent, var(--color-primary), transparent); top: 30%; left: -25%; transform: rotate(-15deg); opacity: 0.2; animation: panLine 10s linear infinite; }
.neon-line:nth-child(2) { top: 70%; background: linear-gradient(90deg, transparent, var(--color-secondary), transparent); transform: rotate(15deg); animation-duration: 15s; animation-delay: -5s; }
@keyframes panLine { 0% { transform: translateY(-50px) rotate(-15deg); opacity: 0.1; } 50% { transform: translateY(50px) rotate(-15deg); opacity: 0.4; } 100% { transform: translateY(-50px) rotate(-15deg); opacity: 0.1; } }

#game-container { position: relative; width: 100%; height: 100%; max-width: 100%; margin: 0 auto; overflow: hidden; z-index: 1; }
#gameCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; display: block; }

.screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; display: flex; transition: opacity 0.3s ease; }
.screen.hidden { opacity: 0; pointer-events: none; z-index: -1; }
.full-screen { align-items: center; justify-content: center; flex-direction: column; }
.overlay-screen { background: rgba(5, 5, 8, 0.75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

#loading-screen { background-color: var(--color-bg); z-index: 999; }
.loader-logo { width: 150px; height: 150px; border-radius: 20px; margin-bottom: 20px; filter: drop-shadow(0 0 20px var(--color-primary-glow)); animation: pulseLogo 2s infinite alternate; }
@keyframes pulseLogo { 0% { transform: scale(1); } 100% { transform: scale(1.05); } }
.glitch-text { font-family: var(--font-heading); font-size: 5rem; font-weight: 700; line-height: 1; text-transform: uppercase; position: relative; text-shadow: 0 0 10px var(--color-primary-glow); }
.sub-title { font-family: var(--font-heading); font-size: 3rem; color: var(--color-primary); letter-spacing: 5px; margin-bottom: 40px; text-shadow: 0 0 15px var(--color-primary-glow); }
.progress-bar-container { width: 300px; height: 4px; background: rgba(255,255,255,0.1); margin: 0 auto 15px; position: relative; overflow: hidden; border-radius: 2px; }
#loading-bar { position: absolute; left: 0; top: 0; height: 100%; background: var(--color-primary); width: 0%; box-shadow: 0 0 10px var(--color-primary); transition: width 0.1s linear; }
#loading-text { font-size: 0.8rem; letter-spacing: 2px; color: var(--color-text-dim); animation: blink 1s infinite alternate; }
@keyframes blink { 0% { opacity: 0.5; } 100% { opacity: 1; } }

#main-menu { background: linear-gradient(135deg, rgba(0,0,0,0.8) 0%, rgba(10,5,0,0.9) 100%), url('../assets/images/thumbnail.png') center/cover no-repeat; flex-direction: row; padding: 50px; }
.menu-left { flex: 1; display: flex; flex-direction: column; justify-content: center; position: relative; z-index: 2; align-items: center;}
.title { font-family: var(--font-heading); font-size: 8rem; line-height: 0.8; margin-bottom: 50px; transform: skewX(-5deg); text-align: center;}
.highlight { color: var(--color-primary); text-shadow: 0 0 20px var(--color-primary-glow); }
.menu-buttons { display: flex; flex-direction: column; gap: 15px; width: max-content; }

/* NEW: Car Selection Styles */
#car-select-screen { background: rgba(10,12,15,0.95); padding: 100px 40px 40px; flex-direction: column; align-items: center;}
.car-carousel { display: flex; gap: 20px; max-width: 100%; overflow-x: auto; padding: 20px; scroll-snap-type: x mandatory; }
.car-card { min-width: 250px; height: 350px; background: rgba(20,25,35,0.8); border: 2px solid rgba(255,255,255,0.1); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; scroll-snap-align: center; transition: all 0.3s; position: relative; overflow: hidden;}
.car-card.selected { border-color: var(--color-primary); box-shadow: 0 0 20px var(--color-primary-glow); transform: scale(1.05); }
.car-card-img { width: 180px; height: 180px; background-size: contain; background-repeat: no-repeat; background-position: center; margin-bottom: 20px; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.8)); }
.car-card h3 { font-family: var(--font-heading); font-size: 2rem; color: white; }
.car-card span.lock { position: absolute; font-size: 4rem; color: rgba(255,0,0,0.5); top: 50%; left: 50%; transform: translate(-50%, -50%); }

.car-stats-panel { background: rgba(0,0,0,0.7); padding: 30px; border-radius: 10px; border-left: 5px solid var(--color-secondary); width: 100%; max-width: 500px; margin-top: 20px; }
.car-stats-panel h3 { font-family: var(--font-heading); font-size: 2.5rem; margin-bottom: 15px; text-transform: uppercase;}
.stat-row { display: flex; align-items: center; margin-bottom: 10px; }
.stat-row label { width: 100px; color: var(--color-text-dim); font-size: 0.9rem; }
.stat-bar { flex: 1; height: 10px; background: rgba(255,255,255,0.1); border-radius: 5px; overflow: hidden; }
.stat-bar .fill { height: 100%; background: var(--color-secondary); transition: width 0.3s ease; }

.horizontal { flex-direction: row; gap: 20px; margin-top: 30px; }

.cyber-btn { position: relative; background: transparent; border: none; color: var(--color-text); font-family: var(--font-heading); font-size: 2rem; text-transform: uppercase; padding: 10px 40px; cursor: pointer; overflow: hidden; transform: skewX(-15deg); transition: all 0.2s ease; border-left: 4px solid var(--color-primary); }
.cyber-btn span { display: inline-block; transform: skewX(15deg); position: relative; z-index: 2; }
.cyber-btn::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); z-index: 1; transition: left 0.4s ease; }
.cyber-btn:hover { background: rgba(255, 170, 0, 0.1); box-shadow: -5px 0 15px var(--color-primary-glow); padding-left: 50px; color: var(--color-primary); }
.cyber-btn:hover::before { left: 100%; }
.cyber-btn-small { font-size: 1.2rem; padding: 5px 15px; border-left: 2px solid var(--color-secondary); background: rgba(0,0,0,0.5); }
.text-btn { background: none; border: none; color: var(--color-text-dim); font-family: var(--font-heading); font-size: 1.5rem; cursor: pointer; transition: color 0.2s; }
.text-btn:hover { color: var(--color-text); }

.cyber-panel { background: var(--color-panel); border: 1px solid rgba(255,255,255,0.1); border-top: 3px solid var(--color-primary); padding: 30px; box-shadow: 0 20px 40px rgba(0,0,0,0.8); position: relative; backdrop-filter: blur(10px); }
#guide-screen { align-items: center; justify-content: center; background: rgba(0,0,0,0.8); }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 20px 0; }
.guide-item { text-align: center; }
.icon-wrap { width: 60px; height: 60px; border: 1px solid rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; font-weight: bold; background: rgba(0,0,0,0.5); }
.police-icon { border-color: var(--color-danger); color: var(--color-danger); text-shadow: 0 0 10px var(--color-danger); }
.guide-text { color: var(--color-text-dim); font-size: 0.9rem; text-align: center; margin-bottom: 20px; }

.header-bar { position: absolute; top: 0; left: 0; width: 100%; padding: 20px 40px; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(180deg, rgba(0,0,0,0.9), transparent); font-family: var(--font-heading); z-index: 10; }
.header-bar h2 { font-size: 3rem; margin: 0; color: white;}
.cash-wrap { font-size: 2rem; color: var(--color-primary); }

#level-select { background: rgba(10,12,15,0.95); padding: 100px 40px 40px; }
.levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; width: 100%; max-width: 800px; margin: 0 auto; max-height: 80vh; overflow-y: auto; padding-right: 10px; }
::-webkit-scrollbar { width: 5px; } ::-webkit-scrollbar-track { background: #111; } ::-webkit-scrollbar-thumb { background: var(--color-primary); }
.level-btn { background: rgba(20,25,35,0.8); border: 1px solid rgba(255,255,255,0.1); height: 100px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; font-family: var(--font-heading); cursor: pointer; transition: all 0.2s; }
.level-btn.locked { opacity: 0.5; background: #0a0a0c; cursor: not-allowed; }
.level-btn:not(.locked):hover { background: rgba(255, 170, 0, 0.2); border-color: var(--color-primary); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
.level-btn .num { font-size: 3rem; line-height: 1; }

#garage-screen { background: rgba(10,12,15,0.95); padding: 100px 40px 40px; }
.garage-content { display: flex; width: 100%; max-width: 1000px; margin: 0 auto; gap: 40px; }
.upgrades-panel { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.upgrade-item { background: rgba(20,25,35,0.8); padding: 20px; border-left: 4px solid var(--color-secondary); }
.upgrade-item h3 { font-family: var(--font-heading); font-size: 2rem; margin-bottom: 10px; color: white;}
.bars { display: flex; gap: 5px; margin-bottom: 15px; }
.bars span { width: 30px; height: 10px; background: rgba(255,255,255,0.1); display: block; transform: skewX(-15deg);}
.bars span.filled { background: var(--color-secondary); box-shadow: 0 0 10px var(--color-secondary-glow); }

#hud-screen { z-index: 5; }

/* NEW: Minimap Styles */
#minimap-container { position: absolute; bottom: 30px; right: 220px; width: 150px; height: 150px; background: rgba(0,0,0,0.8); border-radius: 10px; border: 2px solid rgba(255,255,255,0.2); overflow: hidden; box-shadow: 0 0 20px rgba(0,0,0,0.8); }
.minimap-border { position: absolute; top:0; left:0; width:100%; height:100%; border: 2px solid var(--color-secondary); opacity: 0.5; pointer-events: none;}
#minimapCanvas { width: 100%; height: 100%; display: block;}

/* Mobile Reposition for Minimap */
@media (max-width: 800px) {
    #minimap-container { top: 20px; left: 20px; right: auto; bottom: auto; width: 120px; height: 120px; border-radius: 50%; }
}

#top-hud { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 30px; background: rgba(0,0,0,0.6); padding: 10px 30px; border-bottom: 2px solid var(--color-primary); clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.info-box { display: flex; flex-direction: column; align-items: center; font-family: var(--font-heading); }
.info-box .label { font-size: 1rem; color: var(--color-text-dim); }
.info-box .value { font-size: 2rem; color: white; line-height: 1; }
.timer-box .value { color: var(--color-primary); text-shadow: 0 0 5px var(--color-primary); }

#wanted-level { position: absolute; top: 20px; right: 30px; text-align: right; font-family: var(--font-heading); }
.star-container { font-size: 2rem; color: white; letter-spacing: 5px; }

#speedometer-container { position: absolute; bottom: 30px; right: 30px; width: 160px; height: 160px; background: radial-gradient(circle, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.3) 100%); border-radius: 50%; border: 3px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 0 20px rgba(255,170,0,0.2), 0 0 15px rgba(0,0,0,0.5); font-family: var(--font-heading); }
.speed-ring { position: absolute; top: -3px; left: -3px; right: -3px; bottom: -3px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--color-primary); border-right-color: var(--color-primary); transform: rotate(-45deg); opacity: 0.5; transition: transform 0.1s; }
.speed-value { font-size: 4rem; line-height: 0.9; text-shadow: 0 0 10px var(--color-primary-glow); color: white;}
.nitro-gauge { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); width: 60px; height: 10px; background: rgba(255,255,255,0.1); border-radius: 5px; overflow: hidden; }
.nitro-fill { height: 100%; width: 100%; background: var(--color-secondary); box-shadow: 0 0 10px var(--color-secondary); transition: width 0.1s linear; }

#health-container { position: absolute; bottom: 30px; left: 30px; width: 250px; font-family: var(--font-heading); }
.health-label { font-size: 1.5rem; margin-bottom: 5px; text-transform: uppercase; color: white;}
.health-bar { width: 100%; height: 15px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2); transform: skewX(-15deg); overflow: hidden; }
.health-fill { width: 100%; height: 100%; background: #2ecc71; transition: width 0.3s, background-color 0.3s; }

/* Motion Blur & Fast Nitro FX */
#screen-fx { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
#screen-fx.damaged { background: radial-gradient(circle, transparent 30%, rgba(255,0,0,0.5) 100%); opacity: 1; }
#screen-fx.nitro-active { background: radial-gradient(circle, transparent 30%, rgba(0, 229, 255, 0.25) 100%); box-shadow: inset 0 0 100px rgba(0,229,255,0.5); opacity: 1; animation: speedShake 0.1s infinite; }
@keyframes speedShake { 0% { transform: translate(1px, 1px); } 50% { transform: translate(-1px, 2px); } 100% { transform: translate(-2px, -1px); } }

.busted-text { font-family: var(--font-heading); font-size: 6rem; color: var(--color-danger); text-shadow: 0 0 20px var(--color-danger); margin-bottom: 10px; }
.escape-text { font-family: var(--font-heading); font-size: 6rem; color: #2ecc71; text-shadow: 0 0 20px rgba(46,204,113,0.8); margin-bottom: 10px; }
.stats-recap { text-align: center; font-size: 1.5rem; margin: 20px 0 40px; color: var(--color-text-dim); }
.stats-recap span { color: white; display: inline-block; min-width: 60px; text-align: left; margin-left: 10px; }
.total-cash { color: var(--color-primary); font-size: 3rem; margin-top: 20px; font-family: var(--font-heading); }

.icon-toggle { position: absolute; top: 20px; right: 20px; width: 40px; height: 40px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); color: white; font-size: 1.2rem; cursor: pointer; border-radius: 5px; z-index: 100; }
#btn-pause { right: 70px; }
.icon-toggle:hover { background: rgba(255,255,255,0.1); }

/* Mobile Controls */
#mobile-controls { position: absolute; bottom: 20px; left: 0; right: 0; padding: 0 20px; display: none; justify-content: space-between; align-items: flex-end; }
.steer-controls { display: flex; gap: 15px; }
.action-controls { display: flex; gap: 15px; flex-direction: column; align-items: flex-end; }
.control-btn { background: rgba(10,15,20,0.6); border: 2px solid rgba(255,255,255,0.15); color: rgba(255,255,255,0.6); font-size: 2rem; border-radius: 50%; width: 70px; height: 70px; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); transition: all 0.1s; user-select: none; -webkit-tap-highlight-color: transparent; }
.control-btn:active { background: rgba(255,255,255,0.2); border-color: white; color: white; transform: scale(0.9); }
.control-btn.square { border-radius: 10px; font-family: var(--font-heading); font-size: 1.5rem; height: 60px; }
.control-btn.circle { border-radius: 50%; font-family: var(--font-heading); font-size: 1.5rem; }
.control-btn.special { border-color: rgba(0,229,255,0.4); color: var(--color-secondary); }
.control-btn.special:active { background: rgba(0,229,255,0.3); box-shadow: 0 0 15px var(--color-secondary); }

@media (max-width: 800px) {
    /* Menu & Loading Fixes */
    .menu-left { padding: 20px; }
    .title { font-size: 4rem; margin-bottom: 30px; }
    #main-menu { flex-direction: column; padding: 20px; }
    .glitch-text { font-size: 3.5rem; }
    .sub-title { font-size: 2rem; margin-bottom: 20px; }
    
    /* Top Bar Overhaul */
    .header-bar { padding: 10px; }
    .header-bar h2 { font-size: 1.5rem; }
    .cash-wrap { font-size: 1.2rem; }
    
    /* Sub screen padding */
    #level-select, #garage-screen, #car-select-screen { padding: 80px 10px 20px; }
    .car-card { min-width: 200px; height: 280px; }
    .car-card-img { width: 120px; height: 120px; }
    .garage-content { flex-direction: column; }
    
    /* Mobile Controls Enable */
    #mobile-controls { display: flex; z-index: 50; bottom: 10px; padding: 0 10px; }
    .control-btn { width: 60px; height: 60px; font-size: 1.5rem; border-width: 1px; }

    /* Clean HUD Positioning - Top Side */
    #top-hud { top: 5px; gap: 8px; padding: 5px 15px; border-radius: 10px; border: 1px solid rgba(255,170,0,0.5); clip-path: none; width: auto; max-width: 95%; background: rgba(0,0,0,0.8); z-index: 100;}
    .info-box .label { font-size: 0.7rem; }
    .info-box .value { font-size: 1.3rem; }
    
    /* Top Right: Wanted Level */
    #wanted-level { top: 60px; right: 10px; }
    .star-container { font-size: 1.2rem; text-align: right; }
    .warning-text { font-size: 1rem; }

    /* Top Left: Minimap */
    #minimap-container { top: 60px; left: 10px; right: auto; bottom: auto; width: 100px; height: 100px; border-radius: 5px; }

    /* Bottom Side overlaps */
    /* Health bar strictly above steering on left */
    #health-container { left: 10px; bottom: 85px; width: 120px; }
    .health-label { font-size: 1rem; }

    /* Speedometer strictly above actions on right */
    #speedometer-container { right: 10px; bottom: 85px; width: 90px; height: 90px; }
    .speed-value { font-size: 2rem; }
    .speed-unit { font-size: 0.7rem; }
    .nitro-gauge { width: 40px; height: 8px; bottom: 10px; }
    .nitro-label { font-size: 0.6rem; bottom: 0; }
    
    .icon-toggle { top: 10px; right: 10px; width: 35px; height: 35px; font-size: 1rem; }
    #btn-pause { right: 55px; }
    
    /* Busted / Escaped Screens */
    .busted-text, .escape-text { font-size: 4rem; }
    .total-cash { font-size: 2rem; }
}

@media (max-width: 400px) {
    .title { font-size: 3rem; }
    .busted-text, .escape-text { font-size: 3rem; }
    .loader-logo { width: 100px; height: 100px; }
    .glitch-text { font-size: 2.8rem; }
    .control-btn { width: 55px; height: 55px; }
}
