:root {
    --bg-gradient: linear-gradient(135deg, #09090b, #18181b);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: rgba(255, 255, 255, 0.05);
    --secondary-hover: rgba(255, 255, 255, 0.08);
    --error: #ef4444;
    --success: #10b981;
}

* { box-sizing: border-box; }
body {
    margin: 0; padding: 0;
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex; justify-content: center; align-items: center;
}

#app-container {
    width: 100%; max-width: 450px;
    height: 95vh; max-height: 850px;
    border-radius: 36px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6), inset 0 2px 0 rgba(255,255,255,0.05);
    position: relative; overflow: hidden;
    display: flex; flex-direction: column;
}

.view {
    display: none; flex-direction: column; height: 100%;
    padding: 2.5rem 2rem;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: none; /* Firefox */
}
.view::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}
.view.active { display: flex; }
.center-view { justify-content: center; }

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

.hero-icon { font-size: 4rem; text-align: center; margin-bottom: 1rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.header-text { margin-bottom: 2rem; text-align: center; }
.header-text h1 { font-size: 3.2rem; margin: 0; font-weight: 800; letter-spacing: -1px; }
.header-text h1 span { 
    background: linear-gradient(135deg, #a855f7, #3b82f6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-text p { color: var(--text-muted); font-size: 1.1rem; }

.input-group { margin-bottom: 1.2rem; display: flex; flex-direction: column; }
.input-group label { margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }

input, select {
    background: rgba(0, 0, 0, 0.4); border: 1px solid var(--glass-border);
    border-radius: 16px; padding: 1.2rem; color: white; font-size: 1rem;
    font-family: inherit; outline: none; transition: all 0.2s;
    appearance: none; /* specific styling for modern selects */
}
input:focus, select:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: rgba(0, 0, 0, 0.6);
}
select.lang-selector {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em;
}

.btn {
    width: 100%; padding: 1.2rem; border-radius: 18px; font-size: 1.05rem; font-weight: 700;
    cursor: pointer; border: none; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; justify-content: center; align-items: center; gap: 10px; text-decoration: none;
}
.btn.primary { background: var(--primary); color: white; box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 4px 15px rgba(0,0,0,0.3); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-3px); box-shadow: 0 10px 25px -10px rgba(139, 92, 246, 0.8), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important;}
.btn.primary.glow { background: linear-gradient(135deg, #a855f7, #6366f1); }
.btn.secondary { background: var(--secondary); color: white; border: 1px solid var(--glass-border); }
.btn.secondary:hover { background: rgba(255, 255, 255, 0.1); transform: translateY(-2px); }
.btn.google-btn { background: white; color: #333; }
.btn.google-btn:hover { background: #f8f8f8; transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.btn.text-btn { background: transparent; width: auto; padding: 0; color: var(--text-muted); font-size: 0.9rem;}
.btn.text-btn:hover { color: white; }

.google-icon { width: 22px; height: 22px; }

.divider { text-align: center; margin: 1.5rem 0; position: relative; }
.divider::before, .divider::after { content: ''; position: absolute; top: 50%; width: 35%; height: 1px; background: var(--glass-border); }
.divider::before { left: 0; } .divider::after { right: 0; }
.divider span { color: var(--text-muted); font-size: 0.85rem; font-weight: 500;}

.error-msg { color: var(--error); font-size: 0.9rem; text-align: center; min-height: 20px; margin-top: 1rem; }
.feedback-msg { text-align: center; font-size: 1rem; font-weight: 600; min-height: 25px; transition: color 0.3s; }

.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.dashboard-header h2, .dashboard-header h3 { margin: 0; font-size: 1.5rem; font-weight: 700;}

/* Dynamic Stats Grid */
.stats-box { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 1.5rem; }
.stat {
    border: 1px solid var(--glass-border); border-radius: 24px; padding: 1.5rem 1rem;
    text-align: center; position: relative; overflow: hidden;
}
.stat-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.8;}
.stat-learning { background: linear-gradient(180deg, rgba(59, 130, 246, 0.1), rgba(0,0,0,0)); border-color: rgba(59, 130, 246, 0.3); }
.stat-mastered { background: linear-gradient(180deg, rgba(16, 185, 129, 0.1), rgba(0,0,0,0)); border-color: rgba(16, 185, 129, 0.3); }
.stat-number { display: block; font-size: 2.2rem; font-weight: 800; color: white; line-height: 1; margin-bottom: 5px;}
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600;}

/* Interactive Hero Cards for Games */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.action-card {
    background: var(--secondary); border: 1px solid var(--glass-border);
    border-radius: 20px; padding: 1.5rem 1rem; cursor: pointer; text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.action-card:hover { transform: translateY(-5px); background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }
.action-icon { font-size: 2.5rem; margin-bottom: 10px; }
.action-card h4 { margin: 0 0 5px 0; font-size: 1.1rem; }
.action-card p { margin: 0; font-size: 0.8rem; color: var(--text-muted); }

/* Flashcards */
.flashcard { perspective: 1500px; height: 380px; margin-bottom: 1rem; cursor: pointer; position: relative; }
.card-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); transform-style: preserve-3d; }
.flashcard.flipped .card-inner { transform: rotateY(180deg); }
.card-front, .card-back {
    position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 32px;
    display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2rem;
    border: 1px solid var(--glass-border);
}
.card-front { background: linear-gradient(145deg, #18181b, #09090b); color: white; box-shadow: 0 20px 40px rgba(0,0,0,0.6); }
.card-back { background: linear-gradient(145deg, #4c1d95, #312e81); color: white; transform: rotateY(180deg); box-shadow: 0 20px 40px rgba(76, 29, 149, 0.4); }
.card-front h2 { font-size: 2.5rem; margin: 0; line-height: 1.2;}
.card-back h2 { font-size: 2.2rem; margin: 0; color: #e0e7ff;}
.flip-hint { opacity:0.5; font-size:0.9rem; margin-top:30px; letter-spacing: 2px; text-transform: uppercase;}
.card-back-note { font-size: 1.1rem; color: #a5b4fc; margin-top: 2rem; line-height: 1.5; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 16px;}

.speaker-btn {
    position: absolute; bottom: 25px; right: 25px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%; width: 55px; height: 55px; font-size: 1.5rem; cursor: pointer;
    display: flex; justify-content: center; align-items: center; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); z-index: 10;
}
.speaker-btn:hover { background: rgba(255,255,255,0.25); transform: scale(1.15); }
.controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.controls .btn { width: auto; padding: 1rem 1.5rem; border-radius: 12px; }

/* Match Grid */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-item {
    background: var(--secondary); border: 2px solid transparent; border-radius: 20px; padding: 1.2rem;
    color: white; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    min-height: 85px; display:flex; align-items:center; justify-content:center; text-align:center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.match-item:hover { background: rgba(255,255,255,0.1); transform: translateY(-2px); }
.match-item.selected { background: rgba(139, 92, 246, 0.2); border-color: var(--primary); transform: scale(0.98); }
.match-item.wrong { background: rgba(239, 68, 68, 0.2); border-color: var(--error); animation: shake 0.4s; }
.match-item.correct { background: rgba(16, 185, 129, 0.2); border-color: var(--success); opacity: 0; pointer-events:none; transform: scale(0.8); }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Quiz Progress Bar */
.quiz-progress-bar { width: 100%; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; margin-bottom: 2rem; overflow: hidden;}
.quiz-progress-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 4px; transition: width 0.4s ease; }

/* Quiz Options */
.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.quiz-option {
    background: var(--secondary); border: 2px solid transparent; border-radius: 20px; padding: 1.2rem 1.5rem;
    color: white; font-size: 1.1rem; cursor: pointer; text-align: left; font-weight: 500;
    transition: all 0.2s; display: flex; align-items: center; justify-content: space-between;
}
.quiz-option:hover { background: rgba(255,255,255,0.1); transform: translateX(5px); }
.quiz-option.correct { background: rgba(16, 185, 129, 0.2); border-color: var(--success); }
.quiz-option.wrong { background: rgba(239, 68, 68, 0.2); border-color: var(--error); }

.finish-container { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; animation: fadeIn 0.5s; }
.finish-container h2 { font-size: 3rem; margin-bottom: 10px; color: var(--primary); }
.finish-container p { font-size: 1.1rem; color: var(--text-muted); }

/* Mobile Optimization */
@media (max-width: 480px) {
    #app-container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}

.profiles-box::-webkit-scrollbar { display: none; }
.profile-card {
    background: var(--secondary); padding: 12px 16px; border-radius: 16px; cursor: pointer; border: 2px solid transparent; min-width: 140px; display: inline-block; white-space: nowrap; text-align: left; transition: all 0.3s ease; box-shadow: 0 4px 6px rgba(0,0,0,0.1); flex-shrink: 0;
}
.profile-card.active { border-color: var(--primary); background: rgba(139, 92, 246, 0.15); }
.profile-card:hover { background: rgba(255,255,255,0.1); transform: translateY(-2px); }
