.glass-card {
    background: var(--color-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--color-glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px var(--color-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    
    /* Performance Optimizations */
    content-visibility: auto;
    contain-intrinsic-size: 250px;
    will-change: transform;
}

.glass-card.interactive {
    cursor: pointer;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}
.glass-card.interactive:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.2);
}

.zoom-card {
    transition: transform 0.3s ease, z-index 0s;
    cursor: zoom-in;
    transform-origin: center;
}
.zoom-card:hover {
    transform: scale(2.5);
    z-index: 100;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

button {
    font-family: var(--font-family);
    font-weight: 600;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background var(--transition-speed) ease;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: #5a67d8; }
.btn-secondary { background: rgba(255,255,255,0.5); color: var(--color-text); }
.btn-secondary:hover { background: rgba(255,255,255,0.8); }
.btn-danger { background: var(--color-danger); color: white; }

input {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-glass-border);
    border-radius: 8px;
    background: rgba(255,255,255,0.5);
    font-family: var(--font-family);
}
input:focus { outline: none; border-color: var(--color-primary); background: white; }

.error-msg { color: #e53e3e; font-weight: 600; margin-top: 1rem; }

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal.hidden { display: none !important; }
.modal-content {
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Montessori Word Banner Fonts */
@font-face {
    font-family: 'ASLHandsByFrank';
    src: url('/static/fonts/AslHandsByFrank-PKqxx.otf') format('opentype');
}
@font-face {
    font-family: 'DeafSamutojj';
    src: url('/static/fonts/DeafSamutojjLisItalianSignLanguage-2OLlX.ttf') format('truetype');
}
@font-face {
    font-family: 'LangageDesSignes';
    src: url('/static/fonts/LangageDesSignes-RpwA.ttf') format('truetype');
}
@font-face {
    font-family: 'ZoeGraffiti';
    src: url('/static/fonts/ZoeGermanyFingeralphabetGraffiti-2vwW.ttf') format('truetype');
}
@font-face {
    font-family: 'HandSign';
    src: url('/static/fonts/Handsign-0l5G.ttf') format('truetype');
}
@font-face {
    font-family: 'HandSignEST';
    src: url('/static/fonts/Handsignest-rwny.ttf') format('truetype');
}

.font-base { font-family: 'ASLHandsByFrank', sans-serif; }
.font-fallback-gen { font-family: 'DeafSamutojj', sans-serif; }
.font-fallback-a { font-family: 'LangageDesSignes', sans-serif; }
.font-fallback-g { font-family: 'ZoeGraffiti', sans-serif; }
.font-fallback-x { font-family: 'HandSign', sans-serif; }
.font-fallback-num { font-family: 'HandSignEST', sans-serif; }
.word-banner-container {
    background-color: #fcfcfc;
    border: 4px solid #4682b4;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    text-align: center;
}
.syllables-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}
.syllable-box {
    background: white;
    border: 2px dashed #b0c4de;
    border-radius: 12px;
    padding: 15px 20px;
    display: flex;
    gap: 8px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: default;
    position: relative;
}

.syllable-box:hover {
    transform: scale(2);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border-color: #7998c9;
    z-index: 10;
}
.letter-column {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.letter-text {
    font-size: 6rem;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
}
.letter-sign {
    font-size: 5.5rem;
    color: #7f8c8d;
    margin-top: 5px;
    text-transform: lowercase;
}
.vowel { color: #E74C3C; } /* Rojo */
.consonant { color: #3498DB; } /* Azul */
.definition-text {
    font-size: 1.8rem;
    color: #555;
    margin-top: 10px;
}

/* Main Emoji */
.main-emoji {
    font-size: clamp(8rem, 15vw, 18rem);
    line-height: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
}

/* Pixabay Premium Cards */
.premium-card {
    background: white;
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid #f4f6f7;
}
.premium-card:hover {
    transform: scale(2.5) !important;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5) !important;
    border-color: #aed6f1;
    z-index: 9999 !important;
}
/* Escalate z-index on parent container for the zoom effect */
.pixabay-grid:has(.premium-card:hover) {
    z-index: 9999 !important;
}
.media-zoom-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}
.premium-card-media {
    width: 100%;
    object-fit: cover;
    aspect-ratio: 4/3;
    background-color: #f8f9fa;
    display: block;
}
.premium-card-label {
    margin-top: 12px;
    margin-bottom: 4px;
    font-size: 1rem;
    color: #555;
    font-family: sans-serif;
    text-align: center;
    line-height: 1.2;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .grid-2col {
        grid-template-columns: repeat(2, 1fr);
    }
}

.visual-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

@media (max-width: 768px) {
    .visual-grid { 
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); 
        gap: 0.75rem;
    }
    .letter-text { font-size: 3rem !important; }
    .letter-sign { font-size: 2.5rem !important; }
    .syllable-box { padding: 8px 12px !important; gap: 4px !important; }
    .definition-text { font-size: 1.2rem !important; }
    .main-emoji { font-size: 8rem !important; justify-content: center !important; }
    .glass-card { padding: 1.2rem; }
    button { padding: 0.6rem 1rem; font-size: 0.9rem; }
    .vocab-char-sign { font-size: 2rem !important; }
}

.vocab-title-container {
    container-type: inline-size;
    width: 100%;
}

.vocab-title-text { 
    font-size: 4rem; /* fallback for emoji/button */
    white-space: nowrap;
}

.vocab-word-span {
    font-size: min(4rem, calc(80cqi / var(--char-count, 8)));
    transition: transform 0.3s ease, color 0.3s ease;
    display: inline-block;
    cursor: zoom-in;
}

.vocab-word-span:hover {
    transform: scale(1.15);
    color: #2980b9;
    text-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.vocab-char-main { font-size: 3.5rem; }
.vocab-char-sign { font-size: 4rem; }

@media (max-width: 1024px) {
    .vocab-title-text { font-size: 2.5rem; }
    .vocab-char-main { font-size: 2.5rem; }
    .vocab-char-sign { font-size: 3rem; }
}

.btn-vocab-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.btn-vocab-nav:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.btn-vocab-nav.prev {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--color-primary);
}
.btn-vocab-nav.prev:hover {
    background-color: rgba(79, 70, 229, 0.2);
}
.btn-vocab-nav.next {
    background-color: var(--color-primary);
    color: white;
}
.btn-vocab-nav.next:hover {
    background-color: #4338ca; /* Slightly darker indigo */
}

.vocab-nav-container {
    padding: 15px 20px;
}

@media (max-width: 768px) {
    .btn-vocab-nav {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
        gap: 0.3rem;
    }
    .vocab-nav-container {
        padding: 10px;
    }
    .vocab-nav-status {
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    .vocab-btn-text {
        display: none;
    }
    .btn-vocab-nav {
        padding: 0.4rem;
        border-radius: 50%; /* Make them perfectly circular for just emojis */
    }
    .vocab-nav-status {
        font-size: 0.8rem;
    }
    .vocab-nav-container {
        padding: 8px 5px;
    }
}

/* Typography Ribbon (Vocabulario) */
.typo-variant-box {
    background: white;
    border: 2px dashed #b0bec5;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 1.5rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    cursor: default;
}
.typo-variant-box:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    border-color: #8faacd;
}

/* TTS Buttons */
.tts-btn {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.1));
}
.tts-btn:hover {
    transform: scale(1.2) rotate(-5deg);
    filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.15));
}
.tts-btn:active {
    transform: scale(0.9);
}

/* Game Animations & Errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.shake-error {
    animation: shake 0.4s ease-in-out;
    border-color: #e74c3c !important;
    background-color: #fdf5f5 !important;
}

.locked-card {
    opacity: 0.8;
    cursor: default !important;
    border-color: #27ae60 !important;
    background-color: #f0fdf4 !important;
}

.toast-message {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: var(--card-bg, #ffffff);
    color: var(--text-color, #2c3e50);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    pointer-events: none;
    border: 2px solid transparent;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-message.error {
    border-color: #e74c3c;
    color: #c0392b;
}

.toast-message.success {
    border-color: #27ae60;
}

/* Memory Game Enhancements */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 2rem auto;
    max-width: 600px;
}

.memory-card {
    width: 100%;
    aspect-ratio: 1/1;
    perspective: 1000px;
    cursor: pointer;
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-front, .memory-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    overflow: hidden;
}

.memory-card-front {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-size: 3rem;
}

.memory-card-back {
    background: white;
    transform: rotateY(180deg);
    border: 3px solid #3498db;
    padding: 10px;
}

.memory-card-back img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.memory-card.match-success .memory-card-back {
    border-color: #27ae60;
    box-shadow: 0 0 15px rgba(39, 174, 96, 0.5);
    background: #eafaf1;
}

.memory-card.locked {
    pointer-events: none;
}

.memory-text {
    font-size: 1.5rem;
    color: #2c3e50;
    word-break: break-word;
    text-align: center;
}

@media (max-width: 600px) {
    .memory-grid {
        gap: 8px;
    }
    
    .memory-text {
        font-size: 1rem;
    }
    
    .memory-card-front {
        font-size: 2rem;
    }
    
    .memory-card-back {
        padding: 5px;
    }
}

/* Dactylology Output Area (Search Input Mirror) */
#dactilologia-output-area {
    container-type: inline-size;
}
#dactilologia-output-area .sign-glyph {
    font-size: min(5rem, calc(90cqi / var(--char-count, 10))) !important;
}
#dactilologia-output-area .sign-letter {
    font-size: min(1.2rem, calc(25cqi / var(--char-count, 10))) !important;
}

/* Dactylology Zoom Interaction */
.sign-phrase-inline-zoom {
    cursor: zoom-in;
}
.sign-phrase-inline-zoom .sign-glyph {
    font-size: min(4rem, calc(90cqi / var(--char-count, 10))) !important;
}
.sign-phrase-inline-zoom .sign-letter {
    font-size: min(1.1rem, calc(25cqi / var(--char-count, 10))) !important;
}

/* Lightbox Modal Card */
.lightbox-zoom-card {
    pointer-events: none;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.15));
    padding: 30px;
    background: white;
    border-radius: 24px;
    border: 1px solid rgba(0,0,0,0.05);
    width: 90vw;
    max-width: 900px;
    display: flex;
    justify-content: center;
    container-type: inline-size;
}

.lightbox-zoom-card .sign-word {
    flex-wrap: nowrap;
    overflow: hidden;
    width: 100%;
}

.lightbox-zoom-card .sign-glyph {
    font-size: min(8rem, calc(95cqi / var(--char-count, 10))) !important;
}

.lightbox-zoom-card .sign-letter {
    font-size: min(2rem, calc(25cqi / var(--char-count, 10))) !important;
}

/* Dactylology Module Styles */
.sign-word {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 0 10px;
    padding: 10px 0;
}

.sign-char {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.sign-glyph {
    font-size: 5rem;
    line-height: 1;
    color: #1e293b;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.sign-letter {
    font-size: 1.2rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
}

@media (max-width: 1024px) {
    .sign-glyph { font-size: 4rem; }
    .sign-letter { font-size: 1.1rem; }
}

@media (max-width: 768px) {
    .sign-glyph { font-size: 3rem; }
    .sign-letter { font-size: 0.95rem; }
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.keyboard-container.active {
    transform: translateY(0) !important;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 900px;
    margin-bottom: 8px;
}

.key-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: white;
    padding: 12px 18px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 65px;
    transition: all 0.2s;
}

.key-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    border-color: #38bdf8;
}

.key-btn:active {
    transform: translateY(1px);
}

.key-sign {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: 5px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.key-label {
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: #bae6fd;
}

.key-space {
    width: 280px;
}

.key-backspace {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.5);
}

.key-backspace:hover {
    background: rgba(231, 76, 60, 0.5);
    border-color: rgba(231, 76, 60, 0.7);
}

.advanced-filters-panel {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 500px;
    opacity: 1;
    overflow-y: auto;
    transition: all 0.3s ease-in-out;
}
.advanced-filters-panel.hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
    margin: 0;
    overflow: hidden;
}

.filter-group-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.8rem;
    letter-spacing: 0.05em;
}

.filter-chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(5px);
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.filter-chip:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.filter-chip.active {
    background: #3b82f6;
    color: white;
    border-color: #2563eb;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.filter-chip.active .chip-icon {
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
}
