/* =========================================================================
   RACER ULTIMATE - MULTIPLAYER EDITION - STYLES
   ========================================================================= */

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

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #000;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    color: #fff;
}

canvas {
    display: block;
}

/* ==================== ÉCRANS ==================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.4s, transform 0.4s;
    background: linear-gradient(180deg, #0a0a1a 0%, #1a1a3e 100%);
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

.hidden {
    display: none !important;
}

/* ==================== MENU PRINCIPAL ==================== */
.game-title {
    font-size: clamp(36px, 10vw, 72px);
    font-weight: 900;
    background: linear-gradient(135deg, #00d4ff, #ff6600);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px rgba(0, 212, 255, 0.5));
    margin-bottom: 5px;
}

.game-subtitle {
    font-size: clamp(12px, 3vw, 18px);
    color: #666;
    letter-spacing: 5px;
    margin-bottom: 40px;
}

.menu-btn {
    width: 85%;
    max-width: 320px;
    padding: 18px;
    margin: 8px;
    font-size: clamp(16px, 4vw, 22px);
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #0066ff, #00d4ff);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-btn:hover,
.menu-btn:active {
    transform: scale(1.03);
    box-shadow: 0 8px 30px rgba(0, 150, 255, 0.5);
}

.menu-btn.secondary {
    background: linear-gradient(135deg, #333, #555);
}

.menu-btn.garage {
    background: linear-gradient(135deg, #ff6600, #ff9900);
}

.menu-btn.multiplayer {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.menu-stats {
    position: absolute;
    top: 20px;
    right: 20px;
    text-align: right;
    font-size: 14px;
    color: #888;
    line-height: 1.8;
}

.menu-stats span {
    color: #ffcc00;
    font-weight: bold;
}

.controls-hint {
    margin-top: 30px;
    font-size: 12px;
    color: #555;
    text-align: center;
    line-height: 2;
}

.key {
    display: inline-block;
    background: #222;
    padding: 6px 12px;
    border-radius: 6px;
    color: #00d4ff;
    margin: 2px;
}

/* ==================== GARAGE ==================== */
#garageScreen {
    background: radial-gradient(ellipse at center, #1a2a3a 0%, #0a0a1a 100%);
}

.garage-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.garage-title {
    font-size: clamp(20px, 5vw, 32px);
    font-weight: bold;
    color: #fff;
}

.garage-coins {
    font-size: clamp(14px, 4vw, 18px);
    color: #ffcc00;
}

.garage-back-btn {
    padding: 10px 20px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #333;
    border-radius: 25px;
    color: #fff;
    cursor: pointer;
}

.garage-back-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

#garageCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    width: 90%;
    max-width: 450px;
    height: 200px;
    border-radius: 15px;
}

.car-selector {
    position: absolute;
    bottom: 250px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.car-nav-btn {
    width: 50px;
    height: 50px;
    font-size: 24px;
    background: rgba(0, 150, 255, 0.2);
    border: 2px solid #00d4ff;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.car-nav-btn:hover,
.car-nav-btn:active {
    background: rgba(0, 150, 255, 0.5);
}

.car-info-box {
    text-align: center;
    min-width: 150px;
}

.car-name {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: bold;
}

.car-class {
    font-size: 12px;
    color: #00d4ff;
    letter-spacing: 2px;
}

/* ==================== STATS PANEL ==================== */
.stats-panel {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 380px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    padding: 12px 18px;
}

.stat-row {
    display: flex;
    align-items: center;
    margin: 6px 0;
}

.stat-label {
    width: 95px;
    font-size: 11px;
    color: #aaa;
}

.stat-bar-bg {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin: 0 10px;
}

.stat-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease;
}

.stat-bar.speed {
    background: linear-gradient(90deg, #e74c3c, #f39c12);
}

.stat-bar.accel {
    background: linear-gradient(90deg, #9b59b6, #e74c3c);
}

.stat-bar.handling {
    background: linear-gradient(90deg, #3498db, #2ecc71);
}

.stat-bar.nitro {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
}

.stat-value {
    width: 30px;
    text-align: right;
    font-size: 11px;
    font-weight: bold;
}

.car-price {
    position: absolute;
    bottom: 75px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    color: #ffcc00;
    font-weight: bold;
}

.car-price.owned {
    color: #2ecc71;
}

.car-price.locked {
    color: #e74c3c;
}

.garage-select-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    max-width: 320px;
    padding: 16px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #00cc66, #00ff88);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
}

.garage-select-btn:hover,
.garage-select-btn:active {
    box-shadow: 0 5px 25px rgba(0, 255, 136, 0.5);
}

.garage-select-btn.selected {
    background: linear-gradient(135deg, #333, #555);
}

.garage-select-btn.buy {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.garage-select-btn.locked {
    background: linear-gradient(135deg, #555, #333);
    color: #888;
}

/* ==================== MULTIPLAYER SETUP ==================== */
#multiSetupScreen {
    background: linear-gradient(180deg, #1a0a2e 0%, #0a1a3e 100%);
    padding: 20px;
}

.back-btn-top {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 10px 20px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #333;
    border-radius: 25px;
    color: #fff;
    cursor: pointer;
}

.multi-title {
    font-size: clamp(28px, 7vw, 42px);
    font-weight: bold;
    color: #9b59b6;
    margin-bottom: 5px;
    margin-top: 30px;
}

.multi-subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 25px;
}

.players-setup {
    display: flex;
    flex-direction: row;
    gap: 20px;
    width: 100%;
    max-width: 700px;
    justify-content: center;
    flex-wrap: wrap;
}

.player-setup-box {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 15px;
    padding: 15px;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

#player1Setup {
    border-color: #3498db;
}

#player2Setup {
    border-color: #e74c3c;
}

.player-setup-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 12px;
    color: #fff;
}

#player1Setup .player-setup-title {
    color: #3498db;
}

#player2Setup .player-setup-title {
    color: #e74c3c;
}

.player-name-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #444;
    border-radius: 10px;
    color: #fff;
    text-align: center;
    margin-bottom: 15px;
}

.player-name-input:focus {
    outline: none;
    border-color: #00d4ff;
}

.player-car-select {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.car-select-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #555;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
}

.car-select-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.player-car-preview {
    width: 80px;
    height: 50px;
    background: #333;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.player-car-name {
    font-size: 14px;
    color: #aaa;
}

.start-multi-btn {
    margin-top: 20px;
    background: linear-gradient(135deg, #9b59b6, #8e44ad) !important;
}

.multi-controls-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 25px;
    font-size: 12px;
    color: #666;
}

.control-column {
    text-align: center;
    line-height: 2;
}

.control-column strong {
    color: #aaa;
}

/* ==================== HUD SOLO ==================== */
#gameHUD {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.3s;
}

#gameHUD.visible {
    opacity: 1;
}

.hud-top {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
}

.hud-score {
    font-size: clamp(28px, 7vw, 42px);
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.hud-coins {
    font-size: 16px;
    color: #ffcc00;
    margin-top: 5px;
}

.hud-speed-box {
    text-align: right;
}

.hud-speed {
    font-size: clamp(32px, 8vw, 50px);
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    transition: color 0.2s;
}

.hud-speed.nitro {
    color: #00d4ff;
}

.hud-speed-unit {
    font-size: 12px;
    color: #888;
}

/* ==================== NITRO BAR ==================== */
.nitro-hud {
    position: absolute;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    max-width: 300px;
}

.nitro-bar-container {
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    border: 2px solid #333;
    overflow: hidden;
}

.nitro-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0066ff, #00d4ff, #00ff88);
    border-radius: 6px;
    transition: width 0.1s;
}

.nitro-bar-fill.active {
    animation: nitroGlow 0.2s ease infinite;
}

@keyframes nitroGlow {
    0%, 100% {
        box-shadow: 0 0 10px #00d4ff;
    }
    50% {
        box-shadow: 0 0 25px #00d4ff, 0 0 40px #00ff88;
    }
}

.nitro-label {
    text-align: center;
    font-size: 11px;
    color: #00d4ff;
    margin-top: 4px;
    letter-spacing: 2px;
}

/* ==================== HUD MULTIJOUEUR ==================== */
#multiHUD {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#multiHUD.visible {
    display: block;
}

.split-hud {
    position: absolute;
    top: 10px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

.split-hud.left {
    left: 10px;
    border-left: 3px solid #3498db;
}

.split-hud.right {
    right: 10px;
    text-align: right;
    border-right: 3px solid #e74c3c;
}

.split-player-name {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
}

.split-hud.left .split-player-name {
    color: #3498db;
}

.split-hud.right .split-player-name {
    color: #e74c3c;
}

.split-speed {
    font-size: 24px;
    font-weight: bold;
}

.split-nitro-bar {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
}

.split-nitro-fill {
    height: 100%;
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    border-radius: 4px;
    transition: width 0.1s;
}

.split-divider {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #9b59b6, transparent 20%, transparent 80%, #9b59b6);
}

/* ==================== COMBO POPUP ==================== */
.combo-popup {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(30px, 8vw, 50px);
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 0 0 20px rgba(255, 200, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 60;
}

.combo-popup.show {
    animation: comboPop 0.5s ease-out forwards;
}

@keyframes comboPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(-40px);
    }
}

/* ==================== EFFETS OVERLAY ==================== */
.speed-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.7) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 40;
}

.speed-vignette.active {
    opacity: 1;
}

.nitro-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at bottom center, rgba(0, 180, 255, 0.3) 0%, transparent 60%);
    pointer-events: none;
    opacity: 0;
    z-index: 41;
}

.nitro-flash.active {
    animation: nitroFlash 0.15s ease infinite;
}

@keyframes nitroFlash {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 0.7;
    }
}

/* ==================== CONTRÔLES MOBILE SOLO ==================== */
.mobile-controls {
    position: fixed;
    bottom: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 15px;
    z-index: 55;
    pointer-events: none;
}

.ctrl-btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 26px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: all 0.1s;
}

.ctrl-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.ctrl-nitro {
    width: 85px;
    height: 85px;
    background: linear-gradient(135deg, rgba(0, 100, 200, 0.4), rgba(0, 200, 150, 0.4));
    border: 3px solid #00d4ff;
    font-size: 30px;
}

.ctrl-nitro:active {
    background: linear-gradient(135deg, rgba(0, 150, 255, 0.7), rgba(0, 255, 200, 0.7));
}

/* ==================== CONTRÔLES MOBILE MULTI ==================== */
.mobile-multi-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    display: flex;
    z-index: 55;
    pointer-events: none;
}

.mobile-multi-left,
.mobile-multi-right {
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px;
    pointer-events: auto;
}

.mobile-multi-left {
    background: rgba(52, 152, 219, 0.1);
    border-top: 2px solid rgba(52, 152, 219, 0.3);
}

.mobile-multi-right {
    background: rgba(231, 76, 60, 0.1);
    border-top: 2px solid rgba(231, 76, 60, 0.3);
}

.multi-ctrl-btn {
    width: 55px;
    height: 55px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.multi-ctrl-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

.multi-ctrl-btn.nitro {
    width: 65px;
    height: 65px;
    font-size: 24px;
}

.mobile-multi-left .multi-ctrl-btn.nitro {
    background: rgba(52, 152, 219, 0.3);
    border-color: #3498db;
}

.mobile-multi-right .multi-ctrl-btn.nitro {
    background: rgba(231, 76, 60, 0.3);
    border-color: #e74c3c;
}

/* ==================== GAME OVER SOLO ==================== */
.gameover-title {
    font-size: clamp(40px, 12vw, 70px);
    font-weight: bold;
    color: #ff4444;
    text-shadow: 0 0 30px rgba(255, 50, 50, 0.5);
    margin-bottom: 15px;
}

.gameover-score {
    font-size: clamp(50px, 15vw, 90px);
    font-weight: bold;
}

.gameover-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.gameover-coins-earned {
    font-size: 20px;
    color: #ffcc00;
    margin: 15px 0;
}

.gameover-best {
    font-size: 18px;
    color: #888;
    margin-bottom: 30px;
}

.gameover-best span {
    color: #ffcc00;
}

/* ==================== GAME OVER MULTI ==================== */
#multiGameOverScreen {
    background: linear-gradient(180deg, #1a0a2e 0%, #0a1a3e 100%);
}

.multi-winner-title {
    font-size: clamp(36px, 10vw, 60px);
    font-weight: bold;
    color: #f1c40f;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.5);
}

.multi-winner-name {
    font-size: clamp(32px, 9vw, 56px);
    font-weight: bold;
    color: #fff;
    margin: 15px 0 5px 0;
}

.multi-loser-text {
    font-size: 18px;
    color: #888;
    margin-bottom: 20px;
}

.multi-no-coins {
    font-size: 14px;
    color: #e74c3c;
    margin-bottom: 30px;
    padding: 10px 20px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 20px;
}

/* ==================== RESPONSIVE - PORTRAIT ==================== */
@media (max-width: 600px) {
    .players-setup {
        flex-direction: column;
        align-items: center;
    }
    
    .player-setup-box {
        width: 95%;
    }
    
    .multi-controls-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .car-selector {
        bottom: 240px;
    }
    
    .stats-panel {
        bottom: 110px;
    }
    
    .car-price {
        bottom: 70px;
    }
    
    .garage-select-btn {
        bottom: 15px;
    }
    
    #garageCanvas {
        height: 170px;
    }
}

/* ==================== RESPONSIVE - PAYSAGE ==================== */
@media (max-height: 500px) and (orientation: landscape) {
    .game-title {
        font-size: 36px;
        margin-bottom: 0;
    }
    
    .game-subtitle {
        margin-bottom: 15px;
    }
    
    .menu-btn {
        padding: 12px;
        margin: 5px;
    }
    
    .controls-hint {
        margin-top: 10px;
    }
    
    .players-setup {
        flex-direction: row;
    }
    
    .player-setup-box {
        padding: 10px;
    }
    
    .multi-title {
        font-size: 28px;
        margin-top: 10px;
    }
    
    .multi-subtitle {
        margin-bottom: 10px;
    }
    
    .start-multi-btn {
        margin-top: 10px;
        padding: 12px;
    }
    
    .multi-controls-info {
        margin-top: 10px;
    }
    
    #garageCanvas {
        height: 130px;
        transform: translate(-50%, -60%);
    }
    
    .car-selector {
        bottom: 180px;
    }
    
    .stats-panel {
        bottom: 80px;
        padding: 8px 15px;
    }
    
    .stat-row {
        margin: 4px 0;
    }
    
    .car-price {
        bottom: 55px;
        font-size: 14px;
    }
    
    .garage-select-btn {
        bottom: 10px;
        padding: 10px;
        font-size: 14px;
    }
    
    .ctrl-btn {
        width: 55px;
        height: 55px;
        font-size: 20px;
    }
    
    .ctrl-nitro {
        width: 65px;
        height: 65px;
    }
    
    .nitro-hud {
        bottom: 80px;
    }
    
    .mobile-multi-controls {
        height: 90px;
    }
    
    .multi-ctrl-btn {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    .multi-ctrl-btn.nitro {
        width: 55px;
        height: 55px;
    }
}

/* ==================== DESKTOP - CACHER CONTRÔLES MOBILE ==================== */
@media (min-width: 768px) and (hover: hover) {
    .mobile-controls {
        display: none !important;
    }
    
    .mobile-multi-controls {
        display: none !important;
    }
}

/* ==================== SPLIT SCREEN VIEWPORTS ==================== */
.split-viewport {
    position: fixed;
    top: 0;
    height: 100%;
    overflow: hidden;
}

.split-viewport.left {
    left: 0;
    width: 50%;
    border-right: 2px solid #9b59b6;
}

.split-viewport.right {
    right: 0;
    width: 50%;
    border-left: 2px solid #9b59b6;
}

/* ==================== UTILITIES ==================== */
.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}