body {
    background: linear-gradient(135deg, #8b0000, #b30000);
    color: gold;
    font-family: sans-serif;
    text-align: center;
    margin: 0;
    padding: 20px;
}

h1 {
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    margin: 10px;
    background: gold;
    border: none;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
}

button:hover {
    opacity: 0.8;
}

#envelope-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 30px;
}

#game-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 40px;
    margin: 40px auto;
    width: 90%;
    max-width: 1200px;
    backdrop-filter: blur(6px);
}


.envelope {
    width: 120px;
    height: 170px;
    background: linear-gradient(145deg, #d40000, #a80000);
    border-radius: 16px;
    cursor: pointer;
    font-size: 40px;          /* tăng chữ/icon */
    display: flex;
    align-items: center;
    justify-content: center;
    color: gold;
    box-shadow: 0 12px 25px rgba(0,0,0,0.35);
    transition: all 0.3s ease;
}


.envelope:hover {
    transform: translateY(-8px) scale(1.08);
}

#envelope-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 30px;              /* tăng khoảng cách */
    margin-top: 50px;
    padding: 20px 40px;
}
.envelope span {
    font-size: 50px;
}

/* ===== POPUP ===== */

#popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    display: none;
}

#popup.show {
    display: flex;
}

.popup-content {
    background: #990000;
    padding: 30px;
    border: 3px solid gold;
    min-width: 250px;
}

#config-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
}

#config-popup.show {
    display: flex;
}

#popup-actions {
    display: flex;
    justify-content: center;
    gap: 20px;   /* khoảng cách giữa nút */
    margin-top: 20px;
}

.config-content {
    background: #990000;
    border: 3px solid gold;
    padding: 20px;
    width: 350px;
}

.config-content input,
.config-content textarea {
    width: 100%;
    margin: 5px 0;
    padding: 5px;
}

.config-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}

/* ===== SPIN ANIMATION ===== */

.spin-anim {
    animation: pulse 0.15s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

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

/* ===== ENVELOPE OPEN ===== */

.envelope.opening {
    animation: openEnvelope 0.7s forwards;
    z-index: 10;
}

@keyframes openEnvelope {
    0% {
        transform: scale(1) rotateY(0deg);
    }

    50% {
        transform: scale(1.5) rotateY(90deg);
    }

    100% {
        transform: scale(1.3) rotateY(180deg);
    }
}

/* tiền fade in */
.money-appear {
    animation: fadeInMoney 0.5s ease-in forwards;
}

@keyframes fadeInMoney {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ENVELOPE SELECT EFFECT ===== */

/* khi được chọn */
.envelope.selected {
    transform: scale(1.4);
    z-index: 20;
    box-shadow: 0 0 25px gold;
}

/* lắc */
.envelope.shake {
    animation: shakeEnvelope 1s ease-in-out 3;
}

@keyframes shakeEnvelope {
    0%   { transform: scale(1.4) translateX(0); }
    20%  { transform: scale(1.4) translateX(-8px); }
    40%  { transform: scale(1.4) translateX(8px); }
    60%  { transform: scale(1.4) translateX(-8px); }
    80%  { transform: scale(1.4) translateX(8px); }
    100% { transform: scale(1.4) translateX(0); }
}

/* tiền hiện lên mượt hơn */
#popup-amount {
    font-size: 40px;
    margin-top: 15px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
}

#popup.show #popup-amount {
    opacity: 1;
    transform: translateY(0);
}


/* ===============================
   iPad & Tablet Responsive
================================= */

@media (max-width: 1024px) {

    body {
        padding: 10px;
    }

    h1 {
        font-size: 26px;
        text-align: center;
    }

    button {
        padding: 12px 18px;
        font-size: 16px;
        border-radius: 10px;
    }

    #game-section {
        width: 100%;
    }

    #envelope-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 12px;
        justify-items: center;
    }

    .envelope {
        font-size: 40px;
        width: 70px;
        height: 70px;
    }

    #current-player {
        font-size: 22px;
        margin: 15px 0;
        text-align: center;
    }

    .popup {
        width: 90%;
        max-width: 400px;
        padding: 20px;
        border-radius: 16px;
    }

    .popup button {
        width: 100%;
        margin-top: 10px;
    }
}
