:root {
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --bg-color: #f1f5f9;
    --app-bg: #ffffff;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-light: #3b82f6;
    --bg-color: #020617;
    --app-bg: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --success: #34d399;
    --border: #334155;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    margin: 0; padding: 0;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; overscroll-behavior-y: none;
    transition: background-color 0.3s ease;
}

#app-wrapper {
    width: 100%; max-width: 430px; height: 100dvh;
    background-color: var(--app-bg); color: var(--text-color);
    position: relative; display: flex; flex-direction: column;
    overflow-x: hidden; overflow-y: auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

.noselect { -webkit-user-select: none; user-select: none; }

header {
    padding: calc(env(safe-area-inset-top) + 1rem) 1.5rem 1rem;
    display: flex; justify-content: space-between; align-items: center;
    background: var(--app-bg); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
}

h1 { margin: 0; font-size: 1.4rem; color: var(--error); font-weight: 800; letter-spacing: -0.5px;}

.header-icons { display: flex; gap: 0.5rem; align-items: center; }
.streak-badge { display: flex; align-items: center; gap: 4px; color: var(--warning); font-weight: 800; font-size: 1.1rem; margin-right: 8px;}
.icon-btn { background: var(--app-bg); border: 1px solid var(--border); color: var(--text-color); width: 40px; height: 40px; border-radius: 12px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.2s; }
.icon-btn:active { background: var(--border); transform: scale(0.95); }

main { flex: 1; display: flex; flex-direction: column; padding: 1.5rem; position: relative; }
.view-section { display: none; height: 100%; flex-direction: column; }
.view-section.active { display: flex; animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* === DASHBOARD === */
.intro-text { text-align: center; margin-bottom: 2rem; margin-top: 1rem;}
.intro-text h2 { font-size: 2rem; color: var(--text-color); margin: 0 0 0.2rem 0; font-weight: 800; }
.intro-text p { font-size: 1rem; margin: 0; color: var(--text-muted); font-weight: 600; }

.start-grid { display: flex; flex-direction: column; gap: 1rem; }
.mode-tile { background-color: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; padding: 1.2rem; display: flex; align-items: center; gap: 1.2rem; cursor: pointer; box-shadow: var(--shadow-card); transition: transform 0.2s; position: relative; }
.mode-tile:active:not(.locked) { transform: scale(0.97); }

.mode-tile.locked { opacity: 0.6; pointer-events: none; }
.lock-icon { position: absolute; right: 1.5rem; color: var(--text-muted); opacity: 0.5;}

.mode-icon { color: white; width: 64px; height: 64px; border-radius: 16px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; font-weight: 800; font-size: 1.5rem; }
.mode-info { flex: 1; }
.mode-info h3 { color: var(--text-color); margin: 0 0 0.5rem 0; font-size: 1.2rem; font-weight: 700; }

.progress-bar-small { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 0.5rem;}
.progress-fill { height: 100%; background: var(--border); width: 0%; transition: width 0.3s; }
.mode-tile:not(.locked) .progress-fill { background: var(--primary); }

.unlock-btn { pointer-events: auto; background: var(--bg-color); border: 1px solid var(--border); color: var(--text-muted); width: 32px; height: 32px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.2s; z-index: 5; }
.unlock-btn:active { background: var(--success); color: white; border-color: var(--success); }
.hidden-btn { display: none; }
.mode-tile:not(.locked) .hidden-btn { display: flex; }

/* === DECK MENU === */
.training-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.deck-status-box { background-color: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; padding: 2rem 1.5rem; margin-bottom: 2rem; box-shadow: var(--shadow-card); text-align: center; }
.deck-actions-grid { display: flex; flex-direction: column; gap: 0.8rem; }
.review-row { display: flex; gap: 0.5rem; width: 100%; }

/* === OUTLINE BUTTONS (Edel & Seriös) === */
.btn-outline {
    background: var(--app-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.btn-outline:active { transform: scale(0.97); }

.btn-gray { color: var(--text-color); border-color: var(--border); background-color: var(--app-bg); }
.btn-gray:active { background-color: var(--bg-color); }

.btn-green { color: var(--success); border-color: var(--success); }
.btn-green:active { background-color: rgba(16, 185, 129, 0.1); }

.btn-red { color: var(--error); border-color: var(--error); }
.btn-red:active { background-color: rgba(239, 68, 68, 0.1); }

.btn-orange { color: var(--warning); border-color: var(--warning); }
.btn-orange:active { background-color: rgba(245, 158, 11, 0.1); }

/* === TRAINER VIEW === */
.flashcard-wrapper { flex: 1; display: flex; flex-direction: column; position: relative; margin-bottom: 1.5rem;}
.flashcard { flex: 1; width: 100%; border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-card); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; background-color: var(--card-bg); }
#card-ruby { font-size: 4.5rem; font-weight: 800; color: var(--text-color); text-align: center; display: block; margin-bottom: 2rem; }
#card-furigana { font-size: 1.5rem; color: var(--text-muted); font-weight: 600; display: block; text-align: center; margin-bottom: 0.5rem; }
.card-translation { font-size: 1.6rem; font-weight: 600; color: var(--error); text-align: center; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.trainer-controls { width: 100%; min-height: 60px;}

/* === MODALS === */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; background-color: rgba(0,0,0,0.5); z-index: 9999; align-items: flex-end; justify-content: center; backdrop-filter: blur(2px); }
.modal-overlay.active { display: flex; animation: fadeInModal 0.2s forwards; }
@keyframes fadeInModal { from{opacity:0} to{opacity:1} }
@keyframes slideUpModal { from{transform:translateY(100%)} to{transform:translateY(0)} }
.modal-content { background: var(--app-bg); padding: 1.5rem; border-radius: 24px 24px 0 0; width: 100%; max-width: 430px; display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0,0,0,0.1); animation: slideUpModal 0.3s ease forwards; max-height: 90vh;}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h2 { margin: 0; font-size: 1.3rem; font-weight: 800; color: var(--text-color);}
.close-btn { background: transparent; border: 1px solid var(--border); width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-color); cursor: pointer; transition: all 0.2s; }
.close-btn:active { transform: scale(0.9); background: var(--bg-color);}

.settings-input, .settings-select { width: 100%; padding: 1.2rem 1rem; font-size: 1rem; font-family: 'Poppins', sans-serif; font-weight: 600; border: 2px solid var(--border); border-radius: 14px; background: var(--bg-color); color: var(--text-color); outline: none; margin-bottom: 0.5rem; -webkit-appearance: none; }
.settings-input:focus, .settings-select:focus { border-color: var(--primary); }

/* Wortliste List Items */
.wordlist-item { padding: 1rem 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; }
.wordlist-item:last-child { border-bottom: none; }
.wl-jp { font-size: 1.2rem; font-weight: 700; color: var(--text-color); margin-bottom: 4px;}
.wl-de { font-size: 0.95rem; color: var(--text-muted); }

.goal-reached-anim { display: inline-block; animation: goalBounce 0.8s ease; color: var(--success); }
@keyframes goalBounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.4); font-weight: 800; } }