:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.8);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --font-cyrillic: 'Playfair Display', serif;
}

[data-theme="light"] {
    --bg-color: #f0f9ff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --accent-color: #0284c7;
    --accent-glow: rgba(2, 132, 199, 0.2);
    --card-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.1);
    --modal-overlay: rgba(255, 255, 255, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Background Gradients */
.background-gradients {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: #06b6d4;
    top: 50%;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: #ec4899;
    bottom: -50px;
    left: 20%;
    animation-delay: -10s;
}

@keyframes move {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(20px, -20px) scale(1.1);
    }
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    /* Reduced padding for mobile */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    /* Sticky header for mobile */
    top: 0;
    z-index: 100;
}

.logo {
    display: none;
    /* Deprecated */
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 0.2s ease;
}

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

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .brand-text {
    background: linear-gradient(to right, #1e293b, #475569);
    -webkit-background-clip: text;
    background-clip: text;
}

.brand-separator {
    color: var(--glass-border);
    font-size: 1.5rem;
    font-weight: 300;
}

.course-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.75rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

[data-theme="light"] .course-badge {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s ease;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    width: 100%;
    flex: 1;
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 1rem;
}

.hero h2 {
    font-size: 2.25rem;
    /* Smaller for mobile */
    margin-bottom: 0.75rem;
    font-weight: 800;
    line-height: 1.1;
}

.hero p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Alphabet Grid - Mobile First (2 columns) */
.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Force 2 cols on mobile */
    gap: 1rem;
    padding-bottom: 4rem;
}

.letter-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    /* Better touch target behavior */
    user-select: none;
    -webkit-user-select: none;
}

.letter-card:active {
    transform: scale(0.95);
}

.letter-card .main-letter {
    font-family: var(--font-cyrillic);
    font-size: 3rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .letter-card .main-letter {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.letter-card .transliteration {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

/* Pagination - Mobile */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 3rem;
    padding: 0.75rem;
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--glass-border);
    flex-wrap: wrap;
    /* Allow wrapping on very small screens */
}

.page-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.page-btn.active {
    background: var(--text-primary);
    color: #0f172a;
    font-weight: 800;
    border-color: transparent;
}

.nav-btn {
    width: auto;
    padding: 0 1rem;
    border-radius: 20px;
}

/* Modal - Mobile First */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: end;
    /* Bottom sheet align for mobile feel */
    z-index: 1000;
    background: var(--modal-overlay);
    backdrop-filter: blur(5px);
    opacity: 1;
    transition: opacity 0.3s ease;
    padding: 0;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #1e293b;
    width: 100%;
    /* Full width on mobile */
    max-width: 800px;
    border-radius: 20px 20px 0 0;
    /* Top rounded corners */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    position: relative;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    /* Don't cover entire screen */
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal Content Stacked (Mobile) */
.learning-view {
    display: grid;
    grid-template-columns: 1fr;
    overflow-y: auto;
    /* Scrollable internal content */
    max-height: calc(90vh - 60px);
}

.letter-side {
    background: linear-gradient(145deg, rgba(30, 41, 59, 1), rgba(15, 23, 42, 1));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    position: relative;
    min-height: 250px;
}

.letter-visual-container {
    height: 10rem;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem;
    position: relative;
    width: 100%;
}

.large-letter {
    font-family: var(--font-cyrillic);
    font-size: 8rem;
    /* Increased size for impact */
    line-height: 1;
    color: white;
    text-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    /* Ensure it centers properly if it's the only child */
    display: flex;
    align-items: center;
    justify-content: center;
}

.large-letter-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
    animation: float 6s ease-in-out infinite;
}

.letter-pronunciation {
    font-size: 1.25rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
}

.play-sound-btn {
    background: var(--accent-color);
    color: #0f172a;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.word-side {
    background: #fff;
    color: #0f172a;
    padding: 2rem 1.5rem 5rem 1.5rem;
    /* Extra bottom padding for nav buttons */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.word-example {
    margin-bottom: 1.5rem;
    text-align: center;
}

.word-cyrillic {
    font-size: 2rem;
    font-weight: 800;
    display: block;
    margin-bottom: 0.25rem;
}

.word-phonetic {
    font-size: 1rem;
    color: var(--accent-color);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.word-latin {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.word-english {
    font-size: 1.1rem;
    color: #475569;
    font-weight: 500;
}

.word-image-container {
    width: 100%;
    aspect-ratio: 1;
    background: #f1f5f9;
    border-radius: 12px;
    overflow: hidden;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 400px;
    /* Prevent it from getting too huge on larger screens */
    margin-left: auto;
    margin-right: auto;
}

.word-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    /* Hidden until loaded */
}

/* Beautiful Fallback for missing images */
.word-fallback {
    display: none;
    /* Hidden by default */
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #475569;
    position: relative;
    overflow: hidden;
}

.word-fallback::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0) 60%);
    top: -50%;
    left: -50%;
    opacity: 0.5;
}

.word-fallback-icon {
    font-family: var(--font-cyrillic);
    font-size: 5rem;
    font-weight: 800;
    color: rgba(15, 23, 42, 0.1);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg) scale(1.5);
    z-index: 1;
}

.word-fallback-text {
    font-size: 1.5rem;
    font-weight: 700;
    z-index: 2;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
}

/* Modal Navigation (Bottom Fixed for Mobile) */
.modal-nav-btn {
    position: absolute;
    bottom: 1.5rem;
    z-index: 50;
    background: rgba(30, 41, 59, 1);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-nav-prev {
    left: 1.5rem;
}

.modal-nav-next {
    right: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Desktop/Tablet Expansions */
@media (min-width: 768px) {
    .app-header {
        padding: 2rem;
    }

    .container {
        padding: 2rem;
    }



    .hero h2 {
        font-size: 3rem;
    }

    .alphabet-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        /* Larger cards */
        gap: 2rem;
    }

    .letter-card:hover {
        transform: translateY(-5px) scale(1.02);
        box-shadow: 0 10px 30px -10px var(--accent-glow);
    }

    /* Modal switches to center floating card */
    .modal {
        align-items: center;
    }

    .modal-content {
        width: 90%;
        border-radius: 30px;
        /* Full rounded */
        animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    @keyframes modalPop {
        from {
            transform: scale(0.9);
            opacity: 0;
        }

        to {
            transform: scale(1);
            opacity: 1;
        }
    }

    .learning-view {
        grid-template-columns: 1.2fr 1.8fr;
        min-height: 500px;
        max-height: none;
    }

    .letter-side {
        padding: 3rem;
        min-height: auto;
    }

    .word-side {
        padding: 3rem;
    }

    .large-letter {
        font-size: 8rem;
    }

    .word-example {
        text-align: left;
    }

    /* Reset Nav Buttons to be on sides */
    .modal-nav-btn {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: white;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
        width: 50px;
        height: 50px;
    }

    .modal-nav-prev {
        left: 20px;
    }

    .modal-nav-next {
        right: 20px;
    }

    .modal-nav-btn:hover {
        background: var(--accent-color);
        color: #0f172a;
    }
}

/* Animations */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}