/* =====================================
   LULU MATHE - STYLES
   ===================================== */

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

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f0f2ff;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(79, 70, 229, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

/* ===================================== */
/* SCREENS */
/* ===================================== */
.screen { display: none; padding: 1rem; max-width: 600px; margin: 0 auto; padding-bottom: 2rem; }
.screen.active { display: block; animation: fadeIn 0.3s ease-out; }

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

/* ===================================== */
/* HEADER */
/* ===================================== */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    padding: 1.2rem 1.5rem 1.5rem;
    border-radius: 0 0 24px 24px;
    margin: -1rem -1rem 1rem;
    text-align: center;
}
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.back-link { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.user-name { color: rgba(255,255,255,0.8); font-size: 0.9rem; }
.header h1 { font-size: 1.8rem; font-weight: 900; }
.subtitle { color: rgba(255,255,255,0.7); font-size: 0.9rem; margin-top: 0.2rem; }

/* ===================================== */
/* STATS BANNER */
/* ===================================== */
.stats-banner {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.stat { text-align: center; }
.stat-value { display: block; font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.7rem; color: var(--text-light); text-transform: uppercase; font-weight: 600; }

/* ===================================== */
/* QUICK ACTIONS */
/* ===================================== */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.5rem; }
.action-btn {
    padding: 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
}
.action-btn:active { transform: scale(0.96); }
.action-btn.primary {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
}

/* ===================================== */
/* SECTION TITLE */
/* ===================================== */
.section-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text);
}

/* ===================================== */
/* KAPITEL GRID */
/* ===================================== */
.kapitel-grid { display: grid; gap: 0.75rem; margin-bottom: 1.5rem; }
.kapitel-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid var(--primary-light);
    position: relative;
    overflow: hidden;
}
.kapitel-card:active { transform: scale(0.98); }
.kapitel-card.locked { opacity: 0.5; pointer-events: none; border-left-color: #cbd5e1; }
.kapitel-card.completed { border-left-color: var(--success); }
.kapitel-card .kapitel-icon { font-size: 2rem; }
.kapitel-card .kapitel-content { flex: 1; }
.kapitel-card .kapitel-name { font-weight: 700; font-size: 1rem; }
.kapitel-card .kapitel-sub { font-size: 0.8rem; color: var(--text-light); margin-top: 0.2rem; }
.kapitel-card .kapitel-stars { font-size: 0.85rem; margin-top: 0.3rem; }
.kapitel-card .kapitel-progress-mini {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 0.4rem;
    overflow: hidden;
}
.kapitel-card .kapitel-progress-mini .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7c3aed);
    border-radius: 2px;
    transition: width 0.5s;
}

/* ===================================== */
/* QUICK LINKS */
/* ===================================== */
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.link-btn {
    padding: 0.8rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
}
.link-btn:active { transform: scale(0.96); background: #f8fafc; }

/* ===================================== */
/* SCREEN HEADER */
/* ===================================== */
.screen-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e2e8f0;
}
.screen-header h2 { font-size: 1.2rem; font-weight: 800; }
.back-btn {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    padding: 0.3rem 0;
}

/* ===================================== */
/* KAPITEL DETAIL */
/* ===================================== */
.kapitel-info { margin-bottom: 1.5rem; }
.kapitel-header-img {
    width: 100%;
    height: 150px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-light), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    margin-bottom: 1rem;
    overflow: hidden;
}
.kapitel-header-img img { width: 100%; height: 100%; object-fit: cover; }
.kapitel-progress { display: flex; align-items: center; gap: 0.75rem; }
.progress-bar-bg {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.5s ease;
}
.progress-text { font-size: 0.85rem; font-weight: 700; color: var(--primary); min-width: 35px; }

.themen-list { display: grid; gap: 0.6rem; }
.thema-card {
    background: var(--card);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.thema-card:active { transform: scale(0.98); }
.thema-card.locked { opacity: 0.4; pointer-events: none; }
.thema-nummer {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.thema-card.completed .thema-nummer { background: var(--success); }
.thema-card.locked .thema-nummer { background: #cbd5e1; }
.thema-content { flex: 1; }
.thema-name { font-weight: 600; font-size: 0.95rem; }
.thema-stars { font-size: 0.8rem; margin-top: 0.2rem; }
.thema-arrow { color: #cbd5e1; font-size: 1.2rem; }

/* ===================================== */
/* REGEL CARD */
/* ===================================== */
.regel-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.regel-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.regel-content {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
    border-left: 4px solid var(--primary);
}
.regel-content code {
    background: #eef2ff;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'SF Mono', monospace;
    font-weight: 600;
    color: var(--primary-dark);
}
.regel-beispiel {
    background: #ecfdf5;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--success);
}
.regel-beispiel .label { font-size: 0.75rem; font-weight: 700; color: var(--success); text-transform: uppercase; margin-bottom: 0.3rem; }
.regel-merksatz {
    background: #fffbeb;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--warning);
    font-weight: 600;
}
.regel-bild {
    border-radius: 12px;
    overflow: hidden;
    margin-top: 1rem;
}
.regel-bild img { width: 100%; border-radius: 12px; }
.regel-bild svg { width: 100%; }

.start-ueben-btn {
    width: 100%;
    padding: 1.2rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.3);
}
.start-ueben-btn:active { transform: scale(0.97); }

/* ===================================== */
/* ÜBUNG */
/* ===================================== */
.uebung-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.uebung-header .progress-bar-bg { flex: 1; }
.uebung-counter { font-weight: 700; color: var(--text-light); font-size: 0.85rem; min-width: 40px; text-align: right; }

.aufgabe-container {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.aufgabe-emoji { font-size: 3rem; margin-bottom: 1rem; }
.aufgabe-text { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; line-height: 1.5; }
.aufgabe-visual { margin-bottom: 1.5rem; width: 100%; }
.aufgabe-visual svg { max-width: 100%; }

/* Answer types */
.answer-input-wrap {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 300px;
}
.answer-input {
    flex: 1;
    padding: 1rem;
    border: 3px solid #e2e8f0;
    border-radius: 14px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    background: #f8fafc;
    color: var(--text);
    transition: border-color 0.2s;
}
.answer-input:focus { border-color: var(--primary); outline: none; }
.answer-unit { font-size: 1.2rem; font-weight: 600; color: var(--text-light); align-self: center; }

.submit-btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.2s;
}
.submit-btn:active { transform: scale(0.96); }
.submit-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

/* Multiple Choice */
.mc-options { display: grid; gap: 0.6rem; width: 100%; }
.mc-option {
    padding: 1rem 1.2rem;
    border: 3px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.mc-option:active { transform: scale(0.97); }
.mc-option.selected { border-color: var(--primary); background: #eef2ff; }
.mc-option.correct { border-color: var(--success); background: #ecfdf5; }
.mc-option.wrong { border-color: var(--danger); background: #fef2f2; }

/* True/False */
.tf-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; width: 100%; }
.tf-btn {
    padding: 1.5rem;
    border: 3px solid #e2e8f0;
    border-radius: var(--radius);
    background: #f8fafc;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.tf-btn:active { transform: scale(0.95); }
.tf-btn.correct { border-color: var(--success); background: #ecfdf5; }
.tf-btn.wrong { border-color: var(--danger); background: #fef2f2; }

/* Sort items */
.sort-items { display: grid; gap: 0.5rem; width: 100%; }
.sort-item {
    padding: 0.8rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: var(--card);
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    transition: all 0.15s;
}
.sort-item:active { cursor: grabbing; background: #eef2ff; }
.sort-handle { color: #cbd5e1; }

.uebung-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--card);
    border-radius: 14px;
}
.uebung-score { font-weight: 700; color: var(--primary); }
.uebung-streak-indicator {
    font-weight: 700;
    color: var(--warning);
    animation: pulse 0.5s ease;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }

/* ===================================== */
/* SPEED ROUND */
/* ===================================== */
.speed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.speed-timer {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--danger);
    background: #fef2f2;
    padding: 0.5rem 1rem;
    border-radius: 14px;
}
.speed-score { font-size: 1.2rem; font-weight: 700; color: var(--success); }
.speed-aufgabe {
    text-align: center;
    background: var(--card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 800;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.speed-input-area { display: flex; gap: 0.75rem; }
.speed-input {
    flex: 1;
    padding: 1.2rem;
    border: 3px solid #e2e8f0;
    border-radius: var(--radius);
    font-size: 1.8rem;
    font-weight: 800;
    text-align: center;
    background: var(--card);
}
.speed-input:focus { border-color: var(--primary); outline: none; }
.speed-submit {
    width: 60px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ===================================== */
/* ERGEBNIS */
/* ===================================== */
.ergebnis-content {
    text-align: center;
    padding: 2rem 1rem;
}
.ergebnis-emoji { font-size: 4rem; margin-bottom: 1rem; animation: bounceIn 0.5s; }
@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.ergebnis-content h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.ergebnis-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.ergebnis-stat {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.ergebnis-value { display: block; font-size: 1.5rem; font-weight: 800; }
.ergebnis-stat:nth-child(1) .ergebnis-value { color: var(--success); }
.ergebnis-stat:nth-child(2) .ergebnis-value { color: var(--danger); }
.ergebnis-stat:nth-child(3) .ergebnis-value { color: var(--primary); }
.ergebnis-label { font-size: 0.75rem; color: var(--text-light); text-transform: uppercase; font-weight: 600; }
.ergebnis-sterne { font-size: 2rem; margin-bottom: 1.5rem; }
.ergebnis-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ===================================== */
/* BUTTONS */
/* ===================================== */
.btn-primary {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary:active { transform: scale(0.96); }
.btn-secondary {
    padding: 1rem 1.5rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

/* ===================================== */
/* REGELSAMMLUNG */
/* ===================================== */
.regel-search {
    margin-bottom: 1rem;
}
.regel-search input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 0.95rem;
    background: var(--card);
}
.regel-search input:focus { border-color: var(--primary); outline: none; }
.regeln-list { display: grid; gap: 0.6rem; }
.regel-list-item {
    background: var(--card);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.regel-list-item:active { transform: scale(0.98); }
.regel-list-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #eef2ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.regel-list-text { flex: 1; }
.regel-list-title { font-weight: 600; font-size: 0.9rem; }
.regel-list-kapitel { font-size: 0.75rem; color: var(--text-light); }

/* ===================================== */
/* STATISTIK */
/* ===================================== */
.statistik-content { display: grid; gap: 1rem; }
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}
.stat-card h3 { font-size: 0.9rem; color: var(--text-light); margin-bottom: 0.5rem; }
.stat-card .big-number { font-size: 2rem; font-weight: 800; color: var(--primary); }

/* ===================================== */
/* MODAL / OVERLAY */
/* ===================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    animation: fadeIn 0.2s;
}
.modal-content {
    background: var(--card);
    border-radius: 24px;
    padding: 2rem;
    text-align: center;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.feedback-emoji { font-size: 3rem; margin-bottom: 0.5rem; }
.feedback-erklaerung {
    background: #fff7ed;
    border-radius: 12px;
    padding: 0.8rem;
    margin: 1rem 0;
    font-size: 0.85rem;
    color: #92400e;
    text-align: left;
    border-left: 3px solid var(--warning);
}
.overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.3s;
}
.level-up-content { text-align: center; color: white; }
.level-up-emoji { font-size: 4rem; margin-bottom: 1rem; }
.level-up-content h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.level-up-number { font-size: 4rem; font-weight: 900; margin-bottom: 1.5rem; }
