* {
    box-sizing: border-box;
}
body {
    background: rgb(0, 0, 0);
    font-family: 'Roboto', sans-serif;
    margin: 0px;
    padding: 0px;	
    width: 100%;
    height: 800px;
    margin: 0px;
    overflow: hidden;
}

div.gallery{
    display: grid;  
    background-color: rgba(255, 255, 255, 0.50);
    width: auto;
    margin: 0px;
    filter: invert(0) blur(0px) grayscale(0%);
} 
div.gallery > ul{
    --e-s: 100px;
    /* grid-template-columns: repeat(8,1fr); */
    grid-template-columns: var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s)  var(--e-s) var(--e-s);
    grid-template-rows: var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s) var(--e-s);
    grid-auto-rows: auto;
    display: grid;
    flex-wrap: wrap;
    flex-direction: row;
/*     justify-items: left;
    align-items: start; */
    background: rgba(255, 255, 255, 0);
    margin: 0px;
    padding: 0px;
}
div.gallery > ul > li{
    display: grid;
    width: 100px;
    height: 100px;
    margin: -120px;
    filter: blur(0px);
    transform: rotate(0deg) scale(100%);
    background-color: rgba(255, 255, 255, 0.0);
    opacity: 1;
}
div.gallery > ul > li > div#cube{
    display: grid;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0);
    margin: 0px;
    padding: 0px;
    opacity: 1;
}
div.gallery > ul > li > div#cube > svg{
    width: 220%;
    /* height: 200%; */
    background-color: rgba(255, 255, 255, 0);
    margin: 0px;
    padding: 0px;
    cursor: cursor;  /* -crosshair- */

}

div.gallery > ul > li > div#cube > svg:active{
    filter: drop-shadow(25px 25px 25px rgba(255, 255, 255, 0)) contrast(100%) hue-rotate(270deg) invert(0) blur(0px);
    background-color: rgba(255, 255, 255, 0);
    transform: rotate(90deg) scale(100%);
    transition-duration: 0s;
    transition-timing-function: ease-out;
}

.st0{
    /* transition: all 2s ease-out; */
    stroke-width: 0px;
    stroke-linecap: round;      /*  (butt / round / square) */
    stroke-linejoin: round;   /*  (miter / round / bevel) */
    stroke-miterlimit: 100;
    transform: scale(100%) rotate(0deg) translate(0px, 0px);
}

.st1,
.st2,
.st3,
.st4,
.st5,
.st6,
.st8,
.st9,
.st10,
.st11,
.st12,
.st13{
    transition: color 2s ease-out;
    transform: scale(100%) rotate(0deg) translate(0px, 0px);
}

:root{
    --st0: opacity:0.5;
    --st1: #FF00FF;
    --st2: #FF0000;
    --st3: #0000FF;
    --st4: #00FF00;
    --st5: #00FFFF;
    --st6: #FFFF00;
    --st7: opacity: 0.5;
    --st8: #383838;
    --st9: #606060;
    --st10: #848484;
    --st11: #CCCCCC;
    --st12: #A8A8A8;
    --st13: #E8E8E8;
}

.st0{
    opacity:0.5;
    fill: var(--st0);
}
.st1{
    fill: var(--st1);
    stroke: var(--st13);
    /* stroke:#383838; */
}
.st2{
    fill: var(--st2);
    stroke: var(--st12);
    /* stroke:#606060; */
}
.st3{
    fill: var(--st3);
    stroke: var(--st11);
    /* stroke:#848484; */
}
.st4{
    fill: var(--st4);
    stroke: var(--st10);
    /* stroke:#CCCCCC; */
}
.st5{
    fill: var(--st5);
    stroke: var(--st9);
    /* stroke:#A8A8A8; */
}
.st6{
    fill: var(--st6);
    stroke: var(--st8);
    /* stroke:#E8E8E8; */
}
.st7{
    fill: var(--st7);
    opacity:0.5;
}
.st8{
    fill: var(--st8);
    stroke: var(--st6);
    /* stroke:#FF00FF; */
}
.st9{
    fill: var(--st9);
    stroke: var(--st5);
    /* stroke:#FF0000; */
}
.st10{
    fill: var(--st10);
    stroke: var(--st4);
    /* stroke:#0000FF; */
}
.st11{
    fill: var(--st11);
    stroke: var(--st3);
    /* stroke:#00FF00; */
}
.st12{
    fill: var(--st12);
    stroke: var(--st2);
    /* stroke:#00FFFF; */
}
.st13{
    fill: var(--st13);
    stroke: var(--st1);
    /* stroke:#FFFF00; */
}

div#content{
    position: absolute;
    /* z-index: 1; */
}

div#elementH{
    display: block;
    /* z-index: 2; */
    position: fixed;
    background-color: rgba(0, 0, 0, 0);
    width: 200px;
    height: 600px;
    border-color: rgb(255, 255, 255);
    border-style: solid;
    border-radius: 0px;
    border-width: 0px;
    margin: 0px;
    padding-top: 0px;

}
div#elementH > div{
    width: 250px;
    height: 400px;
}

div#txt{
    background-color: lawngreen;
    width: 300px;
    height: 200px;
    margin-top: 300px;
}

p {
    display: block;
    color: rgb(255, 255, 255);
    font-size: 13px;
    margin-block-start: 1px;
    margin-block-end: 1px;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
}

h1 {
    display: block;
    color: rgb(255, 255, 255);
    font-size: 15px;
    margin: 0px;
    margin-block-start: 1px;
    margin-block-end: 1px;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
}

button {
    width: 160px;
    height: auto;
    appearance: auto;
    /* -webkit-writing-mode: horizontal-tb !important; */
    font-style: normal;
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
    text-rendering: auto;
    color: -internal-light-dark(black, white);
    letter-spacing: normal;
    word-spacing: normal;
    line-height: normal;
    text-transform: none;
    text-indent: 0px;
    text-shadow: none;
    display: inline-block;
    text-align: center;
    align-items: flex-start;
    cursor: pointer;
    box-sizing: border-box;
    background-color: -internal-light-dark(rgb(239, 239, 239), rgb(59, 59, 59));
    margin-left: 0em;
    padding: 1px 6px;
    border-width: 2px;
    border-style: outset;
    border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
    border-image: initial;
}
button#cellules {
    width: 160px;
    height: 25px;
    appearance: auto;
    /* -webkit-writing-mode: horizontal-tb !important; */
    font-style: normal;
    font-size: 12px;
    font-family: Arial, Helvetica, sans-serif;
    text-rendering: auto;
    color: -internal-light-dark(black, white);
    letter-spacing: normal;
    word-spacing: normal;
    line-height: normal;
    text-transform: none;
    text-indent: 0px;
    text-shadow: none;
    display: inline-block;
    text-align: center;
    align-items: flex-start;
    cursor: default;
    box-sizing: border-box;
    background-color: -internal-light-dark(rgb(239, 239, 239), rgb(59, 59, 59));
    margin-left: 25px;
    margin-top: 425px;
    padding: 1px 6px;
    border-width: 2px;
    border-style: outset;
    border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
    border-image: initial;
}



/* --- NOUVEAU STYLE SIDEBAR --- */


#sidebar {
    position: fixed;
    top: 0;
    left: -300px; /* Caché par défaut */
    width: 300px;
    height: 100vh;
    background: rgba(20, 20, 20, 0.25);
    backdrop-filter: blur(0px);
    z-index: 1000; /* Au dessus de tout */
    padding: 0;
    overflow-y: auto;
    transition: left 0.7s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-right: 0px solid #444;
    font-family: 'Roboto', sans-serif;
}

#sidebar.open { left: 0; }

.sidebar-header {
    position: sticky;
    top: 0;
    background: rgba(20, 20, 20, 0.00);
    backdrop-filter: blur(0px);
    padding: 20px;
    border-bottom: 0px solid #333;
    display: flex;
    justify-content: flex-end;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: 1.8rem;
    margin: 0;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-left: 50px;
}

.sidebar-content { padding-top: 5px; padding-bottom: 5px; padding-right: 20px; padding-left: 20px; color: #fff; }

/* Bouton Menu Burger */
#menu-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(4px);
}

#menu-btn:hover { background: rgba(255, 255, 255, 0.5); border-color: #fff; }

#menu-btn span {
    display: block;
    width: 24px;
    height: 3px;
    background-color: #fff;
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

/* Déplacement du bouton quand le menu est ouvert */
#sidebar.open ~ #menu-btn { left: 320px; }

/* Animation Croix */
#sidebar.open #menu-btn span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
#sidebar.open #menu-btn span:nth-child(2) { opacity: 0; width: 0%; }
#sidebar.open #menu-btn span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* Styles des contrôles dans la sidebar */
label { display: block; font-size: 1.1rem; color: #ffffff; margin-top: 15px; margin-bottom: 5px; }
input[type=range] { width: 100%; background: transparent; -webkit-appearance: none; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; height: 12px; width: 12px; border-radius: 50%;
    background: #fff; cursor: pointer; margin-top: -6px;
}
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 1px; background: #ffffff; border-radius: 1px; }

button.ctrl-btn {
    width: 100%; padding: 10px; margin-top: 10px; background: #ffffff1b;
    color: white; border: 1px solid #ffffffaa; cursor: pointer; font-size: 1.1rem;
    /*text-transform: uppercase;*/ 
}
button.ctrl-btn:hover { background: #ffffff2c; }

#text-display-area {
    margin-top: 20px; padding: 10px; background: #222; border: 1px solid #444;
    color: #0f0; font-family: monospace; min-height: 40px; word-break: break-all;
}
input[type="text"] { width: 100%; padding: 8px; background: #333; border: 1px solid #555; color: white; margin-top: 5px; }

/* Filtres globaux */
.filter-invert { filter: invert(1) !important; }
.filter-grayscale { filter: grayscale(100%) !important; }

/* Cachez  #elementH */
#elementH { display: none; }


/* --- _________________________________RESPONSIVE_________________________________ --- */

/* --- MODE MOBILE (Smartphone) --- */
/* Moins de 768px de large */
@media screen and (max-width: 768px) {
    
    /* Cacher complètement la sidebar et le bouton burger sur mobile */
    #sidebar, #menu-btn {
        display: none !important;
    }

    /* On crée le bouton "Roulette" unique */
    #mobile-random-btn {
        display: flex; /* Visible sur mobile */
        position: fixed;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 2000;
        
        /* Style visuel similaire aux boutons ctrl-btn mais adapté */
        width: 60px;
        height: 60px;
        border-radius: 50%; /* Rond */
        background: rgba(255, 255, 255, 0.15); /* Transparent */
        backdrop-filter: blur(5px);
        border: 1px solid rgba(255, 255, 255, 0.4);
        color: white;
        cursor: pointer;
        padding: 0;
        justify-content: center;
        align-items: center;
        font-size: 24px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        transition: transform 0.2s, background 0.3s;
        outline: none;
        -webkit-tap-highlight-color: transparent;
    }

    #mobile-random-btn:active {
        transform: translateX(-50%) scale(0.9);
        background: rgba(255, 255, 255, 0.4);
    }

    /* Bouton random tout "?" */
    #mobile-random-btn::after {
        content: '?';
        /*  content: '🎲';      */
        font-size: 28px;
    }
}

/* --- MODE TABLETTE & DESKTOP (> 768px) --- */
@media screen and (min-width: 769px) {
    /* On s'assure que le bouton mobile est caché sur les grands écrans */
    #mobile-random-btn {
        display: none !important;
    }
}


/* --- _________________________________ IPHONE RESPONSIVE _________________________________ --- */



/* Ajustements généraux pour iOS : évite le zoom automatique et le rebond de scroll */
html, body {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* Utilise la vraie hauteur visible sur mobile (barre d'URL Safari) */
@supports (height: 100dvh) {
    #sidebar { height: 100dvh; }
}

/* --- iPhones "classiques" (SE, 8, mini...) --- */
@media screen and (max-width: 375px) {
    div.gallery > ul {
        --e-s: 70px; /* cellules plus petites */
    }
    div.gallery > ul > li {
        width: 70px;
        height: 70px;
        margin: -84px;
    }
    div.gallery > ul > li > div#cube > svg {
        width: 180%;
    }
    #mobile-random-btn {
        width: 52px;
        height: 52px;
        bottom: 20px;
    }
    #mobile-random-btn::after { font-size: 22px; }
}

/* --- iPhones récents (12/13/14/15) --- */
@media screen and (min-width: 376px) and (max-width: 430px) {
    div.gallery > ul {
        --e-s: 80px;
    }
    div.gallery > ul > li {
        width: 80px;
        height: 80px;
        margin: -96px;
    }
    div.gallery > ul > li > div#cube > svg {
        width: 200%;
    }
}

/* --- iPhones Pro Max / Plus --- */
@media screen and (min-width: 431px) and (max-width: 480px) {
    div.gallery > ul {
        --e-s: 90px;
    }
    div.gallery > ul > li {
        width: 90px;
        height: 90px;
        margin: -108px;
    }
    div.gallery > ul > li > div#cube > svg {
        width: 210%;
    }
}

/* --- Gestion de l'encoche / Dynamic Island (safe-area) --- */
@supports (padding: max(0px)) {
    #mobile-random-btn {
        bottom: max(20px, env(safe-area-inset-bottom));
        left: calc(50% + env(safe-area-inset-left) / 2 - env(safe-area-inset-right) / 2);
    }
    #menu-btn {
        top: max(20px, env(safe-area-inset-top));
        left: max(20px, env(safe-area-inset-left));
    }
    #sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    #sidebar.open ~ #menu-btn {
        left: calc(320px + env(safe-area-inset-left));
    }
}

/* --- Orientation paysage sur iPhone --- */
@media screen and (max-width: 932px) and (orientation: landscape) {
    /* La sidebar devient plus large que haute : on la réduit */
    #sidebar {
        width: 240px;
        left: -260px;
    }
    #sidebar.open { left: 0; }
    #sidebar.open ~ #menu-btn { left: 260px; }

    #mobile-random-btn {
        bottom: 12px;
        width: 48px;
        height: 48px;
    }
    #mobile-random-btn::after { font-size: 20px; }

    /* La galerie doit rester centrée verticalement */
    div.gallery > ul {
        --e-s: 60px;
    }
    div.gallery > ul > li {
        width: 60px;
        height: 60px;
        margin: -72px;
    }
    div.gallery > ul > li > div#cube > svg {
        width: 160%;
    }
}

/* --- Écrans Retina iPhone (rendu net) --- */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    div.gallery > ul > li > div#cube > svg {
        shape-rendering: geometricPrecision;
    }
}

/* --- Empêche le double-tap de zoom sur les boutons --- */
button, #menu-btn, #mobile-random-btn {
    touch-action: manipulation;
}

/* --- Ajustements des contrôles sidebar sur iPhone --- */
@media screen and (max-width: 430px) {
    #sidebar { width: 85vw; left: -90vw; }
    #sidebar.open { left: 0; }
    #sidebar.open ~ #menu-btn {
        left: calc(85vw + 10px);
    }
    .sidebar-content { padding-left: 15px; padding-right: 15px; }
    button.ctrl-btn { padding: 12px; font-size: 1rem; } /* tap targets plus grands */
    input[type=range]::-webkit-slider-thumb {
        height: 20px; width: 20px; /* plus facile à saisir au doigt */
        margin-top: -10px;
    }
    input[type=range]::-webkit-slider-runnable-track { height: 2px; }
}