/* ============================================================
   SECTION 1 : TA BASE D'ORIGINE (MENU & BOUTONS VR)
   ============================================================ */

#menu-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background: rgba(24, 22, 32, 0.8);
    transition: opacity 0.5s ease;
    perspective: 500px;
}

#menu-container.hidden {
    opacity: 0;
    pointer-events: none;
}

#menu-main {
    display: flex;
    flex-direction: column;
    transform: rotateX(10deg);
    animation: rotateAngle 6s linear infinite;
}

/* --- BOUTONS VR --- */
button {
    display: block;
    position: relative;
    margin: 0.5em 0;
    padding: .8em 2.2em;
    cursor: pointer;
    background: #FFFFFF;
    border: none;
    border-radius: .4em;
    text-transform: uppercase;
    font-size: 1.4em;
    font-family: sans-serif;
    font-weight: 500;
    letter-spacing: 0.04em;
    mix-blend-mode: color-dodge;
    transform-style: preserve-3d;
    transition: background 0.3s;
}

button span {
    display: block;
    mix-blend-mode: none;
    position: relative;
    z-index: 2;
    color: #181620;
}

button:before, button:after {
    --z: 0px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    mix-blend-mode: inherit;
    border-radius: inherit;
    transform-style: preserve-3d;
    pointer-events: none;
    content: '';
}

button:after { background-color: #5D00FF; }
button:before { background-color: #FF1731; }

button:hover {
    background-color: #FFF65B;
    transition: background .3s 0.1s;
}

button:hover:before {
    opacity: 1;
    --z: 0.04;
    animation: translateWobble 2.2s ease forwards;
}

button:hover:after {
    opacity: 1;
    --z: -0.06;
    animation: translateWobble 2.2s ease forwards;
}

/* ============================================================
   SECTION 2 : LE SÉLECTEUR DE PERSONNAGES (GRID FIX)
   ============================================================ */

#skin-selector {
    position: absolute;
    width: 85%;
    height: 85%;
    background: rgba(24, 22, 32, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    border-radius: 20px;
    border: 3px solid #5D00FF;
    z-index: 20;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

#skin-selector.hidden { display: none; }

/* LA GRILLE : Empêche la superposition */
.skin-grid {
    display: grid;
    /* Définit des colonnes propres sans chevauchement */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    grid-auto-rows: min-content;
    gap: 20px; 
    width: 100%;
    max-height: 70vh;
    overflow-y: auto; 
    padding: 15px;
    margin-bottom: 20px;
    align-content: start;
}

/* L'ITEM CARRÉ */
.skin-item {
    position: relative;
    aspect-ratio: 1 / 1; /* Carré parfait */
    background: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.skin-item:hover {
    transform: translateY(-5px);
    border-color: #FFF65B;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

/* Image à l'intérieur du carré */
.skin-item img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
}

/* Nom du personnage */
.skin-label {
    background: rgba(0, 0, 0, 0.75);
    color: #FFF65B;
    width: 100%;
    padding: 8px 0;
    text-align: center;
    font-size: 0.85em;
    font-family: sans-serif;
    font-weight: bold;
    z-index: 2;
    text-transform: uppercase;
}

/* ============================================================
   SECTION 3 : SYSTÈME DE COOLDOWN
   ============================================================ */

.cooldown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 23, 49, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5em;
    color: white;
    font-weight: 900;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.skin-grid.locked .cooldown-overlay {
    opacity: 1;
}

.skin-grid.locked .skin-item {
    filter: grayscale(1);
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   SECTION 4 : ANIMATIONS
   ============================================================ */

@keyframes rotateAngle {
    0%, 50%, 100% { transform: rotateY(0deg) rotateX(10deg); }
    25% { transform: rotateY(20deg) rotateX(10deg); }
    75% { transform: rotateY(-20deg) rotateX(10deg); }
}

@keyframes translateWobble {
  0% { opacity: 0; transform: translate3d(0, 0, 0); }
  16% { transform: translate3d(calc(var(--z) * 160px), calc(var(--z) * 160px), calc(var(--z) * 160px)); }
  28% { opacity: 1; transform: translate3d(calc(var(--z) * 70px), calc(var(--z) * 70px), calc(var(--z) * 70px)); }
  100% { opacity: 1; transform: translate3d(calc(var(--z) * 100px), calc(var(--z) * 100px), calc(var(--z) * 100px)); }
}