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

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #102B4E 0%, #1a4a73 50%, #2d5aa0 100%);
    min-height: 100vh;
    color: #333;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

header {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

header h1 {
    color: #4a5568;
    font-size: 2rem;
}

nav a, nav button {
    background: #4299e1;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

nav a:hover, nav button:hover {
    background: #3182ce;
}

.admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #4299e1 !important;
    transition: all 0.3s ease;
}

.admin-link:hover {
    background: #3182ce !important;
    transform: scale(1.1);
}

.admin-link svg {
    width: 20px;
    height: 20px;
}

.new-user-btn {
    background: #38a169 !important;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem !important;
}

.new-user-btn:hover {
    background: #2f855a !important;
}

.users-list-btn {
    background: #805ad5 !important;
    font-size: 0.9rem;
}

.users-list-btn:hover {
    background: #6b46c1 !important;
}

.random-winner-btn {
    background: #f59e0b !important;
    font-size: 0.9rem;
}

.random-winner-btn:hover {
    background: #d97706 !important;
}

main {
    padding: 2rem;
    position: relative;
}

/* User Info Form Styles */
.user-info-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #102B4E 0%, #1a4a73 50%, #2d5aa0 100%);
    z-index: 1000;
}

.user-info-card {
    background: white;
    border-radius: 20px;
    padding: 4rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
    0% {
        transform: scale(0.8) translateY(-50px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.user-info-card h2 {
    color: #4a5568;
    margin-bottom: 1.5rem;
    font-size: 2.2rem;
    font-weight: 700;
}

.user-info-card p {
    color: #718096;
    margin-bottom: 2.5rem;
    font-size: 1.2rem;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #4a5568;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.form-group input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.15);
    background: white;
    transform: translateY(-2px);
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(66, 153, 225, 0.3);
}

/* Floating Admin Button in Form */
.floating-admin-btn {
    position: absolute;
    top: 30px;
    right: 30px;
    z-index: 1001;
}

.form-admin-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.form-admin-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
}

.form-admin-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.form-admin-btn svg {
    width: 18px;
    height: 18px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.form-admin-btn span {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.5px;
}

/* Winner Form Styles */
.winner-form-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    z-index: 1000;
}

.winner-form-card {
    background: white;
    border-radius: 20px;
    padding: 4rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: slideIn 0.6s ease-out;
    border: 3px solid #48bb78;
}

.winner-form-card h2 {
    color: #2d3748;
    margin-bottom: 1.5rem;
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #48bb78, #38a169);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.winner-form-card p {
    color: #4a5568;
    margin-bottom: 2.5rem;
    font-size: 1.2rem;
    line-height: 1.5;
}

.winner-form-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 1rem;
}

.winner-form-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

/* Current User Display */
.current-user-display {
    margin-bottom: 2rem;
}

.user-info-banner {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    padding: 1rem 2rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    margin: 0 auto;
}

.user-info-banner span {
    font-weight: 500;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    color: #4a5568;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #4a5568;
}

.modal-body {
    padding: 2rem;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: #4a5568;
}

.user-phone {
    color: #718096;
    font-size: 0.9rem;
}

.user-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-success {
    background: #c6f6d5;
    color: #22543d;
}

.status-pending {
    background: #fed7d7;
    color: #742a2a;
}

/* Failure Message */
.failure-message {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #e53e3e;
}

.failure-message h2 {
    color: #e53e3e;
    margin-bottom: 1rem;
}

.failure-message button {
    background: #e53e3e;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

.failure-message button:hover {
    background: #c53030;
}

.countdown-text {
    margin-top: 1rem;
    color: #718096;
    font-size: 0.9rem;
}

.countdown-text span {
    font-weight: bold;
    color: #e53e3e;
}

.give-up-btn {
    background: #e53e3e !important;
}

.give-up-btn:hover {
    background: #c53030 !important;
}

/* Result Images */
.result-image {
    max-width: 60vw;
    max-height: 60vh;
    width: auto;
    height: auto;
    margin: 1rem 0;
    animation: bounceIn 0.8s ease-out;
    object-fit: contain;
}

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

.winner-image-display, .loser-image-display {
    text-align: center;
}

/* Random Winner Modal Styles */
.winner-display {
    text-align: center;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.winner-animation {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinning-names {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4299e1;
    animation: spin 0.1s linear infinite;
}

@keyframes spin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.final-winner {
    animation: winnerReveal 1s ease-out;
}

@keyframes winnerReveal {
    0% { transform: scale(0) rotate(180deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(90deg); opacity: 0.7; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.winner-info {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: white;
    padding: 1.5rem;
    border-radius: 15px;
    margin-top: 1rem;
    box-shadow: 0 8px 25px rgba(74, 222, 128, 0.3);
}

.winner-name {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.winner-phone {
    font-size: 1.2rem;
    opacity: 0.9;
}

.winner-controls {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.winner-controls button {
    background: #4299e1;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}

.winner-controls button:hover {
    background: #3182ce;
}

#reset-selection-btn {
    background: #6b7280 !important;
}

#reset-selection-btn:hover {
    background: #4b5563 !important;
}

/* Main Page Styles */
.logos-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-item {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.logo-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.logo-image {
    width: 150px;
    height: 150px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 1rem;
    background: #f7fafc;
    padding: 10px;
}

.upload-status {
    text-align: center;
    padding: 0.5rem;
    border-radius: 5px;
    font-size: 0.9rem;
}

.upload-status .no-image {
    color: #e53e3e;
    font-weight: 500;
}

.upload-status .has-image {
    color: #38a169;
    font-weight: 500;
}

.upload-status .default-image {
    color: #3182ce;
    font-weight: 500;
}

/* Admin Page Styles */
.upload-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.upload-item {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.upload-item h3 {
    margin-bottom: 1rem;
    color: #4a5568;
}

.logo-reference {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
}

.reference-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: white;
    padding: 5px;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
}

.logo-reference h3 {
    margin: 0;
    color: #4a5568;
    font-size: 1.1rem;
}

.upload-item input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 2px dashed #cbd5e0;
    border-radius: 5px;
    margin-bottom: 1rem;
    cursor: pointer;
}

.upload-item input[type="file"]:hover {
    border-color: #4299e1;
}

.preview {
    width: 200px;
    height: 200px;
    border: 2px dashed #cbd5e0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    overflow: hidden;
    background: #f7fafc;
    color: #a0aec0;
}

.preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Puzzle Page Styles */
.puzzle-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Timer Display */
.timer-display {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    animation: pulse 1s infinite;
}

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

.timer-display.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    animation: fastPulse 0.5s infinite;
}

.timer-display.danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    animation: fastPulse 0.3s infinite;
}

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

.puzzle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.puzzle-instructions {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
}

.puzzle-instructions h3 {
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.puzzle-instructions p {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.4;
}

.puzzle-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    background: white;
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border: 3px solid #e2e8f0;
}

.puzzle-slot {
    width: 118px;
    height: 118px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.puzzle-slot.empty-space {
    background: #f7fafc;
    border: 2px dashed #cbd5e0;
}

.puzzle-piece {
    width: 100%;
    height: 100%;
    background-size: 360px 360px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.puzzle-piece:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.puzzle-piece.clickable-piece {
    cursor: pointer;
}

.puzzle-piece:active {
    transform: scale(0.98);
}

.success-message {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.success-message h2 {
    color: #38a169;
    margin-bottom: 1rem;
}

.success-message button {
    background: #38a169;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

.success-message button:hover {
    background: #2f855a;
}

/* Responsive Design */
@media (max-width: 768px) {
    .puzzle-container {
        gap: 1rem;
    }

    .puzzle-instructions {
        max-width: 300px;
        padding: 1rem;
    }

    .puzzle-board {
        padding: 1rem;
        gap: 2px;
    }

    .puzzle-slot {
        width: 88px;
        height: 88px;
    }

    .puzzle-piece {
        background-size: 270px 270px;
    }

    header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1rem;
    }

    nav {
        justify-content: center;
        gap: 0.5rem;
    }

    .user-info-card {
        padding: 2rem;
        width: 95%;
    }

    .user-info-card h2 {
        font-size: 1.8rem;
    }

    .floating-admin-btn {
        top: 20px;
        right: 20px;
    }

    .form-admin-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .form-admin-btn svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .puzzle-slot {
        width: 68px;
        height: 68px;
    }

    .puzzle-piece {
        background-size: 210px 210px;
    }

    .puzzle-board {
        padding: 0.5rem;
        gap: 2px;
    }

    nav a, nav button {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .user-info-card {
        padding: 1.5rem;
    }

    .user-info-card h2 {
        font-size: 1.6rem;
    }

    .form-group input {
        padding: 0.8rem;
        font-size: 1rem;
    }

    .submit-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1.1rem;
    }

    .result-image {
        max-width: 70vw;
        max-height: 50vh;
    }
}

@media (max-width: 320px) {
    .result-image {
        max-width: 80vw;
        max-height: 45vh;
    }

    .floating-admin-btn {
        top: 15px;
        right: 15px;
    }

    .form-admin-btn {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 40px;
    }

    .form-admin-btn svg {
        width: 14px;
        height: 14px;
    }
}
