* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    text-align: center;
    max-width: 1200px;
    width: 100%;
}

h1 {
    color: #fff;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.instruction {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

.angpau-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.angpau-grid.shuffling {
    pointer-events: none;
}

.angpau.shuffling {
    z-index: 100;
    transition: all 1s ease-in-out;
}

.angpau.shuffle-center {
    transform: translate(var(--shuffle-x), var(--shuffle-y)) scale(0.8) !important;
}

.angpau.shuffle-return {
    transform: translate(0, 0) scale(1) !important;
}

.angpau {
    position: relative;
    width: 100%;
    aspect-ratio: 2/3;
    cursor: pointer;
    perspective: 1000px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.hand-pointer {
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 40px;
    height: 40px;
    background-image: url('img/hand-pointer.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 10;
    animation: pointAnimation 1.5s ease-in-out infinite;
    opacity: 0;
    pointer-events: none;
}

.hand-pointer.show {
    opacity: 1;
}

@keyframes pointAnimation {
    0%, 100% {
        transform: translate(0, 0);
    }
    50% {
        transform: translate(-15px, -15px);
    }
}

.angpau-front,
.angpau-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transition: transform 0.6s ease;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.angpau-front {
    background: linear-gradient(135deg, #c92a2a 0%, #e03131 50%, #c92a2a 100%);
    border: 3px solid #ffd700;
    transform: rotateY(0deg);
}

.angpau-symbol {
    font-size: 3rem;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.angpau-back {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border: 3px solid #ffd700;
    transform: rotateY(180deg);
}

.prize-amount {
    font-size: 1.5rem;
    font-weight: bold;
    color: #c92a2a;
}

.angpau.flipped .angpau-front {
    transform: rotateY(180deg);
}

.angpau.flipped .angpau-back {
    transform: rotateY(0deg);
}

.angpau:not(.selected):not(.flipped):hover .angpau-front {
    transform: scale(1.05) rotateY(0deg);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.angpau.disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.angpau.selected .angpau-front {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.95) 100%),
                url('gif/08-51-41-992_512.gif') center center / cover;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.4s ease;
    max-width: 400px;
    width: 90%;
    position: relative;
    backdrop-filter: blur(1px);
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #ce2131;
    font-size: 2rem;
    margin-bottom: 20px;
}

.prize-message {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 30px;
}

.screenshot-instruction {
    font-size: 0.9rem !important;
    color: #666 !important;
    margin-bottom: 20px !important;
    margin-top: 10px !important;
    font-style: italic;
}

#prizeAmount {
    font-size: 2.5rem;
    font-weight: bold;
    color: #5aae5b;
    display: block;
    margin: 20px 0;
}

.reset-btn {
    background: linear-gradient(135deg, #c92a2a 0%, #e03131 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(201, 42, 42, 0.3);
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(201, 42, 42, 0.4);
}

.reset-btn:active {
    transform: translateY(0);
}

/* Refresh Button */
.refresh-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    margin: 30px auto;
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.refresh-btn.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.refresh-btn:active {
    transform: translateY(0);
}

/* Winners Section */
.winners-section {
    margin-top: 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 400px;
    display: flex;
    flex-direction: column;
}

.winners-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.winners-section h3 {
    color: #fff;
    font-size: 1.5rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-dot {
    width: 12px;
    height: 12px;
    background: #ff4444;
    border-radius: 50%;
    animation: breathe 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

.live-text {
    color: #fff;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 1px;
    animation: breatheText 2s ease-in-out infinite;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes breathe {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

@keyframes breatheText {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.winners-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.winner-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideInWinner 0.5s ease;
    border-left: 4px solid #ffd700;
}

@keyframes slideInWinner {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.winner-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.winner-name {
    font-weight: bold;
    color: #333;
    font-size: 1rem;
}

.winner-phone {
    color: #666;
    font-size: 0.85rem;
}

.winner-prize {
    background: linear-gradient(135deg, #c92a2a 0%, #e03131 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(201, 42, 42, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .angpau-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    h1 {
        font-size: 20px;
    }

    .instruction {
        font-size: 1rem;
    }

    .angpau-symbol {
        font-size: 2rem;
    }

    .prize-amount {
        font-size: 1.2rem;
    }

    .winners-section {
        margin-top: 40px;
        padding: 15px;
        height: 350px;
    }

    .winners-section h3 {
        font-size: 1.3rem;
    }

    .live-text {
        font-size: 0.8rem;
    }

    .live-dot {
        width: 10px;
        height: 10px;
    }

    .winner-item {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }



    .winner-name {
        font-size: 0.9rem;
    }

    .winner-phone {
        font-size: 0.8rem;
    }

    .winner-prize {
        align-self: flex-end;
        font-size: 0.9rem;
        padding: 6px 12px;
    }

    .hand-pointer {
        width: 30px;
        height: 30px;
        bottom: -8px;
        right: -8px;
    }

    .refresh-btn {
        margin: 25px auto;
        padding: 10px 25px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .angpau-grid {
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 8px;
        max-width: 100%;
    }

    .angpau {
        aspect-ratio: 3/4;
    }

    h1 {
        font-size: 20px;
    }

    .angpau-symbol {
        font-size: 1.2rem;
    }

    .prize-amount {
        font-size: 0.9rem;
    }

    .modal-content {
        padding: 30px 20px;
    }

    .winners-section {
        margin-top: 40px;
        padding: 12px;
        height: 300px;
    }

    .winners-section h3 {
        font-size: 1.2rem;
    }

    .winners-header {
        margin-bottom: 12px;
    }

    .live-text {
        font-size: 0.7rem;
    }

    .live-dot {
        width: 8px;
        height: 8px;
    }

    .winner-item {
        padding: 10px;
        gap: 6px;
    }

    .winner-name {
        font-size: 18px;
    }

    .winner-phone {
        font-size: 0.75rem;
    }

    .winner-prize {
        font-size: 0.8rem;
        padding: 5px 10px;
    }

    .hand-pointer {
        width: 25px;
        height: 25px;
        bottom: -6px;
        right: -6px;
    }

    @keyframes pointAnimation {
        0%, 100% {
            transform: translate(0, 0);
        }
        50% {
            transform: translate(-10px, -10px);
        }
    }

    .refresh-btn {
        margin: 20px auto;
        padding: 8px 20px;
        font-size: 0.8rem;
    }
}

/* ==================== Already Played Modal Styles ==================== */

.already-played-modal {
    max-width: 450px;
    width: 90%;
    text-align: center;
    padding: 30px 25px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.95) 100%),
                url('gif/08-51-41-992_512.gif') center center / cover;
    position: relative;
    backdrop-filter: blur(1px);
}

.modal-icon-wrapper {
    margin-bottom: 20px;
}

.warning-icon {
    font-size: 4rem;
    animation: warningPulse 2s ease-in-out infinite;
    display: block;
}

@keyframes warningPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.already-played-modal h2 {
    color: #dc3545;
    font-size: 2rem;
    margin: 0 0 15px 0;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.already-played-message {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 25px;
    font-weight: 500;
    white-space: pre-line;
}

.player-reward-display {
    background: #f8f9fa;
    border: 2px solid #28a745;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.reward-label {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 1rem;
    font-weight: 500;
}

.reward-amount {
    font-size: 2.5rem;
    font-weight: bold;
    color: #28a745;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.contact-info {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    border: 2px solid #e9ecef;
}

.contact-info p {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 1rem;
}

.contact-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.contact-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.contact-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.contact-btn:active {
    transform: translateY(0);
}

.livechat-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.website-btn {
    background: linear-gradient(135deg, #007bff 0%, #6610f2 100%);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .already-played-modal {
        padding: 25px 15px;
        margin: 10px;
    }
    
    .warning-icon {
        font-size: 3rem;
    }
    
    .already-played-modal h2 {
        font-size: 1.6rem;
    }
    
    .already-played-message {
        font-size: 14px;
    }
    
    .contact-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .contact-btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
    
    .reward-amount {
        font-size: 2rem;
    }
    
    .reward-label {
        font-size: 0.9rem;
    }
}

/* ==================== GIF Background Enhancements ==================== */

/*
 * HOW TO CUSTOMIZE GIF SIZE AND SPEED:
 * 
 * 1. GIF SIZE CUSTOMIZATION:
 *    Change the values after the last "/" in background property:
 *    - "300px 300px" = 300px width, 300px height
 *    - "200px 200px" = smaller size
 *    - "500px 500px" = larger size
 *    - "50% 50%" = 50% of modal size
 *    - "contain" = fit entire GIF maintaining aspect ratio
 *    - "cover" = fill entire modal
 *    - "auto" = original GIF size
 * 
 * 2. GIF SPEED CUSTOMIZATION:
 *    GIF speed cannot be controlled by CSS. To change speed:
 *    - Edit the GIF file using tools like:
 *      * Online: ezgif.com, giphy.com
 *      * Software: Photoshop, GIMP, After Effects
 *    - Or replace with a different speed version of the same GIF
 *    - Speed is controlled by frame delay in the GIF file itself
 * 
 * 3. ALTERNATIVE SPEED CONTROL (using CSS animation):
 *    If you convert GIF to sprite sheet, you can control speed with CSS
 */

/* Prize Modal with celebration GIF background */
#prizeModal {
    background: url('gif/08-51-41-992_512.gif') center center / 350px 200px,
                rgba(0, 0, 0, 0.7);
    background-repeat: no-repeat;
}

#prizeModal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('gif/08-51-41-992_512.gif') center center / 200px 200px;
    filter: blur(5px);
    mask: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,1) 100%);
    -webkit-mask: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,1) 100%);
    z-index: -1;
}

#prizeModal .modal-content {
    background: white;
}



/* Already Played Modal with warning GIF background */
#alreadyPlayedModal {
    background: url('gif/08-51-41-992_512.gif') center center / 200px 200px,
                rgba(0, 0, 0, 0.7);
    background-repeat: no-repeat;
}

#alreadyPlayedModal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('gif/08-51-41-992_512.gif') center center / 200px 200px;
    filter: blur(5px);
    mask: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,1) 100%);
    -webkit-mask: radial-gradient(circle at center, transparent 30%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,1) 100%);
    z-index: -1;
}

#alreadyPlayedModal .already-played-modal {
    background: white;
}

/* ==================== Congratulations Animation ==================== */

/* Simple scale animation for "Congratulations!" text */
#prizeModal .modal-content h2 {
    animation: simpleScale 2.5s ease-in-out infinite;
}

@keyframes simpleScale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.06);
    }
}

/* GIF delay animation - adds pause between repetitions */
@keyframes gifDelay {
    0% { opacity: 1; }
    70% { opacity: 1; } /* GIF visible for 70% of cycle */
    71% { opacity: 0; } /* Start fade out */
    100% { opacity: 0; } /* Hidden for remaining 30% = delay */
}


/* Shimmer animation for celebration */
@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: 200px 0;
    }
}

/* Warning shimmer animation */
@keyframes warningShimmer {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.6;
    }
}

/* Enhanced text readability over GIF background */
.modal-content h2,
.already-played-modal h2 {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
}

.modal-content .prize-message,
.already-played-modal .already-played-message {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
}

/* Ensure all modal content stays above background */
.modal-content > *,
.already-played-modal > * {
    position: relative;
    z-index: 2;
}
