@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;700&display=swap');

:root {
    /* Card Dimensions */
    --game-card-width-lg: 157px;
    --game-card-height-lg: 220px;
    --game-card-width-sm: 120px;
    --game-card-height-sm: 168px;

    /* Colors & Theme */
    --primary-color: #000000;
    --secondary-color: #ffffff;
    --badge-bg-color: #444444;

    /* Typography */
    --primary-font: 'Quicksand', sans-serif;
}

/* ———————————————————— GLOBAL ———————————————————— */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    height: 100vh;
    margin: 0;
    font-family: var(--primary-font);
    background: #000;
    color: var(--secondary-color);
}

main {
    height: 55%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ———————————————————— CARD CONTAINER ———————————————————— */
.game-card-container {
    position: relative;
    width: 100%;
    max-width: 570px;
    height: 54vh;
    margin: 0 auto;
    /* border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); */
}

/* ———————————————————— CARD BASE ———————————————————— */
.game-card {
    position: absolute !important;
    top: 0;
    left: 0;
    width: var(--game-card-width-lg);
    height: var(--game-card-height-lg);
    cursor: pointer;
    user-select: none;
    z-index: 10;
    will-change: transform, left, top, opacity;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.6));
    transition: none; /* JS controls everything */
    transform-origin: center center;
}

.game-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-style: preserve-3d;
}

.game-card-front,
.game-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

.game-card-back {
    transform: rotateY(180deg);
}

.game-card-inner.flip-it {
    transform: rotateY(180deg);
}

.game-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ———————————————————— SHUFFLE CHAOS ANIMATION ———————————————————— */
.game-card.shuffling-around-screen {
    animation: shuffleChaos 2.4s ease-in-out forwards;
    z-index: 200 !important;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.7));
}

@keyframes shuffleChaos {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    25%  { 
        transform: translate(calc(-30vw + 30%), calc(-30vh + 30%)) 
                   rotate(var(--rand-rot)) 
                   scale(0.9);
        opacity: 0.7;
    }
    50%  { 
        transform: translate(calc(30vw - 30%), calc(30vh - 30%)) 
                   rotate(var(--rand-rot2)) 
                   scale(0.82);
        opacity: 0.5;
    }
    75%  { 
        transform: translate(calc(-20vw + 30%), calc(20vh - 30%)) 
                   rotate(var(--rand-rot3)) 
                   scale(0.95);
        opacity: 0.9;
    }
    100% { 
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

header {
    text-align: center;
    padding: 20px 10px;
}

.current-status {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 10px 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.badge {
    display: inline-block;
    background: var(--badge-bg-color);
    color: var(--secondary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-play-game {
    padding: 14px 32px;
    font-size: 1.4rem;
    font-weight: 700;
    background: #d5b160;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.btn-play-game:hover:not(:disabled) {
    background: #A58E6E;
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.5);
}

.btn-play-game:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-play-game:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.game-card-disabled {
    cursor: not-allowed;
    opacity: 0.5;
    filter: grayscale(1);
}

@media screen and (max-width: 600px) {
    .game-card {
        width: var(--game-card-width-sm);
        height: var(--game-card-height-sm);
    }

    main {
        height: 48%;
    }

    .current-status {
        font-size: 1.3rem;
    }

    #playGame {
        padding: 12px 24px;
        font-size: 1.1rem;
    }
}


/* Coin - V2 */
    .coin-wrap {
        transform: perspective(400px);
        transform-style: preserve-3d;
        display: inline-block;
    }

    .coin {
        font-family: 'Raleway-Bold';
        position: relative;
        transform-style: preserve-3d;
        width: 200px;
        height: 200px;
        margin: 0 auto;
    }

    .coin-result-heads {
        animation: flip-heads 1.25s ease-out forwards;
    }

    .coin-result-tails {
        animation: flip-tails 1.25s ease-out forwards;
    }

    .coin:after {  /* coin depth */
        content: "";
        position: absolute;
        top: 100px; /* Adjusted to center the depth of the coin */
        left: 0;
        right: 0;
        height: 12px;
        transform: rotateX(90deg);
        transform-origin: 50% 100%;
        background-color: #a66b01;
    }

    .coin__front, .coin__back {
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ffffff;
        background-color: #a66b01;
        width: 100%;
        height: 100%;
        font-size: 50px;
        text-shadow: 1px 2px #000000, -1px 0 #000000;
        border-radius: 50%;
        background-image: url(../img/coin.png);
    }

    .coin__front:before, .coin__back:before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 50%;
        transform: scale(0.8);
    }

    .coin__back {
        position: absolute;
        top: 0;
        transform: translateZ(-12px) rotateX(180deg);
        background-image: url(../img/coin.png);
    }

    .coin__front-backface, .coin__back-backface {
        border-radius: 50%;
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 100%;
        background-color: #a66b01;
    }

    .coin__front-backface {
        transform: translateZ(-1px);
    }

    .coin__back-backface {
        transform: translateZ(-11px);
    }
  
    @keyframes flip-heads {
        0% { transform: rotateX(0deg); top: 0px; }
        12.5% { transform: rotateX(45deg); top: -37.5px; }
        25% { transform: rotateX(90deg); top: -75px; }
        37.5% { transform: rotateX(135deg); top: -112.5px; }
        50% { transform: rotateX(180deg); top: -150px; }
        62.5% { transform: rotateX(225deg); top: -112.5px; }
        75% { transform: rotateX(270deg); top: -75px; }
        87.5% { transform: rotateX(315deg); top: -37.5px; }
        100% { transform: rotateX(360deg); top: 0px; }
    }
  
    @keyframes flip-tails {
        0% { transform: rotateX(0deg); top: 0px; }
        8.33% { transform: rotateX(45deg); top: -25px; }
        16.67% { transform: rotateX(90deg); top: -50px; } 
        25% { transform: rotateX(135deg); top: -75px; }
        33.33% { transform: rotateX(180deg); top: -100px; }
        41.67% { transform: rotateX(225deg); top: -125px; }
        50% { transform: rotateX(270deg); top: -150px; }
        58.33% { transform: rotateX(315deg); top: -125px; }
        66.67% { transform: rotateX(360deg); top: -100px; }
        75% { transform: rotateX(405deg); top: -75px; }
        83.33% { transform: rotateX(450deg); top: -50px; }
        91.67% { transform: rotateX(495deg); top: -25px; }
        100% { transform: rotateX(540deg); top: 0px; }
    }

/* COIN TOSS */