/* =================================
   RESET & BASE STYLES
   ================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0f0f;
    --bg-secondary: #1A202C;
    --bg-card: #2D3748;
    --text-primary: #F7FAFC;
    --text-secondary: #A0AEC0;
    --accent-blue: #4299E1;
    --accent-green: #48BB78;
    --accent-magenta: #ED64A6;
    --accent-yellow: #ECC94B;
    --accent-purple: #9F7AEA;
    --accent-cyan: #38B2AC;
    --nav-height: 68px;
    --score-bar-height: 60px;
    --total-header-height: 128px;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.light-mode {
    --bg-primary: #F7FAFC;
    --bg-secondary: #EDF2F7;
    --bg-card: #FFFFFF;
    --text-primary: #1A202C;
    --text-secondary: #4A5568;
}

/* =================================
   CANVAS & PARTICLES
   ================================= */
#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}

.particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: particleFloat 1.5s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-150px) scale(0);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 9999;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-50px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* =================================
   NAVIGATION
   ================================= */
nav {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(26, 32, 44, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1rem 2rem;
    z-index: 1000;
    border-bottom: 1px solid rgba(66, 153, 225, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.light-mode nav {
    background: rgba(255, 255, 255, 0.85);
    border-bottom-color: rgba(0,0,0,0.05);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    font-family: 'Manrope', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    transition: transform 0.3s;
    user-select: none;
}

.logo:hover {
    transform: scale(1.05);
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-links button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
}

.nav-links button:hover,
.nav-links button:focus {
    color: var(--accent-blue);
    background: rgba(66, 153, 225, 0.1);
    outline: none;
}

.nav-links button.active {
    color: var(--accent-blue);
    background: rgba(66, 153, 225, 0.15);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hamburger {
    display: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.5rem;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px 0;
    background: var(--accent-blue);
    transition: all 0.3s ease-in-out;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
    opacity: 0;
}
.hamburger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.theme-toggle {
    background: rgba(66, 153, 225, 0.1);
    border: 2px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle:hover {
    background: var(--accent-blue);
    color: white;
    transform: scale(1.05);
}

.level-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--accent-yellow), var(--accent-magenta));
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(236, 201, 75, 0.3);
    white-space: nowrap;
}

/* =================================
   SCORE BAR
   ================================= */
.score-bar {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    width: 100%;
    background: rgba(26, 32, 44, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    z-index: 999;
    border-bottom: 1px solid rgba(66, 153, 225, 0.1);
}

body.light-mode .score-bar {
    background: rgba(255, 255, 255, 0.85);
    border-bottom-color: rgba(0,0,0,0.05);
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-blue);
    font-weight: 700;
    transition: transform 0.3s;
}

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

.xp-bar {
    position: relative;
    width: 220px;
    height: 24px;
    background: var(--bg-card);
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid var(--accent-blue);
}

.xp-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-green));
    transition: width 0.6s ease-out;
    width: 0%;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 1;
}

/* =================================
   PAGES & SECTIONS
   ================================= */
.page {
    position: relative;
    z-index: 1;
    padding-top: var(--total-header-height);
    min-height: 100vh;
    display: none;
    opacity: 0;
}

.page.active {
    display: block;
    animation: pageEnter 0.6s ease-out forwards;
}

@keyframes pageEnter {
    to {
        opacity: 1;
    }
}

.section {
    padding: 4rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
}

/* =================================
   HERO SECTION
   ================================= */
.hero {
    padding: 4rem 2rem;
    text-align: center;
    max-width: 1200px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    font-family: 'Manrope', sans-serif;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 200%;
    animation: gradientFlow 3s ease infinite;
}

@keyframes gradientFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero-subtitle {
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.hero-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.btn {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    color: white;
    box-shadow: 0 10px 30px rgba(66, 153, 225, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(66, 153, 225, 0.6);
}

.btn-secondary {
    background: rgba(66, 153, 225, 0.1);
    color: var(--accent-blue);
    border: 2px solid var(--accent-blue);
}

.btn-secondary:hover {
    background: rgba(66, 153, 225, 0.2);
    transform: translateY(-3px);
}

.btn-danger {
    background-color: #E53E3E;
    color: white;
    box-shadow: 0 10px 30px rgba(229, 62, 62, 0.4);
}

.btn-danger:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(229, 62, 62, 0.6);
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(45, 55, 72, 0.8);
    backdrop-filter: blur(10px);
    padding: 1.5rem 2rem;
    border-radius: 20px;
    border: 1px solid rgba(66, 153, 225, 0.3);
    min-width: 150px;
    transition: all 0.3s;
}

.stat-box:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(66, 153, 225, 0.3);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* =================================
   CTA SECTION
   ================================= */
.cta-section {
    padding: 5rem 2rem;
    background: var(--bg-secondary);
    text-align: center;
    margin-top: 4rem;
    border-top: 1px solid rgba(66, 153, 225, 0.2);
    border-bottom: 1px solid rgba(66, 153, 225, 0.2);
}

.cta-content {
    max-width: 800px;
    margin: 0 auto;
}

.cta-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.cta-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    line-height: 1.8;
}

/* =================================
   TIMELINE
   ================================= */
.timeline {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    padding: 2rem 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--accent-blue), var(--accent-green));
    transform: translateX(-50%);
}

.timeline-item {
    margin-bottom: 3rem;
    position: relative;
}

.timeline-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 45%;
    position: relative;
    border: 2px solid var(--accent-blue);
    transition: all 0.3s;
}

.timeline-content:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(66, 153, 225, 0.4);
}

.timeline-item:nth-child(odd) .timeline-content {
    margin-left: auto;
}

.timeline-item:nth-child(even) .timeline-content {
    margin-right: auto;
}

.timeline-year {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 700;
    box-shadow: 0 5px 15px rgba(66, 153, 225, 0.5);
    z-index: 1;
}

.timeline-content h3 {
    color: var(--accent-blue);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.timeline-content p {
    color: var(--text-secondary);
    line-height: 1.8;
}

.philosophy-box {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    margin-top: 3rem;
    border: 2px solid var(--accent-green);
    box-shadow: 0 10px 30px rgba(72, 187, 120, 0.3);
}

.philosophy-box h3 {
    text-align: center;
    color: var(--accent-green);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.philosophy-box p {
    color: var(--text-secondary);
    line-height: 1.8;
    text-align: justify;
}

/* =================================
   MATRIX GRID
   ================================= */
.matrix-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    perspective: 1000px;
}

.matrix-card-container {
    position: relative;
    height: 250px;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.matrix-card-container.flipped {
    transform: rotateY(180deg);
}

.matrix-card-front, .matrix-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    background: var(--bg-card);
    border: 2px solid;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.matrix-card-back {
    transform: rotateY(180deg);
}

.number {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.letter {
    font-size: 1.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.example {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.logic {
    font-size: 1.1rem;
    color: var(--accent-blue);
    font-weight: 600;
    margin-bottom: 1rem;
}

.memory-tip {
    font-size: 0.9rem;
    color: var(--accent-green);
    font-style: italic;
}

/* =================================
   TRAINER
   ================================= */
.trainer-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: 25px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(66, 153, 225, 0.2);
}

.mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-btn {
    flex: 1;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-blue);
    color: var(--text-primary);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-family: inherit;
    font-size: 1rem;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    border-color: transparent;
    box-shadow: 0 10px 30px rgba(66, 153, 225, 0.4);
}

.trainer-input {
    width: 100%;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-blue);
    border-radius: 15px;
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-align: center;
    font-family: inherit;
    transition: all 0.3s;
}

.trainer-input:focus {
    outline: none;
    box-shadow: 0 0 30px rgba(66, 153, 225, 0.5);
}

.submit-btn {
    width: 100%;
    padding: 1.2rem;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
    border: none;
    color: white;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    box-shadow: 0 10px 30px rgba(72, 187, 120, 0.4);
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(72, 187, 120, 0.6);
}

.trainer-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.trainer-buttons .submit-btn {
    flex-grow: 1;
}

.trainer-buttons .btn-secondary {
    flex-grow: 0.5;
}

.result {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 15px;
    text-align: center;
    font-size: 1.2rem;
    margin-top: 1rem;
    display: none;
    font-weight: 700;
}

.result.show {
    display: block;
    animation: resultShow 0.3s ease-out;
}

@keyframes resultShow {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result.success {
    border: 3px solid var(--accent-green);
    color: var(--accent-green);
    background: rgba(72, 187, 120, 0.1);
}

.result.error {
    border: 3px solid #FC8181;
    color: #FC8181;
    background: rgba(252, 129, 129, 0.1);
}

.result .highlight {
    color: var(--accent-green);
    font-weight: 700;
}

/* =================================
   ACHIEVEMENT TOAST
   ================================= */
.achievement-toast {
    position: fixed;
    top: 160px;
    right: 20px;
    background: var(--bg-card);
    border: 3px solid var(--accent-green);
    border-radius: 20px;
    padding: 1.5rem;
    display: none;
    align-items: center;
    gap: 1rem;
    z-index: 10000;
    box-shadow: 0 20px 50px rgba(72, 187, 120, 0.6);
    backdrop-filter: blur(20px);
    max-width: 350px;
}

.achievement-toast.show {
    display: flex;
    animation: toastSlide 0.5s ease-out;
}

@keyframes toastSlide {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.achievement-toast-icon {
    font-size: 3rem;
}

.achievement-toast-title {
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 0.25rem;
}

.achievement-toast-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* =================================
   MODE TABS & QUIZ
   ================================= */
.mode-tabs {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.mode-tab {
    padding: 1rem 2rem;
    background: var(--bg-card);
    border: 2px solid var(--accent-blue);
    color: var(--text-primary);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-family: inherit;
    font-size: 1rem;
}

.mode-tab:hover {
    transform: translateY(-3px);
}

.mode-tab.active {
    background: var(--accent-blue);
    box-shadow: 0 10px 30px rgba(66, 153, 225, 0.5);
}

.timer-display {
    text-align: center;
    margin-bottom: 2rem;
}

.timer-circle {
    display: inline-flex;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--accent-blue) 0deg, var(--bg-card) 0deg);
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 10px 30px rgba(66, 153, 225, 0.4);
}

.timer-circle::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-secondary);
}

.timer-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-blue);
    z-index: 1;
}

.quiz-question {
    text-align: center;
    margin-bottom: 2rem;
}

.quiz-question h3 {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.quiz-number {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.quiz-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.quiz-buttons .submit-btn {
    flex-grow: 1;
}

.quiz-buttons .btn-secondary {
    flex-grow: 0.5;
}

/* =================================
   SETTINGS
   ================================= */
.settings-container {
    max-width: 800px;
    margin: 4rem auto 0;
    padding: 1.5rem 2rem;
    background: transparent;
    border-radius: 20px;
    border: 1px dashed var(--text-secondary);
}

.settings-title {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.setting-item p {
    flex-grow: 1;
    color: var(--text-secondary);
}

/* =================================
   INSIGHTS & COMMUNITY
   ================================= */
.insights-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.insight-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(66, 153, 225, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.insight-card h3 {
    color: var(--accent-blue);
    margin-bottom: 1rem;
}

.insight-card p {
    color: var(--text-secondary);
    line-height: 1.8;
}

.community-container {
    margin-top: 4rem;
}

.community-title {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 3rem;
    font-family: 'Manrope', sans-serif;
    color: var(--text-primary);
}

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

.community-card {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid rgba(66, 153, 225, 0.2);
    text-align: center;
    transition: all 0.3s;
    text-decoration: none;
}

.community-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(66, 153, 225, 0.3);
    border-color: var(--accent-blue);
}

.community-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    line-height: 1;
}

.community-card h4 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.community-card p {
    color: var(--text-secondary);
    line-height: 1.8;
    font-size: 0.95rem;
}

.links-container {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 3rem;
}

/* =================================
   AI ASSISTANT WIDGET
   ================================= */
.ai-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    border-radius: 50%;
    border: none;
    font-size: 1.8rem;
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(66, 153, 225, 0.5);
    z-index: 1010;
    transition: transform 0.3s, opacity 0.3s;
}

.ai-fab:hover {
    transform: scale(1.1) rotate(15deg);
}

.ai-fab.hide {
    transform: scale(0);
    opacity: 0;
}

.ai-widget-container {
    position: fixed;
    bottom: 7rem;
    right: 2rem;
    width: 350px;
    max-width: calc(100% - 4rem);
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    z-index: 1009;
    overflow: hidden;
    border: 1px solid rgba(66, 153, 225, 0.2);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.ai-widget-container.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.ai-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(66, 153, 225, 0.1);
}

.ai-widget-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.ai-widget-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
    z-index: 1012;
}

.ai-widget-close:hover {
    color: var(--accent-blue);
}

.ai-widget-body {
    padding: 1.5rem;
}

.ai-message {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 15px 15px 15px 5px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 1rem;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background-color: var(--accent-blue);
    border-radius: 50%;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* =================================
   MODAL
   ================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.modal-content h3 {
    color: var(--accent-blue);
    text-align: center;
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-blue);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-feedback {
    text-align: center;
    margin-top: 1rem;
    font-weight: 600;
}

.hidden { 
    display: none; 
}

/* =================================
   FOOTER
   ================================= */
footer {
    position: relative;
    z-index: 10;
    background: var(--bg-primary);
    padding: 3rem 2rem 2rem;
    border-top: 1px solid rgba(66, 153, 225, 0.2);
    color: var(--text-secondary);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.footer-logo-link {
    display: inline-block;
    line-height: 0;
}

.footer-logo-img {
    height: 35px;
    opacity: 0.8;
}

.footer-links {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s;
    font-weight: 500;
}

.footer-links a:hover {
    color: var(--accent-blue);
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-icon {
    color: var(--text-secondary);
    transition: all 0.3s;
}

.social-icon:hover {
    color: var(--accent-blue);
    transform: translateY(-3px);
}

.social-icon svg {
    width: 24px;
    height: 24px;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(66, 153, 225, 0.1);
    font-size: 0.9rem;
}

.footer-bottom a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.footer-bottom a:hover {
    text-decoration: underline;
}

/* =================================
   UTILITIES
   ================================= */
::selection {
    background: var(--accent-blue);
    color: white;
}

/* =================================
   RESPONSIVE BREAKPOINTS
   ================================= */

/* Tablet (768px - 968px) */
@media (max-width: 968px) {
    .timeline::before {
        left: 0;
    }

    .timeline-content {
        width: 100%;
        margin-left: 2rem !important;
        margin-right: 0 !important;
    }

    .timeline-year {
        left: 0;
        transform: translateX(0);
    }

    .matrix-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* Mobile (up to 768px) */
@media (max-width: 768px) {
    :root {
        --nav-height: 67px;
        --score-bar-height: 80px;
        --total-header-height: 147px;
    }

    /* Disable blur on mobile for better performance */
    nav, .score-bar {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    /* Navigation */
    .nav-container {
        gap: 1rem;
    }

    .logo {
        font-size: 1.3rem;
    }

    .nav-links {
        display: none;
        opacity: 0;
        position: fixed;
        top: var(--nav-height);
        left: 0;
        width: 100%;
        background: var(--bg-secondary);
        flex-direction: column;
        padding: 1rem 0;
        z-index: 998;
        transform: translateY(-150%);
        transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s;
    }

    .nav-links.show {
        display: flex;
        opacity: 1;
        transform: translateY(0);
    }

    .nav-links button {
        width: 100%;
        text-align: center;
        padding: 1rem;
    }

    .hamburger { 
        display: block; 
    }

    .theme-toggle {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .level-badge {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    /* Score Bar */
    .score-bar {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }

    .score-item {
        font-size: 0.9rem;
    }

    .xp-bar {
        width: 100%;
        max-width: 300px;
    }

    /* Hero Section */
    .hero, .section, .cta-section {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .hero {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
    }

    .btn {
        width: 100%;
        padding: 0.9rem 2rem;
        font-size: 1rem;
    }

    .hero-stats {
        gap: 1rem;
    }

    .stat-box {
        min-width: 120px;
        padding: 1rem 1.5rem;
    }

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

    /* Trainer */
    .trainer-container {
        padding: 1.5rem;
    }

    .mode-selector {
        flex-direction: column;
        gap: 0.8rem;
    }

    .mode-btn {
        padding: 0.8rem;
    }

    .trainer-input {
        padding: 1rem;
        font-size: 1rem;
    }

    .trainer-buttons,
    .quiz-buttons {
        flex-direction: column;
    }

    .trainer-buttons .btn-secondary,
    .quiz-buttons .btn-secondary {
        flex-grow: 1;
    }

    /* Matrix Grid */
    .matrix-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
    }

    .matrix-card-container {
        height: 200px;
    }

    .matrix-card-front, .matrix-card-back {
        padding: 1.5rem;
    }

    .number {
        font-size: 3rem;
    }

    .letter {
        font-size: 1.5rem;
    }

    /* Mode Tabs */
    .mode-tabs {
        gap: 0.8rem;
    }

    .mode-tab {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Achievement Toast */
    .achievement-toast {
        top: calc(var(--total-header-height) + 10px);
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }

    /* Timeline */
    .timeline {
        padding: 1rem 0;
    }

    .timeline-content {
        padding: 1.5rem;
        margin-left: 1.5rem !important;
    }

    .timeline-content h3 {
        font-size: 1.2rem;
    }

    /* Community & Insights */
    .community-grid,
    .insights-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* Settings */
    .settings-container {
        padding: 1rem 1.5rem;
        margin-top: 2rem;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .setting-item .btn {
        width: 100%;
    }

    /* Footer */
    .footer-top {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    /* AI Widget */
    .ai-widget-container {
        bottom: 6rem;
        left: 50%;
        width: calc(100% - 2rem);
        transform: translateX(-50%) translateY(20px) scale(0.95);
    }

    .ai-widget-container.show {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    .ai-fab {
        bottom: 1rem;
        right: 1rem;
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }

    /* Modal */
    .modal-content {
        padding: 2rem;
        width: 95%;
    }
}

/* Small Mobile (up to 480px) */
@media (max-width: 480px) {
    .hero-title {
        font-size: 1.8rem;
    }

    .cta-title {
        font-size: 1.6rem;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .timer-circle {
        width: 100px;
        height: 100px;
    }

    .timer-circle::before {
        width: 80px;
        height: 80px;
    }

    .timer-text {
        font-size: 1.5rem;
    }

    .quiz-number {
        font-size: 3rem;
    }

    .achievement-toast-icon {
        font-size: 2.5rem;
    }

    .stat-box {
        min-width: 100px;
        padding: 1rem;
    }

    .matrix-grid {
        grid-template-columns: 1fr;
    }

    .nav-actions {
        gap: 0.5rem;
    }

    .theme-toggle span:not(.icon) {
        display: none;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .page {
        padding-top: calc(var(--nav-height) + 1rem);
    }

    .hero {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    .achievement-toast {
        top: calc(var(--nav-height) + 10px);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: subpixel-antialiased;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark Mode Preference */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        --bg-primary: #0a0f0f;
        --bg-secondary: #1A202C;
        --bg-card: #2D3748;
        --text-primary: #F7FAFC;
        --text-secondary: #A0AEC0;
    }
}

/* Print Styles */
@media print {
    nav,
    .score-bar,
    .ai-fab,
    .ai-widget-container,
    .achievement-toast,
    footer {
        display: none !important;
    }

    .page {
        padding-top: 0 !important;
    }

    body {
        background: white;
        color: black;
    }
}