/* ── Variables ── */
:root {
    --main-bg-color: #0a348f;
    --secondary-bg-color: #0d4fbf;
    --accent-color: #4db8ff;
    --accent-gradient: linear-gradient(45deg, #4db8ff, #0078ff);
    --error-gradient: linear-gradient(45deg, #ff5252, #ff0000);
    --success-gradient: linear-gradient(45deg, #39ff87, #00ff62);
    --text-color: #ffffff;
    --header-color: #ffffff;
    --border-radius: 8px;
    --card-bg: #1a3570;
    --glass: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.14);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--main-bg-color);
    background-image: linear-gradient(to bottom right, #0a348f, #0d4fbf);
    background-attachment: fixed;
    color: #ffffff;
}

a { text-decoration: none; color: var(--text-color); }
ul { list-style: none; }

/* ── Layout ── */
.wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px;
}

.container {
    max-width: 650px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

main { width: 100%; }

.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    width: 100%;
}

/* ── Card (generator-box) ── */
.generator-box {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 2rem 1.5rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    text-align: center;
    position: relative;
    overflow: visible;
    transition: all 0.3s ease;
}

.generator-box::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: var(--accent-gradient);
    border-radius: calc(var(--border-radius) + 2px);
    z-index: -1;
    transition: background 0.3s ease;
}

.generator-box.error::before { background: var(--error-gradient); }
.generator-box.success::before { background: var(--success-gradient); }

/* ── Screen title ── */
.screen-title {
    color: var(--header-color);
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.subtitle {
    color: #c0c0c0;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* ── Lottie animation container ── */
.animation-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 8px rgba(77, 184, 255, 0.5));
}

.animation-container--muted {
    filter: drop-shadow(0 0 6px rgba(150, 160, 180, 0.4));
    opacity: 0.6;
}

/* ── Raffle context card ── */
.raffle-context {
    display: none;
    margin-top: 0.75rem;
    color: #d8e8ff;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    line-height: 1.35;
    text-align: left;
    white-space: pre-wrap;
    font-size: 0.9rem;
}

.raffle-context--visible { display: block; }

/* ── Confetti burst (CSS-only, one-shot) ── */
.confetti-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 10px;
}

.confetti-burst::before,
.confetti-burst::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle, #ffd700 1.5px, transparent 1.5px),
        radial-gradient(circle, #ff5252 1.5px, transparent 1.5px),
        radial-gradient(circle, #39ff87 1.5px, transparent 1.5px),
        radial-gradient(circle, #4db8ff 1.5px, transparent 1.5px),
        radial-gradient(circle, #ff9800 1.5px, transparent 1.5px),
        radial-gradient(circle, #e040fb 1.5px, transparent 1.5px);
    background-size: 10% 10%;
    background-position:
        10% 15%, 30% 25%, 55% 10%, 75% 30%, 90% 18%, 45% 5%;
    animation: confetti-fall 1.8s ease-out forwards;
}

.confetti-burst::after {
    background-position:
        20% 8%, 40% 20%, 65% 12%, 85% 22%, 50% 30%, 15% 28%;
    animation-delay: 0.15s;
}

@keyframes confetti-fall {
    0% { transform: translateY(-40px); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translateY(100%); opacity: 0; }
}

/* ── Countdown hero (confirmed screen) ── */
.countdown-hero {
    margin: 1.25rem 0;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
}

.countdown-hero__label {
    font-size: 0.85rem;
    color: #b4cbff;
    margin-bottom: 0.25rem;
}

.countdown-hero__value {
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.03em;
    text-shadow: 0 0 12px rgba(77, 184, 255, 0.5);
}

/* ── Participants pill ── */
.participants-pill {
    display: inline-block;
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.3rem 1.2rem;
    margin-top: 0.5rem;
    text-shadow: 0 0 8px rgba(77, 184, 255, 0.45);
}

.participants-pill__label {
    font-size: 0.85rem;
    color: #b4cbff;
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
}

/* ── Primary button ── */
.btn-primary {
    display: block;
    width: 100%;
    padding: 0.85rem 1.5rem;
    margin-top: 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(77, 184, 255, 0.4);
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover { background-color: #66c2ff; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(77, 184, 255, 0.5); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(77, 184, 255, 0.3); }

.btn-primary--error {
    background: #ff5252;
    box-shadow: 0 4px 12px rgba(255, 82, 82, 0.4);
}
.btn-primary--error:hover { background: #ff6b6b; box-shadow: 0 6px 16px rgba(255, 82, 82, 0.5); }

.btn-primary--muted {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}
.btn-primary--muted:hover { background: rgba(255, 255, 255, 0.22); box-shadow: none; }

/* ── Empathy message (didn't win) ── */
.empathy-message {
    color: #b4cbff;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

/* ── Channel list ── */
.required-channels { margin-top: 1rem; }

.required-channels-title {
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: left;
}

.required-channels-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.channel-item {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.channel-item--ok {
    border-color: rgba(57, 255, 135, 0.7);
    background: rgba(57, 255, 135, 0.14);
}

.channel-item--miss {
    border-color: rgba(255, 82, 82, 0.8);
    background: rgba(255, 82, 82, 0.16);
}

.channel-item--unknown {
    border-color: rgba(255, 255, 255, 0.18);
}

.channel-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    color: #ffffff;
}

.channel-item:not(.channel-item--ok) .channel-link {
    cursor: pointer;
}

.channel-state {
    min-width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

.channel-name {
    font-weight: 500;
    flex: 1;
    text-align: left;
}

.channel-action {
    font-size: 0.8rem;
    color: #ff8a80;
    white-space: nowrap;
    flex-shrink: 0;
}

.channel-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ── Winners list ── */
.winners-container {
    max-height: 300px;
    overflow-y: auto;
    margin: 1rem 0;
    padding: 0.25rem;
    border-radius: var(--border-radius);
    background-color: rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.05);
}

.winners-container::-webkit-scrollbar { width: 5px; }
.winners-container::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 3px; }
.winners-container::-webkit-scrollbar-thumb { background-color: var(--accent-color); border-radius: 3px; }

.winners-list { padding: 0; margin: 0; }

.winner-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 0.6rem;
}

.winner-item:last-child { border-bottom: none; }

.winner-item--me {
    border-radius: 8px;
    background-color: rgba(57, 255, 135, 0.15);
    border: 1px solid rgba(57, 255, 135, 0.45);
}

.winner-position {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(77, 184, 255, 0.15);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    min-width: 28px;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(77, 184, 255, 0.2);
}

.winner-item:nth-child(1) .winner-position {
    background: linear-gradient(45deg, #ffd700, #ffcc00);
    color: #333;
    width: 30px; height: 30px; min-width: 30px;
}

.winner-item:nth-child(2) .winner-position {
    background: linear-gradient(45deg, #c0c0c0, #e0e0e0);
    color: #333;
}

.winner-item:nth-child(3) .winner-position {
    background: linear-gradient(45deg, #cd7f32, #d3924b);
    color: #333;
}

.winner-avatar-container {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--accent-color);
}

.winner-avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(110deg, rgba(255,255,255,0.05) 8%, rgba(255,255,255,0.15) 18%, rgba(255,255,255,0.05) 33%);
    background-size: 200% 100%;
    animation: shine 1.5s linear infinite;
    border-radius: 50%;
}

.winner-name, .winner-link {
    font-size: 0.95rem;
    font-weight: 500;
    color: #fff;
    flex: 1;
    text-align: left;
}

.winner-link:hover { color: var(--accent-color); }

.winner-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: #1a3570;
    background: #39ff87;
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    margin-left: 0.4rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* ── Stats page ── */
#stats { text-align: center; width: 100%; }

.stats-box { padding: 2rem 1.5rem; }
.stats-header { margin-bottom: 1rem; }
.stats-header h1 { font-size: 1.3rem; margin-bottom: 0; }

.stats-hero {
    margin: 1.25rem 0;
    padding: 1.25rem 1rem;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
}

.stats-hero__label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-color);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.stats-hero__value {
    font-size: 2.8rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 12px rgba(77, 184, 255, 0.5);
    line-height: 1.1;
}

.countdown-section {
    margin: 1rem 0 1.25rem;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
}

.countdown-label {
    font-size: 0.85rem;
    color: #b4cbff;
    margin-bottom: 0.25rem;
}

.countdown-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0 1rem;
}

.stat-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.8rem 0.7rem;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-color);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(77, 184, 255, 0.45);
    display: inline-block;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-badge--created { color: #ffe38a; background: rgba(255, 214, 102, 0.16); border-color: rgba(255, 214, 102, 0.4); }
.status-badge--started { color: #95f7bb; background: rgba(57, 255, 135, 0.14); border-color: rgba(57, 255, 135, 0.4); }
.status-badge--finished { color: #c6d5ff; background: rgba(173, 195, 255, 0.14); border-color: rgba(173, 195, 255, 0.35); }

.stats-refresh { margin-top: 1rem; text-align: center; }

.last-updated {
    font-size: 0.78rem;
    color: #a0a0a0;
}

/* ── Animations ── */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shine {
    to { background-position: -200% 0; }
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .container { padding: 1rem; }
    .generator-box { padding: 1.5rem 1rem; }
    .countdown-hero__value { font-size: 1.6rem; }
    .participants-pill { font-size: 1.3rem; }
    .stats-hero__value { font-size: 2.2rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .stats-box { padding: 1.25rem 1rem; }
    .countdown-value { font-size: 1.1rem; }
}
