body {
    margin: 0;
    padding: 0;
    background-color: #0d0d0d;
    color: #fff;
    font-family: 'Courier New', Courier, monospace;
    display: flex; /* Centre le jeu sur PC */
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; 
    touch-action: none; 
}

/* Écran qui force le mode paysage sur mobile */
#portrait-warning {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #000;
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 20px;
    padding: 20px;
    box-sizing: border-box;
}

/* Taille fixe pour PC (800x600) avec une bordure */
#game-container {
    position: relative;
    width: 800px;
    height: 600px;
    border: 2px solid #444;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.1);
}

canvas {
    display: block;
    background-color: #0a0a0a;
    cursor: crosshair;
}

#ui {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 2;
}

.stat {
    background: rgba(0, 0, 0, 0.8);
    padding: 5px 10px;
    border: 1px solid #333;
    border-radius: 4px;
}

#health-bar-container {
    width: 150px;
    height: 15px;
    background-color: #333;
    border: 1px solid #fff;
    margin-top: 5px;
}

#health-bar {
    width: 100%;
    height: 100%;
    background-color: #00ff88;
    transition: width 0.2s;
}

#mobile-controls {
    position: absolute;
    bottom: 30px;
    left: 30px;
    display: none; /* Toujours caché sur PC */
    z-index: 10;
}

#dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dpad-row {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.ctrl-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
}

.ctrl-btn:active {
    background: rgba(0, 255, 136, 0.4);
    border-color: #00ff88;
}

#game-over {
    position: absolute;
    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;
    display: none;
    z-index: 20;
}

h1, p { text-align: center; }
h1 { color: #ff3333; letter-spacing: 5px; margin-bottom: 10px; }
button#restart-btn { margin-top: 20px; padding: 10px 20px; background: transparent; color: #fff; border: 2px solid #fff; cursor: pointer; text-transform: uppercase; }

/* --- RESPONSIVE & MOBILE --- */
@media (max-width: 1200px), (pointer: coarse) {
    /* Sur mobile, on enlève les bordures et on passe en vrai plein écran */
    #game-container { 
        width: 100vw; 
        height: 100vh; 
        border: none; 
        box-shadow: none; 
    }
    #mobile-controls { display: flex; } 
    #controls-hint { display: none; }
}

@media (orientation: portrait) and (max-width: 900px) {
    #portrait-warning { display: flex; }
    #game-container { display: none; }
}