/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #374151;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

.nav {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.nav-link:hover {
    opacity: 0.8;
}

/* Main content */
.main {
    padding: 2rem 0;
}

/* Progress section */
.progress-section {
    margin-bottom: 3rem;
}

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

.stat-card {
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: #2563eb;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #6b7280;
    font-weight: 500;
}

/* Sections */
.practice-section,
.games-section,
.achievements-section {
    background: rgba(255, 255, 255, 0.9);
    margin: 2rem auto;
    border-radius: 1rem;
    padding: 3rem 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.practice-section h2,
.games-section h2,
.achievements-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.practice-section p,
.games-section p,
.achievements-section p {
    text-align: center;
    color: #6b7280;
    margin-bottom: 2rem;
}

/* Practice grid */
.practice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.practice-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.practice-card:hover {
    border-color: #2563eb;
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

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

.practice-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.practice-card p {
    color: #6b7280;
    margin-bottom: 1rem;
}

/* Progress bar */
.progress-bar {
    background: #e5e7eb;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    background: linear-gradient(135deg, #10b981, #059669);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* Games grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.game-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
}

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

.game-stats {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
}

/* Memory game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

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

/* Enhanced Practice Modal */
.practice-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.practice-modal.active {
    display: flex;
}

/* Comparison and Conversion Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

/* Tool Cards */
.tool-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.tool-card:hover {
    border-color: #2563eb;
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

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

/* Daily Challenge */
.challenge-card {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    color: white;
    border-radius: 1rem;
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
    overflow: hidden;
}

.challenge-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.challenge-content {
    position: relative;
    z-index: 1;
}

.streak-indicator {
    display: inline-flex;
    align-items: center;
    background: rgba(220, 38, 38, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    color: #fecaca;
    font-weight: 600;
}

.bonus-badge {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #92400e;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Input Groups */
.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input-group label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    display: block;
}

.input-group input {
    padding: 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #2563eb;
}

.fraction-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fraction-input input {
    width: 80px;
    text-align: center;
}

/* Tool Results */
.tool-result {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-top: 1rem;
    display: none;
}

.tool-result h4 {
    color: #1f2937;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.tool-result .steps {
    background: white;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.tool-result .steps ol {
    margin-left: 1.5rem;
}

.tool-result .steps li {
    margin-bottom: 0.5rem;
    color: #4b5563;
}

/* Select Dropdown */
select {
    padding: 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

select:focus {
    outline: none;
    border-color: #2563eb;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h3 {
    font-size: 1.5rem;
    color: #1f2937;
}

/* Problem display */
.problem-display {
    text-align: center;
    margin: 2rem 0;
}

.visual-fractions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.visual-fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.visual-label {
    font-weight: bold;
    color: #2563eb;
}

.operation-symbol,
.equals-symbol {
    font-size: 2rem;
    font-weight: bold;
    color: #374151;
}

.question-mark {
    font-size: 3rem;
    color: #ef4444;
    font-weight: bold;
}

.fraction-problem {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.numerator,
.denominator {
    font-weight: bold;
}

.fraction-line {
    width: 100%;
    height: 2px;
    background: #374151;
    margin: 2px 0;
}

.operation,
.equals,
.question {
    font-weight: bold;
    color: #374151;
}

/* Answer buttons */
.answer-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.answer-btn {
    padding: 1rem 1.5rem;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1.125rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.answer-btn:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

/* Explanation */
.explanation {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 2rem 0;
    display: none;
}

.explanation h4 {
    color: #0369a1;
    margin-bottom: 0.5rem;
}

/* Modal actions */
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Race problem */
.race-problem {
    text-align: center;
    margin: 2rem 0;
}

/* XP notifications */
.xp-notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.xp-gain {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    animation: xpFloat 2s ease forwards;
}

@keyframes xpFloat {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    80% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Answer animations */
.correct-answer {
    animation: correctBounce 0.6s ease;
}

.wrong-answer {
    animation: wrongShake 0.6s ease;
}

@keyframes correctBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

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

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

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Enhanced Achievement Badges */
.achievement-badge {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.achievement-badge.earned {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    transform: scale(1);
    animation: none;
}

.achievement-badge.locked {
    background: #e5e7eb;
    color: #9ca3af;
    opacity: 0.6;
}

.achievement-badge:hover.earned {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 20px rgba(251, 191, 36, 0.3);
}

/* Enhanced Memory Cards */
.memory-card {
    aspect-ratio: 1;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    color: transparent;
    position: relative;
    overflow: hidden;
}

.memory-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.memory-card:hover::before {
    transform: translateX(100%);
}

.memory-card.flipped {
    background: #dbeafe;
    color: #1e40af;
    transform: rotateY(180deg);
}

.memory-card.matched {
    background: #dcfce7;
    border-color: #10b981;
    color: #166534;
    cursor: default;
    animation: pulse 1s ease;
}

.memory-card:hover:not(.matched):not(.flipped) {
    transform: scale(1.05);
    border-color: #3b82f6;
    background: #f0f9ff;
}

/* Enhanced Progress Bars */
.progress-bar {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #2563eb;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .nav {
        display: none;
    }
    
    .practice-grid,
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .fraction-problem {
        font-size: 1.5rem;
    }
    
    .visual-fractions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .answer-buttons {
        grid-template-columns: 1fr;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .tool-card {
        padding: 1.5rem;
    }
    
    .challenge-card {
        padding: 1.5rem;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .fraction-input {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stat-number {
        font-size: 2rem;
    }
    
    .practice-section,
    .games-section,
    .achievements-section {
        padding: 2rem 1rem;
    }
    
    .modal-content {
        padding: 1rem;
    }
}