:root {
    --primary: #2196F3;
    --success: #4CAF50;
    --warning: #FFC107;
    --danger: #F44336;
    --purple: #9C27B0;
    --white: #FFFFFF;
    --light-gray: #F5F5F5;
    --dark-gray: #333333;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
    min-height: 100vh;
    color: var(--dark-gray);
    padding-bottom: 80px;
}

/* Header Styles */
.app-header {
    background: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: bold;
}

.user-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--dark-gray);
}

/* Main Content */
.app-main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

/* Home Section */
.welcome-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.welcome-card h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.daily-challenge {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #E0E0E0;
    border-radius: 4px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

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

.game-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    border-color: var(--primary);
}

.game-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.game-card h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.play-btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
}

.play-btn:hover {
    background: #1976D2;
    transform: scale(1.05);
}

/* Game Section */
.game-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 500px;
}

.game-header {
    background: var(--primary);
    color: var(--white);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-btn {
    background: rgba(255,255,255,0.2);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.back-btn:hover {
    background: rgba(255,255,255,0.3);
}

.game-score {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.game-area {
    padding: 2rem;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-content {
    display: none;
    width: 100%;
    text-align: center;
}

.game-content.active {
    display: block;
}

/* Memory Game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto 2rem;
}

.memory-cell {
    aspect-ratio: 1;
    background: var(--light-gray);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    border: 3px solid transparent;
}

.memory-cell.active {
    background: var(--primary);
    color: var(--white);
}

.memory-cell.correct {
    background: var(--success);
    border-color: var(--success);
}

.memory-cell.wrong {
    background: var(--danger);
    border-color: var(--danger);
}

/* Logic Game */
.logic-question {
    max-width: 500px;
    margin: 0 auto;
}

.sequence {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin: 2rem 0;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.logic-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.logic-option {
    padding: 1rem;
    background: var(--light-gray);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.2rem;
    font-weight: bold;
}

.logic-option:hover {
    border-color: var(--primary);
    background: #E3F2FD;
}

.logic-option.correct {
    background: var(--success);
    color: var(--white);
}

.logic-option.wrong {
    background: var(--danger);
    color: var(--white);
}

/* Attention Game */
.target-display {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.target-item {
    width: 60px;
    height: 60px;
    margin: 0 auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--white);
}

.attention-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.attention-item {
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.attention-item:hover {
    transform: scale(1.1);
}

/* Speed Game */
.math-problem {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary);
    margin: 2rem 0;
}

.speed-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-width: 300px;
    margin: 0 auto 2rem;
}

.speed-option {
    padding: 1rem;
    background: var(--light-gray);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.5rem;
    font-weight: bold;
}

.speed-option:hover {
    border-color: var(--primary);
    background: #E3F2FD;
}

.speed-option.correct {
    background: var(--success);
    color: var(--white);
}

.speed-option.wrong {
    background: var(--danger);
    color: var(--white);
}

.speed-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 1.1rem;
    font-weight: bold;
}

/* Game Controls */
.game-controls {
    margin-top: 2rem;
}

.start-btn {
    background: var(--success);
    color: var(--white);
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.start-btn:hover {
    background: #388E3C;
    transform: scale(1.05);
}

/* Game Result */
.game-result {
    display: none;
    padding: 2rem;
    text-align: center;
}

.game-result.active {
    display: block;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-item {
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.play-again-btn, .back-games-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.play-again-btn {
    background: var(--success);
    color: var(--white);
}

.back-games-btn {
    background: var(--light-gray);
    color: var(--dark-gray);
}

/* Reports Section */
.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.reports-header h2 {
    color: var(--primary);
}

#reportPeriod {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background: var(--white);
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.stat-info h3 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.chart-card h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    text-align: center;
}

.chart-card canvas {
    max-width: 100%;
    height: auto;
}

.achievements-section {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.achievements-section h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

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

.achievement-item {
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--border-radius);
    text-align: center;
    transition: var(--transition);
}

.achievement-item.unlocked {
    background: linear-gradient(135deg, var(--warning), #FFA000);
    color: var(--white);
}

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

/* Profile Section */
.profile-header {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    margin-bottom: 2rem;
}

.profile-avatar {
    margin-bottom: 1rem;
}

.avatar-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: var(--white);
}

.change-avatar-btn {
    background: var(--light-gray);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.profile-info h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.xp-bar {
    width: 100%;
    height: 20px;
    background: #E0E0E0;
    border-radius: 10px;
    margin-top: 1rem;
    position: relative;
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    border-radius: 10px;
    transition: width 0.3s ease;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--dark-gray);
}

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

.profile-stat {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.profile-stat h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.profile-stat span {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark-gray);
}

.profile-settings {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.profile-settings h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.setting-item {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.setting-item label {
    font-weight: bold;
    min-width: 150px;
}

.setting-item input, .setting-item select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    flex: 1;
    min-width: 200px;
}

.setting-item button {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.profile-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.reset-btn, .export-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.reset-btn {
    background: var(--danger);
    color: var(--white);
}

.export-btn {
    background: var(--success);
    color: var(--white);
}

/* FAQ styles moved to faq.html */

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    flex-wrap: wrap;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #999;
    transition: var(--transition);
    padding: 0.25rem;
    border-radius: 8px;
    min-width: 60px;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(33, 150, 243, 0.1);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Footer */
footer {
    background: var(--white);
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    color: #666;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    border-top: 1px solid #E0E0E0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer-content p {
    margin: 0;
    color: #666;
    text-decoration: none;
    cursor: default;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem;
    }
    
    .app-header h1 {
        font-size: 1.2rem;
    }
    
    .user-stats {
        font-size: 0.8rem;
        gap: 0.5rem;
    }
    
    .game-grid {
        grid-template-columns: 1fr;
    }
    
    .game-header {
        padding: 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .game-score {
        font-size: 0.8rem;
        gap: 0.5rem;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-item label {
        min-width: auto;
        margin-bottom: 0.5rem;
    }
    
    .profile-actions {
        flex-direction: column;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .bottom-nav {
        padding: 0.5rem 0;
    }
    
    .nav-item {
        min-width: 50px;
        font-size: 0.7rem;
    }
    
    .nav-item i {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .app-main {
        padding: 0.5rem;
    }
    
    .memory-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 300px;
    }
    
    .attention-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 300px;
    }
    
    .logic-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .speed-options {
        grid-template-columns: 1fr;
    }
    
    .math-problem {
        font-size: 2rem;
    }
    
    .sequence {
        font-size: 1.5rem;
    }
}

/* Animation Classes */
.pulse {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

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

.bounce {
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.text-center {
    text-align: center;
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.bg-primary {
    background-color: var(--primary);
}

.bg-success {
    background-color: var(--success);
}

.bg-danger {
    background-color: var(--danger);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
