:root {
    --bg-color: #0f172a;
    --accent-color: #22c55e;
    --text-color: #e2e8f0;
    --text-color-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);

    --font-display: 'Bebas Neue', cursive;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.container {
    width: 100%;
    height: 100%;
    max-width: 1400px;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    background: rgba(15, 23, 42, 0.95);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.page-header, .page-footer {
    padding: 1rem 2rem;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-color-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.page-header {
    border-bottom: 1px solid var(--border-color);
}
.page-footer {
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.content-grid {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
    padding: 2rem;
    overflow: hidden;
}

.qr-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    border-right: 1px solid var(--border-color);
    padding-right: 2rem;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.qr-code-wrapper {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1 / 1;
    background-color: #fff;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 0 40px rgba(34, 197, 94, 0.15);
}

.qr-code-wrapper img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 4px;
}

.instructions {
    text-align: center;
    color: var(--text-color-muted);
}

.instructions p {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

#countdown {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.5rem;
}

.countdown-label {
    font-size: 1rem;
}

.countdown-time {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.poll-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
    overflow-y: auto;
    padding-right: 1rem;
    position: relative;
    z-index: 5;
    min-width: 0;
}

/* Custom scrollbar for poll panel */
.poll-panel::-webkit-scrollbar {
    width: 6px;
}
.poll-panel::-webkit-scrollbar-track {
    background: transparent;
}
.poll-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.poll-question {
    font-family: var(--font-display);
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 2rem;
    letter-spacing: 1px;
    color: var(--text-color);
    position: relative;
    z-index: 5;
    pointer-events: none; /* Prevent overlapping clicks */
}

.poll-choices {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    z-index: 20;
}

/* Voting state (Before voting) */
.poll-choice {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 64px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    color: var(--text-color);
    font-size: 1.25rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    z-index: 10;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.poll-choice .choice-title {
    font-weight: 600;
    position: relative;
    z-index: 2;
    flex-grow: 1;
}

.poll-choice * {
    pointer-events: none;
}

.poll-choice:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.poll-choice:disabled {
    cursor: default;
}

/* Results state (After voting) */
.poll-choices.show-results .poll-choice {
    display: grid;
    grid-template-columns: minmax(100px, 30%) 1fr 100px;
    align-items: center;
    gap: 1rem;
    background: transparent;
    border-color: transparent;
    padding: 0.5rem 0;
    min-height: 48px;
}

.poll-choices.show-results .poll-choice:hover {
    transform: none;
    box-shadow: none;
    background: transparent;
}

.poll-choices.show-results .choice-title {
    font-size: 1.1rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.bar-container {
    display: none;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #16a34a, var(--accent-color));
    border-radius: 8px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.poll-choice.leading .bar {
    animation: pulse 2s infinite;
}

.choice-stats {
    display: none;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
    text-align: right;
    color: var(--text-color);
}

.choice-stats .count-bullet {
    color: var(--text-color-muted);
    font-weight: normal;
}

.poll-choices.show-results .bar-container,
.poll-choices.show-results .choice-stats {
    display: block;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

#wbx-powered-by-slot {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        overflow-y: auto;
    }
    .poll-panel {
        overflow-y: visible;
        padding-right: 0;
    }
    .qr-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 1.5rem;
    }
    .poll-question {
        font-size: 3rem;
        text-align: center;
    }
    .poll-choices.show-results .poll-choice {
        grid-template-columns: 30% 1fr 80px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    .container {
        border-radius: 0;
        border: none;
        max-height: none;
    }
    .poll-question {
        font-size: 2.25rem;
    }
    .qr-code-wrapper {
        max-width: 200px;
    }
    .instructions p {
        font-size: 1rem;
    }
    .countdown-time {
        font-size: 1.25rem;
    }
    .poll-choices.show-results .poll-choice {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    .poll-choices.show-results .choice-title {
        white-space: normal;
    }
    .poll-choices.show-results .choice-stats {
        text-align: left;
    }
}
