/**
 * VocabMaster - English Learning Platform
 * Theme: Learning Spark
 * A vibrant and playful theme for educational platforms
 */

/* ========================================
   FONTS
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ========================================
   CSS VARIABLES - LIGHT THEME
   ======================================== */
:root {
    /* Primary Colors */
    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-primary-light: #DBEAFE;
    --color-primary-dark: #1D4ED8;

    /* Semantic Colors */
    --color-success: #10B981;
    --color-success-hover: #059669;
    --color-success-light: #D1FAE5;

    --color-accent: #F97316;
    --color-accent-hover: #EA580C;
    --color-accent-light: #FFEDD5;

    --color-warning: #F59E0B;
    --color-warning-light: #FEF3C7;

    --color-error: #F43F5E;
    --color-error-hover: #E11D48;
    --color-error-light: #FFE4E6;

    /* Neutral Colors */
    --color-text: #0F172A;
    --color-text-muted: #475569;
    --color-text-light: #64748B;

    --color-background: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-surface-hover: #F1F5F9;
    --color-border: #E2E8F0;
    --color-border-hover: #CBD5E1;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    --gradient-success: linear-gradient(135deg, #10B981 0%, #34D399 100%);
    --gradient-accent: linear-gradient(135deg, #F97316 0%, #FB923C 100%);
    --gradient-hero: linear-gradient(135deg, #3B82F6 0%, #6366F1 50%, #8B5CF6 100%);

    /* Typography */
    --font-heading: 'Fredoka', sans-serif;
    --font-body: 'Nunito', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease-out;
    --transition-base: 200ms ease-out;
    --transition-slow: 300ms ease-out;

    --z-tooltip: 400;

    /* Header Height */
    --header-height: 60px;
    --header-height-mobile: 60px;
}

/* ========================================
   DARK THEME
   ======================================== */
[data-theme="dark"] {
    --color-text: #F1F5F9;
    --color-text-muted: #94A3B8;
    --color-text-light: #CBD5E1;

    --color-background: #0F172A;
    --color-surface: #1E293B;
    --color-surface-hover: #334155;
    --color-border: #334155;
    --color-border-hover: #475569;

    --color-primary-light: rgba(59, 130, 246, 0.2);
    --color-success-light: rgba(16, 185, 129, 0.2);
    --color-accent-light: rgba(249, 115, 22, 0.2);
    --color-warning-light: rgba(245, 158, 11, 0.2);
    --color-error-light: rgba(244, 63, 94, 0.2);

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.4);
}

/* ========================================
   RESET & BASE
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: var(--header-height);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.125rem;
}

h6 {
    font-size: 1rem;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

button {
    cursor: pointer;
    font-family: inherit;
}

/* ========================================
   NAVIGATION
   ======================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    transition: all var(--transition-base);
}

[data-theme="dark"] .main-header {
    background: rgba(15, 23, 42, 0.9);
}

.nav-container {
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    border-bottom: none;
}

/* Header Navigation (inline with logo) */
.header-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-left: var(--spacing-xl);
}

.header-nav .nav-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.header-nav .nav-link:hover {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.header-nav .nav-link.active {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.header-nav .nav-dropdown {
    position: relative;
}

.header-nav .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-sm);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    z-index: 1000;
}

.header-nav .nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Navigation Row Removed */

.nav-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.nav-logo:hover {
    transform: scale(1.02);
}

.logo-icon {
    font-size: 2.25rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

[data-theme="dark"] .logo-text {
    background: linear-gradient(135deg, #60A5FA 0%, #A78BFA 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Footer Brand (Kept for compatibility) */
.brand-icon {
    font-size: 1.75rem;
}

.brand-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: var(--spacing-sm);
    background: none;
    border: none;
}

.mobile-menu-toggle {
    display: none;
    padding: var(--spacing-sm);
    background: none;
    border: none;
    color: var(--color-text);
    font-size: 1.75rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.mobile-menu-toggle:hover {
    color: var(--color-primary);
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    gap: var(--spacing-md);
    width: 100%;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-weight: 600;
    color: var(--color-text-muted);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    font-size: 1rem;
    position: relative;
}

.nav-link:hover {
    color: var(--color-primary);
}

.nav-link.active {
    color: var(--color-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
}

/* Search Header */
.header-search {
    flex: 1;
    max-width: 500px;
    margin: 0 var(--spacing-xl);
}

.search-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    text-align: left;
}

.search-trigger:hover {
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.search-icon {
    font-size: 1.1rem;
}

.search-text {
    flex: 1;
    font-size: 0.95rem;
}

.search-key {
    font-size: 0.75rem;
    background: var(--color-border);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.mobile-search-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    font-size: 1.25rem;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}

.mobile-search-btn:hover {
    background: var(--color-surface);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.user-stats-minimal {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-weight: 700;
    font-size: 1rem;
}

.level-pill {
    background: var(--color-primary-light);
    color: var(--color-primary);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.user-profile-mini {
    position: relative;
    display: flex;
    align-items: center;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 4px;
    padding-right: 12px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.profile-trigger:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    background: var(--color-primary-light);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.username-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: none;
    border: none;
    font-size: inherit;
}

.dropdown-arrow {
    transition: transform var(--transition-fast);
}

.nav-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    padding: var(--spacing-sm);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
    transition-delay: 0.1s;
    /* 小緩衝防止意外關閉 */
    margin-top: var(--spacing-sm);
    z-index: var(--z-dropdown);
}

/* 增加隱形橋樑，防止滑鼠滑過間隙時選單關閉 */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -20px;
    /* 覆蓋上方間隙 */
    left: 0;
    width: 100%;
    height: 20px;
    background: transparent;
}

.nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
    /* 顯示時無延遲 */
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    color: var(--color-text);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.item-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.item-info {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-sm);
}

.item-title {
    font-weight: 600;
    white-space: nowrap;
}

.item-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* User Stats & Profile */
/* Nav Actions Group */
.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.search-pill-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    font-weight: 600;
}

.search-pill-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.search-icon {
    font-size: 1rem;
}

.achievement-pill {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    background: var(--color-background);
    padding: 4px 4px 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
}

.achievement-pill .stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.level-badge {
    background: var(--color-primary);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
}

.user-profile-mini {
    position: relative;
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 4px;
    padding-right: 12px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.profile-pill:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    background: var(--color-primary-light);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.username-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.profile-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.avatar-sm {
    font-size: 1.25rem;
    line-height: 1;
}

.username-mini {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.dropdown-right {
    left: auto !important;
    right: 0;
    transform: none !important;
}

.dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: var(--spacing-xs) 0;
}

.admin-link {
    color: var(--color-accent) !important;
    font-weight: 600 !important;
}

.admin-link:hover {
    background: var(--color-accent-light) !important;
}

/* ========================================
   USER DROPDOWN ENHANCED
   ======================================== */
.user-dropdown .dropdown-chevron {
    font-size: 0.65rem;
    opacity: 0.6;
    transition: transform var(--transition-fast);
}

.user-dropdown:hover .dropdown-chevron {
    transform: rotate(180deg);
}

.user-menu {
    min-width: 280px;
    padding: 0;
    overflow: hidden;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-surface) 100%);
    border-bottom: 1px solid var(--color-border);
}

.user-avatar-lg {
    font-size: 2.5rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text);
    margin-bottom: 4px;
}

.user-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--color-primary);
    background: var(--color-surface);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.level-icon {
    font-size: 0.75rem;
}

.user-xp-bar {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-surface);
}

.xp-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.xp-track {
    height: 6px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.user-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.user-menu .dropdown-item:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.user-menu .dropdown-item .item-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.user-menu .dropdown-item .item-text {
    font-weight: 500;
}

.menu-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    padding: var(--spacing-xs) var(--spacing-lg);
}

.admin-item {
    color: var(--color-warning) !important;
}

.admin-item:hover {
    background: rgba(245, 158, 11, 0.1) !important;
}

.logout-item {
    color: var(--color-text-muted) !important;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    margin-top: var(--spacing-xs);
}

.logout-item:hover {
    color: var(--color-error) !important;
    background: rgba(239, 68, 68, 0.08) !important;
}

.logout-item .item-icon {
    opacity: 0.7;
}

.logout-item:hover .item-icon {
    opacity: 1;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* ========================================
   HERO SECTION
   ======================================== */
.hero {
    position: relative;
    padding: var(--spacing-lg) 0 var(--spacing-3xl);
    overflow: hidden;
}

.hero-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-2xl);
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.hero-content {
    max-width: 600px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
}

.hero-title {
    font-size: 3.5rem;
    line-height: 1.2;
    margin-bottom: var(--spacing-lg);
}

.gradient-text {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
}

.hero-description {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-xl);
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-2xl);
}

.hero-stats {
    display: flex;
    gap: var(--spacing-2xl);
    padding-top: var(--spacing-xl);
    border-top: 1px solid var(--color-border);
}

.hero-stat {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.hero-visual {
    position: relative;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-cards {
    position: relative;
    width: 300px;
    height: 400px;
}

.demo-card {
    position: absolute;
    width: 280px;
    height: 180px;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-slow);
}

.demo-card-1 {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-5deg);
    z-index: 3;
    animation: float 6s ease-in-out infinite;
}

.demo-card-2 {
    top: 30%;
    left: 40%;
    transform: translate(-50%, -50%) rotate(10deg);
    z-index: 2;
    opacity: 0.8;
    animation: float 6s ease-in-out infinite 2s;
}

.demo-card-3 {
    top: 70%;
    left: 60%;
    transform: translate(-50%, -50%) rotate(-15deg);
    z-index: 1;
    opacity: 0.6;
    animation: float 6s ease-in-out infinite 4s;
}

.demo-word {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.demo-translation {
    color: var(--color-text-muted);
}

@keyframes float {

    0%,
    100% {
        transform: translate(-50%, -50%) rotate(-5deg) translateY(0);
    }

    50% {
        transform: translate(-50%, -50%) rotate(-5deg) translateY(-20px);
    }
}

@media (max-width: 1024px) {
    .hero-container {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-content {
        margin: 0 auto;
    }

    .hero-actions {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
    }

    .hero-visual {
        display: none;
    }
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md), 0 4px 14px 0 rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 6px 20px 0 rgba(59, 130, 246, 0.4);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: var(--shadow-md), 0 4px 14px 0 rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 6px 20px 0 rgba(16, 185, 129, 0.4);
}

.btn-accent {
    background: var(--gradient-accent);
    color: white;
    box-shadow: var(--shadow-md), 0 4px 14px 0 rgba(249, 115, 22, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 6px 20px 0 rgba(249, 115, 22, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-outline:hover {
    background: var(--color-primary);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.125rem;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

.btn-icon {
    padding: var(--spacing-sm);
    aspect-ratio: 1;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-hover);
}

/* Learning Mode Cards */
.mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-xl);
    text-align: center;
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--color-border);
    transition: all var(--transition-base);
    cursor: pointer;
}

.mode-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-8px);
}

.mode-icon {
    font-size: 3.5rem;
    margin-bottom: var(--spacing-md);
}

.mode-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.mode-description {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* ========================================
   FLASHCARD
   ======================================== */
.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 3/2;
    margin: 0 auto;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    background: var(--color-surface);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    backface-visibility: hidden;
}

.flashcard-front {
    background: var(--gradient-primary);
    border: none;
    color: white;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--color-surface);
}

.flashcard-word {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
}

.flashcard-pos {
    font-size: 1rem;
    opacity: 0.8;
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
}

.flashcard-translation {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-text);
}

.flashcard-hint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-md);
}

/* Flashcard Actions */
.flashcard-actions {
    display: flex;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
    justify-content: center;
}

.flashcard-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    border: none;
    font-size: 2rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.flashcard-btn.btn-wrong {
    background: var(--color-error-light);
    color: var(--color-error);
}

.flashcard-btn.btn-wrong:hover {
    background: var(--color-error);
    color: white;
    transform: scale(1.1);
}

.flashcard-btn.btn-correct {
    background: var(--color-success-light);
    color: var(--color-success);
}

.flashcard-btn.btn-correct:hover {
    background: var(--color-success);
    color: white;
    transform: scale(1.1);
}

/* ========================================
   MATCHING GAME
   ======================================== */
.matching-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-md);
    max-width: 800px;
    margin: 0 auto;
}

.matching-card {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.matching-card:hover:not(.matched):not(.selected) {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.matching-card.selected {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white;
    transform: scale(1.05);
}

.matching-card.matched {
    border-color: var(--color-success);
    background: var(--color-success-light);
    color: var(--color-success);
    pointer-events: none;
}

.matching-card.wrong {
    animation: shake 0.5s ease-out;
    border-color: var(--color-error);
    background: var(--color-error-light);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-5px);
    }

    40%,
    80% {
        transform: translateX(5px);
    }
}

/* ========================================
   SPELLING PRACTICE
   ======================================== */
.spelling-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.spelling-prompt {
    font-size: 1.5rem;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-md);
}

.spelling-translation {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--spacing-xl);
}

.spelling-input-container {
    position: relative;
    margin-bottom: var(--spacing-xl);
}

.spelling-input {
    width: 100%;
    padding: var(--spacing-lg);
    font-family: var(--font-mono);
    font-size: 2rem;
    text-align: center;
    letter-spacing: 0.5rem;
    background: var(--color-surface);
    border: 3px solid var(--color-border);
    border-radius: var(--radius-xl);
    color: var(--color-text);
    outline: none;
    transition: all var(--transition-fast);
}

.spelling-input:focus {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-glow);
}

.spelling-input.correct {
    border-color: var(--color-success);
    background: var(--color-success-light);
}

.spelling-input.incorrect {
    border-color: var(--color-error);
    background: var(--color-error-light);
}

.spelling-hint {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
}

.hint-letter {
    width: 40px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--color-surface-hover);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
}

.hint-letter.revealed {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ========================================
   QUIZ
   ======================================== */
.quiz-question {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.quiz-number {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

.quiz-word {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-text);
}

.quiz-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    max-width: 600px;
    margin: 0 auto;
}

.quiz-option {
    padding: var(--spacing-lg);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-xl);
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quiz-option:hover:not(.selected):not(.correct):not(.wrong) {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.quiz-option.selected {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white;
}

.quiz-option.correct {
    border-color: var(--color-success);
    background: var(--color-success);
    color: white;
}

.quiz-option.wrong {
    border-color: var(--color-error);
    background: var(--color-error);
    color: white;
}

/* ========================================
   WORD BROWSER
   ======================================== */
.word-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.filter-select,
.filter-input {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--color-text);
    outline: none;
    transition: all var(--transition-fast);
}

.filter-select:focus,
.filter-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.word-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-md);
}

.word-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.word-item:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.word-content {
    flex: 1;
}

.word-english {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.word-chinese {
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.word-pos {
    font-size: 0.8rem;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
}

.word-favorite {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.3;
    transition: all var(--transition-fast);
}

.word-favorite:hover,
.word-favorite.active {
    opacity: 1;
}

/* ========================================
   PROGRESS & STATS
   ======================================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.stat-card {
    padding: var(--spacing-lg);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    text-align: center;
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* ========================================
   ACHIEVEMENTS
   ======================================== */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--spacing-md);
}

.achievement-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    text-align: center;
    transition: all var(--transition-base);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-card.unlocked {
    border-color: var(--color-warning);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

.achievement-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
}

.achievement-name {
    font-family: var(--font-heading);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.achievement-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ========================================
   FOOTER
   ======================================== */
/* ========================================
   FOOTER ENHANCED
   ======================================== */
.footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 80px 0 40px;
    margin-top: 80px;
}

.footer-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.2fr 2fr;
    gap: 60px;
    margin-bottom: 60px;
}

.footer-brand {
    max-width: 360px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.footer-logo .logo-icon {
    font-size: 2.5rem;
}

.footer-logo .logo-text {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.footer-tagline {
    color: var(--color-text-muted);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 28px;
}

.footer-social {
    display: flex;
    gap: 12px;
}

.social-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--color-text-muted);
    transition: all 0.3s;
}

.social-icon:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.footer-links-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}

.footer-section h4 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--color-text);
    position: relative;
    padding-bottom: 12px;
}

.footer-section h4::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 24px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 99px;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section li {
    margin-bottom: 12px;
}

.footer-section a {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.footer-section a:hover {
    color: var(--color-primary);
    padding-left: 6px;
}

.footer-bottom {
    padding-top: 40px;
    border-top: 1px solid var(--color-border);
}

.footer-bottom-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.footer-extra {
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 600;
}

@media (max-width: 1024px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 60px;
    }

    .footer-brand {
        max-width: 100%;
        text-align: center;
    }

    .footer-logo {
        justify-content: center;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-section h4::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .footer-bottom-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

@media (max-width: 640px) {
    .footer-links-group {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 48px;
    }
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-primary {
    color: var(--color-primary);
}

.text-success {
    color: var(--color-success);
}

.text-accent {
    color: var(--color-accent);
}

.text-warning {
    color: var(--color-warning);
}

.text-error {
    color: var(--color-error);
}

.text-muted {
    color: var(--color-text-muted);
}

.bg-primary {
    background: var(--color-primary);
}

.bg-success {
    background: var(--color-success);
}

.bg-accent {
    background: var(--color-accent);
}

.mt-sm {
    margin-top: var(--spacing-sm);
}

.mt-md {
    margin-top: var(--spacing-md);
}

.mt-lg {
    margin-top: var(--spacing-lg);
}

.mt-xl {
    margin-top: var(--spacing-xl);
}

.mt-2xl {
    margin-top: var(--spacing-2xl);
}

.mb-sm {
    margin-bottom: var(--spacing-sm);
}

.mb-md {
    margin-bottom: var(--spacing-md);
}

.mb-lg {
    margin-bottom: var(--spacing-lg);
}

.mb-xl {
    margin-bottom: var(--spacing-xl);
}

.mb-2xl {
    margin-bottom: var(--spacing-2xl);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm {
    gap: var(--spacing-sm);
}

.gap-md {
    gap: var(--spacing-md);
}

.gap-lg {
    gap: var(--spacing-lg);
}

.hidden {
    display: none !important;
}

.desktop-only {
    display: flex !important;
}

.mobile-only {
    display: none !important;
}

@media (max-width: 1024px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-slideUp {
    animation: slideUp 0.4s ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1280px) {
    .nav-text {
        display: none;
    }

    .nav-link {
        padding: 8px 12px;
    }

    .nav-links {
        gap: 2px;
        height: auto;
    }
}

@media (max-width: 1100px) {
    .search-label {
        display: none;
    }

    .search-pill-btn {
        padding: 8px;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
}

@media (max-width: 1024px) {
    .header-search {
        display: none;
    }

    .header-top {
        height: var(--header-height-mobile);
        border-bottom: none;
    }

    .nav-links {
        display: none;
        position: fixed;
        top: var(--header-height-mobile);
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        background: var(--color-surface);
        flex-direction: column;
        justify-content: flex-start;
        padding: var(--spacing-xl);
        gap: var(--spacing-md);
        z-index: 99999;
        overflow-y: auto;
    }

    .header-bottom {
        display: none !important;
    }

    .nav-links.mobile-open {
        display: flex !important;
        animation: fadeIn 0.2s ease-out;
    }

    .header-actions {
        gap: var(--spacing-sm);
    }

    body {
        padding-top: var(--header-height-mobile);
    }

    .username-text {
        display: none;
    }

    .footer-content {
        flex-direction: column;
    }

    .footer-links {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .main-header {
        border-radius: 0;
    }

    .logo-text {
        font-size: 1.4rem;
    }

    .logo-icon {
        font-size: 1.8rem;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .quiz-options {
        grid-template-columns: 1fr;
    }

    .flashcard-word {
        font-size: 2rem;
    }

    .flashcard-translation {
        font-size: 1.5rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .matching-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .word-list {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .achievement-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Touch-friendly button sizes */
    .btn {
        min-height: 48px;
        padding: var(--spacing-md) var(--spacing-lg);
    }

    .btn-sm {
        min-height: 40px;
    }

    /* Form inputs - larger touch targets */
    input,
    select,
    textarea {
        min-height: 48px;
        font-size: 16px !important;
        /* Prevents iOS zoom */
    }

    /* Cards spacing */
    .dashboard-card,
    .learn-card,
    .quiz-card {
        border-radius: var(--radius-lg);
    }

    /* Hero section mobile */
    .hero {
        min-height: 40vh;
        padding: var(--spacing-2xl) var(--spacing-md);
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    /* Learning modules mobile */
    .learn-container {
        padding: var(--spacing-md);
    }

    .learn-settings {
        padding: var(--spacing-md);
    }

    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }

    .settings-row label {
        min-width: auto;
    }

    /* Quiz options full width */
    .quiz-option {
        padding: var(--spacing-md);
        font-size: 1rem;
    }

    /* Flashcard mobile */
    .flashcard {
        min-height: 280px;
    }

    .flashcard-word {
        font-size: 1.75rem;
    }

    /* Spelling input */
    .spelling-input {
        font-size: 1.25rem;
        padding: var(--spacing-md);
    }

    /* Header mobile */
    .nav-logo {
        gap: var(--spacing-xs);
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    /* Hide user stats on very small screens */
    .user-stats-mini {
        display: none;
    }

    /* Modal mobile */
    .modal-content {
        margin: var(--spacing-md);
        max-height: calc(100vh - 2rem);
        border-radius: var(--radius-xl);
    }

    /* Footer mobile */
    .footer {
        padding: var(--spacing-xl) var(--spacing-md);
    }

    .footer-links {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    /* Heatmap smaller cells */
    .activity-heatmap {
        grid-template-columns: repeat(10, 1fr);
        gap: 2px;
    }

    /* Mastery chart mobile */
    .mastery-label {
        width: 60px;
        font-size: 0.8rem;
    }

    .mastery-count {
        width: 45px;
        font-size: 0.9rem;
    }
}

/* Extra small devices (< 360px) */
@media (max-width: 360px) {
    :root {
        --spacing-xl: 1.5rem;
        --spacing-2xl: 2rem;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .activity-heatmap {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .main-content {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .footer {
        padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
    }
}