:root {
    --v66-orange: #ff5a0a;
    --v66-orange-light: #ff8b3d;
    --v66-orange-dark: #d84400;
    --v66-gold: #ffd34e;
    --v66-gold-light: #fff2a0;
    --v66-white: #ffffff;
    --v66-text: #2d160c;
    --v66-muted: #806c62;
    --v66-border: #ffd0b6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    padding: 16px;
    color: var(--v66-text);
    background:
        radial-gradient(
            circle at top right,
            #fff0e4,
            transparent 35%
        ),
        #f1f1f1;
    font-family: Arial, Helvetica, sans-serif;
}

button,
a {
    font-family: inherit;
}

.fortune-container {
    width: calc(100% - 24px);
    max-width: 1500px;
    min-height: calc(100vh - 32px);
    margin: 0 auto;
    overflow: hidden;
    background: white;
    border-radius: 22px;
    box-shadow: 0 16px 45px rgba(67, 31, 13, 0.16);
}


/* Header */

.fortune-header {
    min-height: 76px;
    padding: 14px 24px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    border-bottom: 2px solid var(--v66-orange);
}

.back-button {
    justify-self: start;
    padding: 10px 17px;
    border: 1px solid #ffb58c;
    border-radius: 999px;
    color: var(--v66-orange-dark);
    background: #fff5ef;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    transition: 0.2s ease;
}

.back-button:hover {
    color: white;
    background: var(--v66-orange);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    padding: 10px 15px;
    border-radius: 9px;
    color: white;
    background: linear-gradient(
        135deg,
        var(--v66-orange-dark),
        var(--v66-orange-light)
    );
    box-shadow: 0 5px 14px rgba(255, 90, 10, 0.3);
    font-size: 21px;
    font-style: italic;
    font-weight: 900;
}

.brand-text {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 2px;
}

.chance-box {
    justify-self: end;
    padding: 10px 17px;
    border: 1px solid #ffc09f;
    border-radius: 999px;
    color: var(--v66-orange-dark);
    background: #fff7f2;
    font-size: 14px;
    font-weight: 800;
}


/* Introduction */

.fortune-introduction {
    padding: 27px 20px 25px;
    color: white;
    text-align: center;
    background: linear-gradient(
        110deg,
        #ff4c08,
        #ff7900
    );
}

.fortune-introduction span {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 5px;
}

.fortune-introduction h1 {
    margin-top: 8px;
    font-size: clamp(35px, 4vw, 53px);
    line-height: 1;
}

.fortune-introduction p {
    max-width: 720px;
    margin: 13px auto 0;
    font-size: 15px;
    line-height: 1.6;
}


/* Main game area */

.fortune-game-area {
    padding: 27px 18px 24px;
    text-align: center;
    background: #fafafa;
}

.fortune-scene {
    position: relative;
    width: min(100%, 1050px);
    height: 620px;
    margin: 0 auto;
    overflow: hidden;
    border: 3px solid white;
    border-radius: 25px;
    background-image:
        url("images/v66-golden-tree-background.png");
    background-position: center;
    background-size: cover;
    box-shadow:
        0 18px 35px rgba(94, 55, 10, 0.22),
        0 0 0 1px #ecd5aa;
}


/* Subtle edge contrast */

.fortune-scene::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(
            90deg,
            rgba(62, 30, 5, 0.22),
            transparent 22%,
            transparent 78%,
            rgba(62, 30, 5, 0.22)
        ),
        linear-gradient(
            to top,
            rgba(50, 25, 4, 0.18),
            transparent 35%
        );
}


/* Central light */

.light-glow {
    position: absolute;
    z-index: 1;
    top: 8%;
    left: 50%;
    width: 72%;
    height: 70%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(
        ellipse,
        rgba(255, 247, 180, 0.42),
        rgba(255, 204, 62, 0.12) 48%,
        transparent 72%
    );
    filter: blur(5px);
    pointer-events: none;
}


/* Floating light particles */

.floating-light {
    position: absolute;
    z-index: 4;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff6af;
    box-shadow:
        0 0 10px #fff7b4,
        0 0 20px #ffc92f;
    animation: floatingLight 3s ease-in-out infinite;
}

.light-one {
    top: 27%;
    left: 17%;
}

.light-two {
    top: 42%;
    right: 18%;
    animation-delay: 0.8s;
}

.light-three {
    top: 18%;
    right: 31%;
    animation-delay: 1.5s;
}

@keyframes floatingLight {
    0%,
    100% {
        transform: translateY(0) scale(0.7);
        opacity: 0.4;
    }

    50% {
        transform: translateY(-18px) scale(1.2);
        opacity: 1;
    }
}


/* Tree stage */

.tree-stage {
    position: absolute;
    z-index: 3;
    inset: 0;
}

.fortune-tree {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: 2%;
    width: auto;
    height: 96%;
    max-width: 88%;
    object-fit: contain;
    transform: translateX(-50%);
    transform-origin: 50% 96%;
    filter:
        drop-shadow(0 14px 15px rgba(56, 26, 4, 0.32))
        drop-shadow(0 0 16px rgba(255, 211, 73, 0.22));
    animation: treeGlow 3s ease-in-out infinite;
}

@keyframes treeGlow {
    0%,
    100% {
        filter:
            drop-shadow(0 14px 15px rgba(56, 26, 4, 0.32))
            drop-shadow(0 0 12px rgba(255, 211, 73, 0.18));
    }

    50% {
        filter:
            drop-shadow(0 14px 15px rgba(56, 26, 4, 0.32))
            drop-shadow(0 0 24px rgba(255, 223, 95, 0.5));
    }
}


/* Tree shaking */

.fortune-tree.shaking {
    animation: fortuneTreeShake 0.95s ease-in-out;
}

@keyframes fortuneTreeShake {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }

    15% {
        transform: translateX(-50%) rotate(-2.5deg);
    }

    30% {
        transform: translateX(-50%) rotate(2.5deg);
    }

    45% {
        transform: translateX(-50%) rotate(-3deg);
    }

    60% {
        transform: translateX(-50%) rotate(3deg);
    }

    75% {
        transform: translateX(-50%) rotate(-1.5deg);
    }

    90% {
        transform: translateX(-50%) rotate(1.5deg);
    }

    100% {
        transform: translateX(-50%) rotate(0deg);
    }
}


/* Ground glow */

.ground-glow {
    position: absolute;
    z-index: 2;
    left: 50%;
    bottom: 3%;
    width: 45%;
    height: 9%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(
        ellipse,
        rgba(255, 241, 154, 0.85),
        rgba(255, 188, 35, 0.28) 50%,
        transparent 74%
    );
    filter: blur(7px);
}


/* Falling coin */

.falling-coin {
    position: absolute;
    z-index: 10;
    top: 22%;
    left: 50%;
    width: 72px;
    height: 72px;
    display: none;
    perspective: 600px;
    transform: translateX(-50%);
}

.falling-coin.falling {
    display: block;
    animation: coinFall 1.25s
        cubic-bezier(0.45, 0, 0.72, 1.15)
        forwards;
}

.coin-face {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 5px solid #ffe991;
    border-radius: 50%;
    color: #8d4b00;
    background:
        radial-gradient(
            circle at 32% 27%,
            #fff9bf,
            #ffd94f 25%,
            #f2a900 62%,
            #bc6800 100%
        );
    box-shadow:
        inset 0 0 0 4px #d98a00,
        inset 0 0 16px rgba(255, 255, 255, 0.75),
        0 0 14px #ffe77c,
        0 7px 13px rgba(76, 38, 3, 0.38);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 1px;
}

@keyframes coinFall {
    0% {
        top: 20%;
        transform:
            translateX(-50%)
            rotateY(0deg)
            rotateZ(0deg)
            scale(0.75);
        opacity: 0;
    }

    12% {
        opacity: 1;
    }

    65% {
        top: 70%;
        transform:
            translateX(-50%)
            rotateY(720deg)
            rotateZ(220deg)
            scale(1.08);
    }

    88% {
        top: 82%;
        transform:
            translateX(-50%)
            rotateY(960deg)
            rotateZ(330deg)
            scale(1);
    }

    100% {
        top: 78%;
        transform:
            translateX(-50%)
            rotateY(1080deg)
            rotateZ(360deg)
            scale(1.12);
        opacity: 1;
    }
}


/* Controls */

.shake-tree-button {
    margin-top: 24px;
    padding: 15px 35px;
    border: none;
    border-radius: 999px;
    color: white;
    background: linear-gradient(
        135deg,
        var(--v66-orange),
        var(--v66-orange-light)
    );
    box-shadow: 0 9px 19px rgba(255, 90, 10, 0.27);
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 1px;
    cursor: pointer;
    transition: 0.2s ease;
}

.shake-tree-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(255, 90, 10, 0.34);
}

.shake-tree-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fortune-status {
    min-height: 22px;
    margin-top: 13px;
    color: var(--v66-muted);
    font-size: 14px;
}


/* Rewards */

.reward-section {
    padding: 25px 18px;
    text-align: center;
    border-top: 1px solid #eeeeee;
}

.reward-section h2 {
    margin-bottom: 14px;
    font-size: 21px;
}

.reward-list {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 9px;
}

.reward-list span {
    padding: 8px 13px;
    border: 1px solid var(--v66-border);
    border-radius: 999px;
    color: var(--v66-orange-dark);
    background: #fff7f1;
    font-size: 12px;
    font-weight: 800;
}


/* Footer */

.fortune-footer {
    padding: 20px;
    color: #89756b;
    background: #fafafa;
    text-align: center;
    font-size: 12px;
    line-height: 1.7;
}


/* Result modal */

.result-modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    visibility: hidden;
    opacity: 0;
    background: rgba(38, 19, 5, 0.72);
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.result-modal.show {
    visibility: visible;
    opacity: 1;
}

.result-card {
    width: min(100%, 430px);
    padding: 35px 28px;
    border: 3px solid #ffd159;
    border-radius: 25px;
    background: white;
    box-shadow:
        0 25px 65px rgba(0, 0, 0, 0.3),
        0 0 35px rgba(255, 205, 52, 0.35);
    text-align: center;
    transform: scale(0.84);
    transition: transform 0.25s ease;
}

.result-modal.show .result-card {
    transform: scale(1);
}

.result-coin {
    width: 94px;
    height: 94px;
    margin: 0 auto 17px;
    animation: resultCoinFloat 0.85s ease-in-out infinite alternate;
}

.result-coin-face {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 6px solid #fff0a6;
    border-radius: 50%;
    color: #914c00;
    background: radial-gradient(
        circle at 32% 25%,
        #fffbd1,
        #ffdc54 30%,
        #eda000 68%,
        #b96600
    );
    box-shadow:
        inset 0 0 0 5px #d58600,
        0 0 22px #ffdd59;
    font-size: 21px;
    font-weight: 900;
}

@keyframes resultCoinFloat {
    from {
        transform: translateY(0) rotate(-4deg);
    }

    to {
        transform: translateY(-11px) rotate(4deg);
    }
}

.result-card h2 {
    margin-bottom: 12px;
    font-size: 29px;
}

.result-card strong {
    display: block;
    margin-bottom: 14px;
    color: var(--v66-orange);
    font-size: 39px;
}

.result-card p {
    color: var(--v66-muted);
    font-size: 14px;
    line-height: 1.6;
}

.result-card button {
    margin-top: 22px;
    padding: 13px 29px;
    border: none;
    border-radius: 999px;
    color: white;
    background: var(--v66-orange);
    font-weight: 900;
    cursor: pointer;
}


/* Mobile layout */

@media (max-width: 760px) {
    body {
        padding: 0;
    }

    .fortune-container {
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
    }

    .fortune-header {
        padding: 12px;
        grid-template-columns: auto 1fr auto;
        gap: 8px;
    }

    .back-button {
        padding: 8px 10px;
        font-size: 0;
    }

    .back-button::after {
        content: "←";
        font-size: 18px;
    }

    .brand {
        justify-content: center;
    }

    .brand-logo {
        padding: 8px 10px;
        font-size: 16px;
    }

    .brand-text {
        display: none;
    }

    .chance-box {
        padding: 8px 10px;
        font-size: 12px;
    }

    .fortune-introduction {
        padding: 23px 12px;
    }

    .fortune-introduction span {
        letter-spacing: 3px;
    }

    .fortune-game-area {
        padding: 15px 7px 22px;
    }

    .fortune-scene {
        height: 510px;
        border-radius: 18px;
    }

    .fortune-tree {
        bottom: 3%;
        width: 96%;
        height: auto;
        max-width: none;
        max-height: 91%;
    }

    .falling-coin {
        width: 61px;
        height: 61px;
    }

    .coin-face {
        font-size: 14px;
    }
}/* Separate tree into fixed trunk and moving canopy */

.fortune-tree-wrapper {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: 2%;
    width: 88%;
    height: 96%;
    transform: translateX(-50%);
    pointer-events: none;
}

.fortune-tree-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}


/* Fixed lower trunk layer */

.tree-trunk-layer {
    z-index: 1;

    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 52%,
        rgba(0, 0, 0, 0.35) 59%,
        black 68%,
        black 100%
    );

    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 52%,
        rgba(0, 0, 0, 0.35) 59%,
        black 68%,
        black 100%
    );

    filter:
        drop-shadow(
            0 14px 15px
            rgba(56, 26, 4, 0.32)
        );
}


/* Moving upper branches and leaves */

.tree-canopy-layer {
    z-index: 2;

    -webkit-mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 56%,
        rgba(0, 0, 0, 0.7) 63%,
        transparent 72%,
        transparent 100%
    );

    mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 56%,
        rgba(0, 0, 0, 0.7) 63%,
        transparent 72%,
        transparent 100%
    );

    transform-origin: 50% 66%;

    filter:
        drop-shadow(
            0 0 14px
            rgba(255, 220, 85, 0.3)
        );

    animation:
        canopyGlow 3s ease-in-out infinite;
}


@keyframes canopyGlow {
    0%,
    100% {
        filter:
            drop-shadow(
                0 0 12px
                rgba(255, 216, 71, 0.22)
            );
    }

    50% {
        filter:
            drop-shadow(
                0 0 25px
                rgba(255, 230, 110, 0.55)
            );
    }
}


/* Only the upper tree moves */

.tree-canopy-layer.shaking {
    animation:
        canopyShake 0.95s ease-in-out;
}


@keyframes canopyShake {
    0% {
        transform: rotate(0deg);
    }

    15% {
        transform: rotate(-2deg);
    }

    30% {
        transform: rotate(2deg);
    }

    45% {
        transform: rotate(-2.7deg);
    }

    60% {
        transform: rotate(2.7deg);
    }

    75% {
        transform: rotate(-1.4deg);
    }

    90% {
        transform: rotate(1.4deg);
    }

    100% {
        transform: rotate(0deg);
    }
}


@media (max-width: 760px) {
    .fortune-tree-wrapper {
        bottom: 3%;
        width: 96%;
        height: 91%;
    }
}