/* ===== CSS RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1f2940;
    --bg-glass: rgba(26, 34, 53, 0.85);
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.3);
    --accent-soft: rgba(245, 158, 11, 0.1);
    
    --correct: #10b981;
    --correct-bg: rgba(16, 185, 129, 0.12);
    --correct-border: rgba(16, 185, 129, 0.4);
    --correct-glow: rgba(16, 185, 129, 0.2);
    
    --wrong: #ef4444;
    --wrong-bg: rgba(239, 68, 68, 0.12);
    --wrong-border: rgba(239, 68, 68, 0.4);
    --wrong-glow: rgba(239, 68, 68, 0.2);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

html {
    font-size: 16px;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===== START SCREEN ===== */
.start-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px calc(32px + var(--safe-bottom));
    padding-top: calc(60px + var(--safe-top));
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.start-icon {
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-soft), rgba(245, 158, 11, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 24px;
    color: var(--accent);
    margin-bottom: 24px;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.1); }
    50% { box-shadow: 0 0 40px rgba(245, 158, 11, 0.2); }
}

.start-container h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    text-align: center;
    line-height: 1.5;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-active);
    background: var(--bg-card-hover);
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Action Buttons */
.start-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-large {
    padding: 16px 24px;
    font-size: 16px;
    min-height: 56px;
}

.btn-small {
    padding: 10px 16px;
    font-size: 13px;
    min-height: 40px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #d97706);
    color: #000;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 30px rgba(245, 158, 11, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-active);
}

.btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-tertiary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
}

.btn-ghost:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    color: var(--wrong) !important;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-icon:active {
    transform: scale(0.9);
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

/* ===== FOOTER ===== */
.start-footer {
    display: flex;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ===== QUIZ SCREEN ===== */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    padding-top: calc(8px + var(--safe-top));
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.quiz-progress-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.quiz-mode-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 100px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.quiz-score {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-score {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

/* Progress Bar */
.progress-bar-container {
    height: 3px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #fbbf24);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    border-radius: 0 2px 2px 0;
}

/* Question Container */
.question-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.question-card {
    width: 100%;
    max-width: 600px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-number {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 12px;
}

.question-text {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
}

.option-btn:hover:not(.disabled) {
    border-color: var(--border-active);
    background: var(--bg-card-hover);
}

.option-btn:active:not(.disabled) {
    transform: scale(0.98);
}

.option-label {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    font-weight: 700;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    transition: all 0.2s ease;
}

.option-text {
    flex: 1;
    padding-top: 3px;
}

/* Option states */
.option-btn.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.option-btn.selected .option-label {
    background: var(--accent);
    color: #000;
}

.option-btn.correct {
    border-color: var(--correct-border);
    background: var(--correct-bg);
    box-shadow: 0 0 20px var(--correct-glow);
    animation: correctPulse 0.5s ease;
}

.option-btn.correct .option-label {
    background: var(--correct);
    color: #fff;
}

.option-btn.wrong {
    border-color: var(--wrong-border);
    background: var(--wrong-bg);
    box-shadow: 0 0 20px var(--wrong-glow);
    animation: wrongShake 0.5s ease;
}

.option-btn.wrong .option-label {
    background: var(--wrong);
    color: #fff;
}

.option-btn.disabled {
    cursor: default;
    opacity: 0.5;
}

.option-btn.disabled.correct,
.option-btn.disabled.wrong {
    opacity: 1;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.01); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Question Actions (after answering) */
.question-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.question-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* Archive button */
.btn-archive {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #818cf8;
}

.btn-archive:hover {
    background: rgba(99, 102, 241, 0.2);
}

.btn-archive.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

/* Answer status labels */
.answer-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    width: 100%;
}

.answer-status.incorrect {
    background: var(--wrong-bg);
    color: var(--wrong);
    border: 1px solid var(--wrong-border);
}

/* Stat card color accents */
.stat-card.stat-correct .stat-number { color: var(--correct); }
.stat-card.stat-incorrect .stat-number { color: var(--wrong); }
.stat-card.stat-archive .stat-number { color: #818cf8; }

/* Quiz Navigation */
.quiz-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}

.btn-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn-nav:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

.btn-nav:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-skip {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn-skip:hover {
    color: var(--text-secondary);
    border-color: var(--border-active);
}

.btn-skip:active {
    transform: scale(0.95);
}

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    animation: scaleIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-icon {
    color: var(--wrong);
    margin-bottom: 16px;
}

.modal h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions .btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: var(--radius-md);
}

.modal-actions .btn-danger {
    background: var(--wrong);
    color: #fff !important;
    border: none;
}

.modal-actions .btn-danger:hover {
    background: #dc2626;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 200;
    white-space: nowrap;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .start-container {
        padding-top: 80px;
        justify-content: center;
    }
    
    .question-text {
        font-size: 19px;
    }
    
    .option-btn {
        font-size: 16px;
        padding: 18px;
    }
}
