/* ABC Section Specific Styles
   This file contains styles specific to the ABC learning page (abc.html)
   For shared styles (header, footer, etc.), see styles.css
*/

/* Alphabet Grid */
.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding: 0.5rem; /* Add padding for better touch area */
    justify-content: center; /* Center grid items on smaller screens */
}

/* Optimize grid for very small screens */
@media (max-width: 380px) {
    .alphabet-grid {
        grid-template-columns: repeat(6, 1fr); /* Fixed 6 columns on very small screens */
        gap: 0.4rem;
    }
    
    .letter {
        width: 44px;
        height: 44px;
        font-size: 1.6rem;
        border-radius: 12px;
    }
}

/* Optimize for medium-small screens */
@media (min-width: 381px) and (max-width: 480px) {
    .alphabet-grid {
        grid-template-columns: repeat(7, 1fr); /* 7 columns for small phones */
    }
}

.letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: white;
    border-radius: 20px;
    font-family: 'Fredoka One', cursive;
    font-size: 2.2rem;
    color: #8B4513; /* Earth brown */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 auto;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); /* Better touch feedback on iOS */
    touch-action: manipulation; /* Improve touch responsiveness */
}

.letter:hover {
    transform: scale(1.1);
    background: #FFD700; /* Sunlight yellow */
}

.letter.active {
    background: #8B4513; /* Earth brown */
    color: white;
    transform: scale(1.1);
}

/* Touch-friendly active state for mobile */
.letter:active {
    transform: scale(0.95);
    background: #FFD700; /* Sunlight yellow */
}

/* Letter Display */
.letter-display {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    border-radius: 30px;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    cursor: default;
    transition: all 0.3s ease;
    position: relative;
    z-index: 10;
}

.letter-display:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
}

.current-letter {
    font-family: 'Fredoka One', cursive;
    font-size: 5rem;
    color: #8B4513; /* Earth brown */
    margin-bottom: 1rem;
    text-shadow: 3px 3px 0 #FFD700; /* Sunlight yellow */
    transition: all 0.3s ease;
    backface-visibility: hidden;
}

.letter-phrase {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 1rem;
    font-style: italic;
    transition: all 0.3s ease;
    backface-visibility: hidden;
}

.letter-image {
    max-width: 200px;
    max-height: 150px;
    margin: 0 auto 1rem;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: block;
}

/* Enlarged Flashcard State */
.letter-display.enlarged {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    width: 90vw;
    max-width: 800px;
    height: 80vh;
    max-height: 600px;
    padding: 1.5rem;
    z-index: 1000;
    background: white;
    border-radius: 40px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    cursor: default;
    backface-visibility: hidden;
    will-change: transform;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    isolation: isolate;
    overflow: hidden;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain; /* Prevent scroll chaining */
}

/* Improve touch interaction for modal buttons */
.letter-display.enlarged .close-flashcard,
.letter-display.enlarged .toggle-left,
.letter-display.enlarged .toggle-right {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    user-select: none;
}

/* Active state for better touch feedback */
.letter-display.enlarged .close-flashcard:active,
.letter-display.enlarged .toggle-left:active,
.letter-display.enlarged .toggle-right:active {
    transform: scale(0.95);
}

/* Ensure modal is usable on very small screens */
@media (max-height: 500px) {
    .letter-display.enlarged {
        height: 95vh;
        max-height: 95vh;
        padding: 1rem;
        border-radius: 25px;
    }
    
    .letter-display.enlarged .current-letter {
        font-size: clamp(3rem, 6vw, 5rem);
        max-height: 15vh;
    }
    
    .letter-display.enlarged .letter-phrase {
        font-size: clamp(1rem, 2vw, 1.3rem);
        margin-bottom: 0.5rem;
    }
    
    .letter-display.enlarged .letter-image {
        max-height: 20vh;
    }
}

.letter-display.enlarged .current-letter {
    font-size: clamp(6rem, 12vw, 12rem);
    margin-bottom: 0.5rem;
    text-shadow: 5px 5px 0 #FFD700; /* Sunlight yellow */
    transition: opacity 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
    max-height: 25vh;
}

.letter-display.enlarged .letter-phrase {
    color: #333;
    font-weight: bold;
    margin-bottom: 1rem;
    transition: opacity 0.2s ease;
    text-align: center;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
    padding: 0 1rem;
    line-height: 1.2;
    flex-shrink: 1;
    min-width: 0; /* Allows text to shrink below content size */
    hyphens: auto;
    font-size: clamp(1.8rem, 3.5vw, 2.4rem);
}

.letter-display.enlarged .letter-image {
    max-width: 100%;
    max-height: 35vh;
    width: auto;
    height: auto;
    margin: 0 auto 1rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    object-fit: contain;
    flex-shrink: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.letter-display.enlarged .letter-image:hover {
    transform: scale(1.03);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

/* Class for smooth letter transitions */
.letter-transition {
    opacity: 0;
}

.letter-transition-end {
    opacity: 1;
}

/* Flashcard overlay */
.flashcard-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: none;
    backdrop-filter: blur(5px);
}

.flashcard-overlay.active {
    display: block;
}

/* Close button for enlarged flashcard */
.close-flashcard {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 40px;
    height: 40px;
    background: #8B4513; /* Earth brown */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    z-index: 1001;
}

.close-flashcard:hover {
    background: #A0522D; /* Tree bark - darker brown */
    transform: scale(1.1);
}

/* Toggle buttons for enlarged flashcard */
.toggle-left,
.toggle-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: #228B22; /* Canopy green */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 1001;
}

.toggle-left:hover,
.toggle-right:hover {
    background: #32CD32; /* Leaf green */
    transform: translateY(-50%) scale(1.1);
}

.toggle-left {
    left: 30px;
}

.toggle-right {
    right: 30px;
}

/* Hide toggle buttons when card is not enlarged */
.letter-display:not(.enlarged) .toggle-left,
.letter-display:not(.enlarged) .toggle-right {
    display: none;
}

/* Enlarge button for flashcard */
.enlarge-flashcard {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 40px;
    height: 40px;
    background: #228B22; /* Canopy green */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    z-index: 1001;
}

.enlarge-flashcard:hover {
    background: #32CD32; /* Leaf green */
    transform: scale(1.1);
}

/* Hide enlarge button when card is enlarged */
.letter-display.enlarged .enlarge-flashcard {
    display: none;
}



/* Ensure ABC section fits within viewport */
#abc {
    min-height: 0;
    overflow-x: hidden; /* Prevent horizontal overflow */
    width: 100%;
}

/* iOS-specific improvements */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    .letter {
        -webkit-touch-callout: none; /* Disable callout on long press */
    }
    
    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

/* Prevent blue highlight on tap in iOS Safari */
.letter,
.enlarge-flashcard,
.close-flashcard,
.toggle-left,
.toggle-right {
    -webkit-tap-highlight-color: transparent;
}

/* Improve scrolling on iOS */
.alphabet-grid {
    -webkit-overflow-scrolling: touch;
}

/* Prevent overflow issues on mobile */
@media (max-width: 768px) {
    #abc {
        padding: 0 0.5rem;
    }
    
    .letter-display {
        max-width: 95%;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Prevent text overflow in letter phrases */
.letter-phrase {
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* Ensure images don't cause overflow */
.letter-image {
    max-width: 100%;
    height: auto;
}

/* Responsive Design for ABC Section */
@media (max-width: 768px) {
    .alphabet-grid {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 0.6rem;
        padding: 0.4rem;
    }
    
    .letter {
        width: 60px;
        height: 60px;
        font-size: 2rem;
        min-width: 44px; /* Ensure minimum touch target */
        min-height: 44px;
    }
    
    .current-letter {
        font-size: 4.5rem;
    }
    
    /* Improve touch targets for buttons */
    .enlarge-flashcard,
    .close-flashcard {
        min-width: 44px;
        min-height: 44px;
    }
}

/* iPhone and small mobile devices */
@media (max-width: 480px) {
    .alphabet-grid {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 0.5rem;
        padding: 0.3rem;
    }
    
    .letter {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
        border-radius: 15px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .current-letter {
        font-size: 4rem;
    }
    
    .letter-phrase {
        font-size: 1.3rem;
    }
    
    .letter-image {
        max-width: 160px;
        max-height: 120px;
    }
    
    /* Improve touch targets for small screens */
    .enlarge-flashcard,
    .close-flashcard {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 1rem;
    }
}

/* iPad landscape specific optimizations */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    .alphabet-grid {
        grid-template-columns: repeat(auto-fit, minmax(65px, 1fr));
        gap: 0.7rem;
        max-width: 700px;
    }
    
    .letter {
        width: 65px;
        height: 65px;
        font-size: 2.1rem;
    }
    
    .current-letter {
        font-size: 4.5rem;
    }
    
    .letter-display {
        max-width: 350px;
    }
    
    /* Improve touch targets for iPad landscape */
    .enlarge-flashcard,
    .close-flashcard,
    .toggle-left,
    .toggle-right {
        min-width: 44px;
        min-height: 44px;
    }
}

/* iPad portrait specific optimizations */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
    .alphabet-grid {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 0.8rem;
        max-width: 750px;
    }
    
    .letter {
        width: 70px;
        height: 70px;
        font-size: 2.2rem;
    }
    
    .current-letter {
        font-size: 5rem;
    }
    
    .letter-display {
        max-width: 400px;
        padding: 1.2rem;
    }
    
    /* Adjust section header for iPad portrait */
    .section-header h2 {
        font-size: 2.8rem;
    }
    
    .section-header p {
        font-size: 1.3rem;
    }
}

/* iPhone landscape optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .alphabet-grid {
        grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
        gap: 0.5rem;
    }
    
    .letter {
        width: 55px;
        height: 55px;
        font-size: 1.9rem;
    }
    
    .current-letter {
        font-size: 3.5rem;
    }
    
    .letter-display {
        max-width: 350px;
        padding: 0.8rem;
    }
}

/* Height-based adjustments for ABC section */
@media (max-height: 800px) {
    .section-header {
        margin-bottom: 1rem;
    }
    .section-header h2 {
        font-size: 2.2rem;
    }
    .alphabet-grid {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    .letter {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    .current-letter {
        font-size: 4rem;
    }
    .letter-display {
        padding: 0.75rem;
    }
    .btn-sound {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
}

@media (max-height: 600px) {
    .section-header {
        margin-bottom: 0.75rem;
    }
    .section-header h2 {
        font-size: 1.8rem;
    }
    .alphabet-grid {
        gap: 0.4rem;
        margin-bottom: 0.75rem;
    }
    .letter {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
    }
    .current-letter {
        font-size: 3rem;
    }
    .letter-display {
        padding: 0.5rem;
    }
    .btn-sound {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* Responsive adjustments for enlarged flashcard */
@media (max-width: 768px) {
    .letter-display.enlarged {
        width: 95vw;
        height: 85vh;
        padding: 1rem;
    }
    
    .letter-display.enlarged .current-letter {
        font-size: clamp(5rem, 10vw, 8rem);
        max-height: 20vh;
        margin-bottom: 0.5rem;
    }
    
    .letter-display.enlarged .letter-phrase {
        font-size: clamp(1.5rem, 3vw, 2rem);
        margin-bottom: 0.5rem;
    }
    
    .letter-display.enlarged .letter-image {
        max-height: 30vh;
        margin-bottom: 0.5rem;
    }
    

    
    .toggle-left,
    .toggle-right {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .toggle-left {
        left: 15px;
    }
    
    .toggle-right {
        right: 15px;
    }
}

@media (max-width: 480px) {
    .letter-display.enlarged {
        width: 98vw;
        height: 90vh;
        padding: 0.75rem;
        border-radius: 25px;
    }
    
    .letter-display.enlarged .current-letter {
        font-size: clamp(4rem, 8vw, 6rem);
        margin-bottom: 0.5rem;
        max-height: 15vh;
    }
    
    .letter-display.enlarged .letter-phrase {
        font-size: clamp(1.3rem, 2.5vw, 1.6rem);
        margin-bottom: 0.5rem;
    }
    
    .letter-display.enlarged .letter-image {
        max-height: 25vh;
        margin-bottom: 0.5rem;
    }
    
    .close-flashcard {
        top: 8px;
        right: 12px;
        width: 30px;
        height: 30px;
        font-size: 1.1rem;
    }
    
    .enlarge-flashcard {
        top: 8px;
        right: 12px;
        width: 30px;
        height: 30px;
        font-size: 1.1rem;
    }
    

    
    .toggle-left,
    .toggle-right {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
    }
    
    .toggle-left {
        left: 8px;
    }
    
    .toggle-right {
        right: 8px;
    }
}

/* Help Button and Instructions Modal */
.title-with-help {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.help-button {
    width: 36px;
    height: 36px;
    background: #87CEEB; /* Sky blue */
    color: white;
    border-radius: 50%;
    border: none;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.help-button:hover {
    background: #6495ED; /* Cornflower blue */
    transform: scale(1.1) rotate(10deg);
}

.help-button:active {
    transform: scale(0.95);
}

.help-icon {
    display: block;
    line-height: 1;
}

/* Instructions overlay */
.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1002;
    display: none;
    backdrop-filter: blur(5px);
}

.instructions-overlay.active {
    display: block;
}

/* Instructions modal */
.instructions-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    width: 90vw;
    max-width: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 30px;
    padding: 2rem;
    z-index: 1003;
    display: none;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.instructions-modal.active {
    display: block;
}

.instructions-content h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: #8B4513; /* Earth brown */
    margin-bottom: 1.5rem;
    text-align: center;
}

.instructions-content p {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.instructions-content ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.instructions-content li {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.instructions-content li strong {
    color: #8B4513; /* Earth brown */
}

.close-instructions {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 40px;
    height: 40px;
    background: #8B4513; /* Earth brown */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    z-index: 1004;
}

.close-instructions:hover {
    background: #A0522D; /* Tree bark - darker brown */
    transform: scale(1.1);
}

.close-instructions:active {
    transform: scale(0.95);
}

/* Responsive adjustments for instructions modal */
@media (max-width: 768px) {
    .help-button {
        width: 32px;
        height: 32px;
        font-size: 1.3rem;
    }
    
    .instructions-modal {
        width: 95vw;
        padding: 1.5rem;
        border-radius: 25px;
    }
    
    .instructions-content h3 {
        font-size: 1.8rem;
        margin-bottom: 1.2rem;
    }
    
    .instructions-content p {
        font-size: 1.1rem;
        margin-bottom: 1.2rem;
    }
    
    .instructions-content li {
        font-size: 1rem;
        margin-bottom: 0.6rem;
    }
    
    .close-instructions {
        top: 15px;
        right: 20px;
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .help-button {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
    }
    
    .instructions-modal {
        width: 98vw;
        padding: 1.25rem;
        border-radius: 20px;
        max-height: 85vh;
    }
    
    .instructions-content h3 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
    
    .instructions-content p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .instructions-content ul {
        padding-left: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .instructions-content li {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    .close-instructions {
        top: 10px;
        right: 15px;
        width: 30px;
        height: 30px;
        font-size: 1.1rem;
    }
}

@media (max-height: 600px) {
    .letter-display.enlarged {
        height: 95vh;
        padding: 0.75rem;
    }
    
    .letter-display.enlarged .current-letter {
        font-size: clamp(3.5rem, 7vw, 6rem);
        margin-bottom: 0.25rem;
        max-height: 12vh;
    }
    
    .letter-display.enlarged .letter-phrase {
        font-size: clamp(1.1rem, 2vw, 1.4rem);
        margin-bottom: 0.25rem;
    }
    
    .letter-display.enlarged .letter-image {
        max-height: 20vh;
        margin-bottom: 0.25rem;
    }
    

    
    .toggle-left,
    .toggle-right {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
    }
    
    .toggle-left {
        left: 8px;
    }
    
    .toggle-right {
        right: 8px;
    }
}

/* Help Button and Instructions Modal */
.title-with-help {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.help-button {
    width: 36px;
    height: 36px;
    background: #87CEEB; /* Sky blue */
    color: white;
    border-radius: 50%;
    border: none;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.help-button:hover {
    background: #6495ED; /* Cornflower blue */
    transform: scale(1.1) rotate(10deg);
}

.help-button:active {
    transform: scale(0.95);
}

.help-icon {
    display: block;
    line-height: 1;
}

/* Instructions overlay */
.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1002;
    display: none;
    backdrop-filter: blur(5px);
}

.instructions-overlay.active {
    display: block;
}

/* Instructions modal */
.instructions-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) translateZ(0);
    width: 90vw;
    max-width: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 30px;
    padding: 2rem;
    z-index: 1003;
    display: none;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.instructions-modal.active {
    display: block;
}

.instructions-content h3 {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: #8B4513; /* Earth brown */
    margin-bottom: 1.5rem;
    text-align: center;
}

.instructions-content p {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.instructions-content ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.instructions-content li {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.instructions-content li strong {
    color: #8B4513; /* Earth brown */
}

.close-instructions {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 40px;
    height: 40px;
    background: #8B4513; /* Earth brown */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    z-index: 1004;
}

.close-instructions:hover {
    background: #A0522D; /* Tree bark - darker brown */
    transform: scale(1.1);
}

.close-instructions:active {
    transform: scale(0.95);
}

/* Responsive adjustments for instructions modal */
@media (max-width: 768px) {
    .help-button {
        width: 32px;
        height: 32px;
        font-size: 1.3rem;
    }
    
    .instructions-modal {
        width: 95vw;
        padding: 1.5rem;
        border-radius: 25px;
    }
    
    .instructions-content h3 {
        font-size: 1.8rem;
        margin-bottom: 1.2rem;
    }
    
    .instructions-content p {
        font-size: 1.1rem;
        margin-bottom: 1.2rem;
    }
    
    .instructions-content li {
        font-size: 1rem;
        margin-bottom: 0.6rem;
    }
    
    .close-instructions {
        top: 15px;
        right: 20px;
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .help-button {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
    }
    
    .instructions-modal {
        width: 98vw;
        padding: 1.25rem;
        border-radius: 20px;
        max-height: 85vh;
    }
    
    .instructions-content h3 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
    
    .instructions-content p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .instructions-content ul {
        padding-left: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .instructions-content li {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    .close-instructions {
        top: 10px;
        right: 15px;
        width: 30px;
        height: 30px;
        font-size: 1.1rem;
    }
}