:root {
    --gold: #d5a72f;
    --gold-bright: #ffd66b;
    --cream: #f3ead8;
    --black: #070503;
    --safe-bottom: max(16px, env(safe-area-inset-bottom));
}


* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}


html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}


html {
    background: #070503;
}


body {
    min-height: 100vh;
    min-height: 100dvh;

    overflow: hidden;

    color: var(--cream);

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    /*
        KEIN deckender Body-Hintergrund mehr.
        Sonst kann er sich vor eine negativ geschichtete
        Background-Ebene legen.
    */
    background: transparent;
}


/* =========================================================
   BACKGROUND
   ========================================================= */

/*
   FIX:
   - Keine negativen z-index Werte mehr.
   - Bild ist ein echtes <img>.
   - Game-UI liegt mit z-index: 10 darüber.
*/

.background-scene {
    position: fixed;
    inset: 0;

    z-index: 0;

    overflow: hidden;

    pointer-events: none;

    background: #070503;
}


.background-image {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: cover;

    /*
        Das erzeugte Bild ist Portrait.
        center center hält Tisch + Casino sichtbar.
    */
    object-position: center center;

    transform:
        scale(1.025);

    filter: brightness(0.9) saturate(1.04);

    animation:
        background-drift
        18s
        ease-in-out
        infinite
        alternate;

    will-change: transform;
}


@keyframes background-drift {
    from {
        transform:
            scale(1.025)
            translate3d(-0.3%, -0.2%, 0);
    }

    to {
        transform:
            scale(1.06)
            translate3d(0.4%, 0.25%, 0);
    }
}


.background-overlay {
    position: absolute;

    inset: 0;

    background:
        linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.24) 0%,
            rgba(0, 0, 0, 0.02) 32%,
            rgba(0, 0, 0, 0.04) 60%,
            rgba(0, 0, 0, 0.67) 100%
        ),
        radial-gradient(
            ellipse at center,
            transparent 48%,
            rgba(0, 0, 0, 0.38) 100%
        );
}


/* =========================================================
   APP
   ========================================================= */

.game-shell {
    position: relative;

    z-index: 10;

    width:
        min(
            100%,
            520px
        );

    height: 100vh;
    height: 100dvh;

    margin: 0 auto;

    padding:
        14px
        18px
        var(--safe-bottom);

    display: grid;

    grid-template-rows:
        auto
        1fr
        auto
        auto;

    gap: 10px;
}


/* =========================================================
   HEADER
   ========================================================= */

.casino-header {
    text-align: center;

    text-shadow:
        0
        2px
        10px
        rgba(0, 0, 0, 0.95);
}


.casino-crown {
    height: 17px;

    margin-bottom: -2px;

    color: var(--gold-bright);

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 18px;
}


.casino-header h1 {
    margin: 0;

    color: #f0ca63;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size:
        clamp(
            24px,
            7vw,
            34px
        );

    font-weight: 500;

    line-height: 1.1;
}


.game-subtitle {
    width: 230px;

    margin: 8px auto 0;

    display: grid;

    grid-template-columns:
        1fr
        auto
        1fr;

    align-items: center;

    gap: 9px;

    color: #e0ba53;
}


.game-subtitle strong {
    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 13px;

    letter-spacing: 0.16em;
}


.game-subtitle span {
    height: 1px;

    background:
        linear-gradient(
            to right,
            transparent,
            var(--gold)
        );
}


.game-subtitle span:last-child {
    background:
        linear-gradient(
            to left,
            transparent,
            var(--gold)
        );
}


/* =========================================================
   CAMERA
   ========================================================= */

.camera {
    position: relative;

    min-height: 0;

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    transform-origin:
        50%
        58%;

    will-change: transform;
}


.table-light {
    position: absolute;

    top: 47%;
    left: 50%;

    width: 78%;
    height: 34%;

    border-radius: 50%;

    transform:
        translate(-50%, -50%);

    pointer-events: none;

    filter:
        blur(15px);

    background:
        radial-gradient(
            ellipse,
            rgba(226, 169, 48, 0.14) 0%,
            rgba(37, 100, 49, 0.06) 45%,
            transparent 74%
        );
}


/* =========================================================
   DICE STAGE
   ========================================================= */

.dice-stage {
    position: relative;

    contain: layout paint;

    width:
        min(
            82vw,
            360px
        );

    height:
        clamp(
            230px,
            40vh,
            365px
        );

    display: flex;

    justify-content: center;

    align-items: center;

    perspective: 900px;

    perspective-origin:
        50%
        42%;

    transform-style: preserve-3d;

    isolation: isolate;
}


.dice-flight {
    position: relative;

    z-index: 4;

    width: 150px;
    height: 150px;

    display: flex;

    justify-content: center;

    align-items: center;

    transform-style: preserve-3d;

    transform:
        translate3d(
            0,
            8px,
            0
        );

    transform-origin:
        50%
        80%;

    will-change: transform;
}


/* =========================================================
   SHADOW
   ========================================================= */

.dice-shadow {
    position: absolute;

    z-index: 1;

    left: 50%;
    top: 68%;

    width: 122px;
    height: 34px;

    border-radius: 50%;

    transform:
        translate(-50%, -50%);

    opacity: 0.78;

    filter:
        blur(5px);

    background:
        radial-gradient(
            ellipse at center,
            rgba(0, 0, 0, 0.78) 0%,
            rgba(0, 0, 0, 0.48) 36%,
            rgba(0, 0, 0, 0.06) 70%,
            transparent 100%
        );

    will-change:
        transform,
        filter,
        opacity;
}


/* =========================================================
   3D DICE
   ========================================================= */

.dice {
    position: relative;

    width: 120px;
    height: 120px;

    transform-style: preserve-3d;

    transform:
        rotateX(-20deg)
        rotateY(32deg)
        rotateZ(-4deg);

    will-change: transform;
}


.dice-face {
    position: absolute;

    top: 0;
    left: 0;

    width: 120px;
    height: 120px;

    border:
        1px
        solid
        rgba(
            130,
            112,
            77,
            0.55
        );

    border-radius: 19px;

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

    background:
        linear-gradient(
            145deg,
            #fffdf4 0%,
            #f6eed8 20%,
            #e5d7b8 58%,
            #c1ae89 100%
        );

    box-shadow:
        inset
        10px
        10px
        17px
        rgba(
            255,
            255,
            255,
            0.62
        ),

        inset
        -11px
        -12px
        20px
        rgba(
            74,
            50,
            22,
            0.24
        ),

        0
        0
        0
        1px
        rgba(
            255,
            255,
            255,
            0.12
        );
}


.dice-face::before {
    content: "";

    position: absolute;

    inset: 5px;

    border-radius: 15px;

    pointer-events: none;

    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.34),
            transparent 34%,
            rgba(83, 59, 29, 0.05) 72%,
            rgba(77, 52, 24, 0.14)
        );
}


.face-1 {
    transform:
        rotateY(0deg)
        translateZ(60px);
}


.face-6 {
    transform:
        rotateY(180deg)
        translateZ(60px);
}


.face-2 {
    transform:
        rotateY(90deg)
        translateZ(60px);
}


.face-5 {
    transform:
        rotateY(-90deg)
        translateZ(60px);
}


.face-3 {
    transform:
        rotateX(90deg)
        translateZ(60px);
}


.face-4 {
    transform:
        rotateX(-90deg)
        translateZ(60px);
}


/* =========================================================
   PIPS
   ========================================================= */

.pip {
    position: absolute;

    z-index: 3;

    width: 19px;
    height: 19px;

    border-radius: 50%;

    transform:
        translate(-50%, -50%);

    background:
        radial-gradient(
            circle at 36% 32%,
            #444 0%,
            #171717 32%,
            #050505 76%,
            #000 100%
        );

    box-shadow:
        inset
        2px
        2px
        4px
        rgba(
            255,
            255,
            255,
            0.17
        ),

        inset
        -2px
        -2px
        5px
        rgba(
            0,
            0,
            0,
            0.7
        ),

        0
        1px
        1px
        rgba(
            255,
            255,
            255,
            0.24
        );
}


.top-left {
    left: 26%;
    top: 26%;
}


.top-right {
    left: 74%;
    top: 26%;
}


.middle-left {
    left: 26%;
    top: 50%;
}


.middle-right {
    left: 74%;
    top: 50%;
}


.center {
    left: 50%;
    top: 50%;
}


.bottom-left {
    left: 26%;
    top: 74%;
}


.bottom-right {
    left: 74%;
    top: 74%;
}


/* =========================================================
   STATUS PANEL
   ========================================================= */

.status-panel {
    position: relative;

    contain: layout paint;

    width:
        min(
            100%,
            410px
        );

    min-height: 78px;

    margin-top: -6px;

    padding:
        16px
        18px;

    display: flex;

    justify-content: center;

    align-items: center;

    overflow: hidden;

    border:
        1px
        solid
        rgba(
            206,
            155,
            37,
            0.58
        );

    border-radius: 8px;

    background:
        linear-gradient(
            180deg,
            rgba(10, 8, 5, 0.9),
            rgba(3, 3, 2, 0.86)
        );

    box-shadow:
        0
        8px
        28px
        rgba(
            0,
            0,
            0,
            0.45
        );

}


.status-panel::before,
.status-panel::after {
    content: "◆";

    position: absolute;

    top: 50%;

    color: #b77e16;

    font-size: 7px;

    transform:
        translateY(-50%);
}


.status-panel::before {
    left: 7px;
}


.status-panel::after {
    right: 7px;
}


.status-text {
    color: #eee3ca;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size:
        clamp(
            17px,
            4.4vw,
            20px
        );

    text-align: center;

    text-shadow:
        0
        2px
        6px
        rgba(
            0,
            0,
            0,
            0.9
        );

    transition:
        opacity
        180ms
        ease;
}


.status-text.hidden {
    opacity: 0;
}


/* =========================================================
   RESULT
   ========================================================= */

.result-card {
    position: absolute;

    inset: 0;

    display: flex;

    flex-direction: column;

    justify-content: center;

    align-items: center;

    opacity: 0;

    transform:
        scale(0.6)
        translateY(12px);

    pointer-events: none;
}


.result-card.visible {
    animation:
        result-reveal
        760ms
        cubic-bezier(
            0.16,
            1,
            0.3,
            1
        )
        forwards;
}


@keyframes result-reveal {
    0% {
        opacity: 0;

        transform:
            scale(0.55)
            translateY(14px);

        filter:
            blur(6px);
    }

    58% {
        opacity: 1;

        transform:
            scale(1.12)
            translateY(-2px);

        filter:
            blur(0);
    }

    100% {
        opacity: 1;

        transform:
            scale(1)
            translateY(0);

        filter:
            blur(0);
    }
}


.result-heading {
    color: #d9b23d;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 11px;

    font-weight: 700;

    letter-spacing: 0.22em;
}


.result-number {
    margin-top: -4px;

    color: #ffe184;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 39px;

    font-weight: 700;

    line-height: 1;

    text-shadow:
        0
        0
        9px
        rgba(
            255,
            194,
            46,
            0.75
        ),

        0
        0
        26px
        rgba(
            207,
            123,
            12,
            0.65
        );
}


.result-word {
    margin-top: 2px;

    color: #d6aa42;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 10px;

    font-weight: 700;

    letter-spacing: 0.17em;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.controls {
    display: grid;

    gap: 10px;
}


.button {
    width: 100%;

    min-height: 55px;

    border-radius: 8px;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 17px;

    font-weight: 700;

    letter-spacing: 0.04em;

    cursor: pointer;

    transition:
        transform
        120ms
        ease,
        filter
        120ms
        ease;
}


.button:active {
    transform:
        scale(0.985);

    filter:
        brightness(1.13);
}


.button:disabled {
    opacity: 0.6;

    cursor: default;
}


.button-primary {
    border:
        1px
        solid
        #e7b32c;

    color: #fff0cb;

    background:
        linear-gradient(
            180deg,
            #a81016 0%,
            #79070b 52%,
            #5b0306 100%
        );

    box-shadow:
        inset
        0
        1px
        0
        rgba(
            255,
            255,
            255,
            0.3
        ),

        0
        4px
        13px
        rgba(
            0,
            0,
            0,
            0.42
        );
}


.button-icon {
    display: inline-block;

    margin-right: 9px;

    font-size: 20px;
}


.button-secondary {
    border:
        1px
        solid
        rgba(
            202,
            151,
            36,
            0.6
        );

    color: #eadfca;

    background:
        linear-gradient(
            180deg,
            rgba(15, 13, 10, 0.88),
            rgba(6, 6, 5, 0.92)
        );
}


/* =========================================================
   FOOTER
   ========================================================= */

.footer-note {
    padding-top: 2px;

    color: #b98b2a;

    font-size: 11px;

    text-align: center;

    text-shadow:
        0
        1px
        4px
        #000;
}


/* =========================================================
   LANDING FLASH
   ========================================================= */

.camera.landing-flash::after {
    content: "";

    position: absolute;

    inset:
        12%
        6%
        22%;

    z-index: 20;

    border-radius: 50%;

    pointer-events: none;

    background:
        radial-gradient(
            circle,
            rgba(255, 213, 101, 0.24) 0%,
            rgba(255, 180, 50, 0.07) 36%,
            transparent 67%
        );

    animation:
        landing-flash
        650ms
        ease-out
        forwards;
}


@keyframes landing-flash {
    from {
        opacity: 1;

        transform:
            scale(0.76);
    }

    to {
        opacity: 0;

        transform:
            scale(1.35);
    }
}


/* =========================================================
   SMALL DISPLAYS
   ========================================================= */

@media (
    max-height: 680px
) {

    .game-shell {
        gap: 7px;

        padding-top: 9px;
    }


    .casino-header {
        transform:
            scale(0.88);

        transform-origin:
            top center;
    }


    .dice-stage {
        height:
            clamp(
                190px,
                32vh,
                235px
            );
    }


    .dice {
        width: 100px;
        height: 100px;
    }


    .dice-face {
        width: 100px;
        height: 100px;

        border-radius: 15px;
    }


    .face-1 {
        transform:
            rotateY(0deg)
            translateZ(50px);
    }


    .face-6 {
        transform:
            rotateY(180deg)
            translateZ(50px);
    }


    .face-2 {
        transform:
            rotateY(90deg)
            translateZ(50px);
    }


    .face-5 {
        transform:
            rotateY(-90deg)
            translateZ(50px);
    }


    .face-3 {
        transform:
            rotateX(90deg)
            translateZ(50px);
    }


    .face-4 {
        transform:
            rotateX(-90deg)
            translateZ(50px);
    }


    .pip {
        width: 16px;
        height: 16px;
    }


    .dice-flight {
        width: 120px;
        height: 120px;
    }


    .status-panel {
        min-height: 62px;

        padding:
            12px
            15px;
    }


    .button {
        min-height: 48px;
    }

}
