* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.display-container {
    width: 100%;
    min-height: 100vh;
    padding: 20px;
}

/* Prize Banner */
.prize-banner {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.prize-banner h1 {
    color: white;
    font-size: 76px;
    /* margin-bottom: 15px; */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.prize-banner .totals {
    font-weight: 700;
    color: #fee2e2;
    background-color: #b91c1c;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 1.25rem;
}


.current-prize {
    color: white;
    font-size: 24px;
    font-weight: 600;
}

.current-prize h2 {
    font-size: 32px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.current-prize p {
    font-size: 20px;
    opacity: 0.9;
}

/* Cards Container - override by inline styles */

/* Card Styles */
.card {
    width: 100%;
    aspect-ratio: 3/4;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
    opacity: 0;
    transform: scale(0.5) rotateY(180deg);
    animation: cardAppear 0.5s ease-out forwards;
}

/* Tắt animation sau khi đã load xong */
.card.loaded {
    animation: none;
    opacity: 1;
    transform: scale(1) rotateY(0deg);
}

/* Animation hiệu ứng phát từng lá bài */
@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) rotateY(180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.card.opened .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-pattern {
    width: 80%;
    height: 80%;
    background-image: 
        repeating-linear-gradient(45deg, rgba(255,255,255,0.1) 0px, rgba(255,255,255,0.1) 10px, transparent 10px, transparent 20px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,0.1) 0px, rgba(255,255,255,0.1) 10px, transparent 10px, transparent 20px);
    border-radius: 10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.card-back img {
    width: 100%;
    flex: 1;
    object-fit: cover;
    margin-bottom: 0;
}

.card-info {
    text-align: center;
    width: 100%;
    padding: 8px 10px;
    background: white;
    flex-shrink: 0;
}

.emp-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.emp-code {
    font-size: 10px;
    color: #666;
}

/* Highlight Animation - chỉ phát sáng khi random */
.card.highlight .card-front {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    box-shadow: 0 0 30px rgba(255, 215, 0, 1);
}

/* Blinking Animation - nhấp nháy khi được chọn */
.card.blinking {
    animation: blinkCard 0.3s ease-in-out 6; /* Nhấp nháy 6 lần, mỗi lần 0.3s */
}

@keyframes blinkCard {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 215, 0, 0);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 40px rgba(255, 215, 0, 1), 0 0 80px rgba(255, 215, 0, 0.8);
    }
}

.card.blinking .card-front {
    animation: blinkGlow 0.3s ease-in-out 6;
}

@keyframes blinkGlow {
    0%, 100% {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    50% {
        background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    }
}

/* Clone used for flying animation - placed on body so it animates from exact viewport coords */
.card-clone {
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    border-radius: 15px;
    overflow: hidden;
    transform-origin: center center;
}

.card-clone .card-inner {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}


/* Winner Card Animation */
.card.winner {
    animation: winnerFly 1s ease-out forwards;
    z-index: 1000;
}

@keyframes winnerFly {
    0% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.5) translateY(-50px);
    }
    100% {
        transform: scale(2) translateY(-100px);
        opacity: 0;
    }
}

/* Flying Animation - Bay vào giữa màn hình với zoom in dần */
.card.flying {
    position: fixed !important;
    z-index: 2000;
}

/* Winner Modal */
.winner-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.winner-modal.show {
    opacity: 1;
    pointer-events: all;
}

.winner-content {
    position: relative;
    animation: modalZoom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    perspective: 1500px;
    transform-style: preserve-3d;
}

@keyframes modalZoom {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.winner-card {
    background: white;
    width: 700px;
    height: 1000px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 10;
    overflow: hidden;
}

.winner-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: none;
    border-radius: 0;
    position: absolute;
    top: 0;
    left: 0;
    animation: avatarBounce 0.6s ease-in-out;
}

@keyframes avatarBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.winner-card .card-info {
    position: absolute;
    bottom: 160px;
    left: 0;
    right: 0;
    padding: 20px 30px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
    text-align: center;
    z-index: 2;
}

.winner-card .emp-name {
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 8px;
    font-size: 32px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.5s ease-out 0.2s backwards;
}

.winner-card .emp-dept {
    font-size: 24px;
    color: #f0f0f0;
    margin: 0;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.5s ease-out 0.3s backwards;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.winner-prize {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    margin: 0;
    padding: 35px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 0;
    animation: slideUp 0.5s ease-out 0.4s backwards;
}

.winner-prize h3 {
    font-size: 32px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
}

/* Confetti */
.confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall 3s linear infinite;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Ribbons */
.ribbons {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
}

.ribbon-piece {
    position: absolute;
    width: 15px;
    height: 80px;
    top: -100px;
    border-radius: 3px;
    animation: ribbonFall 4s ease-in infinite;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

@keyframes ribbonFall {
    0% {
        transform: translateY(-100px) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(720deg);
        opacity: 0;
    }
}

/* Emoji Fireworks */
.emoji-fireworks {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9997;
}

.emoji-firework {
    position: absolute;
    animation: emojiExplode 2s ease-out infinite;
    filter: drop-shadow(0 0 5px rgba(255, 255, 0, 0.8));
}

@keyframes emojiExplode {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0.5) rotate(360deg);
        opacity: 0;
    }
}

/* Firework guns (corner shooters) */
.firework-gun {
    position: fixed;
    bottom: 20px;
    width: 80px;
    height: 80px;
    z-index: 10050;
    pointer-events: none;
}
#fireworkLeft, #fireworkRight {
    overflow: visible;
}
.firework-gun.left { left: 20px; }
.firework-gun.right { right: 20px; }

.confetti-shoot {
    position: absolute;
    width: 8px;
    height: 12px;
    opacity: 1;
    transform-origin: center center;
}

@keyframes shootUp {
    0% { 
        transform: translateY(0) translateX(0) scale(0.5) rotate(0deg); 
        opacity: 1;
    }
    25% {
        transform: translateY(-25vh) translateX(calc(var(--tx, 0px) * 0.25)) scale(0.9) rotate(calc(var(--rotate-speed, 360deg) * 0.25));
        opacity: 1;
    }
    50% {
        transform: translateY(-50vh) translateX(calc(var(--tx, 0px) * 0.5)) scale(1.1) rotate(calc(var(--rotate-speed, 360deg) * 0.5));
        opacity: 1;
    }
    75% {
        transform: translateY(-65vh) translateX(calc(var(--tx, 0px) * 0.75)) scale(1.3) rotate(calc(var(--rotate-speed, 360deg) * 0.75));
        opacity: 0.8;
    }
    100% { 
        transform: translateY(-75vh) translateX(var(--tx, 0px)) scale(1.5) rotate(var(--rotate-speed, 720deg)); 
        opacity: 0;
    }
}

/* Fullscreen History Modal */
.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.history-modal.show {
    opacity: 1;
    pointer-events: all;
}

.history-modal-content {
    background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    animation: modalSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.history-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border: none;
    background: #f44336;
    color: white;
    font-size: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

.history-close-btn:hover {
    transform: rotate(90deg) scale(1.1);
    background: #d32f2f;
}

.history-modal-content h2 {
    text-align: center;
    color: #b71c1c;
    font-size: 40px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: titleBounce 0.6s ease-out;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.history-modal-list {
    height: calc(85vh - 140px);
    overflow-y: auto;
    padding-right: 20px;
}

.history-modal-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    margin-bottom: 15px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    animation: itemSlideIn 0.5s ease-out backwards;
}

.history-modal-item:nth-child(1) { animation-delay: 0.1s; }
.history-modal-item:nth-child(2) { animation-delay: 0.15s; }
.history-modal-item:nth-child(3) { animation-delay: 0.2s; }
.history-modal-item:nth-child(n+4) { animation-delay: 0.25s; }

@keyframes itemSlideIn {
    from {
        transform: translateX(-50px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.history-modal-item:hover {
    transform: translateX(10px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.history-rank {
    font-size: 32px;
    font-weight: 700;
    color: #667eea;
    min-width: 60px;
    text-align: center;
}

.history-details {
    flex: 1;
}

.history-name {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.history-info {
    font-size: 16px;
    color: #666;
}

.history-prize {
    font-size: 20px;
    font-weight: 600;
    color: #b71c1c;
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    padding: 10px 20px;
    border-radius: 10px;
    min-width: 200px;
    text-align: center;
}

.history-modal-list::-webkit-scrollbar {
    width: 10px;
}

.history-modal-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.history-modal-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.history-modal-list::-webkit-scrollbar-thumb:hover {
    background: #5566cc;
}

/* Responsive */
@media (max-width: 768px) {
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
        padding: 10px;
    }

    .prize-banner h1 {
        font-size: 24px;
    }

    .current-prize h2 {
        font-size: 20px;
    }

    .winner-card {
        padding: 40px;
    }

    .winner-card img {
        width: 150px;
        height: 150px;
    }

    .winner-card h2 {
        font-size: 32px;
    }

    .winner-info p {
        font-size: 18px;
    }

    .winner-prize h3 {
        font-size: 24px;
    }
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.85;
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}
