/* CUSTOM FONT */
@font-face {
    font-family: 'LeeuwLuiaard';
    src: url('assets/fonts/custom-font.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* VIDEO INTRO OVERLAY */
.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.video-overlay.hidden {
    display: none;
}

.video-overlay video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.click-to-start {
    position: absolute;
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 2rem;
    color: #fff;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    animation: pulse 2s infinite;
}

.click-to-start.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

.skip-intro {
    position: absolute;
    bottom: 30px;
    right: 30px;
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1rem;
    padding: 10px 20px;
    background: rgba(206, 134, 54, 0.8);
    color: #fff;
    border: 2px solid #ce8636;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.skip-intro:hover {
    background: #ce8636;
}

/* WELKOM POP-UP */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 15, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.welcome-overlay.hidden {
    display: none;
}

.welcome-content {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: rgba(10, 25, 47, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 25px;
    padding: 2.5rem 3rem;
    max-width: 600px;
    width: 90%;
    text-align: center;
    color: #e0e6ed;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.welcome-content h1 {
    font-size: 1.8rem;
    color: #ffffff;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.welcome-content h3 {
    font-size: 1.3rem;
    color: #bd814d;
    margin: 1.5rem 0 1rem 0;
}

.welcome-content p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0.8rem 0;
}

.welcome-content ul {
    text-align: left;
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.welcome-content li {
    font-size: 1rem;
    line-height: 1.8;
    margin: 0.3rem 0;
}

.welcome-content .highlight {
    font-size: 1.1rem;
    color: #7c9c84;
    font-style: italic;
    margin: 1.5rem 0;
}

.welcome-content .ready {
    font-size: 1.2rem;
    color: #bd814d;
    margin-top: 1.5rem;
}

.welcome-content button {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.4rem;
    padding: 1rem 2.5rem;
    margin-top: 1.5rem;
    background: linear-gradient(135deg, #bd814d, #7c5c44, #746454);
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.welcome-content button:hover {
    background: linear-gradient(135deg, #5a9c69, #3d7a4d);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* BASIS STIJLEN */
body {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;

    /* THEMA: Night Jungle */
    background-image: url('assets/background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: #e0e6ed;
    /* Lichte tekst */
}

.main-container {
    display: flex;
    /* Glassmorphism effect */
    background: rgba(10, 25, 47, 0.75);
    /* Donkerblauw transparant */
    backdrop-filter: blur(10px);
    /* Wazig effect erachter */
    -webkit-backdrop-filter: blur(10px);

    padding: 3rem;
    /* Meer padding */
    border-radius: 30px;
    /* Iets ronder */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);

    max-width: 1400px;
    /* Veel breder (was 900px) */
    width: 95%;
    gap: 2rem;
    /* Iets minder gap om ruimte te winnen */
    min-height: 80vh;
    /* Hoger spelvenster */
}

/* LINKER KANT: DOBBELSTEEN - Smaller */
.dice-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content: flex-end;  <-- VERWIJDERD zodat H2 bovenaan kan staan */
    border-right: 2px solid rgba(255, 255, 255, 0.1);
    padding-right: 2rem;
    /* Zorg dat de container hoog genoeg is voor de sprong */
    min-height: 65vh;
    padding-bottom: 0.5rem;
    /* Minder padding zodat tekst lager komt */
}

/* RECHTER KANT: KAARTEN - Breder */
.stacks-section {
    flex: 1.5;
    /* Meer ruimte voor kaarten */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dice-section h2,
.stacks-section h2 {
    color: #ce8636;
    text-shadow: 0 0 10px rgba(206, 134, 54, 0.3);
    margin-top: 0;
    font-size: 2rem;
    margin-bottom: 2rem;
}

/* 3D DOBBELSTEEN - NIEUWE IMPLEMENTATIE */
.dice-area {
    width: 100%;
    height: auto;
    margin-top: auto;
    /* <--- DIT zorgt dat de dobbelsteen naar beneden zakt */
    /* Voldoende ruimte voor de sprong */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.dice {
    width: 300px;
    height: 300px;
    position: relative;
    transform-style: preserve-3d;
    transform: translateY(0) rotateX(0deg) rotateY(0deg);
    cursor: pointer;
    transition: transform 0.1s;
    will-change: transform;
}

.dice:hover {
    transform: translateY(0) rotateX(0deg) rotateY(0deg) scale(1.05);
}

.face {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    background: rgba(10, 25, 47, 0.95);
    border: 4px solid rgba(255, 255, 255, 0.4);
    box-shadow: 
        inset 0 0 15px rgba(0, 0, 0, 0.4),
        0 4px 15px rgba(0, 0, 0, 0.5);
}

.face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}

/* POSITIES VAN DE 6 VLAKKEN (300px -> translateZ 150px) */
.face.front {
    transform: rotateY(0deg) translateZ(150px);
}

.face.back {
    transform: rotateY(180deg) translateZ(150px);
}

.face.right {
    transform: rotateY(90deg) translateZ(150px);
}

.face.left {
    transform: rotateY(-90deg) translateZ(150px);
}

.face.top {
    transform: rotateX(90deg) translateZ(150px);
}

.face.bottom {
    transform: rotateX(-90deg) translateZ(150px);
}

/* ANIMATIE */
/* ANIMATIE - SPECIFIEKE UITKOMSTEN */
.dice.roll-lion {
    animation: diceRollLion 3s ease-out forwards;
}

.dice.roll-sloth {
    animation: diceRollSloth 3s ease-out forwards;
}

.dice.roll-together {
    animation: diceRollTogether 3s ease-out forwards;
}

/* 
   Keyframes voor elke uitkomst.
   We zorgen voor een continue beweging (geen plateau) en eindigen exact op de juiste rotatie.
   Lion (Front): rotateX(0), rotateY(0) -> Eindig op veelvoud van 360
   Sloth (Right): rotateY(90) -> Wil je voor zien? Dan rotateY(-90). Eindig op 630 (720 - 90)
   Together (Top): rotateX(90) -> Wil je voor zien? Dan rotateX(-90). Eindig op 630 (720 - 90)
*/

@keyframes diceRollLion {
    0% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }

    20% {
        transform: translateY(-300px) rotateX(360deg) rotateY(180deg);
    }

    100% {
        transform: translateY(0) rotateX(720deg) rotateY(720deg);
    }
}

@keyframes diceRollSloth {
    0% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }

    20% {
        transform: translateY(-300px) rotateX(360deg) rotateY(180deg);
    }

    100% {
        transform: translateY(0) rotateX(720deg) rotateY(630deg);
    }
}

@keyframes diceRollTogether {
    0% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }

    20% {
        transform: translateY(-300px) rotateX(360deg) rotateY(180deg);
    }

    100% {
        transform: translateY(0) rotateX(630deg) rotateY(720deg);
    }
}

.dice-hint {
    margin-top: 3rem;
    color: #a0aec0;
    font-style: italic;
}

/* KAARTEN STAPELS - Groter */
.stacks-container {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-top: 1rem;
    width: 100%;
}

.stack {
    position: relative;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    opacity: 0.6;
    width: auto;
    height: auto;
    max-width: 28%;
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    overflow: hidden;
    /* Zorgt dat img er niet uitsteekt */
}

.stack:hover {
    /* Subtiele hover, geen grote schaal */
    transform: translateY(-2px);
    opacity: 0.8;
}

.stack img {
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
    display: block;
}

/* Tekst is verwijderd uit HTML, dus deze style is niet meer nodig, 
   maar voor de zekerheid verbergen we p tags in stacks */
.stack p {
    display: none;
}

/* ACTIEVE VS DISABLED STATEN */
.stack.active {
    transform: translateY(-5px);
    border: 2px solid #ce8636;
    box-shadow: 0 0 20px rgba(206, 134, 54, 0.6);
    background-color: transparent;
    opacity: 1 !important;
    filter: none !important;
    z-index: 10;
}

.stack.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(80%);
    pointer-events: none;
    /* Geen scale, gewoon dimmen */
}

/* FLYING CARD ANIMATIE */
.flying-card {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    transform-origin: center center;
    perspective: 1000px;
    will-change: transform;
}

.flying-card.hidden {
    display: none;
}

.flying-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.flying-card.flipped .flying-card-inner {
    transform: rotateY(180deg);
}

.flying-card-front,
.flying-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 15px;
    overflow: hidden;
}

.flying-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
}

.flying-card-back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(253, 253, 150, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

.flying-card-back {
    transform: rotateY(180deg);
}

/* Shadow tijdens animatie - JS animation loop gebruikt, geen CSS transitions */
.flying-card:not(.hidden) .flying-card-front,
.flying-card:not(.hidden) .flying-card-back {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .flying-card,
    .flying-card-inner,
    .flying-card.animating {
        transition: none !important;
    }
}

/* MODAL (POPUP) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    /* Iets donkerder voor focus */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem; /* Meer ruimte tussen kaart en knoppen */
}

.modal-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-card {
    flex-shrink: 0;
    position: relative;
}

.modal-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.read-card-button {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.2rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #bd814d, #7c5c44, #746454);
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.read-card-button:hover {
    background: linear-gradient(135deg, #ce8636, #8c6c54);
    transform: scale(1.05);
}

.read-card-button:active {
    transform: scale(0.98);
}

.show-answer-button {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.2rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #bd814d, #7c5c44, #746454);
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}

.show-answer-button:hover {
    background: linear-gradient(135deg, #ce8636, #8c6c54);
    transform: scale(1.05);
}

.show-answer-button:active {
    transform: scale(0.98);
}

.show-answer-button.hidden {
    display: none;
}

/* Antwoord pop-up */
.modal-card {
    position: relative;
}

/* ANTWOORD OVERLAY (zelfde stijl als welkom) */
.answer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 15, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    padding: 20px;
    box-sizing: border-box;
}

.answer-overlay.hidden {
    display: none;
}

.answer-content {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: rgba(10, 25, 47, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 25px;
    padding: 2.5rem 3rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    color: #e0e6ed;
    border: 2px solid rgba(206, 134, 54, 0.5);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.answer-content h3 {
    font-size: 1.5rem;
    color: #ce8636;
    margin: 0 0 1.5rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.answer-content p {
    font-size: 1.2rem;
    line-height: 1.8;
    margin: 0 0 2rem 0;
    text-align: left;
}

.answer-content button {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 1.2rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #bd814d, #7c5c44, #746454);
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.answer-content button:hover {
    background: linear-gradient(135deg, #5a9c69, #3d7a4d);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.answer-popup.hidden {
    display: none;
}

.answer-popup h4 {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #ce8636;
    font-size: 1.6rem;
    margin: 0 0 1.5rem 0;
    text-align: left;
}

.answer-popup p {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #ffffff;
    font-size: 1.3rem;
    line-height: 1.8;
    margin: 0;
    text-align: left;
}

#overlay-img {
    max-width: 70vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 0 50px rgba(253, 253, 150, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    transition: opacity 0.2s ease-in-out;
}

.close-card-button {
    font-family: 'LeeuwLuiaard', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #ce8636;
    background: transparent;
    border: none;
    margin-top: 1.5rem;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    padding: 0.5rem 1rem;
    text-align: center;
    border-top: 1px solid rgba(206, 134, 54, 0.3);
    padding-top: 1rem;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .welcome-overlay {
        padding: 10px;
        overflow-y: auto;
    }

    .welcome-content {
        padding: 1.5rem 1.2rem;
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .welcome-content h1 {
        font-size: 1.3rem;
        margin-bottom: 0.8rem;
    }

    .welcome-content h3 {
        font-size: 1.1rem;
        margin: 1rem 0 0.8rem 0;
    }

    .welcome-content p {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .welcome-content ul {
        padding-left: 1.2rem;
    }

    .welcome-content li {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .welcome-content .highlight {
        font-size: 0.95rem;
        margin: 1rem 0;
    }

    .welcome-content .ready {
        font-size: 1rem;
        margin-top: 1rem;
    }

    .welcome-content button {
        font-size: 1.2rem;
        padding: 0.8rem 2rem;
        margin-top: 1rem;
    }

    .main-container {
        flex-direction: column-reverse;
        padding: 1rem;
        gap: 1rem;
        min-height: auto;
        margin: 10px;
        width: calc(100% - 20px);
    }

    .dice-section {
        border-right: none;
        border-top: 2px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
        padding-right: 0;
        padding-top: 1rem;
        padding-bottom: 0;
        min-height: auto;
        position: relative;
        z-index: 10;
    }

    .stacks-section {
        position: relative;
        z-index: 1;
    }

    .stacks-section h2 {
        font-size: 1.1rem;
        text-align: center;
    }

    .stacks-container {
        gap: 0.5rem;
    }

    .stack {
        width: 90px;
        max-width: 90px;
    }

    .stack img {
        width: 100%;
        height: auto;
    }

    .dice-area {
        height: 280px;
    }

    .dice-hint {
        font-size: 0.9rem;
    }

    #card-overlay .modal-content {
        padding: 10px;
    }

    .modal-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .read-card-button {
        font-size: 1rem;
        padding: 0.8rem 1.2rem;
    }

    #overlay-img {
        max-width: 90vw;
        max-height: 60vh;
        border-radius: 10px;
    }

    #card-overlay .close-card-button {
        font-size: 0.9rem;
        margin-top: 10px;
    }

    /* Aangepaste grootte voor mobiel */
    .dice {
        width: 150px;
        height: 150px;
    }

    .face {
        width: 150px;
        height: 150px;
    }

    .face.front {
        transform: rotateY(0deg) translateZ(75px);
    }

    .face.back {
        transform: rotateY(180deg) translateZ(75px);
    }

    .face.right {
        transform: rotateY(90deg) translateZ(75px);
    }

    .face.left {
        transform: rotateY(-90deg) translateZ(75px);
    }

    .face.top {
        transform: rotateX(90deg) translateZ(75px);
    }

    .face.bottom {
        transform: rotateX(-90deg) translateZ(75px);
    }

    /* Gebruik kleinere animatie op mobiel */
    .dice.roll-lion {
        animation-name: diceRollLionMobile;
    }

    .dice.roll-sloth {
        animation-name: diceRollSlothMobile;
    }

    .dice.roll-together {
        animation-name: diceRollTogetherMobile;
    }
}

@keyframes diceRollLionMobile {
    0% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }

    20% {
        transform: translateY(-120px) rotateX(360deg) rotateY(180deg);
    }

    100% {
        transform: translateY(0) rotateX(720deg) rotateY(720deg);
    }
}

@keyframes diceRollSlothMobile {
    0% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }

    20% {
        transform: translateY(-120px) rotateX(360deg) rotateY(180deg);
    }

    100% {
        transform: translateY(0) rotateX(720deg) rotateY(630deg);
    }
}

@keyframes diceRollTogetherMobile {
    0% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }

    20% {
        transform: translateY(-120px) rotateX(360deg) rotateY(180deg);
    }

    100% {
        transform: translateY(0) rotateX(630deg) rotateY(720deg);
    }
}