/* ===== MAIN UI THEME ===== */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Patrick+Hand&display=swap');

/* Root variables for new theme */
:root {
    /* Color palette */
    --background-color: #E0F2FE;
    --primary-color: #42A5F5;
    --primary-dark: #1976D2;
    --primary-light: rgba(66, 165, 245, 0.1);
    --secondary-color: #FFC107;
    --tertiary-color: #81C784;
    --text-color: #212121;
    --light-gray: #E0E0E0;
    --white: #FFFFFF;
    --error-color: #F44336;
    --success-color: #4CAF50;
    --hint-bg-color: #ebf8ec; /* Light green background for hint */
    --hint-border-color: #81C784; /* Green border for hint */
    
    /* Font variables */
    --font-family-primary: 'Quicksand', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-secondary: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
    
    /* Other variables */
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-xl: 32px;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
    --font-scale: 1;
    
    /* Spacing system */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

/* Base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family-primary);
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== TYPOGRAPHY ===== */
h1 {
    font-family: var(--font-family-secondary);
    font-size: calc(2.5rem * var(--font-scale));
    text-align: center;
    margin: 0.5rem 0;
    color: var(--primary-color);
    letter-spacing: 1px;
    line-height: 1.2;
}

h2 {
    font-family: var(--font-family-secondary);
    font-size: calc(1.8rem * var(--font-scale));
    text-align: center;
    margin: 1rem 0;
    color: var(--primary-color);
    line-height: 1.25;
}

h3 {
    font-family: var(--font-family-primary);
    font-weight: 600;
    font-size: calc(1.2rem * var(--font-scale));
    margin: 0.5rem 0;
    color: var(--text-color);
    text-align: center;
    width: 100%;
    line-height: 1.3;
}

p {
    font-family: var(--font-family-primary);
    line-height: 1.6;
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    min-height: 100vh;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--white);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
}

.screen.active {
    display: flex;
}

/* ===== GAME AREA ===== */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex-grow: 1;
    padding: var(--spacing-md) var(--spacing-md) 0.5rem;
    background-color: var(--white);
    border-radius: var(--border-radius-md);
}

.question {
    font-size: calc(1.4rem * var(--font-scale));
    font-family: var(--font-family-secondary);
    text-align: center;
    margin-bottom: var(--spacing-sm);
    margin-top: 0.5rem;
    color: var(--text-color);
    line-height: 1.3;
}

/* ===== PROGRESS INDICATOR ===== */
.progress-indicator {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    background-color: rgba(66, 165, 245, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
    width: auto;
    display: inline-block;
}

/* ===== ANIMAL CONTAINER ===== */
.animal-container {
    background-color: white;
    border-radius: 50%;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem;
    position: relative;
    overflow: visible; /* Changed from hidden to allow share button to be visible */
    box-shadow: var(--shadow-md);
    border: 3px solid var(--primary-color);
}

.image-container {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
}

.animal-image {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.3s ease;
}

/* Animation for correct answer */
.animal-image.celebration {
    animation: celebration 0.6s ease;
}

@keyframes celebration {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* ===== ANIMAL SHARE BUTTON ===== */
.animal-share-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    z-index: 10; /* Ensure it's above the animal container */
    opacity: 0.9;
}

.animal-share-btn:hover {
    background-color: rgba(255, 255, 255, 1);
    transform: scale(1.15);
    opacity: 1;
    box-shadow: var(--shadow-lg);
}

/* ===== LEARNING MODE TOGGLE ===== */
.learning-toggle-container {
    margin: 0.25rem 0 0.4rem;
    text-align: center;
    width: 100%;
    display: flex;
    justify-content: center;
}

.learning-mode-toggle {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: rgba(66, 165, 245, 0.15);
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.learning-mode-toggle:hover {
    background-color: rgba(66, 165, 245, 0.25);
}

.learning-mode-toggle input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* ===== LEARNING HINT STYLING ===== */
.learning-hint {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
    background-color: var(--hint-bg-color);
    border-radius: var(--border-radius-md);
    padding: 0.6rem 1rem;
    margin: 0.25rem auto 0.5rem;
    width: auto;
    max-width: 400px;
    min-width: 220px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
    border-left: 4px solid var(--hint-border-color);
    line-height: 1.5;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== WORD DISPLAY ===== */
.word-display {
    font-size: calc(1.8rem * var(--font-scale));
    font-family: var(--font-family-secondary);
    letter-spacing: 4px;
    margin: 0.4rem 0;
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    order: 2; /* Ensure it appears before keyboard */
    min-height: 40px;
}

/* First letter highlighting */
.first-letter {
    color: var(--success-color);
    font-weight: bold;
    text-decoration: underline;
    font-size: 110%;
}

/* ===== KEYBOARD STYLING ===== */
.keyboard {
    width: 100%;
    max-width: 500px;
    margin: 0.25rem auto;
    padding: 0;
    order: 3; /* Ensure it appears after word display */
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
    width: 100%;
    gap: 4px; /* Reduced gap for better mobile fit */
}

.key {
    height: 48px;
    min-width: 9%; /* Use percentage-based width for better scaling */
    max-width: 40px;
    flex: 1;
    margin: 0;
    padding: 0;
    background-color: var(--white);
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family-primary);
    font-size: calc(1.1rem * var(--font-scale));
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    color: var(--text-color);
}

.key:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.key:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: var(--shadow-sm);
}

.key:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.key:focus {
    outline: 3px solid rgba(66, 165, 245, 0.5);
    outline-offset: 2px;
    z-index: 1;
}

/* Vowel keys */
.key.vowel {
    background-color: rgba(176, 216, 240, 0.7);
    font-weight: 700;
}

.key.vowel:hover:not(:disabled) {
    background-color: rgba(176, 216, 240, 0.85);
}

/* Keyboard key states */
.key.correct {
    background-color: var(--success-color);
    color: var(--white);
}

.key.wrong {
    color: var(--error-color);
    border: 2px solid var(--error-color);
}

/* ===== FEEDBACK TEXT ===== */
#feedback-text {
    position: absolute;
    bottom: -40px;
    font-size: calc(1.4rem * var(--font-scale));
    font-family: var(--font-family-secondary);
    color: var(--error-color);
    font-weight: bold;
    text-align: center;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-10px);}
    60% {transform: translateY(-5px);}
}

/* ===== BUTTONS ===== */
.primary-btn {
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius-md);
    padding: 0.85rem 2.2rem;
    font-size: calc(1.1rem * var(--font-scale));
    font-family: var(--font-family-primary);
    font-weight: 600;
    cursor: pointer;
    margin: var(--spacing-lg) 0;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    min-height: 48px;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.primary-btn:active {
    transform: translateY(1px);
    box-shadow: var(--shadow-sm);
}

.secondary-btn {
    background-color: var(--light-gray);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius-md);
    padding: 0.85rem 2.2rem;
    font-size: calc(1rem * var(--font-scale));
    font-family: var(--font-family-primary);
    font-weight: 600;
    cursor: pointer;
    margin: var(--spacing-md) 0;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.secondary-btn:hover {
    background-color: #D5D5D5;
    transform: translateY(-2px);
}

/* Back button styling */
.back-btn {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background-color: rgba(66, 165, 245, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Button container for dual buttons */
.button-container {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    margin: var(--spacing-md) 0;
}

/* ===== FOOTER ===== */
footer {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid rgba(66, 165, 245, 0.2);
}

/* Icon buttons */
.icon-btn {
    background: none;
    border: none;
    padding: 0.6rem;
    margin: 0 0.5rem;
    color: var(--primary-color);
    font-size: calc(0.9rem * var(--font-scale));
    font-family: var(--font-family-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
    min-height: 44px;
}

.icon-btn:hover {
    background-color: rgba(66, 165, 245, 0.1);
}

.icon-btn .icon {
    font-size: 1.3rem;
    margin-right: 0.25rem;
}

.copyright {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: var(--spacing-lg);
    color: rgba(33, 33, 33, 0.7);
}

/* ===== MODAL STYLING ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal.show-on-start {
    display: flex;
}

.modal-content {
    background-color: var(--white);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.modal-content p {
    font-family: var(--font-family-secondary);
    font-size: calc(1.2rem * var(--font-scale));
    margin: var(--spacing-md) 0;
    color: var(--text-color);
    line-height: 1.6;
}

.modal-content .primary-btn {
    margin: 1rem auto 0.5rem;
    min-width: 120px;
}

.modal-content h2,
.modal-content h3 {
    font-family: var(--font-family-secondary);
    font-size: calc(1.8rem * var(--font-scale));
    text-align: center;
    margin: var(--spacing-md) 0;
    color: var(--primary-color);
}

/* ===== ACHIEVEMENT BADGES ===== */
.achievement-badge {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    overflow: visible;
}

.achievement-badge:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    z-index: 1;
}

.achievement-badge .icon {
    font-size: calc(2.2rem * var(--font-scale));
    margin-bottom: 0.5rem;
    margin-top: -0.2rem;
    z-index: 2;
}

.achievement-badge .name {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.8rem;
    line-height: 1.2;
    width: auto;
    min-width: 75%;
    max-width: 95%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 3;
}

.achievement-badge.locked {
    background-color: var(--light-gray);
    color: rgba(33, 33, 33, 0.5);
    opacity: 0.8;
}

.achievement-badge.locked .name {
    background-color: rgba(224, 224, 224, 0.9);
    color: rgba(0, 0, 0, 0.6);
}

.achievement-badge.new {
    animation: pulse 1.5s infinite;
}

.achievement-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--spacing-lg);
    justify-content: center;
    margin: var(--spacing-lg) auto;
    width: 100%;
    max-width: 500px;
    padding: 0 var(--spacing-md);
}

/* Achievement share button */
.achievement-share-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--secondary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 4;
    opacity: 0.9;
}

.achievement-badge:hover .achievement-share-btn {
    opacity: 1;
}

/* ===== SHARING MODAL ===== */
.sharing-content {
    padding: 1.5rem;
    text-align: center;
}

.sharing-content p {
    margin: 1rem 0;
    text-align: center;
    font-size: 1.2rem;
    font-family: var(--font-family-secondary);
    max-height: 180px;
    overflow-y: auto;
    line-height: 1.5;
    padding: 0 0.5rem;
    word-break: break-word;
}

/* URL display in share text */
.sharing-content p .url {
    display: block;
    margin-top: 0.5rem;
    font-family: var(--font-family-primary);
    font-size: 1rem;
    color: var(--primary-color);
    word-break: break-all;
}

.share-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 0.75rem;
    margin: 1.25rem auto;
    max-width: 300px;
}

.share-btn {
    width: 100%;
    padding: 0.9rem 1.5rem;
    background-color: var(--white);
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    font-size: calc(0.95rem * var(--font-scale));
    font-family: var(--font-family-primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    transition: all 0.2s ease;
    margin: 0;
    min-height: 48px;
}

.share-btn:hover {
    background-color: rgba(66, 165, 245, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.share-btn .icon {
    margin-right: 0.8rem;
    font-size: 1.2rem;
}

/* Twitter button */
.share-btn.twitter-btn {
    border-color: #1DA1F2;
    color: #1DA1F2;
}

.share-btn.twitter-btn:hover {
    background-color: rgba(29, 161, 242, 0.1);
}

/* Facebook button */
.share-btn.facebook-btn {
    border-color: #4267B2;
    color: #4267B2;
}

.share-btn.facebook-btn:hover {
    background-color: rgba(66, 103, 178, 0.1);
}

/* Copy button */
.share-btn.copy-btn {
    border-color: #616161;
    color: #616161;
}

.share-btn.copy-btn:hover {
    background-color: rgba(97, 97, 97, 0.1);
}

/* Share container in score screen */
.share-container {
    text-align: center;
    width: 100%;
}

.share-container h3 {
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-xs);
    text-align: center;
    width: 100%;
}

/* ===== CONFETTI ANIMATION ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: fall linear forwards;
}

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ===== SCORE SCREEN ===== */
.score-container {
    text-align: center;
    margin: var(--spacing-lg) 0;
    padding: var(--spacing-lg);
    background-color: rgba(66, 165, 245, 0.1);
    border-radius: var(--border-radius-lg);
    width: 100%;
}

.correct {
    color: var(--success-color);
    font-weight: bold;
}

.wrong {
    color: var(--error-color);
    font-weight: bold;
}

.initials-input {
    margin: var(--spacing-lg) 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.initials-field {
    text-align: center;
    font-size: calc(1.5rem * var(--font-scale));
    font-family: var(--font-family-primary);
    font-weight: 700;
    padding: 0.5rem;
    width: 120px;
    margin: var(--spacing-md) 0;
    text-transform: uppercase;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

/* ===== LEADERBOARD ===== */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 0.8rem;
    text-align: center;
    font-family: var(--font-family-primary);
}

.leaderboard-table th {
    background-color: var(--primary-color);
    color: var(--white);
    font-weight: 600;
}

.leaderboard-table tr:nth-child(even) {
    background-color: rgba(66, 165, 245, 0.05);
}

.leaderboard-table tr:hover {
    background-color: rgba(66, 165, 245, 0.1);
}

/* ===== ACCESSIBILITY CLASSES ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.keyboard-focus {
    outline: 3px solid #4d90fe;
    outline-offset: 3px;
}

/* High contrast mode */
.high-contrast {
    --primary-color: #0066CC;
    --primary-dark: #004C99;
    --success-color: #008000;
    --error-color: #CC0000;
    --text-color: #000000;
    --white: #FFFFFF;
}

/* Toast message */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    background-color: #424242;
    color: var(--white);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

/* ===== MEDIA QUERIES ===== */
/* Mobile Extra Small */
@media (max-width: 320px) {
    .keyboard {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }
    
    .keyboard-row {
        gap: 2px;
    }
    
    .key {
        height: 38px;
        min-width: 26px;
        max-width: 28px;
        font-size: 0.8rem;
        padding: 0;
    }
    
    .animal-container {
        width: 160px;
        height: 160px;
    }
    
    .animal-share-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
        top: -6px;
        right: -6px;
    }
    
    h1 {
        font-size: calc(1.8rem * var(--font-scale));
    }
    
    .word-display {
        font-size: calc(1.4rem * var(--font-scale));
    }
    
    /* Make all content more compact */
    .game-area {
        padding: 0.5rem 0.5rem 0.25rem;
    }
    
    .learning-hint {
        padding: 0.5rem;
        margin: 0.25rem auto 0.4rem;
        font-size: 0.85rem;
    }
    
    /* Reduce the size of the share buttons */
    .share-btn {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}

/* Mobile Small */
@media (min-width: 321px) and (max-width: 375px) {
    .keyboard {
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .keyboard-row {
        gap: 3px;
    }
    
    .key {
        height: 40px;
        min-width: 30px;
        max-width: 32px;
        font-size: 0.85rem;
        padding: 0;
    }
    
    .animal-container {
        width: 170px;
        height: 170px;
    }
    
    .animal-share-btn {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }
    
    h1 {
        font-size: calc(1.9rem * var(--font-scale));
    }
    
    .word-display {
        font-size: calc(1.5rem * var(--font-scale));
    }
    
    .game-area {
        padding: 0.75rem 0.75rem 0.35rem;
    }
}

/* Mobile Medium */
@media (min-width: 376px) and (max-width: 390px) {
    .keyboard {
        padding: 0;
        width: 100%;
    }
    
    .keyboard-row {
        gap: 3px;
    }
    
    .key {
        height: 42px;
        min-width: 32px;
        max-width: 35px;
        font-size: 0.9rem;
        padding: 0;
    }
    
    .animal-container {
        width: 180px;
        height: 180px;
    }
}

/* Mobile Large */
@media (min-width: 391px) and (max-width: 420px) {
    .keyboard {
        padding: 0;
        width: 100%;
    }
    
    .keyboard-row {
        gap: 4px;
    }
    
    .key {
        height: 44px;
        min-width: 34px;
        max-width: 38px;
        font-size: 0.95rem;
    }
}

/* Larger screens */
@media (min-width: 480px) {
    .share-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 450px;
    }
    
    .share-btn {
        width: auto;
        min-width: 140px;
    }
    
    .keyboard {
        padding: 0 5px;
    }
    
    .keyboard-row {
        gap: 6px;
    }
    
    .key {
        min-width: 38px;
        max-width: 42px;
    }
}

/* Landscape tablet layout */
@media (min-width: 768px) and (orientation: landscape) {
    .game-area {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        max-width: 900px;
    }
    
    .progress-indicator {
        width: 100%;
        order: 1;
    }
    
    .question {
        width: 100%;
        order: 2;
    }
    
    .animal-container {
        order: 3;
        margin-right: var(--spacing-xl);
    }
    
    .learning-toggle-container {
        order: 4;
        width: auto;
        margin-right: var(--spacing-xl);
    }
    
    .learning-hint {
        order: 5;
        margin-right: var(--spacing-xl);
    }
    
    .word-display {
        order: 6;
        width: 100%;
    }
    
    .keyboard {
        order: 7;
        width: 60%;
        max-width: 600px;
        padding: 0 1rem;
    }
    
    .keyboard-row {
        gap: 8px;
    }
    
    .key {
        min-width: 40px;
        max-width: 48px;
        height: 48px;
    }
    
    footer {
        order: 9;
    }
}

/* Portrait orientation specific adjustments for all mobile devices */
@media (orientation: portrait) and (max-width: 428px) {
    .screen {
        padding: 1rem 0.75rem;
    }
    
    .keyboard {
        width: 100%;
        max-width: 100%;
        margin: 0.2rem auto;
    }
    
    /* Ensure keys stay within the screen */
    .key {
        min-width: 0;
        flex: 1;
        font-size: 0.9rem;
        padding: 0;
    }
    
    /* Reduce whitespace */
    .game-area {
        padding-bottom: 0;
    }
    
    /* Make footer more compact */
    footer {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
    }
    
    .icon-btn {
        padding: 0.5rem;
        margin: 0 0.3rem;
    }
    
    .copyright {
        margin-top: 0.8rem;
        font-size: 0.8rem;
    }
}

/* For reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
        scroll-behavior: auto !important;
    }
    
    .achievement-badge:hover,
    .primary-btn:hover,
    .secondary-btn:hover,
    .back-btn:hover,
    .share-btn:hover,
    .key:hover,
    .animal-share-btn:hover {
        transform: none;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes bounce {
        0%, 100% {transform: translateY(0);}
    }
    
    @keyframes pulse {
        0%, 100% { transform: scale(1); }
    }
    
    @keyframes celebration {
        0%, 100% { transform: translate(-50%, -50%) scale(1); }
    }
}
/* Feedback message styling */
.feedback-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center on the animal */
    font-size: calc(1.6rem * var(--font-scale));
    font-family: var(--font-family-secondary);
    font-weight: bold;
    text-align: center;
    border-radius: var(--border-radius-md);
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-md);
    z-index: 20;
    animation: fadeInOut 2.5s ease forwards;
    pointer-events: none;
    white-space: nowrap;
}

.feedback-message.success {
    color: var(--success-color);
    background-color: rgba(255, 255, 255, 0.85);
}

.feedback-message.error {
    color: var(--error-color);
    background-color: rgba(255, 255, 255, 0.85);
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

/* Hide the old feedback text */
#feedback-text {
    display: none;
}
/* Center buttons in accessibility modal */
.modal-content .secondary-btn {
    margin: 0 auto;
    display: block;
    min-width: 120px; /* Match the primary button width */
}

/* ===== BUTTON LAYOUT IMPROVEMENTS ===== */

/* Separate button container for accessibility modal */
.button-container-accessibility {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    width: 100%;
}

.button-container-accessibility .primary-btn,
.button-container-accessibility .secondary-btn {
    width: 80%; /* Make buttons wider */
    max-width: 250px; /* Limit maximum width */
    margin: 0.25rem 0;
    white-space: nowrap; /* Prevent text wrapping */
}

/* Stack buttons in leaderboard screen */
.button-container {
    display: flex;
    flex-direction: column; /* Change to column for stacked layout */
    align-items: center;
    gap: var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.button-container .back-btn,
.button-container .primary-btn {
    width: 90%; /* Increased width to fit longer text */
    max-width: 300px; /* Increased max width */
    margin: 0.25rem 0; /* Adjust vertical spacing */
    white-space: nowrap; /* Prevent text wrapping */
    font-size: calc(1rem * var(--font-scale)); /* Consistent font size */
    text-align: center; /* Center text */
    justify-content: center; /* Center content for flex */
    padding: 0.85rem 1rem; /* Adjusted padding to be more consistent */
}

/* Global button fixes to prevent text wrapping */
.primary-btn, 
.secondary-btn,
.back-btn {
    white-space: nowrap; /* Prevent text wrapping for all buttons */
    overflow: hidden; /* Hide overflow if needed */
    text-overflow: ellipsis; /* Show ellipsis if text overflows */
    min-width: 150px; /* Ensure minimum width */
    font-size: calc(1rem * var(--font-scale)); /* Consistent font size */
}
/* Difficulty indicator near progress indicator */
.difficulty-indicator {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    background-color: rgba(255, 193, 7, 0.15);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    margin: 0.25rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
    width: auto;
    display: inline-block;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.difficulty-indicator:hover {
    background-color: rgba(255, 193, 7, 0.3);
}

/* Space between progress and difficulty indicators */
#progress-indicator {
    margin-right: 0.5rem;
}

/* Difficulty modal styling */
.difficulty-note {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 1rem 0;
    padding: 0.75rem;
    background-color: rgba(66, 165, 245, 0.1);
    border-radius: var(--border-radius-md);
    border-left: 3px solid var(--primary-color);
    text-align: left;
}

/* Difficulty option group */
.option-group {
    margin: 1rem 0;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.option-group label {
    font-weight: 600;
    margin-right: 0.5rem;
}

.option-group select {
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--light-gray);
    background-color: white;
    min-width: 180px;
    font-family: var(--font-family-primary);
}

/* Checkbox styling */
.option-group input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
}

/* For adaptive difficulty checkbox label that comes after the checkbox */
.option-group label[for="adaptive-difficulty"] {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .difficulty-indicator, 
    #progress-indicator {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        margin: 0.2rem 0;
    }
    
    /* Stack indicators on very small screens */
    @media (max-width: 350px) {
        .difficulty-indicator {
            margin-top: 0.2rem;
        }
    }
}