/* =========================
   CASINO UV2 JUDO
========================= */

.casino-section {
    padding: 40px 20px 70px;
}

.casino-container {
    max-width: 1150px;
    margin: auto;
}

.casino-header {
    text-align: center;
    margin-bottom: 25px;
}

.casino-header h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

.casino-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.casino-btn {
    padding: 12px 22px;
    border: none;
    border-radius: 9px;
    background: #c62828;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .2s;
}

.casino-btn:hover:not(:disabled) {
    background: #a91d1d;
    transform: translateY(-2px);
}

.casino-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.casino-btn-secondary {
    background: #475569;
}

.casino-btn-secondary:hover:not(:disabled) {
    background: #334155;
}

/* Table de jeu */

.casino-table {
    min-height: 380px;
    padding: 35px 20px;
    border-radius: 24px;
    background: radial-gradient(
        ellipse at center,
        #176d46 0%,
        #09452d 75%,
        #063520 100%
    );
    border: 10px solid #5b3822;
    box-shadow:
        0 15px 35px rgba(0, 0, 0, .25),
        inset 0 0 30px rgba(0, 0, 0, .25);
}

/* Paquet */

.casino-deck-area {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
}

.casino-deck {
    width: 115px;
    height: 165px;
    position: relative;
    transform-style: preserve-3d;
}

.casino-deck-card {
    position: absolute;
    inset: 0;
    border: 3px solid white;
    border-radius: 12px;
    background:
        repeating-linear-gradient(
            45deg,
            #a61919 0px,
            #a61919 8px,
            #c62828 8px,
            #c62828 16px
        );
    box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
}

.casino-deck-card:nth-child(1) { transform: translateY(7px); }
.casino-deck-card:nth-child(2) { transform: translateY(6px); }
.casino-deck-card:nth-child(3) { transform: translateY(5px); }
.casino-deck-card:nth-child(4) { transform: translateY(4px); }
.casino-deck-card:nth-child(5) { transform: translateY(3px); }
.casino-deck-card:nth-child(6) { transform: translateY(2px); }
.casino-deck-card:nth-child(7) { transform: translateY(1px); }

/* Mélange façon casino */

.casino-deck.is-shuffling {
    animation: deckShake 2.6s ease-in-out;
}

.casino-deck.is-shuffling .casino-deck-card:nth-child(odd) {
    animation: shuffleLeft 650ms ease-in-out 4;
}

.casino-deck.is-shuffling .casino-deck-card:nth-child(even) {
    animation: shuffleRight 650ms ease-in-out 4;
}

@keyframes shuffleLeft {
    0%, 100% {
        transform: translateX(0) rotate(0);
    }

    45% {
        transform: translateX(-75px) rotate(-18deg);
    }

    70% {
        transform: translateX(-20px) rotate(-5deg);
    }
}

@keyframes shuffleRight {
    0%, 100% {
        transform: translateX(0) rotate(0);
    }

    45% {
        transform: translateX(75px) rotate(18deg);
    }

    70% {
        transform: translateX(20px) rotate(5deg);
    }
}

@keyframes deckShake {
    0%, 100% {
        transform: rotate(0);
    }

    25% {
        transform: rotate(-5deg);
    }

    50% {
        transform: rotate(5deg);
    }

    75% {
        transform: rotate(-3deg);
    }
}

/* Distribution */

.casino-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 18px;
    justify-items: center;
}

.casino-playing-card {
    width: 105px;
    height: 150px;
    border-radius: 11px;
    border: 4px solid white;
    background:
        repeating-linear-gradient(
            45deg,
            #a61919 0px,
            #a61919 8px,
            #c62828 8px,
            #c62828 16px
        );
    cursor: pointer;
    box-shadow: 0 5px 12px rgba(0, 0, 0, .35);
    transition: transform .25s, box-shadow .25s;
    position: relative;
}

.casino-playing-card:hover {
    transform: translateY(-10px) rotate(2deg);
    box-shadow: 0 12px 20px rgba(0, 0, 0, .4);
}

.casino-card-pattern {
    position: absolute;
    inset: 12px;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 25px;
    background: rgba(120, 0, 0, .3);
}

.casino-playing-card.is-dealing {
    animation: dealCard .6s ease-out both;
}

@keyframes dealCard {
    from {
        opacity: 0;
        transform: translateY(-150px) scale(.5) rotate(-25deg);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0);
    }
}

.casino-playing-card.is-revealed {
    border-color: #facc15;
}

.casino-progress {
    text-align: center;
    margin-top: 25px;
    font-size: 18px;
    font-weight: 600;
}

/* Fenêtre de carte */

.casino-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.casino-overlay[hidden] {
    display: none;
}

.casino-modal {
    width: min(100%, 430px);
    position: relative;
    text-align: center;
}

.casino-close {
    position: absolute;
    right: 0;
    top: -48px;
    font-size: 35px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
}

.casino-flip-card {
    width: 100%;
    height: 460px;
    perspective: 1200px;
    cursor: pointer;
}

.casino-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform .8s cubic-bezier(.2, .7, .2, 1);
    transform-style: preserve-3d;
}

.casino-flip-card.is-flipped .casino-flip-inner {
    transform: rotateY(180deg);
}

.casino-face {
    position: absolute;
    inset: 0;
    border-radius: 18px;
    background: #fff;
    color: #172033;
    border: 8px solid #f8fafc;
    box-shadow: 0 12px 35px rgba(0, 0, 0, .4);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px;
    overflow: auto;
}

.casino-face-front h2 {
    font-size: 32px;
    color: #b91c1c;
}

.casino-face-back {
    transform: rotateY(180deg);
}

.casino-face-back h2 {
    color: #b91c1c;
    margin-bottom: 15px;
}

.casino-answer-content {
    overflow-y: auto;
    max-height: 340px;
    width: 100%;
}

.casino-answer-content img {
    max-width: 100%;
    max-height: 190px;
    object-fit: contain;
    margin: 10px auto;
}

.casino-answer-content img[hidden],
.casino-answer-content a[hidden] {
    display: none;
}

.casino-answer-content a {
    display: inline-block;
    margin-top: 12px;
    padding: 9px 16px;
    background: #b91c1c;
    color: white;
    border-radius: 7px;
    text-decoration: none;
}

.casino-corner {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #b91c1c;
    font-weight: 800;
}

.casino-corner-bottom {
    top: auto;
    left: auto;
    bottom: 15px;
    right: 15px;
}

.casino-modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.casino-modal-open {
    overflow: hidden;
}

/* Responsive */

@media (max-width: 600px) {

    .casino-table {
        padding: 20px 10px;
        border-width: 6px;
    }

    .casino-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 10px;
    }

    .casino-playing-card {
        width: 75px;
        height: 110px;
    }

    .casino-card-pattern {
        inset: 8px;
        font-size: 18px;
    }

    .casino-flip-card {
        height: 420px;
    }

    .casino-face-front h2 {
        font-size: 25px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .casino-deck.is-shuffling,
    .casino-deck.is-shuffling .casino-deck-card,
    .casino-playing-card.is-dealing {
        animation: none;
    }

    .casino-flip-inner {
        transition: none;
    }
}
/* =========================
   CORRECTION MODALE MOBILE
========================= */

@media (max-width: 600px) {

    .casino-overlay {
        padding: 12px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .casino-modal {
        width: 100%;
        max-width: 360px;
        min-width: 0;
        margin: auto;
        padding-top: 35px;
        box-sizing: border-box;
    }

    .casino-close {
        top: -5px;
        right: 5px;
        font-size: 30px;
        z-index: 10;
    }

    .casino-flip-card {
        width: 100%;
        height: min(480px, 62dvh);
        min-height: 300px;
    }

    .casino-face {
        padding: 15px;
        border-width: 5px;
        border-radius: 16px;
        overflow: hidden;
    }

    .casino-face-back {
        justify-content: flex-start;
        padding-top: 20px;
    }

    .casino-face-back h2 {
        font-size: 23px;
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    .casino-answer-content {
        max-height: none;
        min-height: 0;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0 5px 10px;
        scrollbar-width: thin;
    }

    .casino-answer-content img {
        display: block;
        width: 100%;
        max-width: 100%;
        max-height: 165px;
        height: auto;
        object-fit: contain;
        margin: 10px auto;
    }

    .casino-answer-content img[hidden] {
        display: none;
    }

    .casino-modal-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
        max-width: 100%;
        margin-top: 15px;
    }

    .casino-modal-actions .casino-btn {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding: 12px 6px;
        font-size: 12px;
        line-height: 1.3;
        white-space: normal;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }
}

@media (max-width: 380px) {

    .casino-modal-actions {
        grid-template-columns: 1fr;
    }

    .casino-modal-actions .casino-btn {
        font-size: 14px;
        padding: 12px;
    }

    .casino-flip-card {
        height: min(440px, 60dvh);
        min-height: 280px;
    }
}
/* =========================
   FILTRES MODE TEST
========================= */

.casino-error {
    max-width: 900px;
    margin: 0 auto 20px;
    padding: 15px 20px;
    border-radius: 10px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    font-weight: 600;
}

/* Formulaire spécifique au Mode Test */
.hero-card:has(+ .casino-section) .revision-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

@media (max-width: 980px) {
    .hero-card:has(+ .casino-section) .revision-filters {
        grid-template-columns: 1fr;
    }
}