/* =====================
   CSS Variables & Theme
   ===================== */
:root {
    --bg-primary: #101d21;
    --bg-secondary: #14252a;
    --bg-card: #192e32;
    --bg-hover: #233b40;
    --text-primary: #f3f4f6;
    --text-secondary: #b5c8cb;
    --text-muted: #99b1b6;
    --accent-purple: #8bbfc4;
    --accent-cyan: #83c3d8;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-pink: #ec4899;
    --accent-red: #ef4444;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.light-theme {
    --bg-primary: #f4f4ee;
    --bg-secondary: #eeeee7;
    --bg-card: #ffffff;
    --bg-hover: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #586b70;
    --accent-purple: #226374;
    --accent-cyan: #246b86;
    --accent-green: #24735c;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

/* =====================
   Base Styles
   ===================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* =====================
   App Container
   ===================== */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =====================
   Header
   ===================== */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

#levelDisplay {
    font-weight: 600;
    color: var(--accent-purple);
}

.xp-container {
    width: 100px;
    height: 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
}

.xp-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    border-radius: 4px;
    transition: width 0.3s ease;
}

#xpDisplay {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#streakDisplay {
    font-weight: 600;
    color: var(--accent-yellow);
}

.theme-toggle {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* =====================
   Navigation Tabs
   ===================== */
.tabs {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
}

/* =====================
   Main Content
   ===================== */
#mainContent {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* =====================
   Game Modes Grid
   ===================== */
.game-modes h2 {
    font-size: 1.75rem;
    margin-bottom: 24px;
    text-align: center;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.mode-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
    opacity: 0;
    transition: opacity 0.3s;
}

.mode-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-purple);
    box-shadow: var(--shadow);
}

.mode-card:hover::before {
    opacity: 1;
}

.mode-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.mode-card h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.mode-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.mode-stats {
    font-size: 0.8rem;
    color: var(--accent-green);
    font-weight: 500;
}

/* =====================
   Question Container
   ===================== */
.question-container {
    max-width: 800px;
    margin: 0 auto;
}

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

.question-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.score {
    font-weight: 600;
    color: var(--accent-green);
}

.timer {
    font-weight: 600;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
}

.timer.timer-warning {
    color: var(--accent-red);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.back-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-purple);
}

/* =====================
   Question Body
   ===================== */
.question-body {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 28px;
}

.problem-statement {
    margin-bottom: 24px;
}

.problem-statement h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.problem-text {
    font-size: 1.15rem;
    color: var(--text-primary);
    line-height: 1.7;
}

.context {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.riddle-text {
    font-size: 1.25rem;
    font-style: italic;
    color: var(--text-primary);
    text-align: center;
    padding: 20px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    line-height: 1.8;
}

.hint {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 16px;
    color: var(--accent-yellow);
    font-size: 0.9rem;
}

.hint-icon {
    margin-right: 8px;
}

/* =====================
   Code Block
   ===================== */
.code-block {
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 16px 0;
}

.code-block code {
    color: #e6edf3;
    white-space: pre;
}

.blank {
    background: var(--accent-purple);
    color: white;
    padding: 2px 12px;
    border-radius: 4px;
    font-weight: 600;
}

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

.option-btn {
    background: var(--bg-hover);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.1);
    transform: translateX(4px);
}

.option-btn:disabled {
    cursor: not-allowed;
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.option-btn.incorrect {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.option-btn code {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
}

.code-option {
    font-family: var(--font-mono);
}

/* =====================
   Feedback
   ===================== */
.feedback {
    margin-top: 20px;
}

.feedback-correct {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--accent-green);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    color: var(--accent-green);
    font-weight: 500;
}

.feedback-wrong {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    color: var(--accent-red);
    font-weight: 500;
}

.next-btn {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

/* =====================
   Explanation Panel
   ===================== */
.explanation-panel {
    display: none;
    margin-top: 24px;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.explanation-panel.show {
    display: block;
}

.explanation-content {
    padding: 24px;
}

.explanation-content h4 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--accent-cyan);
}

.exp-summary {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.7;
}

.key-insight {
    background: rgba(34, 211, 238, 0.1);
    border-left: 3px solid var(--accent-cyan);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.insight-icon {
    margin-right: 8px;
}

.why-correct {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--accent-green);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.why-not {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--accent-red);
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.exp-steps, .exp-how {
    margin: 20px 0;
}

.exp-steps ol, .exp-how ol {
    padding-left: 24px;
    color: var(--text-secondary);
}

.exp-steps li, .exp-how li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.exp-walkthrough {
    margin: 20px 0;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.walkthrough-input {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.walkthrough-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 12px 0;
}

.walkthrough-table th,
.walkthrough-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.walkthrough-table th {
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.walkthrough-table code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.walkthrough-result {
    margin-top: 12px;
    color: var(--accent-green);
    font-weight: 500;
}

.exp-complexity {
    margin: 16px 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.complexity-badge {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: var(--accent-purple);
    font-family: var(--font-mono);
}

.exp-analysis, .exp-operations {
    margin: 16px 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.exp-code {
    margin: 20px 0;
}

.exp-code pre {
    background: #0d1117;
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
}

.exp-code code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #e6edf3;
    white-space: pre;
}

.bug-info {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 16px 0;
}

.bug-info p {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.bug-info p:last-child {
    margin-bottom: 0;
}

.exp-mistakes, .exp-errors, .exp-gotchas {
    margin: 16px 0;
}

.exp-mistakes ul, .exp-errors ul, .exp-gotchas ul {
    padding-left: 24px;
    color: var(--text-secondary);
}

.exp-mistakes li, .exp-errors li, .exp-gotchas li {
    margin-bottom: 6px;
}

.exp-related {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =====================
   Mode Complete
   ===================== */
.mode-complete {
    text-align: center;
    padding: 60px 20px;
}

.mode-complete h2 {
    font-size: 2rem;
    margin-bottom: 32px;
}

.complete-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
}

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

.stat-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-purple);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.complete-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border: none;
    color: white;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--accent-purple);
}

/* =====================
   Learn Tab
   ===================== */
.learn-container {
    max-width: 900px;
    margin: 0 auto;
}

.learn-container h2 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.learn-intro {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.pattern-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.pattern-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.pattern-card:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
}

.pattern-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pattern-icon {
    font-size: 1.5rem;
}

.pattern-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.pattern-preview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
    line-height: 1.5;
}

.pattern-complexity {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--accent-cyan);
}

/* =====================
   Pattern Detail
   ===================== */
.pattern-detail {
    max-width: 800px;
    margin: 0 auto;
}

.pattern-detail-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin: 24px 0 32px;
}

.pattern-icon-large {
    font-size: 3rem;
}

.pattern-detail-header h2 {
    margin-bottom: 8px;
}

.pattern-detail-header p {
    color: var(--text-secondary);
}

.pattern-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.pattern-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--accent-cyan);
}

.pattern-section ul {
    padding-left: 20px;
    color: var(--text-secondary);
}

.pattern-section li {
    margin-bottom: 8px;
}

.invariant, .key-insight-text {
    color: var(--text-secondary);
    line-height: 1.7;
}

.complexity-badges {
    display: flex;
    gap: 12px;
}

.problem-list {
    color: var(--text-secondary);
}

/* =====================
   Quick Ref Tab
   ===================== */
.ref-container {
    max-width: 900px;
    margin: 0 auto;
}

.ref-container h2 {
    font-size: 1.75rem;
    margin-bottom: 24px;
}

.ref-section {
    margin-bottom: 32px;
}

.ref-section h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--accent-cyan);
}

.ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.ref-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
}

.ref-card h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.ref-card pre {
    background: #0d1117;
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    margin: 0;
}

.ref-card code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #e6edf3;
    line-height: 1.6;
}

.ref-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.ref-table th,
.ref-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.ref-table th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-secondary);
}

.ref-table td {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.ref-note {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pattern-quick-ref {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.pattern-quick-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pattern-quick-icon {
    font-size: 1.2rem;
}

.pattern-quick-card strong {
    flex: 1;
    font-size: 0.85rem;
}

.pattern-quick-trigger {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =====================
   Progress Tab
   ===================== */
.progress-container {
    max-width: 900px;
    margin: 0 auto;
}

.progress-container h2 {
    font-size: 1.75rem;
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-purple);
    display: block;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.achievements-section {
    margin-bottom: 32px;
}

.achievements-section h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.achievement-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.achievement-card.earned {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.05);
}

.achievement-card.locked {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 2rem;
}

.achievement-info strong {
    display: block;
    margin-bottom: 4px;
}

.achievement-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.reset-section {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* =====================
   Notifications
   ===================== */
.level-up-notification,
.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--accent-purple);
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: var(--shadow);
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.level-up-notification.show,
.achievement-notification.show {
    transform: translateX(0);
}

.level-up-content,
.achievement-popup {
    display: flex;
    align-items: center;
    gap: 12px;
}

.level-up-icon {
    font-size: 1.5rem;
}

.achievement-popup-icon {
    font-size: 2rem;
}

.achievement-popup strong {
    display: block;
    color: var(--accent-green);
    font-size: 0.85rem;
}

/* =====================
   Confetti Canvas
   ===================== */
#confetti {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-stats {
        width: 100%;
        justify-content: space-between;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab-btn {
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    #mainContent {
        padding: 20px 16px;
    }

    .mode-grid {
        grid-template-columns: 1fr;
    }

    .question-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .complete-stats {
        flex-direction: column;
        gap: 20px;
    }

    .walkthrough-table {
        font-size: 0.75rem;
    }

    .walkthrough-table th,
    .walkthrough-table td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.2rem;
    }

    .xp-container {
        width: 60px;
    }

    .mode-card {
        padding: 16px;
    }

    .mode-icon {
        font-size: 2rem;
    }

    .question-body {
        padding: 16px;
    }

    .option-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Compact editorial skin. No fonts, images, or runtime dependencies to fetch. */
header { position: relative; background: var(--bg-primary); }
.header-content, .tabs, #mainContent { max-width: 1060px; }
.header-content { padding-top: 26px; padding-bottom: 22px; }
.header-content h1 { font-size: 1.3rem; letter-spacing: -.04em; background: none; color: var(--text-primary); -webkit-text-fill-color: currentColor; }
.brand-caption { display: block; margin-top: 4px; color: var(--text-secondary); font-size: .75rem; font-weight: 400; letter-spacing: 0; }
.header-stats { gap: 12px; font-size: .75rem; }
.xp-container { width: 64px; height: 4px; }
.tabs { padding: 0 24px; gap: 6px; }
.tab-btn { padding: 12px 16px; font-size: .83rem; border-radius: 6px 6px 0 0; }
.tab-btn.active { color: var(--accent-cyan); background: var(--bg-card); border-bottom-color: var(--accent-cyan); }
.section-label { color: var(--accent-cyan); letter-spacing: .16em; font: 600 .7rem var(--font-mono); margin-bottom: 12px; }
.game-modes h2 { text-align: left; font-size: clamp(1.7rem,4vw,2.6rem); letter-spacing: -.045em; line-height: 1.15; margin-bottom: 12px; }
.practice-intro { max-width: 540px; color: var(--text-secondary); font-size: .94rem; margin-bottom: 30px; }
.mode-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.mode-card { padding: 22px; border-top: 2px solid var(--accent-cyan); min-width: 0; box-shadow: 0 2px 3px #00000006; transition: border-color .15s, transform .15s, background .15s; }
.mode-card:nth-child(3n + 2) { border-top-color: var(--accent-green); }
.mode-card:nth-child(3n) { border-top-color: #9d9675; }
.mode-card::before { display: none; }
.mode-card:hover { transform: translateY(-2px); box-shadow: 0 5px 14px #00000014; }
.mode-icon { font: 500 1.15rem var(--font-mono); color: var(--accent-cyan); margin-bottom: 22px; }
.mode-card h3 { font-size: 1rem; letter-spacing: -.02em; }
.mode-card p { font-size: .84rem; line-height: 1.65; min-height: 44px; }
.mode-stats { font: .67rem var(--font-mono); letter-spacing: .03em; border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 18px; color: var(--text-muted); }
.pattern-cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
.pattern-card { padding: 20px; transition: border-color .15s; }
.pattern-card:hover { transform: none; }
.pattern-preview { color: var(--text-secondary); }
.question-body, .pattern-section { box-shadow: none; border: 1px solid var(--border-color); }
.question-header { flex-wrap: wrap; gap: 12px; }
.question-header h2 { font-size: 1.1rem; }
.code-block { font-size: .83rem; line-height: 1.7; max-width: 100%; }
.option-btn { font: inherit; font-size: .9rem; line-height: 1.55; min-height: 46px; overflow-wrap: anywhere; transition: background .15s,border-color .15s; }
.option-btn:hover:not(:disabled) { transform: none; }
.option-btn.correct { color: var(--text-primary); border-color: var(--accent-green); background: color-mix(in srgb, var(--accent-green) 18%,var(--bg-card)); }
.option-btn.incorrect { color: var(--text-primary); background: color-mix(in srgb, var(--accent-red) 16%,var(--bg-card)); }
.next-btn, .btn-primary { background: var(--accent-cyan); color: #101d21; box-shadow: none; font-weight: 650; }
.light-theme .next-btn, .light-theme .btn-primary { color: #fff; }
.next-btn:hover, .btn-primary:hover { transform: none; filter: brightness(1.08); }
.achievement-card.locked { opacity: 1; background: var(--bg-primary); }
.achievement-card.locked .achievement-icon { opacity: .5; }
.exp-extra { margin: 14px 0; color: var(--text-secondary); }
.exp-extra strong, .exp-extra dt { color: var(--text-primary); }
.exp-extra ul { padding-left: 20px; }
button, [role="button"] { touch-action: manipulation; }
:is(button,[role="button"]):focus-visible { outline: 3px solid var(--accent-cyan); outline-offset: 4px; }
.ref-table, .walkthrough-table { display: block; max-width: 100%; overflow-x: auto; }
@media(max-width: 760px) {
 .mode-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .header-content { gap: 18px; padding: 20px; }
 .tabs { padding: 0 16px; justify-content: space-between; }
 .tab-btn { padding: 12px 8px; font-size: .78rem; }
 #mainContent { padding: 24px 18px; }
 .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width: 440px) {
 .mode-grid, .pattern-cards, .ref-grid { grid-template-columns: minmax(0,1fr); }
 .mode-card { padding: 18px; }
 .mode-icon { margin-bottom: 12px; }
 .mode-card p { min-height: 0; }
 .mode-stats { margin-top: 12px; }
 .pattern-detail-header { align-items: flex-start; gap: 12px; }
 .pattern-detail-header h2 { font-size: 1.45rem; }
 .pattern-icon-large { font-size: 1.8rem; }
 .pattern-section { padding: 16px; }
}
@media(prefers-reduced-motion: reduce) {
 *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
 .mode-card:hover { transform: none; }
 #confetti { display: none; }
}
