:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-hover: rgba(51, 65, 85, 0.8);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);
    --highlight-bg: rgba(253, 224, 71, 0.15);
    --highlight-text: #fde047;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    position: relative;
    padding: 1rem 0; /* Reduced padding for mobile */
    word-break: break-word;
}

/* Dynamic background */
.background-animation {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #0f172a 50%);
    z-index: -1;
    animation: rotate 60s linear infinite;
}

.background-animation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* SPA Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}
.view.active {
    display: flex;
    flex-direction: column;
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 0 1rem; /* Reduced padding for mobile */
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Reduced gap for mobile */
    z-index: 1;
}

/* General Layout */
.text-center { text-align: center; }
.text-left { text-align: left; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }
.mt-3 { margin-top: 2rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Typography */
.main-title {
    font-size: 1.75rem; /* Smaller for mobile */
    font-weight: 800;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.05em;
    margin-bottom: 0.5rem;
}
.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem; /* Smaller for mobile */
    margin-bottom: 1.5rem;
}
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; font-weight: 500; color: var(--text-primary); }

/* Glass Card */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
}
.card { padding: 1.5rem 1rem; } /* Mobile-first card padding */

/* Registration / Landing */
.disclaimer {
    background-color: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--error);
    padding: 1rem;
    border-radius: 0 12px 12px 0;
    font-size: 0.85rem; /* Mobile text size */
    color: #fca5a5;
    margin-bottom: 1.5rem;
    text-align: left;
}
.register-form {
    background: rgba(0,0,0,0.2);
    padding: 1.5rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}
.input-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-bottom: 1rem;
}
.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}
.input-group input {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 0.85rem;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255,255,255,0.1);
}

/* Dashboard */
.dashboard-header {
    padding: 1.2rem 1.2rem;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr; /* Stack vertically on mobile */
    gap: 1rem;
}
.interactive-card {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
}
.interactive-card:active {
    transform: scale(0.98);
}
.interactive-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}
.card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

/* Progress Bar */
.progress-container { width: 100%; }
.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}
.progress-bar {
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 999px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.bg-success { background: linear-gradient(90deg, #10b981, #22c55e) !important; }
.bg-warning { background: linear-gradient(90deg, #f59e0b, #fbbf24) !important; }

/* Questions UI */
.question {
    font-size: 1.15rem; /* Smaller for mobile */
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}
.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.option {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 1rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem; /* Smaller text for options */
    line-height: 1.35;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.option-letter {
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    min-width: 20px;
}

/* Study Mode Highlights */
.option.highlighted-correct {
    background-color: var(--highlight-bg);
    border-color: #facc15;
    color: var(--highlight-text);
}
.option.highlighted-correct .option-letter { color: var(--highlight-text); }

/* Exam Mode Interactive */
.interactive-options .option {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.interactive-options .option:active {
    transform: scale(0.98);
}
.interactive-options .option.selected {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-color);
}
.interactive-options.locked .option {
    cursor: default;
    pointer-events: none;
}
.interactive-options.locked .option.correct {
    background: var(--success-bg);
    border-color: var(--success);
}
.interactive-options.locked .option.wrong {
    background: var(--error-bg);
    border-color: var(--error);
    opacity: 0.7;
}

/* Buttons */
.controls { 
    display: flex; 
    justify-content: space-between; 
    gap: 0.75rem; 
    width: 100%;
}
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.85rem 1rem; font-size: 0.9rem; font-weight: 600; font-family: inherit;
    border-radius: 12px; border: none; cursor: pointer;
    transition: all 0.2s ease; outline: none; flex: 1;
    -webkit-tap-highlight-color: transparent;
}
.btn-small { padding: 0.5rem 0.8rem; font-size: 0.8rem; border-radius: 10px; flex: none; }
.btn-block { width: 100%; }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white; box-shadow: 0 4px 10px -2px rgba(59, 130, 246, 0.5);
}
.btn-primary:active:not(:disabled) {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.05); color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-text {
    background: transparent; color: var(--text-secondary); padding: 0.5rem;
}
.btn-text:active { color: var(--text-primary); background: rgba(255,255,255,0.05); }

/* Results Circular Chart */
.score-circle {
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
}
.circular-chart { display: block; margin: 0 auto; max-width: 100%; max-height: 250px; }
.circle-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 3.8; }
.circle { 
    fill: none; stroke-width: 2.8; stroke-linecap: round; 
    transition: stroke-dasharray 1s ease-out;
}
.percentage {
    fill: white; font-family: 'Inter', sans-serif; font-weight: 700;
    font-size: 0.5em; text-anchor: middle;
}
.score-text { font-size: 1rem; color: var(--text-secondary); }

/* Failed list */
.failed-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px; /* Shorter for mobile */
    overflow-y: auto;
    padding-right: 5px;
}
.failed-list::-webkit-scrollbar { width: 4px; }
.failed-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
.failed-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
.failed-item {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 0.85rem;
    border-radius: 10px;
}
.failed-q { font-weight: 500; margin-bottom: 0.5rem; font-size: 0.85rem; line-height: 1.3;}
.failed-ans { color: var(--success); font-size: 0.85rem; display: flex; gap: 0.5rem; align-items: flex-start;}

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

/* Tablet and Desktop Enhancements */
@media (min-width: 600px) {
    body { padding: 2rem 0; }
    .app-container { padding: 0 2rem; gap: 1.5rem; }
    .main-title { font-size: 2.5rem; }
    .subtitle { font-size: 1.1rem; }
    .card { padding: 2.5rem; }
    .dashboard-grid { grid-template-columns: 1fr 1fr; } /* Side by side on larger screens */
    .question { font-size: 1.3rem; }
    .option { padding: 1.2rem 1.5rem; font-size: 1.05rem; }
    .btn { padding: 1rem 2rem; font-size: 1rem; }
    .score-circle { width: 150px; height: 150px; }
    .failed-list { max-height: 400px; }
}
