:root {
    --bg-color: #f0f4f8;
    /* Fallback */
    --text-color: #1a202c;
    /* Darker for better contrast on glass */
    --card-bg: rgba(255, 255, 255, 0.15);
    /* Glass base */
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --primary-color: #4338ca;
    /* Deep Indigo for better visibility */
    --accent-color: #dd6b20;
    /* Darker Orange */
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;

    /* Fluid spacing and type */
    --header-h1-size: clamp(1.8rem, 5vw, 3rem);
    --card-font-size: clamp(2rem, 4vw, 3.5rem);
    --grid-gap: clamp(0.75rem, 2vw, 2rem);
    --container-padding: clamp(1rem, 3vw, 2rem);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: var(--container-padding);
    position: relative;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* Background Video Styling */
#bg-video {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
    width: 100%;
    height: 100%;
    z-index: -1;
    object-fit: cover;
}

/* Overlay to ensure text readability if video is too bright/busy */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(240, 244, 248, 0.4);
    z-index: -1;
    pointer-events: none;
    /* Allow clicks to pass through */
}

.app-container {
    width: 100%;
    max-width: 1200px;
    text-align: center;
    /* Ensure container doesn't get too squeezed on mobile */
    min-width: 0;
}

header {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

header h1 {
    font-size: var(--header-h1-size);
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    line-height: 1.2;
}

header p {
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    font-weight: 500;
    color: #2d3748;
}

/* Grid Layout - Mobile First Approach */
.alphabet-grid {
    display: grid;
    gap: var(--grid-gap);
    padding: 0.5rem;

    /* Default: 2 columns for very small screens */
    grid-template-columns: repeat(2, 1fr);
}

/* Mobile: Larger phones (3 columns) */
@media (min-width: 400px) {
    .alphabet-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet: Portrait (4 columns) */
@media (min-width: 600px) {
    .alphabet-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Tablet: Landscape / Small Desktop (5-6 columns) */
@media (min-width: 900px) {
    .alphabet-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Desktop: Wide (8 columns) */
@media (min-width: 1200px) {
    .alphabet-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

/* Glassmorphism Letter Cards */
.letter-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    border-radius: 1rem;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--card-font-size);
    font-weight: 700;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
    /* For ripple or contain effects */
}

.letter-card::after {
    /* Shine effect hint */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.letter-card:hover::after {
    opacity: 1;
}

.letter-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    color: var(--primary-color);
    z-index: 10;
}

.letter-card:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.5);
}

.letter-card.speaking {
    background: rgba(67, 56, 202, 0.85);
    /* Primary color opacity */
    color: white;
    transform: scale(1.1);
    border-color: transparent;
    box-shadow: 0 0 20px rgba(67, 56, 202, 0.4);
    text-shadow: none;
    z-index: 20;
    /* Ensure active card is above others */
}

/* Special Emphasis for Ñ */
.letter-card[data-letter="Ñ"] {
    color: var(--accent-color);
    border: 2px solid rgba(237, 137, 54, 0.3);
}

.letter-card[data-letter="Ñ"]:hover {
    background: rgba(237, 137, 54, 0.2);
    border-color: var(--accent-color);
    color: #c05621;
}

.letter-card[data-letter="Ñ"].speaking {
    background: var(--accent-color);
    color: white;
}

/* Status Message */
.status-message {
    margin-top: 2rem;
    min-height: 1.5rem;
    font-size: 1rem;
    color: #e53e3e;
    font-weight: bold;
    text-shadow: 0 1px 1px white;
}

/* Accessibility Focus */
.letter-card:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 4px;
}

/* --- Mobile Specific Adjustments --- */

@media (max-width: 480px) {

    /* Simpler Header on small screens */
    header {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }

    /* Adjust video position if necessary (often fixed is fine, but sometimes needs tweaks) */
    #bg-video {
        /* Ensure video plays nicely on mobile without quirky zoom */
        height: 100vh;
    }

    body {
        /* Smaller padding on mobile edges */
        padding: 1rem 0.5rem;
    }
}

/* Fix for landscape on mobile phones - reduce height issues */
@media (max-height: 500px) and (orientation: landscape) {
    header h1 {
        font-size: 1.5rem;
    }

    header {
        margin-bottom: 1rem;
        padding: 0.5rem;
    }

    .alphabet-grid {
        gap: 0.5rem;
    }

    .letter-card {
        font-size: 1.5rem;
    }
}