/* Wrapper global */
.wp2048-wrapper {
    max-width: 360px;
    margin: 2rem auto;
    padding-top: 1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    border-radius: 12px;
    background: #faf8ef;
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    position: relative;
}

/* Header */
.wp2048-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.wp2048-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #776e65;
}

.wp2048-scores {
    display: flex;
    gap: 0.3rem;
}

.wp2048-score-box {
    background: #bbada0;
    color: #f9f6f2;
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
margin-left:0.2rem;
    text-align: center;
    min-width: 64px;
}

.wp2048-score-box .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wp2048-score-box .value {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
}

/* Controls */
.wp2048-controls {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.75rem;
}

.wp2048-new-game {
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.9rem;
    background: #8f7a66;
    color: #f9f6f2;
    cursor: pointer;
    font-size: 0.85rem;
}

.wp2048-new-game:hover {
    filter: brightness(1.05);
}

/* Grille */
.wp2048-grid {
    position: relative;
    background: #bbada0;
    border-radius: 6px;
    padding: 8px;
    display: grid;
    gap: 8px;
    margin-bottom: 0.75rem;
}

.wp2048-wrapper[data-size="4"] .wp2048-grid {
    grid-template-columns: repeat(4, 1fr);
}
.wp2048-wrapper[data-size="5"] .wp2048-grid {
    grid-template-columns: repeat(5, 1fr);
}
.wp2048-wrapper[data-size="6"] .wp2048-grid {
    grid-template-columns: repeat(6, 1fr);
}

/* Cellule */
.wp2048-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #cdc1b4;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: #776e65;
    box-sizing: border-box;
    transition: transform 0.12s ease-out;
}

/* Styles pour les valeurs */
.wp2048-cell.value-2    { background: #eee4da; color: #776e65; }
.wp2048-cell.value-4    { background: #ede0c8; color: #776e65; }
.wp2048-cell.value-8    { background: #f2b179; color: #f9f6f2; }
.wp2048-cell.value-16   { background: #f59563; color: #f9f6f2; }
.wp2048-cell.value-32   { background: #f67c5f; color: #f9f6f2; }
.wp2048-cell.value-64   { background: #f65e3b; color: #f9f6f2; }
.wp2048-cell.value-128  { background: #edcf72; color: #f9f6f2; font-size: 1.1rem; }
.wp2048-cell.value-256  { background: #edcc61; color: #f9f6f2; font-size: 1.1rem; }
.wp2048-cell.value-512  { background: #edc850; color: #f9f6f2; font-size: 1.1rem; }
.wp2048-cell.value-1024 { background: #edc53f; color: #f9f6f2; font-size: 1rem; }
.wp2048-cell.value-2048 { background: #edc22e; color: #f9f6f2; font-size: 1rem; }

/* Animations de déplacement */
.wp2048-anim-from-left {
    animation: wp2048-slide-from-left 0.30s ease-out;
}
.wp2048-anim-from-right {
    animation: wp2048-slide-from-right 0.30s ease-out;
}
.wp2048-anim-from-up {
    animation: wp2048-slide-from-up 0.30s ease-out;
}
.wp2048-anim-from-down {
    animation: wp2048-slide-from-down 0.30s ease-out;
}

/* Pop-in des nouvelles tuiles */
.wp2048-anim-spawn {
    animation: wp2048-pop-in 0.30s ease-out;
}

/* Animation de fusion (pop) */
.wp2048-anim-merge {
    animation: wp2048-merge-pop 0.30s ease-out;
}

/* KEYFRAMES */
@keyframes wp2048-slide-from-left {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}
@keyframes wp2048-slide-from-right {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
@keyframes wp2048-slide-from-up {
    from { transform: translateY(-100%); }
    to   { transform: translateY(0); }
}
@keyframes wp2048-slide-from-down {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@keyframes wp2048-pop-in {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

@keyframes wp2048-merge-pop {
    0%   { transform: scale(0.9); }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Overlay fin de partie */
.wp2048-overlay {
    position: absolute;
    inset: 0;
    background: rgba(238, 228, 218, 0.75);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    z-index: 10;
}

.wp2048-hidden {
    display: none;
}

.wp2048-message {
    font-size: 1.3rem;
    font-weight: 700;
    color: #776e65;
    margin-bottom: 0.75rem;
    text-align: center;
    padding: 0 1rem;
}

.wp2048-restart {
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    background: #8f7a66;
    color: #f9f6f2;
    cursor: pointer;
    font-size: 0.9rem;
}

.wp2048-restart:hover {
    filter: brightness(1.05);
}

/* Aide */
.wp2048-help {
    font-size: 0.8rem;
    line-height: 1rem;
    color: #776e65;
    margin: 0;
}

.wp_link {
    font-size: 0.8rem;
    line-height: 1rem;
    color: #776e65;
    margin: 0;
    padding-bottom: 0.5rem;
}

.wp_link img {
    margin-top: 0.5rem;
    border: 1px solid #ccc;
}

/* ===== GLITCH : grille 10×10 ===== */

/* La grille de Glitch utilise un layout en 10 colonnes */
.wpglitch-wrapper .wpglitch-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    margin-top: 10px;
}

/* Chaque case : carré via aspect-ratio */
.wpglitch-wrapper .wpglitch-cell {
    float: none;
    width: 100%;
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: bold;
    border-radius: 4px;
    font-size: 12px;
}

/* Cases encore disponibles */
.wpglitch-wrapper .wpglitch-cell.glitch-safe {
    background: #eee4da;
}

/* Cases déjà "glitched" / effacées */
.wpglitch-wrapper .wpglitch-cell.glitch-hole {
    background: #cdc1b4;
}

/* Joueur bien visible */
.wpglitch-wrapper .wpglitch-cell.glitch-player {
    background: #f67c5f;
    color: #f9f6f2;
}

/* ===== ECHO : labyrinthe sonore ===== */

.wpecho-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    margin-top: 10px;
}

.wpecho-cell {
    float: none;
    width: 100%;
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    transition: opacity 0.4s ease-out;
    opacity: 0;
}

/* par défaut, sol "neutre" */
.wpecho-cell.echo-floor {
    background: #cdc1b4;
}

/* murs */
.wpecho-cell.echo-wall {
    background: #776e65;
}

/* sortie */
.wpecho-cell.echo-exit {
    background: #8f7a66;
    color: #f9f6f2;
}

/* joueur */
.wpecho-cell.echo-player {
    background: #f67c5f;
    color: #f9f6f2;
    font-weight: bold;
}

/* non visible */
.wpecho-cell.echo-hidden {
    opacity: 0;
}

/* visible (écho) */
.wpecho-cell.echo-visible {
    opacity: 1;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.25) inset;
}

/* ===== SWAP GRID : grille qui change de règles ===== */

.wpswap-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    margin-top: 10px;
}

.wpswap-cell {
    float: none;
    width: 100%;
    height: auto;
    padding-bottom: 0;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
}

/* types de cases */
.wpswap-cell.swap-empty {
    background: #cdc1b4;
}

.wpswap-cell.swap-wall {
    background: #776e65;
}

.wpswap-cell.swap-teleport {
    background: #8f7a66;
    color: #f9f6f2;
}

.wpswap-cell.swap-slide {
    background: #f2b179;
    color: #f9f6f2;
}

.wpswap-cell.swap-switch {
    background: #f59563;
    color: #f9f6f2;
}

/* joueur */
.wpswap-cell.swap-player {
    background: #23b68d;
    color: #de2c2c;
    font-weight: bold;
}

/* ===== PIXELFALL : Tetris-like pixelisé ===== */

.wppixelfall-grid {
    display: grid;
    grid-template-columns: repeat(var(--wppf-cols, 10), 1fr);
    gap: 2px;
    margin-top: 10px;
}

/* on écrase les tailles de wp2048-cell pour ce jeu */
.wppixelfall-cell {
    float: none !important;
    width: 100%;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    font-size: 11px;
}

/* Fonds de base */
.wppixelfall-cell.pfall-empty {
    background: #cdc1b4;
}

/* blocs parasites */
.wppixelfall-cell.pfall-noise {
    background: #3c3a32;
}

/* blocs verrouillés */
.wppixelfall-cell.pfall-solid {
    background: #8f7a66;
}

/* bloc actif */
.wppixelfall-cell.pfall-active {
    box-shadow: 0 0 4px rgba(255,255,255,0.4) inset;
}

/* variations de couleurs */
.wppixelfall-cell.pfall-color-1 { background: #f2b179; }
.wppixelfall-cell.pfall-color-2 { background: #f59563; }
.wppixelfall-cell.pfall-color-3 { background: #f67c5f; }
.wppixelfall-cell.pfall-color-4 { background: #f6d565; }
.wppixelfall-cell.pfall-color-5 { background: #edcf72; }
.wppixelfall-cell.pfall-color-6 { background: #9c60ff; }

/* ===== SLIDEGRID : Match-3 par glissade de lignes/colonnes ===== */

.wpslidegrid-grid {
    display: grid;
    grid-template-columns: repeat(var(--sg-cols, 10), 1fr);
    gap: 2px;
    margin-top: 10px;
}

.wpslidegrid-cell {
    float: none !important;
    width: 100%;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e1c1a;
    border: 1px solid rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

/* Quand un bonbon va être détruit */

.wpslidegrid-cell.wpsg-clearing {
    animation: sg-shrink 0.22s ease-out forwards;
}

@keyframes sg-shrink {
    from { transform: scale(1.5);   opacity: 1; }
    to   { transform: scale(0.3); opacity: 0; }
}



/* Palette de bonbons (couleurs de base) */
.wpslidegrid-cell.wpsg-color-0 { background: #ff6b6b; }  /* rouge */
.wpslidegrid-cell.wpsg-color-1 { background: #ffd93b; }  /* jaune */
.wpslidegrid-cell.wpsg-color-2 { background: #6bcb77; }  /* vert */
.wpslidegrid-cell.wpsg-color-3 { background: #4d96ff; }  /* bleu */
.wpslidegrid-cell.wpsg-color-4 { background: #af7aff; }  /* violet */
.wpslidegrid-cell.wpsg-color-5 { background: #ff9f1c; }  /* orange (si colors>5) */
.wpslidegrid-cell.wpsg-color-6 { background: #ff5ea3; }  /* rose (si colors>6) */
.wpslidegrid-cell.wpsg-color-7 { background: #00c2a8; }  /* turquoise (si colors>7) */


/* ===== TUILES SPÉCIALES (version ultra simple) ===== */

/* --- PIERRES (STONE) ---
   Bloc gris foncé, aspect "béton". */
.wpslidegrid-cell.wpsg-stone {
    background: #4b4641;
    border-color: #1b1816;
}

.wpslidegrid-cell.wpsg-stone::before {
    content: "";
    position: absolute;
    inset: 25%;
    border-radius: 3px;
    border: 2px solid rgba(255, 255, 255, 0.12);
}

/* --- CAMÉLÉONS (CHAMELEON) ---
   Même couleur que les autres, mais avec une bordure blanche pointillée. */
.wpslidegrid-cell.wpsg-chameleon {
    border: 2px dashed #ffffff;
}

/* --- ÉNERGIE (ENERGY) ---
   Garde la couleur de base, mais ajoute un symbole ⚡ bien visible. */
.wpslidegrid-cell.wpsg-energy {
    border: 2px solid #ffffff;
}

.wpslidegrid-cell.wpsg-energy::before {
    content: "⚡";
    position: absolute;
    font-size: 1.1rem;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
}

/* ===== Icônes simplifiées pour la légende Slidegrid ===== */

.sg-icon {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    margin-bottom: 5px;
    border-radius: 3px;
    vertical-align: middle;
}

/* Bonbon "normal" de base, exemple rouge */
.sg-basic {
    background: #ff6b6b;
}

/* Pierre : gris foncé */
.sg-stone {
    background: #4b4641;
    border: 1px solid #1b1816;
}

/* Caméléon : violet + bordure pointillée */
.sg-chameleon {
    background: #af7aff;
    border: 2px dashed #ffffff;
}

/* Énergie : jaune + symbole ⚡ */
.sg-energy {
    background: #ffd93b;
    border-radius: 3px;
    position: relative;
}

.sg-energy::before {
    content: "⚡";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #000000;
}



/* ===== TRAPRUN : platformer piégé ===== */

.wptraprun-grid {
    display: grid;
    grid-template-columns: repeat(var(--trap-cols, 18), 1fr);
    gap: 2px;
    margin-top: 10px;
}

/* Base des cases */
.wptrap-cell {
    float: none;
    width: 100%;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #cdc1b4;
    position: relative;
}

/* Types de tuiles */
.wptrap-cell.trap-solid {
    background: #b8aa9a;
}

.wptrap-cell.trap-void {
    background: #3c3a32;
}

.wptrap-cell.trap-spike-hidden {
    background: #b8aa9a; /* ressemble à du sol normal */
}

.wptrap-cell.trap-spike-visible {
    background: #8f3b3b;
}

.wptrap-cell.trap-exit {
    background: #23b68d;
    box-shadow: 0 0 6px rgba(35,182,141,0.7);
}

/* Joueur : un petit carré coloré au centre */
.wptrap-cell.trap-player::after {
    content: "";
    width: 60%;
    height: 60%;
    border-radius: 2px;
    background: #f67c5f;
    box-shadow: 0 0 4px rgba(0,0,0,0.4);
}

/* Mort / piège déclenché */
.wptrap-cell.trap-hit {
    animation: wptrap-hit 0.2s ease-out;
}

/* dalle friable : ressemble au sol mais fissurée */
.wptrap-cell.trap-crumble {
    background: #c9b29c;
    position: relative;
}

.wptrap-cell.trap-crumble::before {
    content: "";
    position: absolute;
    inset: 25% 20%;
    border-top: 2px solid rgba(90, 70, 50, 0.7);
    transform: rotate(-10deg);
    opacity: 0.9;
}

@keyframes wptrap-hit {
    0% { transform: scale(1);   background-color: #f67c5f; }
    50% { transform: scale(1.1); background-color: #ff3b3b; }
    100% { transform: scale(1); }
}

