/* ========================================
   Random Winner - Professional Design
   ======================================== */

/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #1e1b4b;
    --dark-light: #312e81;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f0c29;
    background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    background-image: url('https://images.unsplash.com/photo-1534796636912-3b95b3ab5986?w=1920&q=80');
}

/* Background Decoration */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite;
}

.circle-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.circle-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #f472b6, #ec4899);
    bottom: -50px;
    left: -50px;
    animation-delay: -7s;
}

.circle-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, var(--secondary), #f97316);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(20px, -30px) scale(1.05);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
    75% {
        transform: translate(30px, 10px) scale(1.02);
    }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 520px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.trophy-icon {
    font-size: 36px;
    color: white;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.header h1 {
    font-size: 32px;
    font-weight: 800;
    color: white;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 15px;
    text-shadow: 0 1px 5px rgba(0,0,0,0.3);
}

/* Cards */
.input-card, .settings-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}

.input-card:hover, .settings-card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.card-header i {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.card-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}

/* Input Group */
.input-group label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 10px;
}

.input-group label i {
    margin-right: 6px;
    color: var(--primary);
}

.input-group .hint {
    font-weight: 400;
    font-size: 12px;
    color: var(--gray-400);
}

textarea {
    width: 100%;
    min-height: 140px;
    padding: 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
    background: var(--gray-50);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

textarea::placeholder {
    color: var(--gray-400);
}

.participant-count {
    text-align: right;
    margin-top: 10px;
    font-size: 13px;
    color: var(--gray-500);
}

.participant-count span {
    font-weight: 700;
    color: var(--primary);
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 10px;
}

.setting-item label i {
    color: var(--primary);
}

.counter-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.counter-btn {
    width: 40px;
    height: 40px;
    border: 2px solid var(--gray-200);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--gray-600);
}

.counter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.counter-btn:active {
    transform: scale(0.95);
}

.counter-input input {
    width: 60px;
    height: 40px;
    text-align: center;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}

.counter-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.mode-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--success);
}

/* Draw Button */
.draw-btn {
    position: relative;
    width: 100%;
    padding: 20px 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.draw-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.draw-btn:hover::before {
    left: 100%;
}

.draw-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), 0 0 0 6px rgba(99, 102, 241, 0.15);
}

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

.draw-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-text {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.btn-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    opacity: 0;
    transition: opacity 0.3s;
}

/* Ladder Overlay */
.ladder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.ladder-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.ladder-modal {
    background: white;
    border-radius: var(--radius-2xl);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-2xl);
}

.ladder-header {
    text-align: center;
    margin-bottom: 24px;
}

.ladder-header h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.ladder-container {
    overflow-x: auto;
    padding: 10px 0;
}

.ladder-names {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.ladder-name {
    padding: 12px 20px;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 15px;
    color: var(--gray-700);
    transition: var(--transition);
    white-space: nowrap;
    border: 2px solid transparent;
}

.ladder-name.scrolling {
    animation: scrollShake 0.1s ease infinite;
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

@keyframes scrollShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.ladder-name.selected {
    background: linear-gradient(135deg, var(--secondary), #f97316);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
    border-color: var(--secondary);
}

.ladder-name.eliminated {
    opacity: 0.3;
    transform: scale(0.9);
}

.ladder-progress {
    margin-top: 24px;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    width: 0;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Result Modal */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 20px;
}

.result-modal.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-2xl);
    padding: 40px;
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-2xl);
    animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header {
    margin-bottom: 30px;
}

.celebration-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--secondary), #f97316);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
    animation: celebrateBounce 0.6s ease infinite;
}

@keyframes celebrateBounce {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

.celebration-icon i {
    font-size: 40px;
    color: white;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--gray-800);
}

.winners-container {
    margin-bottom: 30px;
    max-height: 300px;
    overflow-y: auto;
}

.winners {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.winner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--secondary), #f97316);
    border-radius: var(--radius-xl);
    font-size: 18px;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(245, 158, 11, 0.2);
    animation: winnerPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.winner:nth-child(1) { animation-delay: 0.1s; }
.winner:nth-child(2) { animation-delay: 0.3s; }
.winner:nth-child(3) { animation-delay: 0.5s; }
.winner:nth-child(4) { animation-delay: 0.7s; }
.winner:nth-child(5) { animation-delay: 0.9s; }

@keyframes winnerPop {
    from {
        transform: scale(0) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.winner i {
    font-size: 20px;
}

.close-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: var(--gray-100);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--gray-200);
    border-color: var(--gray-300);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.footer p {
    font-size: 13px;
    color: var(--gray-400);
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 24px 16px 40px;
    }

    .header h1 {
        font-size: 26px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .ladder-modal, .modal-content {
        padding: 24px;
    }

    .winner {
        font-size: 16px;
        padding: 14px 20px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Ad Banners */
.ad-banner {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.ad-left {
    left: 20px;
}

.ad-right {
    right: 20px;
}

@media (max-width: 1024px) {
    .ad-banner {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .ad-banner {
        display: none !important;
    }
}
