@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&family=Pompiere&family=Knewave&display=swap');

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

body, canvas, #speed-vignette {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#panel-header h1 {
    font-family: 'Knewave','Manrope', sans-serif;
    font-size: 49px;
    font-weight: 400;
    letter-spacing: 1px;
    margin-left:20px;
}
@font-face {
  font-family: 'DejaVu Sans';
  src: url('./fonts/dejavu-sans/DejaVuSans.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Emoji';
  src: url('./fonts/dejavu-sans/NotoColorEmoji.ttf') format('truetype');
  font-display: swap;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#canvas-container {
    width: 100vw;
    height: 100vh;
}

/* =========================================
   PANEL PRINCIPAL
   ========================================= */
#controls-panel {
    position: absolute;
    top: 0px;
    left: 0px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    background-color:rgba(255, 255, 255, 0.85);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top left;
    z-index: 999999;
}

#panel-header, 
#tabs-navigation {
    flex-shrink: 0; 
}

#panel-scroll-content {
    flex: 1; 
    overflow-y: auto;       
    overflow-x: hidden;
    padding-right: 5px;     
    padding-top: 5px;
    min-height: 0;
    padding-bottom: 40px; 
}

#panel-scroll-content::-webkit-scrollbar { width: 6px; }
#panel-scroll-content::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); border-radius: 10px; margin-top: 5px; }
#panel-scroll-content::-webkit-scrollbar-thumb { background: rgba(102, 126, 234, 0.4); border-radius: 10px; }
#panel-scroll-content::-webkit-scrollbar-thumb:hover { background: rgba(102, 126, 234, 0.6); }

/* --- ÉTAT COLLAPSED --- */
#controls-panel.collapsed {
    top: 20px;
    left: 20px;
    padding: 0;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90000 !important;
    overflow: hidden;
}

#controls-panel.collapsed:hover { transform: scale(1.1); }
#controls-panel.collapsed * { display: none; }
#controls-panel.collapsed::before {
  content: '⚙\fe0e';
  font-size: 28px;
  line-height: 1;
  color:#6a6a99;
  margin-top: -2px;
}

#panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

#collapse-btn {
    background: rgba(0,0,0,0.05);
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    color: #555;
    width: auto;
    font-weight: bold;
}
#collapse-btn:hover { background: rgba(0,0,0,0.1); color: #333; }

/* =========================================
   NAVIGATION ONGLETS
   ========================================= */
#tabs-navigation {
    display: flex;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 20px;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 2px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
    box-shadow: none;
    margin: 0;
}

.tab-btn .tab-icon {
    font-size: 22px;
    margin-bottom: 4px;
    filter: grayscale(100%);
    opacity: 0.7;
    transition: all 0.2s;
}

.tab-btn:hover { background: rgba(255, 255, 255, 0.5); }

.tab-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tab-btn.active .tab-icon {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.1);
}

.tab-label {
    display: block;
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

.section-header h3 {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    color: #444;
    margin: 0;
}

.points-balance {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* =========================================
   TAB: WORLDS
   ========================================= */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 25px;
    padding-bottom: 20px;
}

.world-card {
    position: relative;
    width: 100%;
    height: 280px; 
    border-radius: 16px;
    overflow: hidden;
    background-size: cover !important;
    background-position: center !important;
    background-blend-mode: overlay;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: flex-end;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
}

.world-card-content {
    width: 100%;
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,40,0.4) 0%, rgba(0,0,40,0.1) 40%, transparent 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    text-shadow: 0px 0px 15px black;
}

/* =========================================
   TAB: SKINS (Galerie Images PNG) - STYLE CARTE INTÉGRÉE
   ========================================= */
#skins-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px;
    padding: 10px;
}

.skin-card {
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.skin-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.15);
    z-index: 2;
}

.skin-card.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}

.skin-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; 
    background: radial-gradient(circle, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.skin-image-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60%;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    pointer-events: none; /* Laisse les clics passer au travers */
    z-index: 2;
}
.skin-buy-btn {
    position: absolute;
    top: 15px;
    right: 30px; /* Décalé de 30px pour ne pas chevaucher la barre de progression (right: 15px) */
    z-index: 10;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 11px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    text-transform: uppercase;
    transition: transform 0.2s, background 0.2s;
}

.skin-buy-btn:active { 
    transform: scale(0.95); 
}
.skin-buy-btn.btn-buy { 
    background: #667eea; color: white; 
}
.skin-buy-btn.btn-buy:hover { 
    background: #5a6fd6; 
}
.skin-buy-btn.btn-locked { 
    background: rgba(255, 255, 255, 0.8); color: #888; cursor: not-allowed; backdrop-filter: blur(4px);
}

.skin-card:not(.selected) .skin-image {
    opacity: 0.5;
    filter: grayscale(60%) brightness(1.2);
    transition: all 0.3s ease;
}

.skin-card.selected .skin-image {
    opacity: 1;
    filter: grayscale(0%) brightness(1);
}

.skin-card:not(.selected):not(.skin-locked):hover .skin-image {
    opacity: 1;
    filter: grayscale(0%) brightness(1);
}

.skin-card.skin-locked:hover .skin-image {
    opacity: 0.7;
    filter: grayscale(40%) brightness(1.1);
}

.skin-image {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    transition: transform 0.4s ease;
    z-index: 1;
}


.skin-name-overlay {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 30px; 
    font-family: 'Knewave', sans-serif;
    font-size: 24px;
    color: #ffffff;
    z-index: 3;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 1px;
    text-shadow: 0px 2px 4px rgba(0,0,0,0.5);
}

.skin-level-badge {
    position: absolute;
    top: 15px;
    left: 15px; /* Déplacé à gauche pour équilibrer avec la barre à droite */
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 12px;
    z-index: 3;
    border: 1px solid rgba(255,255,255,0.2);
}

/* Barre verticale sur l'image */
.skin-progress-integrated {
    position: absolute;
    top: 15px;
    bottom: 15px;
    right: 15px;
    width: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    backdrop-filter: blur(2px);
}

.skin-progress-fill {
    width: 100%;
    background: linear-gradient(0deg, #38ef7d, #11998e);
    border-radius: 3px;
    transition: height 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}


.skin-name {
    font-family: 'Knewave', sans-serif;
    font-size: 20px;
    color: #333;
    margin-bottom: 15px; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.skin-card .unified-btn {
    font-size: 12px;
    padding: 10px 0;
    border-radius: 10px;
}

/* =========================================
   TAB: SKILLS & PREVIEW
   ========================================= */
.skin-showcase {
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.6) 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column; 
    text-align: center; 
    align-items: center; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid white;
    gap: 15px; 
}

.skin-preview-box-3d canvas {
    display: block;
    outline: none;
}
.skin-preview-box-3d:active {
    cursor: grabbing;
}

.skin-info-box {
    flex: 1;
}
/* === STYLE GLOBAL POUR LA BOITE D'INFO === */
.skin-info-box {
    background: rgba(255,255,255,0.5);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.6);
    padding: 15px;
    margin-bottom: 20px;
    flex: 1; /* Important pour le layout desktop */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.skin-info-box h2 { 
    margin: 0 0 10px 0; 
    font-size: 20px; 
    color: #333; 
}
/* --- NOUVEAU : STATS GRID DANS INFO BOX --- */
.skin-stats-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.stat-badge {
    background: rgba(255,255,255,0.6);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #444;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid rgba(255,255,255,0.8);
}

.stat-badge .stat-icon {
    font-size: 16px;
}

/* --- ANIMATION BARRE PROGRESSION --- */
@keyframes barFlash {
    0% { filter: brightness(1); }
    50% { filter: brightness(2); box-shadow: 0 0 15px white; }
    100% { filter: brightness(1); }
}

.flash-effect {
    animation: barFlash 0.4s ease-out;
}

/* === OVERRIDES POUR MOBILE === */
@media (max-width: 768px) {
    .skin-info-box {
        width: 100%;
        margin-top: -95px; /* L'effet de chevauchement spécifique au mobile */
    }
}

/* === OVERRIDES POUR DESKTOP === */
@media (min-width: 700px) {
    .skin-info-box {
        margin-top: 0px; /* Pas de chevauchement sur desktop */
    }
}

.skin-info-box h2 { margin: 0; font-size: 20px; color: #333; }

.skill-item-large {
    background: rgba(255,255,255,0.8);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

/* Barres de progression */
.global-progress-container {
    margin-top: 10px;
    width: 100%; 
    /* width: 80%; supprimé pour éviter conflit */
}

.global-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #555;
    font-weight: 700;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.global-progress-track {
    width: 100%;
    height: 16px;
    background: rgba(0,0,0,0.1);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.5);
}

.global-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #11998e 0%, #38ef7d 100%);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 0 5px rgba(56, 239, 125, 0.5);
}

.skin-mini-progress-container {
    width: 100%;
    height: 6px;
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
    margin: 8px 0;
    overflow: hidden;
}

.skin-mini-progress-bar {
    height: 100%;
    background: #667eea;
    width: 0%;
    border-radius: 3px;
}

.skin-card:hover .skin-mini-progress-bar {
    background: #4CAF50;
}

.skill-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.skill-info-group {
    display: flex;
    flex-direction: column; /* Mobile first: nom au dessus, bonus en dessous */
    align-items: flex-start;
}
@media (min-width: 400px) {
    .skill-info-group {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
}

.skill-title {
    font-weight: 800;
    color: #444;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.skill-current-bonus {
    font-size: 14px;
    font-weight: 700;
    color: #667eea; /* Couleur distinctive pour le bonus */
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- GROS CHIFFRE MASTERY LEVEL --- */
.mastery-display {
    text-align: center;
    margin: 10px 0;
}

.mastery-number {
    font-family: 'Knewave', 'Manrope', sans-serif; /* Police stylée si dispo */
    font-size: 48px;
    line-height: 1;
    font-weight: 900;
    color: #333;
    display: inline-block;
    transition: color 0.3s;
    text-shadow: 2px 2px 0px rgba(255,255,255,0.5);
}

/* Animation "POP" pour le chiffre */
@keyframes textPop {
    0% { transform: scale(1); color: #333; }
    50% { transform: scale(1.5); color: #FFC107; text-shadow: 0 0 10px #FFC107; }
    100% { transform: scale(1); color: #333; }
}

.pop-anim {
    animation: textPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- NETTOYAGE SKIN INFO BOX --- */
.skin-info-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.skill-title { font-weight: 800; color: #444; display: flex; gap: 8px; align-items: center; }
.skill-cost-btn { padding: 6px 12px; border-radius: 6px; font-weight: bold; border:none; cursor: pointer; transition: transform 0.1s; }
.skill-cost-btn:active { transform: scale(0.95); }

.big-progress-track {
    width: 100%; height: 12px; background: rgba(0,0,0,0.1); border-radius: 6px; overflow: hidden;
}
.big-progress-fill { height: 100%; background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); transition: width 0.4s ease; }
.skill-stats-text { display: flex; justify-content: space-between; font-size: 12px; color: #666; margin-top: 5px; font-weight: 600; }

/* =========================================
   TAB: QUESTS
   ========================================= */
.quests-container { display: flex; flex-direction: column; gap: 10px; }
.quest-item {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    padding: 12px;
    border-left: 5px solid #667eea;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.quest-header { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.quest-name { font-weight: 700; font-size: 14px; color: #333; }
.progress-bar { height: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: #4CAF50; }

/* =========================================
   TAB: SETTINGS
   ========================================= */
#tab-settings {
    padding-bottom: 30px;
}

#tab-settings .control-group {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

#tab-settings label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: #444;
    font-size: 14px;
    font-weight: 700;
}

#tab-settings .value-display {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}

#tab-settings select, 
#tab-settings input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 2px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    background: white;
    font-size: 14px;
    color: #333;
    outline: none;
    transition: border-color 0.2s;
}

#tab-settings select:focus { border-color: #667eea; }

#tab-settings .mode-btn {
    width: 100%;
    padding: 10px;
    background: #e0e0e0;
    color: #555;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    margin-top: 5px;
}
#tab-settings .mode-btn.active {
    background: #667eea;
    color: white;
}

.control-row {
    display: flex;
    gap: 15px;
    width: 100%;
}

.control-group.half-width {
    flex: 1; 
    margin-bottom: 0; 
}

.danger-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%); 
    color: #d63031;
    border: 1px solid #ff7675;
    font-weight: 800;
    margin-top: 15px;
    box-shadow: 0 4px 6px rgba(214, 48, 49, 0.2);
}
.danger-btn:hover { background: #ff7675; color: white; }

.toggle-switch-container { position: relative; width: 50px; height: 26px; }
.toggle-switch-container input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.toggle-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .toggle-slider { background-color: #667eea; }
input:checked + .toggle-slider:before { transform: translateX(24px); }


/* =========================================
   FLIGHT INSTRUMENTS
   ========================================= */
#flight-instruments {
    position: fixed;
    bottom: 30px;
    left: 10px;
    width: 170px;
    height: 150px;
    z-index: 900;
    pointer-events: none; 
}
#compass {
    position: absolute;
    bottom: -8px;
    right: 82px;
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    pointer-events: auto; 
    cursor: pointer;
    z-index: 100;
}

#compass * {
    pointer-events: none !important;
}

#compass-rose { position: absolute; width: 100%; height: 100%; top: 0; left: 0; }
.compass-mark { position: absolute; color: white; font-size: 14px; font-weight: bold; text-shadow: 0 0 3px rgba(0, 0, 0, 0.8); }
.compass-n { top: 5px; left: 50%; transform: translateX(-50%); color: #ff4444; }
.compass-e { right: 8px; top: 50%; transform: translateY(-50%); }
.compass-s { bottom: 5px; left: 50%; transform: translateX(-50%); }
.compass-w { left: 8px; top: 50%; transform: translateY(-50%); }

#compass-needle {
    position: absolute;
    width: 2px;
    height: 30px;
    background: linear-gradient(to bottom, #ff4444 0%, #ff4444 50%, white 50%, white 100%);
    top: 50%; left: 50%;
    transform-origin: center center;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease-out;
    box-shadow: 0 0 5px rgba(255, 68, 68, 0.8);
}
#compass-center {
    position: absolute; width: 8px; height: 8px; background: white; border-radius: 50%;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
}
#compass-degrees {
    position: absolute; bottom: -25px; left: 50%; transform: translateX(-50%);
    color: white; font-size: 12px; font-weight: bold;
    background: rgba(0, 0, 0, 0.6); padding: 2px 8px; border-radius: 10px;
}

#flight-instruments,
#speed-indicator {
    /* Le transform ne casse pas votre mise en page, il translate juste le bloc */
    transform: translateY(calc(-1 * var(--map-offset-bottom, 0px)));
    
    /* Animation fluide synchronisée avec l'ouverture de la map */
    transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    
    /* S'assure qu'ils restent cliquables et au-dessus du panel de la map */
    z-index: 10050 !important; 
}

#artificial-horizon {
    position: absolute;
    top: 96px; right: 0;
    width: 65px; height: 65px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}
#horizon-container { position: absolute; width: 200%; height: 200%; top: 50%; left: 50%; transform: translate(-50%, -50%); }
#horizon-sky { position: absolute; top: 0; left: 0; width: 100%; height: 50%; background: linear-gradient(to bottom, #2196F3, #64B5F6); }
#horizon-ground { position: absolute; top: 50%; left: 0; width: 100%; height: 50%; background: linear-gradient(to bottom, #8B4513, #654321); }
#horizon-line { position: absolute; top: 50%; left: 0; width: 100%; height: 2px; background: white; z-index: 4000; box-shadow: 0 0 5px white; }
#horizon-wings { position: absolute; width: 100%; height: 100%; top: 0; left: 0; pointer-events: none; z-index: 11; }
.wing-left, .wing-right { position: absolute; width: 16px; height: 2px; background: white; top: 50%; transform: translateY(-50%); box-shadow: 0 0 5px white; }
.wing-left { left: 8px; } .wing-right { right: 8px; }
#horizon-ball {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #FFD700; 
    border: 1px solid rgba(0,0,0,0.5);
    border-radius: 50%;
    margin-left:-5px;
    transform: translate(-50%, -50%);
    z-index: 100; 
    box-shadow: 0 0 4px rgba(0,0,0,0.8);
}

#speedometer {
    position: absolute;
    bottom: 91px; left: 9px;
    width: 65px; height: 65px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}
#speed-needle {
    position: absolute; bottom: 6%; left: 50%; width: 2px; height: 25px;
    background-color: rgb(0, 230, 118); transform-origin: center bottom;
    transition: transform 0.1s ease-out; box-shadow: 0 0 5px rgba(0, 230, 118, 0.8);
}
#speed-center { position: absolute; width: 6px; height: 6px; background: white; border-radius: 50%; top: 50%; left: 50%; transform: translate(-50%, -50%); }
#speed-value { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); color: white; font-size: 10px; font-weight: bold; }

/* =========================================
   HUD & WIDGETS
   ========================================= */
.hidden { display: none !important; }
#loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: white; text-align: center; }
.spinner { border: 4px solid rgba(255,255,255,0.3); border-top: 4px solid white; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 10px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.mode-toggle-btn { position: fixed; bottom: 80px; right: 10px; width: 35px; height: 35px; border-radius: 50%; background: rgba(0,0,0,0.6); color: white; border:none; cursor: pointer; z-index: 1000; backdrop-filter: blur(5px); }
#pause-btn { bottom: 125px; }
#fullscreen-btn { position: fixed; bottom: 10px; right: 10px; border-radius: 50%; width: 35px; height: 35px; background: rgba(0,0,0,0.5); color: white; border:none; z-index:999; backdrop-filter: blur(5px); font-size: 20px;}

#info { position: absolute; bottom: 20px; left: 20px; background: white; padding: 15px; border-radius: 8px; font-size: 12px; z-index: 1200; max-width: 300px; box-shadow: 0 5px 20px rgba(0,0,0,0.2); }
#info-close { position: absolute; top: 5px; right: 5px; border:none; background:none; cursor: pointer; font-size: 16px; color:#999; }

#altimeter-strip { position: fixed; left: 0; top: 0; bottom: 0; width: 6px; background: rgba(0,0,0,0.2); z-index: 800; display:flex; flex-direction:column; justify-content:flex-end;}
#altimeter-bar {
    width: 100%;
    position: absolute; 
    bottom: 0; 
    left: 0;
    background: linear-gradient(to top, #4CAF50 0%, #03A9F4 100%);
    transition: height 0.2s linear;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}
#altimeter-text { position: absolute; left: 10px; bottom: 10px; color: white; background: rgba(0,0,0,0.5); padding: 2px 4px; border-radius: 3px; font-size: 10px; font-family: monospace; }
#speed-control-indicator { position: fixed; bottom: 20px; right: 60px; color: white; background: rgba(0,0,0,0.5); padding: 5px 10px; border-radius: 15px; font-size: 12px; z-index: 100; backdrop-filter: blur(4px); text-align: center; }

/* =========================================
   RESPONSIVE MOBILE
   ========================================= */
@media (max-width: 768px) {
    #controls-panel { width: 100%; max-width: none; border-radius: 0; }
    
    .cards-grid { grid-template-columns: 1fr; }
    .world-card { width: 100%; }

    #skins-container,
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
        gap: 10px !important;
    }    #flight-instruments { bottom: 25px; left: 5px; transform: scale(0.9); transform-origin: bottom left; }
    .control-row { flex-direction: column; gap: 10px; }
    .control-group.half-width { width: 100%; }

    .skin-showcase { flex-direction: column; text-align: center; }
    .skin-preview-box-3d { width: 100%; height: 200px; }
    .skin-card {
        border-radius: 16px; 
    }
    
    .skin-card-inner-top {
        padding: 20px 15px 5px 15px !important;
        gap: 10px !important;
    }

    .skin-name {
        font-size: 16px !important; 
        margin-top: 0 !important; /* On retire l'ancien margin négatif */
        text-shadow: none !important; /* Plus d'ombre sale */
        margin-bottom: 12px !important;
    }
    
    .skin-card .unified-btn {
        font-size: 10px !important;
        padding: 5px 0 !important;
    }
    .world-card {
        height: 140px !important;
    }
    
    .world-card-content {
        padding: 10px !important;
    }
    
    .world-info h4 {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .world-info p {
        font-size: 10px;
        opacity: 0.8;
    }
    #flight-instruments {
        bottom: 25px;
        left: 5px;
        transform: translateY(calc(-1 * var(--map-offset-bottom, 0px))) scale(0.9);
        transform-origin: bottom left;
    }
    
    #speed-indicator {
        transform: translateY(calc(-1 * var(--map-offset-bottom, 0px))) scale(0.9);
        transform-origin: bottom left;
    }
}

.skin-name-title {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skin-preview-box-3d {
    width: 100%; 
    height: 350px; 
    border-radius: 16px; 
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.1) 70%);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
}
#skin-level-header {
    width: 100%;
    height: 350px; 
    margin-bottom: 20px;
    display: block;
}
/* === MISE EN PAGE DESKTOP === */
@media (min-width: 700px) {
    .skin-info-box { margin-top:0px; }
    #tab-skills.active {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto 1fr; 
        gap: 30px;
        height: 100%;
        overflow: hidden; 
    }

    #skin-level-header {
        height: 100%;
        margin-bottom: 0;
    }

    .skin-preview-box-3d {
        flex: 1;
        height: auto; 
        max-width: none;
        border: 2px solid rgba(255,255,255,0.8);
        background: radial-gradient(circle at center, rgba(255,255,255,0.9) 0%, rgba(200,200,255,0.2) 100%);
    }

    #skills-container {
        grid-column: 2;
        grid-row: 2;
        padding-right: 10px;
        overflow-y: auto; 
        padding-bottom: 20px;
    }

    #tab-skills .section-header {
        grid-column: 1 / -1;
        grid-row: 1;
        margin-bottom: 0;
    }
}

/* =========================================
   BOUTONS UNIFIÉS
   ========================================= */
.unified-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%; 
}

.unified-btn:active { transform: scale(0.95); }

.btn-buy { background: #667eea; color: white; }
.btn-buy:hover { background: #5a6fd6; }

.btn-equip { background: #4CAF50; color: white; }
.btn-equip:hover { background: #43A047; }

.btn-travel {
    background: linear-gradient(135deg, #FFC107 0%, #FF9800 100%);
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-active, .btn-owned {
    background: #e0e0e0;
    color: #888;
    cursor: default;
    box-shadow: none;
}
.btn-locked {
    background: #f5f5f5;
    color: #bbb;
    cursor: not-allowed;
}

/* =========================================
   SLIDER DE ZOOM VERTICAL
   ========================================= */
.preview-container-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
}

.zoom-slider-container {
    position: absolute;
    left: 10px;
    top: 20px;
    bottom: 20px;
    width: 30px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    padding: 10px 0;
    backdrop-filter: blur(2px);
}

input[type=range].vertical-slider {
    writing-mode: bt-lr; 
    -webkit-appearance: slider-vertical; 
    width: 8px;
    height: 100%;
    outline: none;
    background: transparent;
}

.zoom-icon {
    font-size: 12px;
    color: #555;
    font-weight: bold;
    margin-bottom: 5px;
}

/* =========================================
   NOTIFICATIONS (TOASTS)
   ========================================= */
#notification-area {
    position: fixed;
    top: 80px; 
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.game-toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 2px solid #FFD700; 
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 250px;
}

.game-toast.show { opacity: 1; transform: translateY(0); }
.game-toast.hide { opacity: 0; transform: translateY(-20px); }

.toast-icon {
    font-size: 20px;
    background: #FFF9C4;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-content {
    font-weight: 700;
    color: #333;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toast-bonus {
    color: #4CAF50;
    font-weight: 800;
    font-size: 14px;
    margin-left: auto;
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}
@media (max-width: 768px) {
.zoom-slider-container {
    bottom:90px;
}
}



/* Focus pour la navigation à la manette */
.gamepad-focus {
    outline: 3px solid #ffff00 !important; /* Bordure jaune brillante */
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.8) !important;
    transform: scale(1.05); /* Légère mise en avant */
    z-index: 100;
    transition: all 0.1s ease;
}

/* Cas spécifiques pour ne pas casser la mise en page */
.tab-btn.gamepad-focus {
    background: rgba(255, 255, 255, 0.2);
}

/* Focus sur les sélecteurs et checkbox */
select.gamepad-focus, input[type="checkbox"].gamepad-focus + label {
    border-color: #ffff00;
}

/* === OPTIMISATION MOBILE PAYSAGE (LANDSCAPE) === */
/* Cette section écrase les styles pour maximiser la visibilité sur les écrans larges mais peu hauts (ex: iPhone en paysage) */
@media (max-height: 550px) and (orientation: landscape) {
    #controls-panel {
        padding: 5px 15px !important; /* Réduit drastiquement le padding */
    }

    /* En-tête ultra compact en ligne */
    #panel-header {
        margin-bottom: 5px !important;
        padding-bottom: 0 !important;
        display: flex;
        align-items: center;
        height: 30px;
    }

    #panel-header h1 {
        font-size: 20px !important; /* Titre réduit */
        margin-left: 0 !important;
    }
    
    #collapse-btn {
        padding: 2px 8px !important;
        font-size: 12px !important;
    }

    /* Onglets ultra fins */
    #tabs-navigation {
        margin-bottom: 5px !important;
        padding: 2px !important;
        height: 35px;
        min-height: 0 !important;
    }

    .tab-btn {
        flex-direction: row !important; /* Icône à côté du texte au lieu d'au-dessus */
        padding: 2px 5px !important;
        gap: 5px;
    }
    
    .tab-btn .tab-icon {
        font-size: 14px !important;
        margin-bottom: 0px !important;
    }
    
    .tab-label {
        font-size: 10px !important;
    }
    
    /* Zone de contenu maximisée */
    #panel-scroll-content {
        padding-top: 0px;
        padding-bottom: 10px !important; /* On retire l'espace vide en bas */
    }

    /* Titres de section (Select Destination, etc.) plus petits */
    .section-header {
        margin-bottom: 5px !important;
        padding-bottom: 2px !important;
    }
    .section-header h3 {
        font-size: 14px !important;
    }
    .points-balance {
        padding: 2px 8px !important;
        font-size: 11px !important;
    }

    /* Optimisation Grille Cartes (Worlds & Skins) */
    .cards-grid, #skins-container {
        grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)) !important;
        gap: 8px !important;
    }

    /* Cartes Mondes Compactes */
    .world-card {
        height: 110px !important;
    }
    .world-card-content {
        padding: 8px !important;
    }
    .world-info h4 { font-size: 13px !important; }

    /* Cartes Skins Compactes */
    .skin-card {
        border-radius: 12px !important;
    }
    .skin-image-wrapper {
        margin-bottom: 2px !important;
        border-radius: 10px !important;
    }
    .skin-name {
        margin-top: -35px !important;
        font-size: 14px !important;
    }

    .skin-preview-box-3d {
        height: 160px !important; 
        border-radius: 10px !important;
    }
    #skin-level-header {
        height: 160px !important;
        margin-bottom: 10px !important;
    }
}


@keyframes textBlinkRed {
    0%, 100% { 
        color: white; 
        text-shadow: 0 0 2px black; 
        transform: scale(1);
    }
    50% { 
        color: #ff3333; 
        text-shadow: 0 0 10px #ff0000; 
        transform: scale(1.1); 
    }
}

@keyframes barBlinkRed {
    0%, 100% { 
        filter: brightness(1) hue-rotate(0deg);
        box-shadow: none;
    }
    50% { 
        /* Astuce: on change la teinte et la saturation pour simuler le rouge sans casser le gradient */
        filter: brightness(1.5) sepia(1) saturate(5) hue-rotate(-50deg);
        box-shadow: 0 0 15px #ff0000;
    }
}

/* Application de l'alerte */
.altitude-warning #altimeter-text {
    animation: textBlinkRed 0.5s ease-in-out infinite alternate !important;
    font-weight: 900 !important;
    color: #ff3333 !important; /* Couleur de repli si l'anim échoue */
}

.altitude-warning #altimeter-bar {
    /* On utilise filter au lieu de background pour garder la performance et le gradient */
    animation: barBlinkRed 0.5s ease-in-out infinite alternate !important;
    border-top: 2px solid white;
}


#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4); /* Assombrit légèrement le fond */
    backdrop-filter: blur(3px); /* Le décor sera flouté en arrière-plan */
    z-index: 10000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#start-title {
    font-family: 'Knewave', 'Manrope', sans-serif;
    font-size: 128px; /* Agrandissement (était 64px) */
    color: #ffffff;
    text-shadow: 0 4px 15px rgba(0,0,0,0.3), 0 0 30px rgba(102, 126, 234, 0.4);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

.start-modal {
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 340px;
    text-align: center;
    backdrop-filter: blur(3px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    opacity: 0;
    visibility: hidden;
    animation: modalFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) 3.1s forwards;
}

@keyframes modalFadeIn {
    0% {
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    #start-title { font-size: 60px; min-height: 50px; }
    .start-modal { width: 90%; padding: 30px; }
}

.fade-letter {
    opacity: 0;
    display: inline-block;
    animation: fadeLetterAnim 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards; 
}

@keyframes fadeLetterAnim {
    0% {
        opacity: 0;
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
    }
}