* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg1: #667eea;
    --bg2: #764ba2;
    --primary: #667eea;
    --primary2: #764ba2;
    --text: #1f2937;
    --muted: #6b7280;
    --border: rgba(17, 24, 39, 0.12);
    --card: rgba(255, 255, 255, 0.92);
    --card-solid: #ffffff;
    --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 14px 30px rgba(0, 0, 0, 0.12);
    --shadow-sm: 0 8px 18px rgba(0, 0, 0, 0.10);
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: radial-gradient(1200px 600px at 10% 10%, rgba(255, 255, 255, 0.16), transparent 55%),
        radial-gradient(900px 500px at 95% 15%, rgba(0, 0, 0, 0.12), transparent 55%),
        linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 28px 18px;
    color: var(--text);
}

.container {
    width: 100%;
    max-width: 980px;
    position: relative;
}

.screen {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 26px;
    padding: 44px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    color: #111827;
    text-align: left;
    margin-bottom: 26px;
    font-size: 2.45em;
    letter-spacing: -0.02em;
}

.home-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 24px;
}

.option-card {
    background: var(--card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 38px 30px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    box-shadow: var(--shadow-sm);
}

#drag-zone {
    border: 2px dashed rgba(102, 126, 234, 0.35);
    background: rgba(102, 126, 234, 0.06);
}

.option-card:hover {
    border-color: rgba(102, 126, 234, 0.55);
    transform: translateY(-8px);
    box-shadow: 0 18px 45px rgba(102, 126, 234, 0.22);
}

.option-card.drag-over {
    border-color: #4caf50;
    background: #e8f5e9;
}

.option-card .icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.option-card h2 {
    color: #111827;
    font-size: 1.5em;
    margin-bottom: 10px;
}

.option-card p {
    color: var(--muted);
    margin-bottom: 20px;
}

.join-section {
    margin-top: 40px;
    padding: 32px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.10) 100%);
    border: 1px solid rgba(102, 126, 234, 0.18);
    border-radius: var(--radius-lg);
    text-align: center;
}

.join-section--primary {
    margin-top: 18px;
}

#browse-quizzes-btn {
    margin-top: 14px;
    width: 100%;
}

/* Make JSON import option less prominent */
#drag-zone {
    padding: 26px 22px;
}

#drag-zone .icon {
    font-size: 3.2em;
    margin-bottom: 12px;
}

#drag-zone h2 {
    font-size: 1.25em;
}

.join-section h3 {
    color: #111827;
    margin-bottom: 20px;
}

.join-form {
    display: flex;
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.join-form input {
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
    text-align: center;
}

.join-form .btn-primary {
    flex: 0 0 auto;
    padding: 12px 25px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.header-nav h1 {
    margin: 0;
    flex: 1;
}

.btn-back {
    background: rgba(17, 24, 39, 0.06);
    border: 1px solid rgba(17, 24, 39, 0.10);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.btn-back:hover {
    background: rgba(17, 24, 39, 0.09);
    transform: translateY(-1px);
}

.config-section {
    margin-bottom: 25px;
}

label {
    display: block;
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

input, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 12px;
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    background: rgba(255, 255, 255, 0.85);
}

input:focus, textarea:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.18);
}

small {
    color: var(--muted);
    font-size: 0.85em;
}

small a {
    color: #667eea;
    text-decoration: none;
}

.api-key-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.api-key-container input {
    flex: 1;
}

.btn-icon {
    padding: 12px 16px;
    background: rgba(17, 24, 39, 0.06);
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 12px;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-icon:hover {
    background: rgba(102, 126, 234, 0.10);
    border-color: rgba(102, 126, 234, 0.45);
    transform: translateY(-1px);
}

.api-key-actions {
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #666;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.9em;
}

.difficulty-select {
    padding: 12px;
    font-size: 1em;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
}

.mode-toggle {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    background: rgba(17, 24, 39, 0.06);
    color: #111827;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 14px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.mode-btn:hover {
    background: rgba(102, 126, 234, 0.10);
    transform: translateY(-1px);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary2) 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.35);
}

.action-buttons {
    display: flex;
    gap: 15px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header label {
    margin: 0;
}

.input-mode-toggle {
    display: flex;
    gap: 5px;
}

.input-mode-btn {
    padding: 6px 12px;
    background: rgba(17, 24, 39, 0.06);
    color: #111827;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.input-mode-btn:hover {
    background: rgba(102, 126, 234, 0.10);
}

.input-mode-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary2) 100%);
    color: white;
    border-color: transparent;
}

.visual-questions {
    display: block;
}

.raw-questions {
    display: block;
}

.hidden {
    display: none !important;
}

.question-card-edit {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(17, 24, 39, 0.12);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.06);
}

.question-card-edit:hover {
    border-color: rgba(102, 126, 234, 0.55);
    box-shadow: 0 18px 35px rgba(102, 126, 234, 0.14);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-number {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1em;
}

.btn-delete {
    background: #ffebee;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: #f44336;
    transform: scale(1.1);
}

.question-card-edit input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.question-card-edit input:focus {
    outline: none;
    border-color: #667eea;
}

.question-card-edit .question-input {
    font-weight: 600;
    font-size: 1.05em;
}

.question-card-edit .correct-answer {
    border-color: #4caf50;
    background: #f1f8f4;
}

.btn-add {
    width: 100%;
    padding: 15px;
    background: rgba(102, 126, 234, 0.08);
    color: var(--primary);
    border: 1px dashed rgba(102, 126, 234, 0.55);
    border-radius: 14px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: rgba(102, 126, 234, 0.14);
    border-style: solid;
}

.btn-primary {
    flex: 1;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary2) 100%);
    color: white;
    border: none;
    border-radius: 999px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(102, 126, 234, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    flex: 1;
    padding: 12px;
    background: rgba(17, 24, 39, 0.06);
    color: #111827;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 999px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(102, 126, 234, 0.10);
    border-color: rgba(102, 126, 234, 0.35);
    color: #111827;
}

.quiz-header {
    margin-bottom: 30px;
}

.timer-bar {
    width: 100%;
    height: 12px;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.1);
    position: relative;
}

.timer-bar::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    right: 1px;
    height: 4px;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 100%);
    border-radius: 20px 20px 0 0;
    pointer-events: none;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        #00e676 0%, 
        #69f0ae 20%,
        #b2ff59 40%, 
        #ffeb3b 60%, 
        #ff9800 80%, 
        #f44336 100%);
    background-size: 200% 100%;
    border-radius: 20px;
    transition: width 0.1s linear;
    width: 100%;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5), inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
}

.timer-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 50%, rgba(0,0,0,0.1) 100%);
    border-radius: 20px;
}

.timer-fill.low {
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.3);
    animation: timerPulse 0.5s ease-in-out infinite;
}

.timer-fill.critical {
    box-shadow: 0 0 25px rgba(244, 67, 54, 0.7), inset 0 1px 0 rgba(255,255,255,0.3);
    animation: timerPulse 0.3s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; transform: scaleY(1); }
    50% { opacity: 0.85; transform: scaleY(0.95); }
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
    width: 0%;
}

.stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 10px;
}

.streak-badge {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    animation: bounceIn 0.3s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.question-card {
    margin-bottom: 30px;
}

#question-text {
    color: #111827;
    font-size: 1.9em;
    line-height: 1.4;
    margin-bottom: 30px;
}

.difficulty-badge {
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.7em;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.difficulty-badge.fácil,
.difficulty-badge.facil {
    background: #4caf50;
    color: white;
}

.difficulty-badge.media {
    background: #ff9800;
    color: white;
}

.difficulty-badge.difícil,
.difficulty-badge.dificil {
    background: #f44336;
    color: white;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
    max-width: 760px;
    margin: 0 auto;
}

.option-btn {
    padding: 20px;
    background: rgba(17, 24, 39, 0.04);
    border: 3px solid transparent;
    border-radius: 12px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.option-btn:hover {
    background: rgba(102, 126, 234, 0.10);
    border-color: rgba(102, 126, 234, 0.55);
    transform: translateY(-2px);
}

.option-btn.correct {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
}

.option-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #c62828;
}

.option-btn.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.feedback {
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.feedback.hidden {
    display: none;
}

.feedback.correct {
    background: #e8f5e9;
    color: #2e7d32;
}

.feedback.incorrect {
    background: #ffebee;
    color: #c62828;
}

.results-summary {
    display: flex;
    justify-content: space-around;
    margin: 40px 0;
    flex-wrap: wrap;
    gap: 20px;
}

.results-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.results-actions .btn-primary,
.results-actions .btn-secondary {
    flex: 1;
}

.leaderboard-section {
    margin: 30px 0;
    padding: 25px;
    background: rgba(102, 126, 234, 0.06);
    border: 1px solid rgba(102, 126, 234, 0.14);
    border-radius: 16px;
}

.leaderboard-section h2 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.06);
}

.leaderboard-entry.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.leaderboard-entry.silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
}

.leaderboard-entry.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #e8a860 100%);
    color: white;
}

.leaderboard-position {
    font-size: 1.5em;
    font-weight: 700;
    width: 50px;
    text-align: center;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-weight: 600;
    font-size: 1.1em;
}

.leaderboard-details {
    font-size: 0.85em;
    opacity: 0.8;
}

.leaderboard-score {
    font-size: 1.3em;
    font-weight: 700;
    color: #667eea;
}

.leaderboard-entry.gold .leaderboard-score,
.leaderboard-entry.bronze .leaderboard-score {
    color: inherit;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 12, 24, 0.62);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
    border: 1px solid rgba(17, 24, 39, 0.12);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 15px;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
}

.modal-content input {
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.2em;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.share-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
    padding: 20px;
    background: rgba(17, 24, 39, 0.05);
    border-radius: 12px;
}

.share-code span {
    font-size: 2em;
    font-weight: 700;
    letter-spacing: 5px;
    color: #667eea;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: rgba(17, 24, 39, 0.04);
    border: 1px solid rgba(17, 24, 39, 0.10);
    border-radius: 12px;
    min-width: 150px;
}

.stat-value {
    font-size: 3em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #666;
    margin-top: 5px;
    font-size: 1.1em;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.loading p {
    color: white;
    font-size: 1.2em;
    margin-top: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .screen {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    #question-text {
        font-size: 1.3em;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }
}

/* Quizzes Grid */
.quizzes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.quiz-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.quiz-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.25);
}

.quiz-card h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.quiz-card-info {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.quiz-card-stats {
    font-size: 0.85em;
    color: #888;
}

.modal-large {
    max-width: 500px;
}

.quiz-code-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    display: inline-block;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.quiz-code-display strong {
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    margin-left: 8px;
}

.quiz-detail-info {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

#detail-leaderboard {
    margin: 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
}

#detail-leaderboard h3 {
    margin-bottom: 15px;
    text-align: center;
    color: #667eea;
}

.no-scores {
    text-align: center;
    color: #888;
    padding: 20px;
}

.no-quizzes {
    text-align: center;
    color: #888;
    padding: 40px;
    font-size: 1.1em;
}

.app-footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 0.9em;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.app-footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.app-footer a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* ==============================
   Professional Theme Override
   (keeps HTML/JS unchanged)
   ============================== */

:root {
    --p-bg-1: #0b1020;
    --p-bg-2: #24114a;
    --p-surface: rgba(255, 255, 255, 0.92);
    --p-surface-2: rgba(255, 255, 255, 0.86);
    --p-border: rgba(15, 23, 42, 0.12);
    --p-text: #0f172a;
    --p-muted: #475569;
    --p-primary: #6366f1;
    --p-primary-2: #8b5cf6;
    --p-success: #16a34a;
    --p-danger: #ef4444;
    --p-warning: #f59e0b;
    --p-shadow-lg: 0 30px 80px rgba(2, 6, 23, 0.35);
    --p-shadow-md: 0 16px 40px rgba(2, 6, 23, 0.18);
    --p-shadow-sm: 0 10px 22px rgba(2, 6, 23, 0.12);
    --p-radius-lg: 26px;
    --p-radius-md: 16px;
    --p-radius-sm: 12px;
}

body {
    color: var(--p-text);
    background:
        radial-gradient(900px 500px at 10% 15%, rgba(99, 102, 241, 0.35), transparent 55%),
        radial-gradient(800px 480px at 90% 20%, rgba(139, 92, 246, 0.32), transparent 55%),
        radial-gradient(900px 700px at 50% 100%, rgba(16, 185, 129, 0.12), transparent 55%),
        linear-gradient(135deg, var(--p-bg-1) 0%, var(--p-bg-2) 100%);
    padding: 28px 18px;
}

.container {
    max-width: 1000px;
    z-index: 1;
}

#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.9;
}

.screen {
    background: var(--p-surface);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--p-radius-lg);
    box-shadow: var(--p-shadow-lg);
    padding: clamp(22px, 3.5vw, 46px);
}

h1 {
    text-align: left;
    color: var(--p-text);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    margin-bottom: 22px;
}

/* Cards (home / quizzes list) */
.home-options {
    margin-top: 18px;
    gap: 22px;
}

.option-card {
    border-radius: var(--p-radius-lg);
    border: 1px solid var(--p-border);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--p-shadow-sm);
    padding: 34px 26px;
}

.option-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 24px 55px rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(255, 255, 255, 0.98);
}

#drag-zone {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.06) 100%);
    border: 2px dashed rgba(99, 102, 241, 0.35);
}

.option-card.drag-over {
    border-color: rgba(22, 163, 74, 0.75);
    background: rgba(22, 163, 74, 0.08);
    box-shadow: 0 24px 55px rgba(22, 163, 74, 0.18);
}

.option-card h2 {
    color: var(--p-text);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.option-card p {
    color: var(--p-muted);
}

/* Inputs / textareas */
input, textarea, select {
    border-radius: var(--p-radius-sm);
}

input, textarea {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.14);
}

input:focus, textarea:focus {
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

.difficulty-select {
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: var(--p-radius-sm);
    background: rgba(255, 255, 255, 0.95);
}

/* Buttons */
.btn-primary {
    border-radius: 999px;
    background: linear-gradient(135deg, var(--p-primary) 0%, var(--p-primary-2) 100%);
    box-shadow: 0 14px 30px rgba(99, 102, 241, 0.45);
}

.btn-primary:hover {
    box-shadow: 0 18px 38px rgba(99, 102, 241, 0.55);
}

.btn-secondary {
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(15, 23, 42, 0.14);
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.25);
    color: var(--p-text);
}

.btn-back {
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.06);
}

.btn-back:hover {
    background: rgba(15, 23, 42, 0.09);
}

.btn-icon {
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: rgba(15, 23, 42, 0.06);
}

/* Toggles */
.mode-btn {
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: rgba(15, 23, 42, 0.05);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--p-primary) 0%, var(--p-primary-2) 100%);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.35);
}

.input-mode-btn {
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: rgba(15, 23, 42, 0.05);
}

.input-mode-btn.active {
    background: linear-gradient(135deg, var(--p-primary) 0%, var(--p-primary-2) 100%);
    border-color: transparent;
}

/* Join section */
.join-section {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--p-shadow-md);
}

.join-section--primary {
    padding: 34px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.14) 0%, rgba(139, 92, 246, 0.10) 100%);
    border: 1px solid rgba(99, 102, 241, 0.22);
}

#browse-quizzes-btn {
    margin-top: 14px;
    width: 100%;
}

.join-section h3 {
    color: var(--p-text);
    font-weight: 800;
}

.join-form input {
    border: 1px solid rgba(15, 23, 42, 0.14);
    background: rgba(255, 255, 255, 0.92);
    color: var(--p-text);
}

#drag-zone {
    padding: 26px 22px;
    background: rgba(99, 102, 241, 0.06);
}

#drag-zone .icon {
    font-size: 3.2em;
    margin-bottom: 12px;
}

#drag-zone h2 {
    font-size: 1.25em;
}

/* Quiz UI */
.question-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: var(--p-radius-lg);
    box-shadow: var(--p-shadow-md);
    padding: clamp(18px, 3vw, 28px);
    max-width: 920px;
    margin: 0 auto;
}

#question-text {
    color: var(--p-text);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.progress-bar {
    background: rgba(15, 23, 42, 0.10);
}

.progress-fill {
    background: linear-gradient(90deg, var(--p-primary) 0%, var(--p-primary-2) 100%);
}

.stats {
    color: var(--p-muted);
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 760px;
    margin: 0 auto;
}

.option-btn {
    background: rgba(15, 23, 42, 0.04);
    border-radius: var(--p-radius-md);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 8px 18px rgba(2, 6, 23, 0.06);
}

.option-btn:hover {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.45);
    transform: translateY(-2px);
}

.option-btn.correct {
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(22, 163, 74, 0.35);
    color: #0b3b1a;
}

.option-btn.incorrect {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #4a0b0b;
}

/* Results + leaderboard */
.result-stat {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.10);
    box-shadow: 0 12px 22px rgba(2, 6, 23, 0.08);
    border-radius: var(--p-radius-lg);
}

.stat-value {
    color: var(--p-primary);
}

.leaderboard-section {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(15, 23, 42, 0.10);
    box-shadow: 0 14px 26px rgba(2, 6, 23, 0.10);
}

.leaderboard-section h2 {
    color: var(--p-text);
    font-weight: 800;
}

.leaderboard-entry {
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 22px rgba(2, 6, 23, 0.06);
}

/* Modals */
.modal {
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(7px);
}

.modal-content {
    border-radius: var(--p-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--p-shadow-lg);
}

.share-code {
    background: rgba(15, 23, 42, 0.05);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.share-code span {
    color: var(--p-primary);
}

/* Quizzes browse */
.quiz-card {
    border-radius: var(--p-radius-lg);
    border: 1px solid rgba(15, 23, 42, 0.10);
    box-shadow: 0 14px 28px rgba(2, 6, 23, 0.10);
}

.quiz-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 55px rgba(99, 102, 241, 0.22);
}

.quiz-card h3 {
    color: var(--p-text);
    font-weight: 800;
}

/* Footer */
.app-footer {
    margin-top: 26px;
    padding-top: 16px;
    border-top: 1px solid rgba(15, 23, 42, 0.10);
    color: rgba(15, 23, 42, 0.70);
    text-align: center;
}

.app-footer a {
    color: rgba(15, 23, 42, 0.90);
    text-decoration: none;
}

.app-footer a:hover {
    color: rgba(15, 23, 42, 1);
}

.credits-name {
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--p-primary) 0%, var(--p-primary-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Accessibility + polish */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 600px) {
    h1 {
        text-align: center;
    }

    .header-nav {
        gap: 12px;
    }

    .options-grid {
        grid-template-columns: 1fr;
        max-width: 520px;
    }
}