:root {
    /* Default Theme (Light Blue Glass) */
    --bg-gradient-start: #E0EAFC;
    --bg-gradient-end: #CFDEF3;
    --surface-light: rgba(255, 255, 255, 0.6);
    --surface-border: rgba(255, 255, 255, 0.4);
    --text-main: #2D3748;
    --text-muted: #718096;
    --accent-primary: #667EEA;
    --accent-hover: #5A67D8;
    --accent-secondary: #ED8936;
    --success: #48BB78;
    --error: #F56565;
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    
    --blur-strong: blur(16px);
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
}

[data-theme="neon"] {
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e1b4b;
    --surface-light: rgba(15, 23, 42, 0.6);
    --surface-border: rgba(99, 102, 241, 0.4);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-primary: #ec4899;
    --accent-hover: #db2777;
    --accent-secondary: #06b6d4;
    --shadow-soft: 0 0 20px rgba(236, 72, 153, 0.2);
}

[data-theme="galaxy"] {
    --bg-gradient-start: #2e1065;
    --bg-gradient-end: #000000;
    --surface-light: rgba(46, 16, 101, 0.6);
    --surface-border: rgba(139, 92, 246, 0.4);
    --text-main: #f3e8ff;
    --text-muted: #c4b5fd;
    --accent-primary: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-secondary: #fcd34d;
    --shadow-soft: 0 8px 32px 0 rgba(139, 92, 246, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background 0.5s ease;
}

.app-container {
    width: 100%;
    max-width: 480px; 
    height: 100vh;
    max-height: 850px;
    position: relative;
}

@media (min-width: 481px) {
    .app-container {
        height: 90vh;
        border-radius: 40px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        overflow: hidden;
    }
}

.glass-panel {
    background: var(--surface-light);
    backdrop-filter: var(--blur-strong);
    -webkit-backdrop-filter: var(--blur-strong);
    border: 1px solid var(--surface-border);
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px);
    overflow-y: auto;
}

.view.active-view {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.modal-view {
    z-index: 10;
    transform: translateY(100%);
}
.modal-view.active-view {
    transform: translateY(0);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    margin-top: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-select {
    padding: 4px 8px;
    font-size: 0.85rem;
    max-width: 120px;
    width: auto;
    min-height: 32px;
}

.small-btn {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    font-weight: 800;
}

.lang-btn {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.2s;
    height: 32px;
}
.lang-btn:hover { transform: scale(1.05); background: var(--accent-hover); }

.stats-row { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 24px; }
.stat-badge {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    padding: 6px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.welcome-section { margin-bottom: 20px; }
.welcome-section h2 { font-size: 1.8rem; font-weight: 800; line-height: 1.2; margin-bottom: 8px; }
.welcome-section p { color: var(--text-muted); font-size: 1rem; margin-bottom: 16px; }

.action-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.action-btn {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.action-btn:hover { background: rgba(255,255,255,0.8); transform: translateY(-2px); }

.settings-section { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.settings-label { font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }
.glass-select {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: var(--surface-light);
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}
.glass-select option { background: white; color: black; }

.modules-grid { display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px; }
.module-card {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    text-align: left;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease;
    width: 100%;
    color: var(--text-main);
}
.module-card:hover { transform: translateY(-4px); }
.card-icon {
    font-size: 1.8rem;
    background: var(--accent-primary);
    color: white;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-lg);
}
.card-content h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.card-content p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }

/* Game View */
.game-header { display: flex; align-items: center; gap: 16px; margin-bottom: 40px; margin-top: 10px; }
.btn-icon {
    background: var(--surface-light);
    border: 1px solid var(--surface-border);
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; color: var(--text-main); transition: background 0.2s;
}
.btn-icon:hover { background: rgba(255,255,255,0.8); }

.progress-container { flex-grow: 1; height: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent-primary); transition: width 0.3s ease; }
.streak-text { font-weight: 800; font-size: 1.1rem; color: var(--accent-secondary); }

.equation-area { flex-grow: 1; display: flex; justify-content: center; align-items: center; }
.equation-display { font-size: 5rem; font-weight: 800; letter-spacing: -2px; display: flex; align-items: center; gap: 16px; }
.operator { color: var(--accent-primary); }

.input-area { text-align: center; margin-bottom: 40px; }
.input-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

#answer-input {
    width: 140px;
    height: 80px;
    font-size: 3rem;
    font-weight: 800;
    text-align: center;
    border: 3px solid var(--surface-border);
    border-radius: var(--radius-md);
    background: var(--surface-light);
    color: var(--text-main);
    outline: none;
    transition: all 0.3s;
}
#answer-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 15px rgba(102, 126, 234, 0.3); }
#answer-input.input-correct { border-color: var(--success); background: rgba(72, 187, 120, 0.1); }
#answer-input.input-error { border-color: var(--error); background: rgba(245, 101, 101, 0.1); }

.submit-answer-btn {
    background: var(--accent-primary);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-md);
    font-size: 2rem;
    width: 80px;
    height: 80px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.submit-answer-btn:active {
    transform: scale(0.92);
}
.submit-answer-btn:hover {
    background: var(--accent-hover);
}

.hidden-submit { display: none; }
.feedback-msg { height: 30px; margin-top: 16px; font-weight: 600; font-size: 1rem; opacity: 0; transition: opacity 0.2s; text-align: center; }
.feedback-msg.show { opacity: 1; }
.feedback-msg.success { color: var(--success); }
.feedback-msg.error { color: var(--error); }

.visual-aid { margin-top: 10px; display: grid; gap: 8px; justify-content: center; padding: 16px; border-radius: var(--radius-lg); }
.dot-row { display: flex; gap: 8px; }
.dot { width: 14px; height: 14px; background: var(--accent-secondary); border-radius: 50%; opacity: 0; animation: popIn 0.3s forwards; }

/* Modals General */
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-weight: 800; font-size: 1.5rem; }

/* Shop */
.shop-balance { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-weight: 600; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.theme-card {
    background: var(--surface-light);
    border: 2px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 16px; text-align: center; cursor: pointer;
    transition: all 0.2s;
}
.theme-card.active-theme { border-color: var(--accent-primary); background: rgba(255,255,255,0.2); }
.theme-card.locked { opacity: 0.7; }
.theme-icon { font-size: 2rem; margin-bottom: 8px; }
.theme-name { font-weight: 800; margin-bottom: 4px; font-size: 1rem; }
.theme-price { font-size: 0.85rem; font-weight: 600; color: var(--accent-secondary); }

/* Heatmap */
.heatmap-legend { display: flex; justify-content: center; gap: 16px; margin-bottom: 20px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 600; }
.box { width: 12px; height: 12px; border-radius: 3px; }
.box-mastered { background: var(--success); }
.box-learning { background: var(--accent-secondary); }
.box-struggle { background: var(--error); }
.box-empty { background: rgba(0,0,0,0.1); }

.heatmap-container {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 4px;
    background: var(--surface-light);
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
}
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    display: flex; justify-content: center; align-items: center;
    font-size: 0.6rem; font-weight: 800; color: rgba(0,0,0,0.4);
}
.cell-mastered { background: var(--success); color: white; }
.cell-learning { background: var(--accent-secondary); color: white; }
.cell-struggle { background: var(--error); color: white; }
.cell-empty { background: rgba(0,0,0,0.1); }

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}
@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
