/* --- Global App Styles --- */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius);
    padding: 30px;
}

/* --- Auth Page --- */
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { text-align: center; margin-bottom: 25px; }
.auth-card .button { width: 100%; margin-top: 10px; }
.auth-toggle-text { text-align: center; margin-top: 20px; font-size: 0.9rem; }
.auth-toggle-text a { color: var(--accent-color); text-decoration: none; font-weight: 600; }

/* --- Modals --- */
#modal-backdrop {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: rgba(10, 5, 20, 0.6);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 1000; display: flex; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
    padding: 20px;
}
#modal-backdrop:not(.hidden) { opacity: 1; pointer-events: auto; }
.modal-container {
    background-color: #1A202C; border-radius: var(--border-radius);
    width: 100%; max-width: 600px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transform: scale(0.95); transition: transform 0.3s ease;
    display: flex; flex-direction: column;
    max-height: 95vh;
}
#modal-backdrop:not(.hidden) .modal-container { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 25px; border-bottom: 1px solid var(--glass-border); flex-shrink: 0; }
.modal-header h2 { margin: 0; }
.close-modal-btn { background: none; border: none; color: var(--body-text); font-size: 1.5rem; cursor: pointer; transition: color 0.2s; }
.close-modal-btn:hover { color: var(--light-text); }
.modal-content { padding: 25px; overflow-y: auto; flex-grow: 1;}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 25px; border-top: 1px solid var(--glass-border); margin-top: auto; flex-shrink: 0; }

/* --- Admin Layout --- */
.admin-container { display: flex; height: 100vh; }
.sidebar { width: 280px; flex-shrink: 0; background: var(--glass-bg); border-right: 1px solid var(--glass-border); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: flex; flex-direction: column; transition: transform 0.3s ease; }
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { margin: 0; font-size: 1.5rem; color: #ffffff; background: none; background-clip: initial; -webkit-background-clip: initial; -webkit-text-fill-color: initial; }

/* Make the second word in sidebar header match landing logo styling but with reduced glow */
.sidebar-header .logo-sparks {
    font-weight: 800;
    background: linear-gradient(90deg, #ffffff 0%, #fff9d6 60%, #ffd86b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #fff;
    text-shadow: 0 1px 6px rgba(255,220,140,0.55);
}
.sidebar-content { padding: 20px; flex-grow: 1; overflow-y: auto; }
.sidebar h3 { margin-top: 20px; }
.new-poll-btn { width: 100%; }
.item-list { margin-top: 20px; }

/* Sidebar footer pinned to bottom */
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--glass-border); margin-top: auto; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-radius: 8px; margin-bottom: 8px; cursor: pointer; font-weight: 500; transition: background-color 0.2s; }
.list-item:hover { background-color: rgba(255,255,255,0.05); }
.list-item.selected { background: var(--primary-gradient); color: white; font-weight: 700; }

/* Drag handle for reorderable list items */
.drag-handle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-right: 12px; border-radius: 8px; color: var(--body-text); cursor: grab; }
.drag-handle:hover { color: var(--light-text); background: rgba(255,255,255,0.02); }
.list-item.dragging { opacity: 0.85; }
.list-item.dragging .drag-handle { cursor: grabbing; }
.main-content { flex-grow: 1; overflow-y: auto; padding: 30px; }
.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; min-height: 40px; }
.header-info { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.main-header h1 { margin: 0; font-size: 2rem; }
.header-actions { display: flex; gap: 10px; }
.mobile-menu-btn { display: none; background: none; border: none; padding: 5px; cursor: pointer; font-size: 1.5rem; color: var(--light-text); }
.centered-content { display: flex; justify-content: center; align-items: center; height: calc(100% - 150px); }
.placeholder-text-lg { text-align: center; color: var(--body-text); }
.tabs { display: flex; border-bottom: 1px solid var(--glass-border); margin-bottom: 25px; gap: 10px; }
.tab-button { padding: 10px 20px; cursor: pointer; background: none; border: none; font-size: 1rem; color: var(--body-text); border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; transition: all 0.2s; }
.tab-button.active { font-weight: 700; color: var(--light-text); border-bottom-color: var(--accent-color); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Button Text Styling for Responsiveness */
.btn-text-short { display: none; }

/* --- LIVE TAB STYLES --- */
.interaction-strip { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 25px; background: var(--glass-bg); border: 1px solid var(--glass-border); padding: 15px 20px; border-radius: var(--border-radius); margin-bottom: 25px; }
.interaction-item label { font-size: 0.8rem; font-weight: 500; color: var(--body-text); margin-bottom: 8px; display: block; }
.live-main-grid { display: grid; grid-template-columns: minmax(350px, 450px) 1fr; gap: 25px; align-items: start; }
.control-column h3, .preview-column h3 { margin-top: 0; margin-bottom: 15px; font-size: 1.2rem; }
.control-panel { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--border-radius); padding: 20px; }
.show-lobby-btn { width: 100%; margin-bottom: 20px; }
.live-questions-list { max-height: 60vh; overflow-y: auto; }
.live-question-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 15px; padding: 12px; border-bottom: 1px solid var(--glass-border); }
.live-question-item:last-child { border-bottom: none; }
.live-question-item.active { background-color: rgba(255,255,255,0.05); border-radius: 8px; }
.live-q-status { font-weight: 600; font-size: 0.8rem; padding: 4px 10px; border-radius: 20px; text-align: center; }
.live-q-status.ready { background-color: var(--body-text); color: var(--dark-bg); }
.live-q-status.live { background-color: #FBBF24; color: var(--dark-bg); animation: pulse 1.5s infinite; }
.live-q-status.results-shown { background-color: var(--success-color); color: white; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); } 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); } }
.live-q-buttons { display: flex; gap: 8px; }
.live-q-buttons .push-btn, .live-q-buttons .reveal-btn { font-weight: 600; }
.live-q-buttons .reveal-btn { background: var(--accent-color); border: none; }
.preview-wrapper { position: relative; width: 100%; aspect-ratio: 16 / 9; background-color: #000; border-radius: var(--border-radius); overflow: hidden; border: 1px solid var(--glass-border); }
#live-preview-iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 720px; border: 0; transform-origin: top left; }

/* --- Question Tab --- */
.questions-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.question-card { background: var(--glass-bg); border: 1px solid var(--glass-border); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: var(--border-radius); padding: 20px; margin-bottom: 15px; display: flex; align-items: center; gap: 15px; transition: background-color 0.2s; }
.question-card:hover { background-color: rgba(255,255,255,0.03); }
.q-card-text { flex-grow: 1; font-weight: 500; }
.question-type-pill { padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--light-text); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.q-actions { display: flex; gap: 8px; }
.q-actions button { background: none; border: none; padding: 5px; cursor: pointer; color: var(--body-text); font-size: 1rem; transition: all 0.2s; }
.q-actions button:hover { color: var(--light-text); }
.q-actions .delete-btn:hover { color: var(--danger-color); }

/* --- Question Editor Form (in Modal) --- */
.option-input-group { display: grid; grid-template-columns: 1fr auto auto; gap: 15px; align-items: center; margin-bottom: 15px; }
.color-picker-wrapper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; }
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--light-text); }
input[type="color"] { width: 32px; height: 32px; padding: 0; border: none; background: none; border-radius: 50%; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 15px; }
.correct-option-control { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 700; color: var(--light-text); white-space: nowrap; }
.question-correct-answer-hint { margin: 0 0 10px; color: var(--body-text); font-size: 0.9rem; }

/* --- Analytics Tab Styles --- */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 25px; }
.analytics-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--border-radius); padding: 20px 25px; display: flex; flex-direction: column; }
.analytics-card-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--glass-border); padding-bottom: 15px; margin-bottom: 15px; }
.analytics-card-header h4 { margin: 0; font-size: 1.1rem; line-height: 1.4; }
.analytics-stats { flex-shrink: 0; text-align: right; color: var(--body-text); font-size: 0.9rem; }
.analytics-stats strong { display: block; font-size: 1.5rem; font-weight: 700; color: var(--light-text); }
.analytics-stat-secondary { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--body-text); }
.analytics-card-body { display: grid; grid-template-columns: 1fr 150px; gap: 20px; align-items: center; }
.analytics-option-list { display: flex; flex-direction: column; gap: 12px; }
.analytics-option-row { display: grid; grid-template-columns: 20px 1fr auto auto; align-items: center; gap: 12px; font-size: 0.95rem; }
.color-legend { width: 12px; height: 12px; border-radius: 3px; }
.analytics-option-row .option-text { font-weight: 500; color: var(--light-text); }
.analytics-option-row .option-percent { font-weight: 700; color: var(--light-text); justify-self: end; }
.analytics-option-row .option-votes { font-size: 0.85rem; color: var(--body-text); justify-self: end; width: 80px; text-align: right; }
.analytics-option-row.is-correct { padding: 10px 12px; border-radius: 12px; background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3); }
.analytics-chart-container { height: 150px; width: 150px; justify-self: center; }
.analytics-wordcloud-container { min-height: 220px; }
.analytics-text-results-container { min-height: 220px; }
.correct-answer-badge { display: inline-flex; align-items: center; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(16, 185, 129, 0.16); color: #86efac; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }

.wordcloud { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; justify-content: center; min-height: 180px; padding: 14px 0; }
.wordcloud-compact { gap: 10px 14px; justify-content: flex-start; min-height: 200px; }
.wordcloud-word { display: inline-block; font-weight: 800; line-height: 1; text-transform: lowercase; text-shadow: 0 4px 18px rgba(0,0,0,0.25); }
.wordcloud-empty { width: 100%; text-align: center; color: var(--body-text); margin: 0; }

.response-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-height: 420px; overflow: auto; padding-right: 6px; }
.response-list-compact { max-height: 240px; }
.response-list-item { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); text-align: left; }
.response-list-index { color: var(--body-text); font-size: 0.85rem; font-weight: 700; }
.response-list-text { color: var(--light-text); line-height: 1.5; word-break: break-word; }
.response-list-empty { width: 100%; text-align: center; color: var(--body-text); margin: 0; }

/* --- Public Pages (Display & Vote) --- */
.vote-body { display: flex; justify-content: center; align-items: center; }
.display-body, .vote-body { background-color: #0c0a15; color: var(--light-text); overflow: hidden; }
.background-shapes { position: fixed; width: 100vw; height: 100vh; top: 0; left: 0; background-image: radial-gradient(circle at 10% 20%, rgba(200, 80, 192, 0.2) 0%, transparent 40%), radial-gradient(circle at 80% 90%, rgba(65, 88, 208, 0.2) 0%, transparent 40%); z-index: -1; }
.display-state { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; height: 100vh; width: 100%; padding: 40px; box-sizing: border-box; }
.display-state h1 { font-size: clamp(2.2rem, 6.2vw, 5rem); font-weight: 800; line-height: 1.1; margin-bottom: 6px; }
.join-prompt { font-size: clamp(1rem, 2.4vw, 1.5rem); color: var(--body-text); margin-bottom: 16px; font-weight: 500; }
.qr-container { background: white; padding: 14px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
#qrcode canvas { display: block; width: 210px !important; height: 210px !important; }
.join-url-line { margin: 10px 0 6px; color: var(--body-text); font-size: clamp(0.95rem, 1.8vw, 1.15rem); }
.join-url-text {
    color: #ffffff;
    font-size: clamp(1.1rem, 3.2vw, 1.6rem);
    font-weight: 800;
    text-decoration: none;
    letter-spacing: 0.02em;
    max-width: min(92vw, 980px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* No underline and keep white on hover/focus */
.join-url-text:hover,
.join-url-text:focus-visible {
    text-decoration: none;
    color: #ffffff;
}

@media (max-height: 820px) {
    .display-state { padding: 20px; }
    .display-state h1 { font-size: clamp(1.8rem, 5vw, 3.6rem); margin-bottom: 4px; }
    .join-prompt { margin-bottom: 10px; }
    .qr-container { padding: 10px; }
    #qrcode canvas { width: 180px !important; height: 180px !important; }
    .join-url-line { margin-top: 8px; }
}

/* *** RESTORED STYLES FOR DISPLAY PAGE OPTIONS *** */
.options-display-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; width: 85%; margin: 30px 0; }
/* Fixed-height display tiles; font will shrink to fit via JS fallback */
.option-display-item { padding: 20px; color: white; font-size: clamp(14px, 2.6vw, 28px); font-weight: 700; text-align: center; border-radius: var(--border-radius); text-shadow: 1px 1px 3px rgba(0,0,0,0.4); border: 4px solid; height: 180px; display: flex; align-items: center; justify-content: center; overflow: hidden; }

/* Responsive: single column on narrow screens */
@media (max-width: 700px) {
    .options-display-grid { grid-template-columns: 1fr; gap: 12px; width: 94%; }
    .option-display-item { padding: 20px; }
}

/* Allow long option text to wrap and clamp to a few lines on small screens */
.option-display-item {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Allow display options to expand vertically so text never gets clipped */
.option-display-item {
    display: block;
    overflow: visible;
    cursor: pointer;
}

#display-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px 30px; margin-top: 30px; width: 90%; max-width: 1100px; }
.display-legend-item { display: flex; align-items: center; gap: 12px; }
.display-legend-item.is-correct { padding: 10px 14px; border-radius: 14px; background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.28); }
.display-legend-color { width: 20px; height: 20px; border-radius: 4px; }
.display-legend-text { color: var(--light-text); font-size: 1.2rem; font-weight: 500; }
.display-correct-answer { margin: 8px 0 20px; padding: 14px 20px; border-radius: 16px; background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.32); color: #d1fae5; font-size: clamp(1rem, 2vw, 1.3rem); }
.timer-container { display: none !important; }
#timer { display: none !important; }
.chart-container { width: 90%; max-width: 1100px; height: 65vh; }
.vote-question-title { font-size: 2.2rem; margin-bottom: 30px; text-align: center; }
.chart-container-vote { position: relative; height: 300px; width: 100%; max-width: 450px; margin: 20px auto; }
.vote-result-status { width: 100%; max-width: 540px; margin: 14px auto 6px; padding: 14px 18px; border-radius: 16px; font-size: 1rem; line-height: 1.5; }
.vote-result-status.is-correct { background: rgba(16, 185, 129, 0.16); border: 1px solid rgba(16, 185, 129, 0.35); color: #d1fae5; }
.vote-result-status.is-incorrect { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: var(--light-text); }
.sparkquiz-player-shell { width: min(100%, 360px); margin: 18px auto 0; display: flex; flex-direction: column; gap: 12px; }
.sparkquiz-player-shell input { width: 100%; }
.sparkquiz-player-status { margin: 0; color: var(--body-text); font-size: 0.95rem; min-height: 1.4em; }
.sparkquiz-countdown-shell { display: flex; justify-content: center; margin: 0 0 18px; }
.sparkquiz-countdown-shell-display { margin: 0 0 24px; }
.sparkquiz-countdown { display: inline-flex; align-items: center; justify-content: center; min-width: 120px; padding: 10px 18px; border-radius: 999px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); color: var(--light-text); font-size: 1.05rem; font-weight: 800; letter-spacing: 0.03em; }
.sparkquiz-countdown.is-warning { background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.32); color: #fde68a; }
.sparkquiz-countdown.is-danger { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.35); color: #fecaca; }
.sparkquiz-summary-card { width: min(100%, 560px); margin: 12px auto 0; padding: 16px 20px; border-radius: 18px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: var(--light-text); line-height: 1.5; }
.sparkquiz-panels { width: min(100%, 960px); margin: 24px auto 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; text-align: left; }
.sparkquiz-panels-display { width: min(1100px, 92vw); }
.sparkquiz-panel { padding: 18px 20px; border-radius: 18px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); }
.sparkquiz-panel h3 { margin: 0 0 14px; font-size: 1.05rem; color: var(--light-text); }
.sparkquiz-panel p { margin: 0; color: var(--body-text); }
.sparkquiz-podium { width: min(100%, 860px); margin: 18px auto 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.sparkquiz-podium-display { width: min(1000px, 92vw); }
.sparkquiz-podium-slot { padding: 18px 16px; border-radius: 20px 20px 14px 14px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); text-align: center; }
.sparkquiz-podium-slot.is-first { min-height: 210px; background: linear-gradient(180deg, rgba(251, 191, 36, 0.22), rgba(255,255,255,0.06)); border-color: rgba(251, 191, 36, 0.4); }
.sparkquiz-podium-slot.is-second { min-height: 180px; }
.sparkquiz-podium-slot.is-third { min-height: 160px; }
.sparkquiz-podium-rank { display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 54px; margin-bottom: 10px; border-radius: 999px; background: rgba(255,255,255,0.1); font-size: 1.1rem; font-weight: 900; color: #fff; }
.sparkquiz-podium-name { font-size: 1.1rem; font-weight: 800; color: var(--light-text); }
.sparkquiz-podium-score { margin-top: 8px; font-size: 1.4rem; font-weight: 900; color: #fff; }
.sparkquiz-podium-meta { margin-top: 6px; color: var(--body-text); font-size: 0.92rem; }
.sparkquiz-leaderboard-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sparkquiz-entry { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); }
.sparkquiz-entry.is-current-player { background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.35); }
.sparkquiz-rank { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 42px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--light-text); font-weight: 800; }
.sparkquiz-entry-name { font-weight: 700; color: var(--light-text); }
.sparkquiz-entry-meta { font-size: 0.9rem; color: var(--body-text); }
.sparkquiz-entry-score { font-weight: 800; color: var(--light-text); white-space: nowrap; }
.sparkquiz-rank-change { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 3px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; }
.sparkquiz-rank-change.is-up { background: rgba(16, 185, 129, 0.16); color: #86efac; }
.sparkquiz-rank-change.is-down { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.sparkquiz-rank-change.is-same { background: rgba(255,255,255,0.08); color: var(--body-text); }
.vote-results-legend { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 20px; padding: 0 10px; width: 100%; max-width: 450px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 1rem; }
.legend-item.is-correct { padding: 10px 12px; border-radius: 12px; background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.28); }
.legend-color-box { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }
.legend-text { color: var(--light-text); font-weight: 500; }
/* Options grid for voting choices. Use flexible layout so buttons can differ in size. */
#options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
    max-width: 900px;
    justify-content: center;
    align-items: stretch;
    /* allow vertical scroll when there are many options */
    max-height: calc(100vh - 260px); /* leaves space for title and padding */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px; /* allow space for scrollbar */
    box-sizing: border-box;
}

/* Ensure the vote page can scroll when content is taller than the viewport (overrides generic hidden rule) */
.vote-body { overflow: auto !important; overflow-x: hidden !important; }

/* Single-column layout on narrow screens */
@media (max-width: 700px) {
    #options-grid { gap: 12px; }
    .option-button { flex: 1 1 100% !important; }
    .sparkquiz-panels { grid-template-columns: 1fr; }
    .sparkquiz-podium { grid-template-columns: 1fr; }
    .sparkquiz-podium-slot.is-first,
    .sparkquiz-podium-slot.is-second,
    .sparkquiz-podium-slot.is-third { min-height: auto; }
}
.text-answer-form { width: 100%; max-width: 720px; display: flex; flex-direction: column; gap: 16px; }
.text-answer-form textarea { font-size: 1.2rem; min-height: 180px; }
.option-button {
    border-radius: var(--border-radius);
    color: white;
    font-size: clamp(14px, 2.2vw, 1.6rem);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 3px solid rgba(255,255,255,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 12px;
    box-sizing: border-box;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.05;
    min-width: 0;
}
.option-button:hover { transform: scale(1.05); border-color: white; }

/* Size variants (assigned by JS) */
.option-button.size-large { flex: 1 1 48%; min-height: 180px; }
.option-button.size-medium { flex: 1 1 32%; min-height: 150px; }
.option-button.size-small { flex: 1 1 22%; min-height: 130px; }
.option-button.size-full { flex: 1 1 100%; min-height: 160px; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--glass-border); border-radius: 50%; border-top-color: var(--accent-color); margin: 0 auto 15px auto; animation: spin 1s linear infinite; }
.checkmark { width: 80px; height: 80px; margin: 20px auto; }
.checkmark__circle { stroke-width: 3; stroke: var(--success-color); fill: none; stroke-dasharray: 166; stroke-dashoffset: 166; animation: stroke .6s cubic-bezier(0.65, 0, 0.45, 1) forwards; }
.checkmark__check { stroke-dasharray: 48; stroke-dashoffset: 48; stroke-width: 3; stroke: white; transform-origin: 50% 50%; animation: stroke .3s cubic-bezier(0.65, 0, 0.45, 1) .8s forwards; }
.vote-results-wordcloud { width: 100%; max-width: 720px; min-height: 280px; margin-top: 16px; }
.display-wordcloud { width: min(1100px, 90vw); min-height: 55vh; display: flex; align-items: center; justify-content: center; }
.confetti { position: fixed; top: -10vh; pointer-events: none; z-index: 9999; opacity: 1; }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes stroke { 100% { stroke-dashoffset: 0; } }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); opacity: 0; } }

/* --- Responsive --- */
@media (max-width: 992px) { 
    .live-main-grid { grid-template-columns: 1fr; } 
    .analytics-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
    .analytics-card-body { grid-template-columns: 1fr; }
    .analytics-chart-container { margin-top: 20px; }
}
@media (max-width: 768px) {
    .admin-container { flex-direction: column; }
    .sidebar { position: fixed; top: 0; left: 0; height: 100%; z-index: 2000; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { padding: 15px; }
    .mobile-menu-btn { display: inline-flex; }
    .main-header h1 { font-size: 1.5rem; }
    
    /* Responsive Header Buttons */
    .btn-text { display: none; }
    .btn-text-short { display: inline; }
}
/* --- Table styles for admin stats --- */
.table-wrap { overflow-x: auto; width: 100%; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; background: transparent; border-radius: var(--border-radius); overflow: hidden; box-shadow: 0 8px 30px rgba(2,6,23,0.6); border: 1px solid var(--glass-border); }
.table thead { background: linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)); }
.table th, .table td { padding: 12px 16px; text-align: left; color: var(--light-text); font-size: 0.95rem; border-bottom: 1px solid rgba(255,255,255,0.03); }
.table th { font-weight: 700; color: #ffffff; font-size: 0.9rem; letter-spacing: 0.02em; }
.table tbody tr { background: rgba(255,255,255,0.01); transition: background 0.15s ease, transform 0.12s ease; }
.table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.table tbody tr:hover { background: rgba(255,255,255,0.04); transform: translateY(-1px); }
.table .badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,0.04); color: var(--light-text); font-weight: 700; font-size: 0.85rem; }

/* Plan badge styles */
.plan-badge { display:inline-block; padding:4px 8px; border-radius:999px; font-weight:700; font-size:0.85rem; text-transform:capitalize; }
.plan-badge--free { background: rgba(255,255,255,0.04); color: var(--light-text); }
.plan-badge--premium { background: rgba(34,197,94,0.12); color: #22c55e; }
.table-full { width: 100%; }

@media (max-width: 820px) {
    .table { min-width: 600px; }
}

/* toolbar + pager */
.stats-toolbar input[type="search"] { min-width: 200px; }
.stats-toolbar select { background: transparent; }
.stats-pager button { margin: 0 6px; }
.stats-pager { display: inline-flex; gap: 8px; align-items: center; }
.stats-pager .button[disabled] { opacity: 0.4; cursor: not-allowed; }

/* small responsive tweaks */
@media (max-width: 700px) {
    .stats-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .stats-toolbar #stats-count { margin-left: 0; text-align: right; }
}


/* =============================
   LAUNCHER PAGE
   ============================= */
.launcher-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.launcher-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.launcher-brand h1 {
    margin: 0;
    font-size: 1.4rem;
    color: #ffffff;
    background: none;
    background-clip: initial;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
}

.launcher-brand .logo-sparks {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.launcher-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.launcher-actions > * {
    flex-shrink: 0;
}

.launcher-org-switcher {
    min-width: 220px;
    max-width: 280px;
    margin-bottom: 0;
}

.launcher-user-email {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-right: 4px;
}

.org-launcher-actions .launcher-user-email {
    display: inline-block;
    max-width: none;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.org-launcher-actions #logout-button {
    flex-shrink: 0;
}

.org-page-header {
    justify-content: space-between;
}

.org-page-header .org-launcher-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    margin-left: auto;
}

.account-page-header {
    justify-content: space-between;
}

.account-page-header .account-launcher-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    margin-left: auto;
}

.org-launcher-actions,
.account-launcher-actions,
.admin-launcher-actions {
    min-width: 0;
}

.org-launcher-actions .launcher-org-switcher,
.account-launcher-actions .launcher-org-switcher,
.admin-launcher-actions .launcher-org-switcher {
    min-width: 190px;
    width: 190px;
}

.org-launcher-actions .launcher-user-email,
.account-launcher-actions .launcher-user-email,
.admin-launcher-actions .launcher-user-email {
    display: inline-block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Keep invite controls aligned in Organization page header row. */
.org-invite-row input,
.org-invite-row select {
    margin-bottom: 0;
}

.org-invite-submit-btn {
    margin-bottom: 0;
}

.org-invite-code-row input {
    margin-bottom: 0;
}

.org-invite-code-apply-btn {
    margin-bottom: 0;
}

.org-name-edit-row input {
    margin-bottom: 0;
}

.org-name-save-btn {
    margin-bottom: 0;
}

.launcher-main {
    flex: 1;
    padding: 48px 32px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.launcher-welcome {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 32px 0;
    opacity: 0.9;
}

.launcher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.launcher-news-section {
    margin-top: 42px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.launcher-news-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.launcher-news-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
}

.launcher-news-header p {
    margin: 0;
    color: var(--body-text);
    font-size: 0.92rem;
}

.launcher-news-list {
    display: grid;
    gap: 14px;
}

.launcher-news-item {
    padding: 18px 20px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.launcher-news-item time {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.48);
}

.launcher-news-item h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.launcher-news-item p {
    margin: 0;
    color: var(--body-text);
    line-height: 1.55;
    font-size: 0.92rem;
}

.launcher-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 28px 24px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.launcher-card:hover {
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.15);
}

.launcher-card-icon {
    font-size: 2rem;
    margin-bottom: 16px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.launcher-card h3 {
    margin: 0 0 8px 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
}

.launcher-card p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.6;
    line-height: 1.5;
}

/* Back-to-home link in sidebar header */
.back-home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.back-home-link:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

@media (max-width: 600px) {
    .launcher-header { padding: 14px 18px; }
    .launcher-main { padding: 28px 18px; }
    .launcher-actions { flex-wrap: wrap; overflow-x: visible; }
    .launcher-user-email { display: none; }
    .launcher-org-switcher { min-width: 0; width: 100%; max-width: none; }
    .header-actions .button { padding: 8px 12px; }
    .launcher-news-header { flex-direction: column; align-items: flex-start; }

    /* Responsive Question Editor Modal */
    .option-input-group { grid-template-columns: 1fr; gap: 10px; }
    
    .form-grid-3 { grid-template-columns: 1fr; }
    .modal-container { width: 95%; max-width: none; }
    .modal-header, .modal-footer { padding: 15px 20px; }
    .modal-content { padding: 20px; }
    
    #options-grid, .options-display-grid { grid-template-columns: 1fr; }
    .live-main-grid { grid-template-columns: 1fr; }
    .interaction-strip { flex-direction: column; align-items: stretch; }
    .live-questions-list { max-height: 40vh; }
    
    .analytics-grid { grid-template-columns: 1fr; }

    .org-page-header .org-launcher-actions {
        flex-wrap: wrap;
    }
}

   
