/* Question Image Section */
.q-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.q-image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

.q-image-container:hover .q-image-preview {
    transform: scale(1.02);
}

.remove-image-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    z-index: 10;
}

.remove-image-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.q-image-placeholder {
    width: 100%;
    height: 60px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s;
}

.q-image-placeholder:hover {
    background: rgba(56, 189, 248, 0.05);
    border-color: var(--accent-color);
}

.add-image-btn {
    background: transparent;
    color: var(--accent-color);
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.q-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sticky-controls {
    position: sticky;
    top: 0;
    z-index: 1500;
    padding: 12px 20px;
    background: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    margin: 0 -20px 20px -20px;
    width: calc(100% + 40px);
}

@media (min-width: 768px) {
    .sticky-controls {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }
}

.search-bar {
    flex: 1;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(30, 41, 59, 0.9);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--accent-color);
}

.add-q-sticky-btn {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 20px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
    white-space: nowrap;
    transition: all 0.2s;
}

.add-q-sticky-btn:active {
    transform: scale(0.95);
}

.questions-list {
    display: grid;
    gap: 24px;
}

.question-item {
    background: #1e293b;
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-margin-top: 140px;
    /* Header + Sticky Controls + Buffer */
}

.q-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-color);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.75rem;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.btn-sm:active {
    transform: scale(0.9);
    background: rgba(220, 38, 38, 0.2);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.delete-q-btn {
    background: #1e293b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

textarea,
input[type="text"].opt-text {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-color);
    padding: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus,
input[type="text"].opt-text:focus {
    border-color: var(--accent-color);
}

textarea {
    min-height: 80px;
    resize: vertical;
    margin-bottom: 12px;
}

.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.option-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.option-row:active {
    transform: scale(0.98) translateX(4px);
}

.option-row.correct {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.1);
}

.option-row .indicator {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 800;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.option-row.correct .indicator {
    background: #22c55e;
    color: white;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.option-row input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-row input[type="text"] {
    background: transparent;
    border: none;
    padding: 2px 0;
}

/* Quiz Split Modal Specifics */
.split-options {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.split-type-btn {
    background: #1e293b;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 16px;
    color: #ffffff;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.split-type-btn.active {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
}

.split-input-group {
    margin-top: 10px;
    display: none;
}

.split-input-group.active {
    display: block;
}

.split-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    margin-top: 8px;
}

/* Leaderboard View */
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    margin-bottom: 20px;
}

.lb-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.lb-tab.active {
    background: var(--accent-color);
    color: #0f172a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.lb-type-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.lb-type-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 12px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.lb-type-btn.active {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
}

.lb-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 150px;
}

.lb-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 14px 18px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
}

.lb-card.top-1 {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05));
    border-color: rgba(251, 191, 36, 0.3);
}

.lb-card.top-2 {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(148, 163, 184, 0.05));
    border-color: rgba(148, 163, 184, 0.3);
}

.lb-card.top-3 {
    background: linear-gradient(135deg, rgba(180, 83, 9, 0.15), rgba(180, 83, 9, 0.05));
    border-color: rgba(180, 83, 9, 0.3);
}

.lb-rank {
    font-size: 1.1rem;
    font-weight: 800;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.top-1 .lb-rank {
    background: #fbbf24;
    color: #78350f;
}

.top-2 .lb-rank {
    background: #94a3b8;
    color: #1e293b;
}

.top-3 .lb-rank {
    background: #b45309;
    color: white;
}

.lb-info {
    flex-grow: 1;
    min-width: 0;
}

.lb-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 2px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-username {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-score {
    text-align: right;
}

.lb-score-val {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 1.1rem;
}

.lb-score-unit {
    font-size: 0.7rem;
    opacity: 0.6;
    display: block;
}

.my-rank-sticky {
    position: fixed;
    bottom: calc(84px + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 560px;
    /* Stay inside #app's 600px */
    padding: 16px 20px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 450;
    border: 1px solid var(--accent-color);
    background: #1e293b;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: popUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes highlight-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px 10px rgba(56, 189, 248, 0.2);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}

.highlight-pulse {
    animation: highlight-pulse 1s ease-in-out 2;
    border-color: var(--accent-color) !important;
}

.lb-loader {
    display: flex;
    justify-content: center;
    padding: 40px;
}

/* Performance View */
.perf-stats-card {
    padding: 24px;
    border-radius: 24px;
    margin-bottom: 24px;
    text-align: center;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid var(--border-color);
}

#perf-user-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--accent-color);
}

.perf-main-row {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 20px;
}

.perf-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.perf-val {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.perf-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.rules-guide-btn {
    background: rgba(56, 189, 248, 0.1);
    border: 1px dashed var(--accent-color);
    color: var(--accent-color);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.rules-guide-btn:active {
    background: rgba(56, 189, 248, 0.2);
    transform: scale(0.98);
}

.perf-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-muted);
    padding-left: 4px;
}

.perf-list {
    display: grid;
    gap: 12px;
    padding-bottom: 40px;
}

.perf-item {
    padding: 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.perf-item-info {
    flex: 1;
    min-width: 0;
    /* Critical for truncation in flex container */
    margin-right: 10px;
}

.perf-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    word-break: break-word;
}

.perf-item-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    /* Allow stats to wrap if very narrow */
}

.perf-item-score {
    text-align: right;
}

.score-val {
    font-size: 1.1rem;
    font-weight: 700;
    display: block;
}

.score-val.positive {
    color: var(--success-color);
}

.score-val.negative {
    color: var(--danger-color);
}

/* Premium Rules Modal Styles */
/* Premium Rules Modal Styles */
.premium-modal {
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%) !important;
    border: 1px solid rgba(56, 189, 248, 0.2) !important;
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.1), 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    position: relative;
    display: flex !important;
    flex-direction: column !important;
    max-height: 85vh !important;
    overflow: hidden !important;
    /* Container doesn't scroll, content does */
    padding: 0 !important;
    /* Remove padding from container, add to children */
}

.premium-modal .rules-list {
    overflow-y: auto;
    flex-grow: 1;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.premium-modal .modal-header {
    flex-shrink: 0;
    padding: 20px 20px 10px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.premium-modal .modal-footer {
    flex-shrink: 0;
    padding: 16px 20px;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.premium-modal::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.header-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.5));
    animation: bounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.premium-modal h2 {
    background: linear-gradient(to right, #fff, var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
}

.premium-modal .rule-item {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: staggeredIn 0.5s ease-out forwards;
    opacity: 0;
    animation-delay: calc(var(--i) * 0.1s);
}

.premium-modal .rule-item:hover {
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.3);
    transform: scale(1.02);
    box-shadow: 0 5px 20px rgba(56, 189, 248, 0.15);
}

.premium-modal .rule-icon {
    font-size: 2rem;
    margin-bottom: 4px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.premium-modal .rule-title {
    color: #f8fafc;
    font-size: 1rem;
    font-weight: 600;
}

.premium-modal .rule-desc {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 0.9rem;
}

/* Glow Button Style */
.glow-btn {
    background: linear-gradient(135deg, #0284c7, #0ea5e9) !important;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem !important;
}

.glow-btn:hover {
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.6) !important;
    transform: translateY(-2px);
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes staggeredIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
