/* ... (code précédent body, canvas, hud...) ... */

body {
    margin: 0;
    overflow: hidden; /* Empêche les barres de défilement */
    background-color: #000; /* Fond noir pour l'espace */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
    user-select: none; /* Empêche la sélection de texte */
}

canvas {
    display: block; /* Évite les marges implicites en bas du canvas */
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Permet de cliquer à travers le HUD vers le canvas */
    display: none; /* Caché au départ, affiché après sélection du vaisseau */
}

#speedometer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #00aaff;
    z-index: 10;
    min-width: 280px;
}

#mode-display {
    font-size: 14px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}

#mode-value {
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 3px;
}

#mode-value.mode-normal {
    background: #335533;
    color: #88ff88;
}

#mode-value.mode-light {
    background: #553388;
    color: #ffaa00;
    animation: pulse-light 1s infinite;
}

@keyframes pulse-light {
    0%, 100% { box-shadow: 0 0 5px #ffaa00; }
    50% { box-shadow: 0 0 15px #ffaa00; }
}

#speed-display {
    font-size: 20px;
    margin-bottom: 5px;
}

#speed-value {
    color: #00ff00;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

#speed-light {
    font-size: 14px;
    color: #aaaaaa;
}

#speed-percent {
    color: #ffaa00;
}

#distance-display {
    font-size: 16px;
    color: #cccccc;
}

#dist-value {
    color: #00aaff;
    font-weight: bold;
}

#distance-ua {
    font-size: 12px;
    color: #888888;
}

#dist-ua {
    color: #ffaa00;
}

#controls-hint {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 14px;
    text-align: right;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    opacity: 0.7;
    z-index: 10;
}

/* --- Radar --- */
#radar {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 200px;
    background: rgba(0, 20, 40, 0.8);
    border: 2px solid #00aaff;
    border-radius: 50%; /* Cercle */
    overflow: hidden; /* Masquer ce qui sort du radar */
    pointer-events: none;
    z-index: 10;
}

/* Lignes de repère du radar (croix) */
#radar::before, #radar::after {
    content: '';
    position: absolute;
    background: rgba(0, 170, 255, 0.3);
    z-index: 0;
}

#radar::before {
    top: 50%; left: 0; width: 100%; height: 1px;
}

#radar::after {
    left: 50%; top: 0; width: 1px; height: 100%;
}

#radar-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    box-shadow: 0 0 5px white;
}

/* Triangle du joueur (pointe vers le haut = direction du vaisseau) */
#radar-center::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 6px solid white;
}

/* Conteneur du blip (point + label) */
.radar-blip-container {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

/* Le point du blip */
.radar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.radar-dot.sun { 
    width: 10px; 
    height: 10px; 
    background: yellow; 
    box-shadow: 0 0 8px yellow; 
}

.radar-dot.planet { 
    width: 5px; 
    height: 5px; 
}

/* Flèche pour les blips hors zone */
.radar-dot.arrow {
    width: 0;
    height: 0;
    border-radius: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 8px solid currentColor;
    background: transparent !important;
}

/* Label du blip */
.radar-label {
    font-size: 8px;
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
    margin-top: 2px;
    text-shadow: 0 0 3px black, 0 0 3px black;
}

/* Style pour les blips hors de portée */
.radar-blip-container.out-of-range {
    opacity: 0.7;
}

.radar-blip-container.out-of-range .radar-label {
    font-size: 7px;
}

/* --- Hyperespace Menu (FIX) --- */
#hyperspace-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: auto; /* Réactive le clic pour le bouton */
    padding: 10px 20px;
    background: rgba(0, 100, 255, 0.3);
    border: 1px solid #00aaff;
    color: #00aaff;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    transition: 0.3s;
    z-index: 20; /* Au-dessus de tout */
}

#hyperspace-btn:hover {
    background: rgba(0, 100, 255, 0.6);
    box-shadow: 0 0 10px #00aaff;
}

/* Le conteneur du menu doit être centré et caché par défaut */
#hyperspace-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #00aaff;
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.5);
    padding: 20px;
    border-radius: 10px;
    pointer-events: auto;
    min-width: 300px;
    text-align: center;
    z-index: 100; /* Le plus haut niveau */
    display: block; /* Par défaut affiché... */
}

/* ...sauf si on a la classe hidden */
#hyperspace-menu.hidden {
    display: none !important;
}

#hyperspace-menu h2 {
    margin-top: 0;
    color: #00aaff;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 18px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

#destinations-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

#destinations-list li {
    margin: 5px 0;
}

#destinations-list button {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #444;
    color: white;
    cursor: pointer;
    text-align: left;
    transition: 0.2s;
    font-family: monospace;
    text-transform: uppercase;
}

#destinations-list button:hover {
    background: rgba(0, 170, 255, 0.2);
    border-color: #00aaff;
    padding-left: 15px; /* Petit effet de glissement */
}

#close-menu-btn {
    background: #aa3333;
    border: none;
    color: white;
    padding: 8px 20px;
    cursor: pointer;
    border-radius: 3px;
    font-weight: bold;
    width: 100%;
}

#close-menu-btn:hover {
    background: #cc4444;
}

/* === BARRES DE VIE (Bouclier + Coque) === */
#health-bars {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
}

.health-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.health-bar-label {
    font-size: 12px;
    width: 80px;
    text-align: right;
}

.health-bar {
    width: 200px;
    height: 16px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid #444;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.health-bar-fill {
    height: 100%;
    transition: width 0.2s ease-out;
}

.shield-fill {
    background: linear-gradient(90deg, #00aaff, #00ffff);
}

.hull-fill {
    background: linear-gradient(90deg, #00ff00, #88ff00);
}

.health-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}

/* Animation de danger */
@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Overlay de dégâts (flash rouge) */
#damage-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(255, 0, 0, 0.4) 100%);
    pointer-events: none;
    opacity: 0;
    z-index: 1000;
}

/* Écran Game Over */
#game-over {
    position: fixed;
    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;
    z-index: 2000;
}

#game-over h1 {
    font-size: 48px;
    color: #ff3333;
    text-shadow: 0 0 20px #ff0000;
    margin-bottom: 20px;
}

#game-over p {
    font-size: 18px;
    color: #cccccc;
    margin-bottom: 30px;
}

#game-over button {
    padding: 15px 40px;
    font-size: 20px;
    background: #00aaff;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 5px;
    transition: 0.3s;
}

#game-over button:hover {
    background: #00ddff;
    box-shadow: 0 0 20px #00aaff;
}

/* === SCORE === */
#score-display {
    position: absolute;
    top: 20px;
    left: calc(50% + 250px);
    text-align: left;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #ffaa00;
    z-index: 10;
}

.score-label {
    font-size: 12px;
    color: #ffaa00;
    margin-bottom: 5px;
}

.score-value {
    font-size: 28px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 10px #ffaa00;
    font-family: 'Courier New', monospace;
}

.asteroids-count {
    font-size: 11px;
    color: #888888;
    margin-top: 5px;
}

/* === STATIONS SPATIALES === */

/* Menu de station */
#station-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.95);
    border: 2px solid #00aaff;
    border-radius: 15px;
    padding: 25px;
    min-width: 350px;
    z-index: 1000;
    box-shadow: 0 0 30px rgba(0, 170, 255, 0.5);
}

.station-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #00aaff44;
}

.station-name {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 10px #00aaff;
}

.station-code {
    display: block;
    font-size: 12px;
    color: #00aaff;
    letter-spacing: 3px;
    margin-top: 5px;
}

.station-services {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.service {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: rgba(0, 100, 150, 0.2);
    border-radius: 8px;
    border: 1px solid #00557788;
}

.service.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.service-icon {
    font-size: 28px;
}

.service-name {
    flex: 1;
    font-size: 16px;
    color: #ffffff;
}

.service-btn {
    padding: 8px 20px;
    background: linear-gradient(180deg, #00aaff, #0066aa);
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.service-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #00ccff, #0088cc);
    box-shadow: 0 0 15px #00aaff;
}

.service-btn:disabled {
    background: #444444;
    color: #888888;
    cursor: not-allowed;
}

.station-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #00aaff44;
}

.station-footer .hint {
    font-size: 12px;
    color: #666666;
}

/* Indication d'approche de station */
#station-hint {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 20, 40, 0.9);
    border: 2px solid #00aaff;
    border-radius: 10px;
    padding: 15px 25px;
    display: none;
    text-align: center;
    z-index: 100;
    animation: pulse-hint 1.5s infinite;
}

@keyframes pulse-hint {
    0%, 100% { box-shadow: 0 0 10px rgba(0, 170, 255, 0.5); }
    50% { box-shadow: 0 0 25px rgba(0, 170, 255, 0.8); }
}

#station-hint .hint-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 5px;
}

#station-hint .hint-text {
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    display: block;
}

#station-hint .hint-action {
    font-size: 12px;
    color: #00aaff;
    display: block;
    margin-top: 5px;
}

/* === MENU DE SÉLECTION DE VAISSEAU === */

#ship-selection-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a2a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

#ship-selection-menu.hidden {
    display: none;
}

#ship-selection-menu h1 {
    font-size: 48px;
    color: #ffffff;
    text-shadow: 0 0 30px #00aaff, 0 0 60px #0066aa;
    margin-bottom: 10px;
    letter-spacing: 5px;
}

#ship-selection-menu h2 {
    font-size: 20px;
    color: #88aacc;
    margin-bottom: 40px;
    font-weight: normal;
}

#ship-options {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 1000px;
}

.ship-option {
    width: 200px;
    padding: 20px;
    background: rgba(0, 50, 100, 0.3);
    border: 2px solid #335577;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.ship-option:hover {
    background: rgba(0, 100, 150, 0.4);
    border-color: #00aaff;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 170, 255, 0.3);
}

.ship-option.selected {
    background: rgba(0, 150, 200, 0.4);
    border-color: #00ffaa;
    box-shadow: 0 0 30px rgba(0, 255, 170, 0.5);
}

.ship-option .ship-icon {
    font-size: 50px;
    margin-bottom: 10px;
}

.ship-option .ship-name {
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 8px;
}

.ship-option .ship-desc {
    font-size: 12px;
    color: #88aacc;
    line-height: 1.4;
}

#start-game-btn {
    margin-top: 40px;
    padding: 18px 50px;
    font-size: 22px;
    font-weight: bold;
    background: linear-gradient(180deg, #00aaff, #0066aa);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

#start-game-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #00ccff, #0088cc);
    box-shadow: 0 0 30px #00aaff;
    transform: scale(1.05);
}

#start-game-btn:disabled {
    background: #444466;
    color: #666688;
    cursor: not-allowed;
}

/* Animation d'étoiles en arrière-plan du menu */
#ship-selection-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, white, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 370px 50px, white, transparent),
        radial-gradient(2px 2px at 450px 180px, rgba(255,255,255,0.8), transparent);
    background-size: 500px 200px;
    animation: twinkle 5s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* === MINIMAP SYSTÈME SOLAIRE === */

#minimap-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(5, 10, 20, 0.95);
    border: 2px solid #00aaff;
    border-radius: 15px;
    padding: 15px;
    z-index: 1500;
    box-shadow: 0 0 50px rgba(0, 170, 255, 0.4);
    max-height: 90vh;
    max-width: 90vw;
    overflow: hidden;
}

#minimap-container.hidden {
    display: none;
}

.minimap-header {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #00aaff44;
}

.minimap-title {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 10px #00aaff;
    margin-bottom: 3px;
}

.minimap-hint {
    font-size: 11px;
    color: #668899;
}

#minimap-canvas {
    display: block;
    border-radius: 10px;
    cursor: crosshair;
}

.minimap-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #00aaff44;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #aabbcc;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.player {
    background: #ff4444;
    box-shadow: 0 0 8px #ff4444;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 12px solid #ff4444;
    border-radius: 0;
}

.legend-dot.station {
    background: #00ffaa;
    box-shadow: 0 0 8px #00ffaa;
    border-radius: 2px;
}

.legend-dot.asteroid {
    background: rgba(139, 119, 101, 0.6);
    box-shadow: 0 0 5px #8b7765;
}

.minimap-zoom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.minimap-zoom button {
    width: 30px;
    height: 30px;
    font-size: 18px;
    font-weight: bold;
    background: rgba(0, 100, 150, 0.5);
    border: 1px solid #00aaff;
    border-radius: 5px;
    color: #00aaff;
    cursor: pointer;
    transition: 0.2s;
}

.minimap-zoom button:hover {
    background: rgba(0, 150, 200, 0.7);
    box-shadow: 0 0 10px #00aaff;
}

#minimap-zoom-level {
    font-size: 14px;
    color: #88aacc;
    min-width: 80px;
    text-align: center;
}
