
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;

    font-family: Arial, sans-serif;
    color: #f8fafc;

    background:
        radial-gradient(ellipse at top, #303b65 0%, transparent 65%),
        linear-gradient(135deg, #111827, #19152f);
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 36px 24px;
    text-align: center;

    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;

    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
}

h1 {
    margin-top: 0;
    font-size: clamp(2rem, 7vw, 2.8rem);
    letter-spacing: -1px;
}

/* The shadow underneath the coin */
.coin-container::after {
    content: "";
    position: absolute;
    bottom: 8px;
    left: 20%;
    width: 60%;
    height: 18px;

    background: #000;
    filter: blur(16px);
    border-radius: 50%;
    opacity: 0.3;
    transform: scaleX(1);
    transition: transform 0.3s, opacity 0.3s;
    pointer-events: none;
}

.coin-container:has(.flipping)::after {
    animation: shadow-flip 1s ease-in-out infinite;
}

@keyframes shadow-flip {
    0%, 100% {
        transform: scaleX(1);
        opacity: 0.3;
    }

    50% {
        transform: scaleX(0.6);
        opacity: 0.12;
    }
}

#resultText {
    min-height: 36px;
    margin: 24px 0;
    font-size: 1.8rem;
    transition: transform 0.2s;
}

#resultText.result-pop {
    animation: result-pop 0.45s cubic-bezier(.2, 1.6, .4, 1);
}

@keyframes result-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

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

button {
    padding: 15px 38px;
    border: none;
    border-radius: 12px;

    font-size: 1.2rem;
    font-weight: bold;
    color: white;

    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    box-shadow: 0 6px 0 #4338a3, 0 10px 25px #0003;

    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s,
                opacity 0.2s;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #4338a3, 0 14px 30px #0004;
}

button:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #4338a3;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


.coin-container {
    position: relative;
    width: 280px;
    height: 280px;
    max-width: 100%;
    margin: 40px auto;

    display: flex;
    align-items: center;
    justify-content: center;

    perspective: 1100px;
    perspective-origin: 50% 45%;
}

/* Schaduw onder de munt */
.coin-shadow {
    position: absolute;
    width: 65%;
    height: 20px;
    bottom: 20px;
    left: 17.5%;

    border-radius: 50%;
    background: #000;
    filter: blur(14px);
    opacity: 0.45;
    transform: scaleX(1);
    transition: transform 0.4s, opacity 0.4s;
}

.coin-3d {
    position: relative;
    width: 230px;
    height: 230px;
    max-width: 90%;
    max-height: 90%;
    aspect-ratio: 1;

    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;

    transform: rotateX(0deg) rotateZ(-8deg);

    will-change: transform;
}

.coin-face {
    position: absolute;
    inset: 0;

    border-radius: 50%;
    overflow: hidden;

    border: 7px solid #e5b84b;
    background: #b87922;

    /* Gelaagde gouden rand en diepte */
    box-shadow:
        inset 0 0 0 2px #fff0a0,
        inset 0 0 0 5px #9a601b,
        0 1px 0 #d49b34,
        0 2px 0 #9a651e,
        0 3px 0 #d49b34,
        0 4px 0 #85531a,
        0 5px 0 #bd842a,
        0 6px 0 #6d4317,
        0 7px 0 #b77d25,
        0 12px 20px #0005;

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.coin-front {
    transform: translateZ(4px);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.coin-back {
    transform: rotateX(180deg) translateZ(4px);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.coin-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Extra glans op het metaal */
.coin-face::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;

    background: linear-gradient(
        135deg,
        #ffffff35 0%,
        transparent 35%,
        transparent 65%,
        #00000025 100%
    );
}

.coin-shadow.flipping {
    transform: scaleX(0.65);
    opacity: 0.25;
}


@media (max-width: 420px) {
    .coin-container {
        height: 250px;
    }

    .coin-3d {
        width: 205px;
        height: 205px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .coin-image.flipping,
    .coin-container:has(.flipping)::after,
    #resultText.result-pop {
        animation: none;
    }
    .coin-3d {
        will-change: auto;
    }
}
