/* ===== Modern Color Palette ===== */
:root {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-bg: #eef2ff;
    --primary-rgb: 99, 102, 241;
    --primary-text: #4f46e5;     /* accessible text: 6.3:1 on white */

    /* Secondary Colors */
    --secondary: #10b981;
    --secondary-light: #34d399;
    --secondary-dark: #059669;

    /* Accent Colors */
    --accent: #f59e0b;
    --accent-rgb: 245, 158, 11;
    --warning: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
    --success-rgb: 16, 185, 129;
    --info: #3b82f6;
    --info-rgb: 59, 130, 246;

    /* Game Accent Colors */
    --game-teal: #14b8a6;
    --game-teal-rgb: 20, 184, 166;
    --game-cyan: #06b6d4;
    --game-cyan-rgb: 6, 182, 212;
    --game-pink: #ec4899;
    --game-pink-rgb: 236, 72, 153;
    --game-orange: #f97316;
    --game-orange-rgb: 249, 115, 22;
    --game-indigo: #6366f1;
    --game-indigo-rgb: 99, 102, 241;
    --game-lime: #84cc16;
    --game-lime-rgb: 132, 204, 22;
    --game-amber: #f59e0b;
    --game-amber-rgb: 245, 158, 11;
    --game-rose: #f43f5e;
    --game-rose-rgb: 244, 63, 94;

    /* Neutral Colors */
    --white: #ffffff;
    --on-primary: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --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);

    /* Semantic Color Tints */
    --green-50: #f0fdf4;
    --green-200: #bbf7d0;
    --green-400: #4ade80;
    --green-700: #15803d;
    --blue-50: #eff6ff;
    --blue-200: #bfdbfe;
    --blue-400: #60a5fa;
    --blue-700: #1d4ed8;
    --yellow-50: #fefce8;
    --yellow-200: #fef08a;
    --yellow-400: #facc15;
    --yellow-700: #a16207;
    --red-50: #fef2f2;
    --red-200: #fecaca;
    --red-400: #f87171;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    --purple-50: #faf5ff;
    --purple-700: #7e22ce;

    /* RGB variants for rgba() usage */
    --white-rgb: 255, 255, 255;
    --gray-900-rgb: 17, 24, 39;
    --danger-rgb: 239, 68, 68;
    --warning-rgb: 245, 158, 11;
    --green-rgb: 34, 197, 94;
    --blue-rgb: 59, 130, 246;
    --purple-rgb: 168, 85, 247;
    --red-rgb: 239, 68, 68;
    --yellow-rgb: 234, 179, 8;

    /* Primary extras */
    --primary-border: #c7d2fe;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* State Colors */
    --success-bg: #d1fae5;
    --success-border: #86efac;
    --success-text: #065f46;
    --danger-bg: #fee2e2;
    --danger-border: #fecaca;
    --danger-text: #991b1b;
    --danger-hover: #dc2626;
    --info-bg: #e3f2fd;
    --info-border: #1976d2;
    --info-text: #1976d2;
    --error-bg: #fef2f2;

    /* Semantic backgrounds */
    --hint-bg: rgba(245, 158, 11, 0.06);
    --explain-bg: rgba(59, 130, 246, 0.06);

    /* Semantic text aliases */
    --text-dark: var(--gray-900);
    --text-light: var(--gray-500);
    --success-light: #d1fae5;

    /* Overlay */
    --modal-overlay: rgba(0, 0, 0, 0.5);

    /* Toast */
    --toast-bg: #1f2937;
    --toast-text: #f9fafb;

    /* Typography */
    --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

    /* Transitions */
    --transition: all 0.2s ease;
    --transition-fast: all 0.15s ease;

    /* Mobile ergonomics */
    --touch-target-min: 44px;

    /* Global floating safe-area system */
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --floating-badge-size: 3.25rem;
    --floating-offset-bottom: calc(1.5rem + var(--safe-area-bottom));
    --floating-offset-right: calc(1.5rem + var(--safe-area-right));
    --floating-badge-clearance: calc(var(--floating-offset-right) + var(--floating-badge-size) + 0.75rem);

    /* Heading accent */
    --heading-accent: var(--gray-900);

    /* Lernpfad map surface (forced-dark) */
    --lernpfad-dark: #1e1e3a;
    --lernpfad-dark-rgb: 30, 30, 58;

    /* Coming-soon badge */
    --coming-soon-bg: #996515;

    /* ===== Design Tokens (UX Harmonization) ===== */

    /* Spacing Scale */
    --space-2xs: 0.25rem;   /* 4px */
    --space-xs: 0.5rem;     /* 8px */
    --space-sm: 0.75rem;    /* 12px */
    --space-md: 1rem;       /* 16px */
    --space-lg: 1.25rem;    /* 20px */
    --space-xl: 1.5rem;     /* 24px */
    --space-2xl: 2rem;      /* 32px */
    --space-3xl: 3rem;      /* 48px */

    /* Typography Scale (Mobile-optimized) */
    --text-2xs: 0.75rem;    /* 12px — badges/kicker only */
    --text-xs: 0.8125rem;   /* 13px — meta, timestamps */
    --text-sm: 0.875rem;    /* 14px — descriptions, secondary */
    --text-base: 1rem;      /* 16px — body, card titles */
    --text-md: 1.125rem;    /* 18px — section headings */
    --text-lg: 1.25rem;     /* 20px — page headings */
    --text-xl: 1.5rem;      /* 24px — hero headings */
    --text-2xl: 1.875rem;   /* 30px — large headings */

    /* Container Widths */
    --container-narrow: 640px;
    --container-medium: 800px;
    --container-wide: 1000px;

    /* Card Interaction Tokens */
    --card-hover-lift: -4px;
    --card-focus-lift: -2px;
    --card-gradient-angle: 160deg;
    --card-gradient-flat: 180deg;
    --card-border-accent: 3px;
    --card-stagger-step: 0.05s;

    /* Icon Container Sizes */
    --icon-sm: 2.25rem;     /* 36px */
    --icon-md: 2.75rem;     /* 44px */
    --icon-lg: 3rem;        /* 48px */
    --icon-xl: 3.75rem;     /* 60px */
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-bg: #1e1b4b;
    --primary-rgb: 99, 102, 241;
    --primary-text: #818cf8;     /* accessible text: 5.7:1 on dark bg */

    /* Secondary Colors */
    --secondary: #34d399;
    --secondary-light: #6ee7b7;
    --secondary-dark: #10b981;

    /* Accent Colors */
    --accent: #af8518;
    --accent-rgb: 175, 133, 24;
    --warning: #af8518;
    --danger: #f87171;
    --success: #34d399;
    --success-rgb: 52, 211, 153;
    --info: #60a5fa;
    --info-rgb: 96, 165, 250;

    /* Game Accent Colors */
    --game-teal: #2dd4bf;
    --game-teal-rgb: 45, 212, 191;
    --game-cyan: #22d3ee;
    --game-cyan-rgb: 34, 211, 238;
    --game-pink: #f472b6;
    --game-pink-rgb: 244, 114, 182;
    --game-orange: #fb923c;
    --game-orange-rgb: 251, 146, 60;
    --game-indigo: #818cf8;
    --game-indigo-rgb: 129, 140, 248;
    --game-lime: #a3e635;
    --game-lime-rgb: 163, 230, 53;
    --game-amber: #fbbf24;
    --game-amber-rgb: 251, 191, 36;
    --game-rose: #fb7185;
    --game-rose-rgb: 251, 113, 133;

    /* Neutral Colors (inverted) */
    --white: #1a1b2e;
    --on-primary: #ffffff;
    --gray-50: #1e2035;
    --gray-100: #252740;
    --gray-200: #2e3150;
    --gray-300: #3d4060;
    --gray-400: #6b7094;
    --gray-500: #9196b0;
    --gray-600: #b0b5cc;
    --gray-700: #cdd1e0;
    --gray-800: #e2e5f0;
    --gray-900: #f1f2f6;

    /* Semantic Color Tints (dark) */
    --green-50: rgba(52, 211, 153, 0.1);
    --green-200: rgba(52, 211, 153, 0.3);
    --green-400: #4ade80;
    --green-700: #4ade80;
    --blue-50: rgba(96, 165, 250, 0.1);
    --blue-200: rgba(96, 165, 250, 0.3);
    --blue-400: #60a5fa;
    --blue-700: #60a5fa;
    --yellow-50: rgba(251, 191, 36, 0.1);
    --yellow-200: rgba(251, 191, 36, 0.3);
    --yellow-400: #facc15;
    --yellow-700: #facc15;
    --red-50: rgba(248, 113, 113, 0.1);
    --red-200: rgba(248, 113, 113, 0.3);
    --red-400: #f87171;
    --red-600: #f87171;
    --red-700: #f87171;
    --purple-50: rgba(167, 139, 250, 0.1);
    --purple-700: #c084fc;
    --primary-border: #3730a3;

    /* RGB variants (dark) */
    --white-rgb: 26, 27, 46;
    --gray-900-rgb: 241, 242, 246;
    --danger-rgb: 248, 113, 113;
    --warning-rgb: 251, 191, 36;
    --green-rgb: 52, 211, 153;
    --blue-rgb: 96, 165, 250;
    --purple-rgb: 167, 139, 250;
    --red-rgb: 248, 113, 113;
    --yellow-rgb: 251, 191, 36;

    /* State Colors */
    --success-bg: rgba(52, 211, 153, 0.15);
    --success-border: #065f46;
    --success-text: #6ee7b7;
    --danger-bg: rgba(248, 113, 113, 0.15);
    --danger-border: #991b1b;
    --danger-text: #fca5a5;
    --danger-hover: #ef4444;
    --info-bg: rgba(96, 165, 250, 0.15);
    --info-border: #60a5fa;
    --info-text: #93c5fd;
    --error-bg: rgba(248, 113, 113, 0.1);

    /* Semantic backgrounds */
    --hint-bg: rgba(251, 191, 36, 0.08);
    --explain-bg: rgba(96, 165, 250, 0.08);

    /* Semantic text aliases */
    --text-dark: var(--gray-900);
    --text-light: var(--gray-500);
    --success-light: rgba(52, 211, 153, 0.15);

    /* Overlay */
    --modal-overlay: rgba(0, 0, 0, 0.7);

    /* Toast */
    --toast-bg: #111827;
    --toast-text: #e5e7eb;

    /* Shadows (stronger for dark surfaces) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 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-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);

    /* Heading accent */
    --heading-accent: #e2b94e;

    /* Lernpfad map surface (forced-dark) */
    --lernpfad-dark: #12132a;
    --lernpfad-dark-rgb: 18, 19, 42;

    /* Coming-soon badge */
    --coming-soon-bg: #7a5110;

    /* Design Tokens — inherited from :root, no overrides needed */
}

@media (max-width: 480px) {
    :root {
        --floating-badge-size: 2.75rem;
        --floating-offset-bottom: calc(1rem + var(--safe-area-bottom));
        --floating-offset-right: calc(1rem + var(--safe-area-right));
    }
}
