/*
 * Palace Game - Premium Mobile-First Design v2
 * Corrections : responsive, cartes avec fond, pas de débordement
 */

/* ===== Game Container - Full Viewport avec padding top pour header ===== */
.palace-game {
    position: fixed;
    top: 60px;
    /* Espace pour le header du site */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 20%, #1b4d3e 0%, #0f2e23 35%, #0a0f1c 100%);
    color: white;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* ===== Header Adversaires ===== */
.palace-opponents {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.palace-opponent {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 65px;
    transition: all 0.3s ease;
}

.palace-opponent.active-turn {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.25);
}

.opponent-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #6366f1;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.opponent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.opponent-name {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    max-width: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opponent-palace-cards {
    display: flex;
    gap: 2px;
    margin-top: 4px;
}

.opponent-palace-cards .mini-card {
    width: 20px;
    height: auto;
    border-radius: 3px;
    background: white;
    padding: 1px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Info cartes adversaires */
.opponent-info {
    display: flex;
    gap: 6px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

.opponent-info span {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ===== Zone Centrale - Flexible ===== */
.palace-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    min-height: 0;
    gap: 8px;
}

.palace-table {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* Pioche */
.palace-draw {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.draw-stack {
    position: relative;
    width: 45px;
    height: 63px;
    background: linear-gradient(145deg, #1e40af, #2563eb);
    border-radius: 5px;
    box-shadow:
        2px 2px 0 #1e3a8a,
        4px 4px 0 rgba(30, 58, 138, 0.4),
        0 6px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.draw-stack::before {
    content: '🎴';
    font-size: 20px;
    opacity: 0.8;
}

.draw-count {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
}

.table-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pile centrale */
.palace-pile-center {
    position: relative;
    width: 60px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pile-empty {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.15);
}

.pile-card-img {
    width: 50px;
    height: auto;
    border-radius: 4px;
    background: white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.pile-count-badge {
    position: absolute;
    bottom: -6px;
    background: rgba(0, 0, 0, 0.7);
    color: #4ade80;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
}

/* Brûlées */
.palace-burn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.burn-zone {
    width: 45px;
    height: 63px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 5px;
}

.burn-icon {
    font-size: 22px;
    animation: flicker 0.4s infinite alternate;
}

@keyframes flicker {
    from {
        opacity: 0.6;
    }

    to {
        opacity: 1;
    }
}

/* Indicateur de tour */
.palace-status {
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.palace-status.my-turn {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
    color: #4ade80;
    font-weight: 600;
}

/* ===== Zones de Cartes du Joueur ===== */
.palace-my-area {
    flex-shrink: 0;
    padding: 6px 8px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), #0a0f1c);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.palace-zone {
    margin-bottom: 4px;
    padding: 4px 8px;
    border-radius: 8px;
}

.palace-zone:last-child {
    margin-bottom: 0;
}

.palace-zone.active {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.zone-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.zone-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.zone-locked {
    font-size: 10px;
}

/* Rangée de cartes - PLUS de padding pour éviter coupure */
.cards-row {
    display: flex;
    justify-content: flex-start;
    /* Important pour le scroll sur mobile */
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding: 20px 20px 15px 20px;
    /* Padding latéral accru */
    margin-top: -10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    width: 100%;

    /* Indicateur de dégradé pour le scroll (fade sur les bords) */
    mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 5%, black 95%, transparent);
}

/* Sur grand écran ou si peu de cartes, on centre (si possible) */
@media (min-width: 600px) {
    .cards-row {
        justify-content: center;
        /* Désactiver le mask sur grand écran si on veut voir tout net, ou le garder */
        mask-image: none;
        -webkit-mask-image: none;
    }
}

.cards-row::-webkit-scrollbar {
    display: none;
}

/* ===== Cartes Individuelles avec Fond Blanc + Bordure ===== */
.palace-card {
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    scroll-snap-align: center;
}

/* Conteneur blanc avec padding pour l'image */
.palace-card .card-img {
    width: 48px;
    height: auto;
    border-radius: 6px;
    background: white;
    padding: 3px;
    /* Bordure blanche autour de l'image */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
}

.palace-card.playable:hover {
    transform: translateY(-12px);
    z-index: 10;
}

.palace-card.playable:hover .card-img {
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
}

.palace-card.selected {
    transform: translateY(-18px);
    z-index: 20;
}

.palace-card.selected .card-img {
    box-shadow: 0 0 0 3px #22c55e, 0 10px 25px rgba(34, 197, 94, 0.6);
}

.palace-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: brightness(0.8);
}

.palace-card.disabled:hover {
    transform: none;
}

.zone-empty {
    font-size: 16px;
    color: #22c55e;
    padding: 6px;
}

/* ===== Boutons d'Action - Compacts ===== */
.palace-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.palace-actions.hidden {
    display: none;
}

.btn-play,
.btn-take {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 25px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-play {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.4);
}

.btn-play:disabled {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.25);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-play:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(34, 197, 94, 0.5);
}

.btn-take {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #f87171;
}

.btn-take:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-2px);
}

/* ===== Responsive Mobile ===== */
@media (max-width: 400px) {
    .palace-game {
        top: 55px;
    }

    .palace-card .card-img {
        width: 40px;
    }

    .palace-table {
        gap: 15px;
    }

    .draw-stack,
    .burn-zone {
        width: 40px;
        height: 56px;
    }

    .palace-pile-center {
        width: 50px;
        height: 70px;
    }

    .pile-card-img {
        width: 42px;
    }

    .btn-play,
    .btn-take {
        padding: 8px 18px;
        font-size: 11px;
    }
}

/* Très petits écrans */
@media (max-height: 650px) {
    .palace-game {
        top: 50px;
    }

    .palace-opponents {
        padding: 5px 8px;
    }

    .palace-center {
        padding: 6px;
        gap: 5px;
    }

    .palace-my-area {
        padding: 4px 6px;
    }

    .palace-zone {
        margin-bottom: 2px;
        padding: 2px 6px;
    }

    .cards-row {
        padding: 6px 4px 10px 4px;
        gap: 3px;
    }

    .palace-card .card-img {
        width: 38px;
    }

    .palace-actions {
        padding: 6px 10px;
    }

    .btn-play,
    .btn-take {
        padding: 7px 16px;
        font-size: 10px;
    }
}

/* Carte sélectionnée - Halo puissant */
.palace-card.selected .card-img {
    box-shadow: 0 0 0 4px #22c55e, 0 0 15px rgba(34, 197, 94, 0.8) !important;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 6px;
    /* Match card radius usually */
}

/* Layout header fix */
.palace-game {
    /* Assurer que le top est suffisant */
    top: 70px !important;
    height: calc(100vh - 70px);
}

/* Overlay Révélation Carte */
.card-reveal-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
    pointer-events: none;
}

.card-reveal-overlay.active {
    transform: translate(-50%, -50%) scale(1.5);
}

.card-reveal-overlay img {
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border: 2px solid white;
}

.pile-count-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

/* Historique (Logs) */
.palace-logs-container {
    width: 100%;
    max-width: 400px;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
}

.logs-header {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

.logs-header:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.logs-content {
    transition: all 0.3s ease;
    max-height: 150px;
}

.logs-content.hidden {
    max-height: 0;
}

.logs-list {
    padding: 8px;
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    font-size: 10px;
    display: flex;
    gap: 6px;
    color: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 2px;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
}

.log-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
    padding: 10px;
}

/* Paysage - éviter sur mobile */
@media (orientation: landscape) and (max-height: 450px) {
    .palace-opponents {
        display: none;
    }

    .palace-card .card-img {
        width: 35px;
    }

    .palace-center {
        padding: 4px;
    }
}

/* === PREMIUM UI REWORK === */

/* Grid Layout Joueur */
.palace-player-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 10px 10px 10px;
    width: 100%;
}

.palace-top-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Glassmorphism Containers */
.glass-box {
    background: rgba(15, 23, 42, 0.65);
    /* Fond sombre mais transparent */
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
}

.box-facedown,
.box-faceup {
    min-width: 130px;
    /* Enough for 3 cards */
}

.box-hand {
    width: 100%;
    background: rgba(15, 23, 42, 0.45);
    /* Un peu plus clair pour la main */
}

.glass-box.active-zone {
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
    /* Réduit un peu l'intensité */
    background: linear-gradient(to bottom, rgba(34, 197, 94, 0.05), rgba(15, 23, 42, 0.7));
}

.box-header {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    letter-spacing: 0.8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.box-icon {
    font-size: 11px;
    opacity: 0.9;
}

/* Slots de Cartes & Placeholders */
.cards-row-slots {
    display: flex;
    gap: 8px;
    padding: 12px 4px 4px 4px;
    z-index: 10;
}

.card-slot {
    width: 46px;
    /* Doit être plus large que la carte (38px) */
    height: 64px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    /* Le fond sombre visible sous la carte */
    border-radius: 8px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.card-slot.empty .slot-placeholder {
    width: 100%;
    height: 100%;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    opacity: 0.5;
}

.card-slot.filled:hover .palace-card,
.palace-card.selected {
    transform: translateY(-5px) !important;
    /* Réduit de -8px à -5px */
    z-index: 50 !important;
    /* Force au dessus de tout */
    position: relative;
    /* Assure que z-index marche */
}

/* Hand Scroller Override */
.hand-scroller {
    width: 100%;
    overflow-x: auto;
    display: flex;
    justify-content: flex-start;
    /* Aligné gauche pour scroll */
    padding: 15px 4px 5px 4px !important;
    gap: 6px !important;
    mask-image: none !important;
    overflow-y: visible !important;
    /* Scrollbar invisible */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hand-scroller::-webkit-scrollbar {
    display: none;
}

/* Avatars & Opponents */
.opponent-avatar-wrapper {
    position: relative;
    width: 38px;
    height: 38px;
    margin-bottom: 4px;
}

.turn-indicator-spinner {
    position: absolute;
    top: -3px;
    right: -3px;
    font-size: 9px;
    width: 14px;
    height: 14px;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: spin 2.5s linear infinite;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Pile Placeholder & Badges */
.pile-placeholder {
    width: 42px;
    height: 60px;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}

.pile-badge,
.burn-count {
    position: absolute;
    top: -6px;
    right: -8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.burn-pile-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 62px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.draw-pile-container.empty {
    width: 44px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.8);
    border: 2px dashed rgba(255, 255, 255, 0.15);
}

.card-back-stack {
    width: 42px;
    height: 60px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 0 #1e3a8a, 0 8px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ajustement Plateau Central */
.palace-table {
    gap: 25px;
    /* Plus d'espace */
    align-items: center;
    /* Centrage vertical */
    margin: 10px 0;
    justify-content: center;
}

/* Fix Card Size for new slots */
.palace-card {
    width: 38px !important;
    margin: 0 !important;
}

.palace-card .card-img {
    width: 100%;
    display: block;
    border-radius: 4px;
}

.mini-card {
    width: 18px;
}

/* === FINAL TWEAKS === */

/* Pioche Minimaliste (Emoji Centré) - RENAMED */
.draw-pile-final {
    width: 44px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

.draw-pile-final.empty {
    border-style: dashed;
    opacity: 0.4;
    font-size: 20px;
    color: rgba(255, 255, 255, 0.3);
}

.pile-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.pile-icon {
    font-size: 26px;
    /* Grand Emoji */
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Override Badge Position for Draw Pile */
.draw-pile-final .pile-badge {
    top: -6px;
    right: -8px;
    z-index: 10;
}

/* Fix Cut Cards - Force Visible Overflow & Z-Index Layering */
/* Fix Cut Cards - Force Visible Overflow & Z-Index Layering */

/* Z-Index Hierarchy: Hand > TopRow */
.box-hand {
    position: relative;
    z-index: 50 !important;
    /* Higher than TopRow */
    overflow: visible !important;
}

.palace-top-row {
    position: relative;
    z-index: 10;
    /* Lower than Hand */
}



/* Ensure header stays below */
.box-header {
    z-index: 1 !important;
    position: relative;
}

.cards-row-slots {
    z-index: 10 !important;
    position: relative;
}



/* Fix Cut Cards - Force Visible Overflow */
.glass-box,
.palace-player-grid,
.box-hand {
    overflow: visible !important;
}

.card-slot.filled:hover .palace-card,
.palace-card.selected {
    transform: translateY(-4px) !important;
    /* Très léger */
    z-index: 100 !important;
    /* Passe devant tout */
}

/* Ensure header stays below */
.box-header {
    z-index: 1 !important;
    position: relative;
}

.cards-row-slots {
    z-index: 10 !important;
    position: relative;
}

/* === UX FIXES FINAL === */

/* 1. Main Vide : Conserver taille min, supprimer texte */
/* 1. Main Vide & Scroller Fix (Large Padding pour éviter crop) */
/* 1. Main Vide & Scroller Fix (Large Padding pour éviter crop) */

.hand-scroller {
    min-height: 110px !important;
    padding-top: 40px !important;
    /* Espace pour monter */
    margin-top: -25px !important;
    /* Remonte visuellement */
    padding-bottom: 20px !important;
    /* Extra padding bottom for fade */
    align-items: flex-start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    /* Clipping inévitable avec scroll x */

    /* Masque de fondu : Gauche, Droite, et Bas */
    mask-image: linear-gradient(to right, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%),
        linear-gradient(to bottom, black 85%, transparent 100%) !important;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 20px, black calc(100% - 20px), transparent 100%),
        linear-gradient(to bottom, black 85%, transparent 100%) !important;
    mask-composite: intersect !important;
    -webkit-mask-composite: source-in !important;
    /* Fallback for composite */
}

/* 2. Avatar Fix Display */
.opponent-avatar {
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #0f172a;
    color: white;
}

.opponent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.initial {
    font-weight: 700;
    font-size: 18px;
    text-transform: uppercase;
}

/* 3. Revealed Card Fix - Clean Overlay */
#revealed-overlay {
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#revealed-overlay .palace-card.revealed-card-large {
    width: 140px !important;
    margin: 0;
    max-width: 80vw;
    border-radius: 12px;
    background: white;
    /* Fond blanc cadre */
    padding: 6px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
    position: relative;
    /* Remove fixed top left */
    top: auto;
    left: auto;
    transform: none;
    animation: revealPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#revealed-overlay .palace-card .card-img {
    width: 100%;
    display: block;
    border-radius: 6px;
}

@keyframes revealPop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}