/* ============================================
   TestHub - Professional Quiz App Styles
   Mobile-first responsive design
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #0f1029;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-glass: rgba(15, 16, 41, 0.85);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    --accent-python: #7c3aed;
    --accent-python-light: #a78bfa;
    --accent-python-dim: rgba(124, 58, 237, 0.15);
    --accent-db: #10b981;
    --accent-db-light: #34d399;
    --accent-db-dim: rgba(16, 185, 129, 0.15);

    --correct: #22c55e;
    --correct-bg: rgba(34, 197, 94, 0.12);
    --correct-border: rgba(34, 197, 94, 0.5);
    --wrong: #ef4444;
    --wrong-bg: rgba(239, 68, 68, 0.12);
    --wrong-border: rgba(239, 68, 68, 0.5);

    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: -webkit-fill-available;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* --- Background Orbs --- */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.3), transparent 70%);
    top: -100px;
    left: -80px;
    animation: orbFloat1 20s ease-in-out infinite;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.25), transparent 70%);
    bottom: -80px;
    right: -60px;
    animation: orbFloat2 25s ease-in-out infinite;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.2), transparent 70%);
    top: 40%;
    right: 20%;
    animation: orbFloat3 18s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(40px, 60px) scale(1.1); }
    66% { transform: translate(-30px, 30px) scale(0.9); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-50px, -40px) scale(1.15); }
    66% { transform: translate(30px, -60px) scale(0.95); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 40px) scale(1.1); }
}

/* --- App & Screens --- */
#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

.screen {
    display: none;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.screen.active {
    display: flex;
    flex-direction: column;
    animation: screenFadeIn 0.4s ease;
}

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

/* --- Loading Screen --- */
#loading-screen {
    align-items: center;
    justify-content: center;
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.loader-ring {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-python);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   HOME SCREEN
   ============================================ */
.home-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.home-header {
    text-align: center;
    padding: 40px 0 36px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 12px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-python), #3b82f6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 22px;
    color: white;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.logo-text {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.home-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 400;
}

/* --- Subject Cards --- */
.subject-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.subject-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition);
    touch-action: manipulation;
}

.subject-card:active {
    transform: scale(0.97);
}

.card-glow {
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
    top: -40px;
    left: -40px;
    transition: opacity var(--transition);
}

.python-glow { background: var(--accent-python); }
.db-glow { background: var(--accent-db); }

.subject-card:active .card-glow { opacity: 0.3; }

.card-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.python-card .card-icon-wrap {
    background: var(--accent-python-dim);
}

.db-card .card-icon-wrap {
    background: var(--accent-db-dim);
}

.card-icon {
    font-size: 28px;
    line-height: 1;
}

.card-body {
    flex: 1;
    min-width: 0;
}

.card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.card-top h2 {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.test-badge {
    background: var(--accent-python-dim);
    color: var(--accent-python-light);
}

.theory-badge {
    background: var(--accent-db-dim);
    color: var(--accent-db-light);
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.card-meta {
    display: flex;
    gap: 16px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
}

.meta-icon {
    font-size: 13px;
}

.card-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.subject-card:active .card-arrow {
    transform: translateX(3px);
}

.home-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 20px 0;
    margin-top: auto;
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
}

.btn-icon:active {
    transform: scale(0.9);
    background: var(--bg-card-hover);
}

.timer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    min-width: 100px;
    justify-content: center;
}

.timer.urgent {
    border-color: var(--wrong-border);
    color: var(--wrong);
    animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.15); }
}

.timer-icon-svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.timer.urgent .timer-icon-svg { color: var(--wrong); }

.db-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.counter {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-variant-numeric: tabular-nums;
}

.counter span:first-child {
    color: var(--text-primary);
    font-weight: 700;
}

/* --- Progress Bar --- */
.progress-track {
    height: 3px;
    background: var(--border);
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 0 3px 3px 0;
    transition: width 0.4s ease;
    position: relative;
}

.python-fill {
    background: linear-gradient(90deg, var(--accent-python), var(--accent-python-light));
}

.db-fill {
    background: linear-gradient(90deg, var(--accent-db), var(--accent-db-light));
}

/* ============================================
   PYTHON QUIZ
   ============================================ */
.quiz-body {
    flex: 1;
    padding: 20px 16px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    perspective: 1200px;
    position: relative;
    overflow: hidden;
}

.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    transform-origin: center center;
    will-change: transform, opacity;
}

/* 3D Slide out to left */
.question-card.slide-out-left,
.options-list.slide-out-left {
    animation: slideOutLeft3D 0.28s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slideOutLeft3D {
    0% {
        transform: translateX(0) scale(1) rotateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-50px) scale(0.92) rotateY(-8deg);
        opacity: 0;
    }
}

/* 3D Slide in from right with spring */
.question-card.slide-in-right {
    animation: slideInRight3D 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.options-list.slide-in-right {
    animation: slideInRight3D 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInRight3D {
    0% {
        transform: translateX(60px) scale(0.92) rotateY(5deg);
        opacity: 0;
    }
    100% {
        transform: translateX(0) scale(1) rotateY(0);
        opacity: 1;
    }
}

/* Staggered option entrance */
.option-btn.option-stagger {
    animation: optionPopIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes optionPopIn {
    0% {
        transform: translateY(18px) scale(0.92);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Legacy fallback */
.question-card.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

.question-card.fade-in {
    animation: fadeSlideIn 0.35s ease;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.q-label {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-python-light);
    margin-bottom: 10px;
}

#database-screen .q-label {
    color: var(--accent-db-light);
}

.q-text {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Code Block */
.code-block-wrap {
    margin-top: 14px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #1a1b2e;
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: none;
}

.code-block-wrap.visible {
    display: block;
}

.code-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.code-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.code-dot.red { background: #ff5f57; }
.code-dot.yellow { background: #febc2e; }
.code-dot.green { background: #28c840; }

.code-lang {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
    font-weight: 500;
}

.code-block {
    padding: 14px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.code-block::-webkit-scrollbar {
    height: 4px;
}

.code-block::-webkit-scrollbar-track {
    background: transparent;
}

.code-block::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
    position: relative;
    transform-origin: center center;
    will-change: transform, opacity;
}

.options-list.fade-out {
    opacity: 0;
    transform: translateX(-20px);
}

.options-list.fade-in {
    animation: fadeSlideIn 0.35s ease;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}

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

.option-key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

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

/* Option States */
.option-btn.selected-correct {
    background: var(--correct-bg);
    border-color: var(--correct-border);
    animation: correctPulseGlow 0.6s ease;
}

@keyframes correctPulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.option-btn.selected-correct .option-key {
    background: var(--correct);
    color: white;
}

.option-btn.selected-wrong {
    background: var(--wrong-bg);
    border-color: var(--wrong-border);
    animation: shakeX 0.4s ease;
}

.option-btn.selected-wrong .option-key {
    background: var(--wrong);
    color: white;
}

.option-btn.reveal-correct {
    background: var(--correct-bg);
    border-color: var(--correct-border);
}

.option-btn.reveal-correct .option-key {
    background: var(--correct);
    color: white;
}

.option-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

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

/* Skip Button */
.btn-skip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1.5px dashed var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    margin-top: auto;
}

.btn-skip:active {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--text-muted);
    color: var(--text-secondary);
    transform: scale(0.98);
}

.btn-skip.hidden {
    display: none;
}

/* Auto-advance bar */
.auto-advance-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    z-index: 20;
    opacity: 0;
    transition: opacity var(--transition-fast);
    padding-bottom: var(--safe-bottom);
}

.auto-advance-bar.visible {
    opacity: 1;
}

.auto-advance-fill {
    height: 100%;
    width: 0;
    border-radius: 0 2px 2px 0;
    transition: none;
}

.auto-advance-fill.correct-fill {
    background: linear-gradient(90deg, var(--correct), #4ade80);
}

.auto-advance-fill.wrong-fill {
    background: linear-gradient(90deg, var(--wrong), #f87171);
}

.auto-advance-fill.animating {
    transition: width linear;
}

/* ============================================
   CREATIVE EFFECTS (Python Quiz)
   ============================================ */

/* Correct flash overlay */
.quiz-body.correct-flash::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(34, 197, 94, 0.14), transparent 65%);
    pointer-events: none;
    z-index: 50;
    animation: flashOverlay 0.8s ease-out forwards;
}

/* Wrong flash overlay */
.quiz-body.wrong-flash::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(239, 68, 68, 0.12), transparent 65%);
    pointer-events: none;
    z-index: 50;
    animation: flashOverlay 0.8s ease-out forwards;
}

@keyframes flashOverlay {
    0% { opacity: 0; transform: scale(0.7); }
    25% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.15); }
}

/* Floating result indicator */
.floating-indicator {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 900;
    pointer-events: none;
    z-index: 40;
    animation: floatUpFade 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fi-icon {
    font-size: 32px;
    line-height: 1;
}

.fi-text {
    font-size: 24px;
    line-height: 1;
}

.fi-correct {
    color: var(--correct);
    text-shadow: 0 0 24px rgba(34, 197, 94, 0.6), 0 2px 8px rgba(0,0,0,0.3);
}

.fi-wrong {
    color: var(--wrong);
    text-shadow: 0 0 24px rgba(239, 68, 68, 0.6), 0 2px 8px rgba(0,0,0,0.3);
}

.fi-skip {
    color: var(--text-muted);
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

@keyframes floatUpFade {
    0% {
        opacity: 0;
        transform: translate(-50%, -30%) scale(0.4);
    }
    25% {
        opacity: 1;
        transform: translate(-50%, -60%) scale(1.15);
    }
    60% {
        opacity: 0.9;
        transform: translate(-50%, -100%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -160%) scale(0.7);
    }
}

/* Counter bounce animation */
.num-bounce {
    display: inline-block;
    animation: numBounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes numBounce {
    0% { transform: scale(1); }
    40% { transform: scale(1.5); color: var(--accent-python-light); }
    100% { transform: scale(1); }
}

/* Enhanced progress bar glow */
.python-fill {
    position: relative;
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.5), 0 0 4px rgba(124, 58, 237, 0.3);
}

/* ============================================
   DATABASE SCREEN
   ============================================ */
.db-body {
    align-items: center;
}

.db-timer-wrap {
    position: relative;
    width: 110px;
    height: 110px;
    margin: 10px 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-slow);
}

.db-timer-wrap.hidden-timer {
    opacity: 0;
    transform: scale(0.5);
    height: 0;
    margin: 0;
    overflow: hidden;
}

.timer-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 5;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--accent-db);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke var(--transition);
}

.timer-ring-progress.urgent-ring {
    stroke: var(--wrong);
}

.timer-ring-number {
    font-size: 40px;
    font-weight: 800;
    color: var(--text-primary);
    z-index: 1;
    font-variant-numeric: tabular-nums;
    transition: all var(--transition);
}

.timer-ring-number.pop {
    animation: numberPop 0.3s ease;
}

@keyframes numberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.db-q-card {
    width: 100%;
    text-align: center;
}

.db-q-card .q-text {
    font-size: 17px;
    line-height: 1.7;
}

/* Answer Card */
.answer-card {
    width: 100%;
    background: var(--accent-db-dim);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 16px;
    opacity: 0;
    transform: translateY(15px);
    transition: all var(--transition-slow);
    max-height: 0;
    overflow: hidden;
    padding: 0 20px;
}

.answer-card.visible {
    opacity: 1;
    transform: translateY(0);
    max-height: 1000px;
    padding: 20px;
}

.answer-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-db-light);
    margin-bottom: 12px;
}

.answer-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.answer-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.keyword-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-full);
    color: var(--accent-db-light);
}

/* Next Button */
.btn-next {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 280px;
    padding: 16px 24px;
    margin-top: 20px;
    background: linear-gradient(135deg, var(--accent-db), #0d9488);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.btn-next.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.btn-next:active {
    transform: scale(0.96) translateY(0);
}

/* ============================================
   RESULTS SCREEN
   ============================================ */
#results-screen {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.results-container {
    padding: 30px 20px 40px;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.results-header {
    text-align: center;
    margin-bottom: 28px;
}

.results-emoji {
    font-size: 56px;
    display: block;
    margin-bottom: 12px;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.results-title {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 6px;
}

.results-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Score Ring */
.score-ring-wrap {
    position: relative;
    width: 170px;
    height: 170px;
    margin-bottom: 28px;
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.score-ring-fill {
    fill: none;
    stroke: var(--accent-python);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 490.09;
    stroke-dashoffset: 490.09;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-ring-fill.db-ring {
    stroke: var(--accent-db);
}

.score-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-percent {
    font-size: 38px;
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1;
}

.score-fraction {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 4px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}

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

.stat-correct { border-color: rgba(34, 197, 94, 0.2); }
.stat-wrong { border-color: rgba(239, 68, 68, 0.2); }
.stat-skipped { border-color: rgba(234, 179, 8, 0.2); }

.stat-val {
    font-size: 26px;
    font-weight: 800;
}

.stat-correct .stat-val { color: var(--correct); }
.stat-wrong .stat-val { color: var(--wrong); }
.stat-skipped .stat-val { color: #eab308; }

.stat-lbl {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Time Display */
.time-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.time-display svg {
    color: var(--text-muted);
}

/* Results Actions */
.results-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 15px 20px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    border: none;
}

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

.btn-review-action {
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    color: var(--text-primary);
}

.btn-retry-action {
    background: linear-gradient(135deg, var(--accent-python), #6366f1);
    color: white;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

.btn-retry-action.db-retry {
    background: linear-gradient(135deg, var(--accent-db), #0d9488);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.btn-home-action {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
}

/* Review Section */
.review-section {
    width: 100%;
    margin-top: 24px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all var(--transition-slow);
}

.review-section.visible {
    max-height: 10000px;
    opacity: 1;
}

.review-heading {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.review-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-item {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    align-items: flex-start;
}

.review-status {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    font-weight: 700;
}

.review-status.r-correct {
    background: var(--correct-bg);
    border: 1px solid var(--correct-border);
    color: var(--correct);
}

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

.review-status.r-skipped {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #eab308;
}

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

.review-q {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.review-answers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
}

.review-tag {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.review-tag.your-answer {
    background: var(--wrong-bg);
    color: var(--wrong);
}

.review-tag.your-answer.is-correct {
    background: var(--correct-bg);
    color: var(--correct);
}

.review-tag.correct-answer {
    background: var(--correct-bg);
    color: var(--correct);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 28px 24px;
    padding-bottom: calc(28px + var(--safe-bottom));
    z-index: 101;
    text-align: center;
    transform: translateY(100%);
    transition: transform var(--transition);
}

.modal.visible {
    transform: translateY(0);
}

.modal-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

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

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

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

.modal-btn {
    flex: 1;
    padding: 14px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    touch-action: manipulation;
    transition: all var(--transition-fast);
}

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

.modal-btn-cancel {
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    color: var(--text-primary);
}

.modal-btn-confirm {
    background: var(--wrong);
    color: white;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 480px) {
    .home-container {
        padding: 32px 24px;
    }
    
    .home-header {
        padding: 50px 0 44px;
    }
    
    .logo-text {
        font-size: 36px;
    }
    
    .subject-card {
        padding: 24px;
    }
    
    .quiz-body {
        padding: 24px 20px;
    }
    
    .q-text {
        font-size: 17px;
    }
}

@media (min-width: 768px) {
    .home-container {
        padding: 40px 32px;
        justify-content: center;
    }
    
    .home-header {
        padding: 20px 0 44px;
    }
    
    .subject-cards {
        flex-direction: row;
    }
    
    .subject-card {
        flex-direction: column;
        text-align: center;
        padding: 28px;
    }
    
    .card-top {
        justify-content: center;
        flex-direction: column;
    }
    
    .card-desc {
        text-align: center;
    }
    
    .card-meta {
        justify-content: center;
    }
    
    .card-arrow {
        display: none;
    }
    
    .quiz-body {
        padding: 28px 24px;
    }
    
    .option-btn {
        padding: 16px 20px;
    }
}

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

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

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

/* Selection */
::selection {
    background: rgba(124, 58, 237, 0.3);
    color: white;
}
