* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    font-family: "Press Start 2P", serif;
    font-weight: 400;
    font-style: normal;
    background-color: black;
}

#canvas {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: 100%;
    background-image: url('./Assets/entrance.png');
    background-size: cover;
    background-repeat: no-repeat;
    transition: background-color 1s ease-in-out;
    animation: fadeIn 3s ease-in-out forwards;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

#backgroundmusic {
    position: absolute;
    top: 3%;
    left: 93%;
    width: 70px;
    height: 70px;
    font-size: 16px;
    border: none;
    color: white;
    cursor: pointer;
}

#playPauseImage {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#starttext {
    position: absolute;
    top: 75%;
    left: 52%;
    transform: translate(-50%, -50%);
    color: red;
    text-shadow: 2px 2px 2px black;
}

#voicediv {
    position: absolute;
    top: 20%;
    left: 73%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    line-height: 2;
    text-shadow: 2px 2px 4px black;
    text-align: center;
}

#voiceline {
    width: 100%;
    height: 100%;
    font-size: 16px;
    color: white;
    text-shadow: 2px 2px 2px black;
    text-align: center;
    line-height: 2.2;
    white-space: pre-wrap;
}

#warning {
    display: none;
    position: absolute;
    top: 45%;
    left: 52%;
    transform: translate(-50%, -50%);
    color: red;
    text-shadow: 2px 2px 2px black;
    animation: fadeIn 3s ease-in-out forwards;
}

#upperdiv {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: 27%;
}

#dealerhand {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 50%;
    height: 100%;
}

#middlediv {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 45%;
}

#betfield {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 21.5%;
    height: 100%;
}

#pentagram {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 400px;
    height: 400px;
    background-image: url('./Assets/blackpentagram.png');
    background-size: 80% 80%;
    background-repeat: no-repeat;
    background-position: 50% 50%;
}

#coinstack {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 55%;
    margin-bottom: 7%;
    background-image: url('./Assets/coinstack.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: 50% 50%;
}

#battlefield {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 57%;
    height: 100%;
}

#dialoguediv {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 60%;
    padding-top: 10%;
    font-size: 18px;
    color: white;
}

#buttonsdiv {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-start;
    width: 95%;
    height: 35%;
}

.betbutton {
    width: 120px;
    height: 50px;
    font-size: 16px;
    color: black;
    text-shadow: 2px 2px 2px white;
    background-color: black;
    border: 2px solid white;
    cursor: pointer;
    font-family: "Press Start 2P", serif;
    background-color: red;
}

#allin {
    background-color: black;
    color: red;
    text-shadow: 2px 2px 2px black;
}

#deckfield {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 21.5%;
    height: 100%;
    margin-right: 1%;
}

#backcard {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 300px;
    height: 220px;
    background-image: url('./Assets/blueflipbackcard.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
}

#lowerdiv {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: 27%;
}

#playerhand {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 50%;
    height: 100%;
}

#souldiv {
    position: absolute;
    bottom: 10%;
    left: 6%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    width: 190px;
    height: 100px;
    border: 2px solid white;
}

#cross {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 25%;
    height: 60%;
    margin-left: 5%;
    background-image: url('./Assets/cross.png');
    background-size: cover;
    background-repeat: no-repeat;
}

#soulvalue {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 70%;
    height: 100%;
    font-size: 17px;
    color: white;
    text-shadow: 2px 2px 2px black;
}

.score-display {
    position: absolute;
    font-size: 40px;
    font-family: "Press Start 2P", monospace;
    color: white;
    text-shadow: 2px 2px 2px black;
    padding: 5px 10px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 1000;
}

#dealerScore {
    top: 40%;
    right: 22%;
}

#playerScore {
    bottom: 40%;
    right: 22%;
}

#laughOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    pointer-events: none;
    display: none;
    grid-template-columns: repeat(var(--cols, 10), 1fr);
    grid-auto-rows: 1fr;
    gap: 0;
    background: rgba(0, 0, 0, 1);
}

.laughCell {
    display: grid;
    place-items: center;
    font-family: "Press Start 2P", serif;
    font-weight: 900;
    color: #ff1515;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .75);
    opacity: 0;
    transition: opacity .18s ease;
    user-select: none;
}

@keyframes haCombo {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }

    12% {
        transform: translate(-2px, 2px) rotate(-2deg) scale(1.05);
    }

    25% {
        transform: translate(2px, -1px) rotate(2deg) scale(1.10);
    }

    37% {
        transform: translate(-1px, -2px) rotate(-1deg) scale(1.15);
    }

    50% {
        transform: translate(1px, 1px) rotate(1deg) scale(1.25);
    }

    62% {
        transform: translate(-2px, 1px) rotate(0deg) scale(1.15);
    }

    75% {
        transform: translate(2px, 0px) rotate(2deg) scale(1.10);
    }

    87% {
        transform: translate(-1px, -1px) rotate(-2deg) scale(1.05);
    }

    100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
}

.haAnim {
    animation: haCombo 0.8s ease-in-out infinite;
}

@keyframes fadeOutOverlay {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.fadeOut {
    animation: fadeOutOverlay 2s ease forwards;
}

#heartbeatOverlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    pointer-events: none;
    display: none;
    opacity: 0;
    transform: translateZ(0);
    background-image: url("./Assets/heart.png");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: min(20vmin, 20vh);
    box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, 0.18);
    filter: drop-shadow(0 8px 20px rgba(255, 0, 0, 0.35));
}

#heartbeatOverlay.heartbeatVisible {
    display: block;
    opacity: 1;
    animation: heartbeat var(--hb-dur, 900ms) ease-in-out infinite;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 8px 20px rgba(255, 0, 0, .35)) brightness(1);
    }

    8% {
        transform: scale(1.05);
        filter: drop-shadow(0 10px 24px rgba(255, 0, 0, .42)) brightness(1.12);
    }

    16% {
        transform: scale(1);
        filter: drop-shadow(0 8px 20px rgba(255, 0, 0, .35)) brightness(1);
    }

    24% {
        transform: scale(1.07);
        filter: drop-shadow(0 12px 28px rgba(255, 0, 0, .48)) brightness(1.10);
    }

    32% {
        transform: scale(1);
        filter: drop-shadow(0 8px 20px rgba(255, 0, 0, .35)) brightness(1);
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0 8px 20px rgba(255, 0, 0, .35)) brightness(1);
    }
}

@keyframes fadeOutOverlay {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

#heartbeatOverlay.fadeOut {
    animation: fadeOutOverlay 300ms ease forwards;
}