:root {
    --bg-color: #ffc3a0;
    --bg-gradient: linear-gradient(to bottom, #ffdde1, #ee9ca7);
    --machine-color: #ff9a9e;
    --machine-dark: #e47c81;
    --glass-border: rgba(255, 255, 255, 0.4);
    --btn-color: #fca0c9;
    --btn-shadow: #d86a96;
}

body {
    background-image: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    /* Stack items vertically */
    justify-content: flex-start;
    /* Start from top */
    align-items: center;
    /* Center horizontally */
    min-height: 100vh;
    font-family: 'Prompt', 'Varela Round', sans-serif;
    margin: 0;
    overflow: hidden;
}

/* --- Game Title --- */
.game-title {
    position: relative;
    margin-top: 40px;
    /* Space from top of screen */
    margin-bottom: 20px;
    /* Space between title and machine */
    text-align: center;
    z-index: 1000;
    animation: fadeInDown 0.8s ease-out;
    flex-shrink: 0;
    /* Prevent title from shrinking */
}

.game-title h1 {
    font-family: 'Prompt', 'Fredoka One', sans-serif;
    font-size: clamp(1.5rem, 5vw, 3rem);
    margin: 0;
    letter-spacing: 1px;
    line-height: 1.2;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    /* Space between emojis and text */
}

.game-title h1 .text-content {
    /* Deep Raspberry to Hot Pink Gradient */
    background: linear-gradient(135deg, #d81b60 0%, #ff4081 50%, #f50057 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* White glow/shadow */
    filter: drop-shadow(0px 2px 0px rgba(255, 255, 255, 0.8)) drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.2));
}

.game-title h1 .emoji {
    filter: drop-shadow(2px 4px 4px rgba(0, 0, 0, 0.1));
    /* Gentle shadow for emojis */
    font-size: 0.8em;
    /* make emojis slightly smaller to balance with text if needed, or keep 1em */
    /* No bg clip here, so they show original colors */
}

/* Subtitle style removed as it's no longer used */

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center machine in the remaining space */
    flex-grow: 1;
    /* Take up remaining vertical space */
    width: 100%;
    padding-bottom: 20px;
}

/* --- ตัวตู้ --- */
.gacha-machine {
    position: relative;
    width: 320px;
    height: 550px;
    background-color: var(--machine-color);
    border-radius: 100px;
    box-shadow:
        inset -10px -10px 30px var(--machine-dark),
        inset 10px 10px 30px rgba(255, 255, 255, 0.8),
        0 30px 50px rgba(238, 156, 167, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 40px;
    z-index: 10;
}

/* ฝาบน */
.gacha-machine::before {
    content: '';
    position: absolute;
    top: -15px;
    width: 150px;
    height: 30px;
    background-color: #fad0c4;
    border-radius: 20px;
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
}

/* ไฟวิ้งๆ */
.decor-light {
    position: absolute;
    color: #fff;
    font-size: 24px;
    animation: twinkle 2s infinite;
}

.left {
    top: 50px;
    left: 30px;
}

.right {
    top: 60px;
    right: 30px;
    animation-delay: 1s;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2) rotate(10deg);
    }
}

/* --- กระจก --- */
.glass-window {
    position: relative;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
    border-radius: 50%;
    border: 8px solid var(--glass-border);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5);
    overflow: hidden;
    z-index: 2;
}

.shine-reflection {
    position: absolute;
    top: 15%;
    left: 15%;
    width: 40px;
    height: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: rotate(-45deg);
    filter: blur(2px);
}

/* --- ลูกบอลในตู้ --- */
.capsule-container {
    position: absolute;
    width: 100%;
    height: 100%;
}

.mini-ball {
    position: absolute;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    box-shadow: inset -5px -5px 10px rgba(0, 0, 0, 0.2), 2px 2px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

/* --- Special Balls --- */
.ball-rainbow {
    background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    background-size: 200%;
    animation: rainbow 2s linear infinite;
    border: none !important;
}

@keyframes rainbow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

.ball-rgb {
    background-color: #ff0000;
    animation: rgbCycle 1s infinite alternate;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), inset 0 0 10px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
}

@keyframes rgbCycle {
    0% {
        background-color: #ff0000;
        box-shadow: 0 0 15px #ff0000;
    }

    33% {
        background-color: #00ff00;
        box-shadow: 0 0 15px #00ff00;
    }

    66% {
        background-color: #0000ff;
        box-shadow: 0 0 15px #0000ff;
    }

    100% {
        background-color: #ff00ff;
        box-shadow: 0 0 15px #ff00ff;
    }
}

.ball-heart {
    background-color: #fd79a8;
    display: flex !important;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #c44569;
}

.mini-ball::after {
    content: '';
    position: absolute;
    top: 20%;
    left: 20%;
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.6;
}

/* --- ปุ่มกดหัวใจ --- */
.control-area {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.heart-btn-bg {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 4px solid #fff;
}

.heart-btn {
    width: 90px;
    height: 80px;
    background-color: var(--btn-color);
    border: none;
    border-radius: 40px;
    /* ทรงแคปซูล */
    cursor: pointer;
    box-shadow: 0 8px 0 var(--btn-shadow);
    transition: all 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.heart-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 4px 0 var(--btn-shadow);
}

.heart-btn:disabled {
    filter: grayscale(1);
    cursor: not-allowed;
}

.heart-icon {
    font-size: 30px;
    color: #fff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* --- ลูกบอลรางวัล --- */
.exit-hole {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 20;
}

.prize-ball {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    position: absolute;
    bottom: 50px;
    opacity: 0;
    transform: scale(0.5);
    transition: none;
}

/* --- Animations --- */
.shaking {
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(-2px, 2px) rotate(-2deg);
    }

    50% {
        transform: translate(2px, -2px) rotate(2deg);
    }

    75% {
        transform: translate(-2px, 2px) rotate(-2deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

.dropping {
    animation: drop 1s cubic-bezier(0.5, 0, 0.5, 1) forwards;
}

@keyframes drop {
    0% {
        bottom: 250px;
        opacity: 1;
        transform: scale(0.5);
        z-index: 5;
    }

    60% {
        bottom: 20px;
        transform: scale(1);
    }

    80% {
        bottom: 60px;
    }

    /* Bounce */
    100% {
        bottom: 40px;
        opacity: 1;
        transform: scale(1);
        z-index: 100;
    }
}

/* --- UI Texts --- */
.status-box {
    margin-top: 20px;
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#resultText {
    font-size: 1.2rem;
    min-height: 1.5em;
}

#resetBtn {
    background: #fff;
    color: var(--machine-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.hidden {
    display: none !important;
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 80%;
    max-width: 300px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from {
        transform: scale(0.5);
    }

    to {
        transform: scale(1);
    }
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #aaa;
}

.big-ball {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 20px auto;
    box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.2);
}

.confirm-btn {
    background: var(--machine-dark);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 20px;
    margin-top: 15px;
    cursor: pointer;
}