/* MathQuest - Duolingo-Style Colourful CSS */

:root {
    --purple: #A78BFA;
    --purple-dark: #7C3AED;
    --green: #34D399;
    --green-dark: #059669;
    --yellow: #FBBF24;
    --orange: #F97316;
    --pink: #F472B6;
    --blue: #60A5FA;
    --red: #F87171;
    --bg-light: #F5F3FF;
    --text-dark: #1E1B4B;
    --text-light: #6B7280;
    --white: #FFFFFF;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --radius: 24px;
}

/* ===== GENERAL ===== */
body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== WELCOME / SPLASH ===== */
.welcome-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-card {
    background: white;
    border-radius: var(--radius);
    padding: 48px 40px;
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 480px;
    width: 90%;
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.welcome-logo {
    font-size: 64px;
    margin-bottom: 8px;
}

.welcome-title {
    font-size: 42px;
    font-weight: 900;
    color: var(--purple-dark);
    margin-bottom: 4px;
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--text-light);
    margin-bottom: 32px;
}

.btn {
    display: inline-block;
    padding: 16px 32px;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 800;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(0); }

.btn-purple { background: var(--purple); color: white; }
.btn-green { background: var(--green); color: white; }
.btn-orange { background: var(--orange); color: white; }
.btn-yellow { background: var(--yellow); color: var(--text-dark); }
.btn-blue { background: var(--blue); color: white; }
.btn-pink { background: var(--pink); color: white; }
.btn-white { background: white; color: var(--purple-dark); }

.btn-lg { padding: 20px 40px; font-size: 22px; border-radius: 60px; }
.btn-sm { padding: 10px 20px; font-size: 14px; border-radius: 40px; }

.btn-group { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-top: 24px; }

/* ===== FORMS ===== */
.form-box {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
    max-width: 440px;
    margin: 60px auto;
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.form-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 8px;
    text-align: center;
}

.form-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 32px;
    font-size: 15px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 15px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 14px 18px;
    border: 3px solid #E5E7EB;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 600;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--purple);
}

.error-msg {
    background: #FEE2E2;
    color: #DC2626;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
}

.info-msg {
    background: #DBEAFE;
    color: #1D4ED8;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
}

/* ===== NAV ===== */
.top-bar {
    background: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 16px rgba(0,0,0,0.1);
    border-radius: 0 0 24px 24px;
}

.top-bar-logo {
    font-size: 28px;
    font-weight: 900;
    color: var(--purple-dark);
    text-decoration: none;
}

.top-bar-logo span { font-size: 32px; }

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    color: var(--text-dark);
}

.top-bar-user .avatar {
    width: 44px;
    height: 44px;
    background: var(--purple);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

/* ===== PARENT DASHBOARD ===== */
.parent-dashboard {
    padding: 32px 0;
}

.dashboard-header {
    text-align: center;
    color: white;
    margin-bottom: 32px;
}

.dashboard-header h1 {
    font-size: 36px;
    font-weight: 900;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.dashboard-header p { font-size: 18px; opacity: 0.9; }

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

.stat-card {
    background: white;
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-emoji { font-size: 48px; margin-bottom: 8px; }
.stat-card .stat-num {
    font-size: 32px;
    font-weight: 900;
    color: var(--purple-dark);
}
.stat-card .stat-label {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 600;
}

.children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.child-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.child-card-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.child-card-header .avatar {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.child-card-header h3 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-dark);
}

.child-card-header .badge {
    background: var(--green);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.child-card-body { padding: 0 24px 24px; }

.progress-section { margin-bottom: 20px; }

.progress-label {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.progress-bar-bg {
    background: #E5E7EB;
    border-radius: 50px;
    height: 16px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
    border-radius: 50px;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 11px;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-history {
    background: #F9FAFB;
    border-radius: 16px;
    padding: 16px;
    margin-top: 16px;
}

.quiz-history h4 {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.quiz-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #E5E7EB;
    font-size: 14px;
}

.quiz-row:last-child { border: none; }

.quiz-score {
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.quiz-score.good { background: #D1FAE5; color: #065F46; }
.quiz-score.ok { background: #FEF3C7; color: #92400E; }
.quiz-score.fail { background: #FEE2E2; color: #991B1B; }

/* ===== STUDENT DASHBOARD ===== */
.student-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.student-nav {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0 0 24px 24px;
}

.student-nav-logo {
    font-size: 28px;
    font-weight: 900;
    color: white;
    text-decoration: none;
}

.student-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.streak-badge {
    background: var(--yellow);
    color: var(--text-dark);
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.student-main {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 20px;
}

.student-welcome {
    text-align: center;
    color: white;
    margin-bottom: 32px;
}

.student-welcome h1 {
    font-size: 36px;
    font-weight: 900;
    margin-bottom: 4px;
}

.student-welcome p { font-size: 18px; opacity: 0.9; }

/* TOPIC CARDS */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.topic-card {
    background: white;
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-decoration: none;
    display: block;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.topic-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
}

.topic-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
}

.topic-card.purple::before { background: var(--purple); }
.topic-card.green::before { background: var(--green); }
.topic-card.orange::before { background: var(--orange); }
.topic-card.blue::before { background: var(--blue); }
.topic-card.pink::before { background: var(--pink); }

.topic-emoji {
    font-size: 64px;
    margin-bottom: 12px;
}

.topic-name {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.topic-desc {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.topic-progress {
    background: #F3F4F6;
    border-radius: 50px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.topic-progress-fill {
    height: 100%;
    border-radius: 50px;
    transition: width 0.8s;
}

.topic-progress-fill.done { background: var(--green); }
.topic-progress-fill.in-progress { background: var(--yellow); }
.topic-progress-fill.locked { background: var(--text-light); }

.topic-status {
    font-size: 13px;
    font-weight: 700;
}

.topic-status.done { color: var(--green-dark); }
.topic-status.in-progress { color: var(--orange); }
.topic-status.locked { color: var(--text-light); }

.quiz-unlock {
    background: var(--green);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    margin-top: 8px;
    display: inline-block;
}

/* GAMES SECTION */
.games-section { margin-top: 32px; }

.games-title {
    color: white;
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 20px;
    text-align: center;
}

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

.game-card {
    background: white;
    border-radius: 20px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: block;
    box-shadow: var(--shadow);
}

.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 36px rgba(0,0,0,0.2);
}

.game-emoji { font-size: 56px; margin-bottom: 8px; }
.game-name { font-size: 18px; font-weight: 800; color: var(--text-dark); margin-bottom: 4px; }
.game-desc { font-size: 12px; color: var(--text-light); }

/* ACHIEVEMENTS */
.achievements-section { margin-top: 32px; }

.achievements-title {
    color: white;
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 20px;
    text-align: center;
}

.badges-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.badge-item {
    background: white;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    width: 120px;
    box-shadow: var(--shadow);
}

.badge-item.earned { border: 3px solid var(--yellow); }
.badge-item.locked { opacity: 0.4; filter: grayscale(1); }

.badge-emoji { font-size: 48px; margin-bottom: 8px; }
.badge-name { font-size: 12px; font-weight: 800; color: var(--text-dark); }

/* ===== PRACTICE PAGE ===== */
.practice-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 24px 20px;
}

.question-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.question-number {
    font-size: 14px;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 16px;
}

.question-text {
    font-size: 52px;
    font-weight: 900;
    color: var(--text-dark);
    margin-bottom: 32px;
}

.answer-input {
    width: 180px;
    padding: 16px;
    border: 4px solid var(--purple);
    border-radius: 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 32px;
    font-weight: 800;
    text-align: center;
    color: var(--text-dark);
}

.answer-input:focus { outline: none; border-color: var(--orange); }

.hint-box {
    background: #FEF3C7;
    border: 3px solid var(--yellow);
    border-radius: 16px;
    padding: 16px 20px;
    margin: 20px 0;
    font-size: 16px;
    font-weight: 700;
    color: #92400E;
}

.explanation-box {
    background: #EDE9FE;
    border: 3px solid var(--purple);
    border-radius: 16px;
    padding: 20px;
    margin: 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #5B21B6;
    text-align: left;
}

.answer-buttons { display: flex; gap: 16px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }

/* Progress bar top of practice */
.practice-progress {
    background: rgba(255,255,255,0.2);
    border-radius: 50px;
    height: 12px;
    margin-bottom: 32px;
    overflow: hidden;
}

.practice-progress-fill {
    height: 100%;
    background: var(--yellow);
    border-radius: 50px;
    transition: width 0.4s;
}

/* ===== QUIZ PAGE ===== */
.quiz-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 20px;
}

.quiz-header {
    text-align: center;
    color: white;
    margin-bottom: 24px;
}

.quiz-header h1 { font-size: 32px; font-weight: 900; margin-bottom: 8px; }
.quiz-header p { font-size: 16px; opacity: 0.9; }

.quiz-timer {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 10px 24px;
    display: inline-block;
    font-size: 18px;
    font-weight: 800;
    color: white;
    margin-bottom: 24px;
}

.quiz-q-card {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.quiz-q-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 12px;
}

.quiz-q-text {
    font-size: 40px;
    font-weight: 900;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 24px;
}

.quiz-q-input {
    width: 100%;
    padding: 16px;
    border: 3px solid #E5E7EB;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 24px;
    font-weight: 800;
    text-align: center;
}

.quiz-q-input:focus { outline: none; border-color: var(--purple); }

/* ===== QUIZ RESULT ===== */
.result-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 32px 20px;
    text-align: center;
}

.result-card {
    background: white;
    border-radius: var(--radius);
    padding: 48px 32px;
    box-shadow: var(--shadow);
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-emoji {
    font-size: 96px;
    margin-bottom: 16px;
}

.result-score {
    font-size: 72px;
    font-weight: 900;
    color: var(--purple-dark);
    margin-bottom: 8px;
}

.result-label {
    font-size: 20px;
    color: var(--text-light);
    margin-bottom: 32px;
}

.result-passes {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 32px;
}

.result-passes.pass { color: var(--green-dark); }
.result-passes.fail { color: var(--red); }

.result-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* ===== GAME PAGE ===== */
.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.game-header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.game-header h1 { font-size: 32px; font-weight: 900; }

#gameCanvas {
    background: #0a0a2e;
    border-radius: 20px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.game-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.game-stats {
    display: flex;
    gap: 20px;
}

.game-stat {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px 20px;
    color: white;
    text-align: center;
}

.game-stat-num { font-size: 28px; font-weight: 900; }
.game-stat-label { font-size: 12px; opacity: 0.8; }

.math-question-box {
    background: white;
    border-radius: 16px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.math-q-text {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-dark);
}

.math-q-input {
    width: 100px;
    padding: 10px;
    border: 3px solid var(--purple);
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-size: 20px;
    font-weight: 800;
    text-align: center;
}

.math-q-input.correct { border-color: var(--green); background: #D1FAE5; }
.math-q-input.wrong { border-color: var(--red); background: #FEE2E2; animation: shake 0.4s; }

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

/* ===== CERTIFICATE ===== */
.cert-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 20px;
}

.cert-card {
    background: white;
    border: 8px solid var(--purple);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    box-shadow: 0 16px 64px rgba(0,0,0,0.2);
    position: relative;
}

.cert-card::before {
    content: '';
    position: absolute;
    top: 12px; left: 12px; right: 12px; bottom: 12px;
    border: 3px solid var(--yellow);
    border-radius: 12px;
    pointer-events: none;
}

.cert-emoji { font-size: 80px; margin-bottom: 16px; }
.cert-title { font-size: 48px; font-weight: 900; color: var(--purple-dark); margin-bottom: 8px; }
.cert-subtitle { font-size: 20px; color: var(--text-light); margin-bottom: 32px; }
.cert-name { font-size: 36px; font-weight: 900; color: var(--text-dark); margin-bottom: 8px; }
.cert-score { font-size: 24px; color: var(--green-dark); font-weight: 800; margin-bottom: 8px; }
.cert-date { font-size: 16px; color: var(--text-light); margin-bottom: 32px; }
.cert-badge { font-size: 64px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .welcome-title { font-size: 32px; }
    .form-box { margin: 20px auto; padding: 28px; }
    .question-text { font-size: 36px; }
    .quiz-q-text { font-size: 28px; }
    .student-welcome h1 { font-size: 26px; }
    .dashboard-header h1 { font-size: 26px; }
    .stat-card .stat-num { font-size: 24px; }
}

/* ===== CONFETTI ANIMATION ===== */
@keyframes confetti {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    animation: confetti 3s ease-in forwards;
}
