/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#app {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Main Menu */
#main-menu {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
}

.header p {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.9);
    font-weight: 600;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    max-width: 600px;
    width: 100%;
}

.menu-btn {
    background: white;
    border: none;
    border-radius: 20px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 120px;
}

.menu-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.15);
}

.menu-btn:active {
    transform: translateY(-2px);
}

.menu-btn .icon {
    font-size: 2.5rem;
}

.menu-btn .label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

/* Game Screens */
.game-screen {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-btn, .home-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.home-btn {
    background: #4caf50;
}

.back-btn:hover, .home-btn:hover {
    transform: translateY(-2px);
}

.back-btn:hover {
    background: #ff5252;
}

.home-btn:hover {
    background: #45a049;
}

.game-header h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    color: #333;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.score {
    background: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 700;
    color: #333;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

/* Question Area */
.question-area {
    text-align: center;
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    min-width: 300px;
}

.question-area p {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.target-letter {
    font-size: 4rem;
    font-weight: 700;
    color: #667eea;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    max-width: 500px;
    width: 100%;
}

.option-btn {
    background: white;
    border: 3px solid transparent;
    border-radius: 15px;
    padding: 20px;
    font-size: 2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.option-btn:active {
    transform: translateY(-1px);
}

.option-btn.correct {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.option-btn.wrong {
    background: #ff9800;
    color: white;
    border-color: #ff9800;
}

/* Numbers Game Specific */
.objects-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.count-object {
    font-size: 2rem;
    animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Math Game Specific */
.math-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 2rem;
    font-weight: 700;
}

.math-objects {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.math-operator, .math-equals, .math-question {
    color: #667eea;
    font-size: 2.5rem;
}

/* Shapes Game Specific */
.target-shape {
    width: 100px;
    height: 100px;
    margin: 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
}

.shapes-drop-area {
    background: rgba(255,255,255,0.5);
    border: 3px dashed #667eea;
    border-radius: 20px;
    padding: 40px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone {
    width: 120px;
    height: 120px;
    border: 2px dashed #667eea;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #667eea;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-color: #4caf50;
    color: #4caf50;
}

.shapes-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.shape-option {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.shape-option:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.shape-option.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

/* Words Game Specific */
.word-difficulty {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.difficulty-btn {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn.active {
    background: #667eea;
    color: white;
}

.word-image {
    font-size: 4rem;
    margin-bottom: 10px;
}

.word-building-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.word-slots {
    display: flex;
    gap: 10px;
}

.letter-slot {
    width: 60px;
    height: 60px;
    border: 3px dashed #667eea;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    background: rgba(255,255,255,0.5);
    transition: all 0.3s ease;
}

.letter-slot.filled {
    background: white;
    border-color: #4caf50;
    color: #333;
}

.letter-slot.empty {
    background: rgba(255,255,255,0.8);
    border-color: #ff9800;
    border-style: solid;
}

.letter-slot.pre-filled {
    background: #e3f2fd;
    border-color: #2196f3;
    cursor: default;
}

.word-letters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.letter-option {
    width: 50px;
    height: 50px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #333;
}

.letter-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.letter-option.used {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Feedback Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.feedback-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.feedback-message {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
}

.continue-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.continue-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2.5rem;
    }
    
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .menu-btn {
        padding: 20px 15px;
        min-height: 100px;
    }
    
    .menu-btn .icon {
        font-size: 2rem;
    }
    
    .game-header h2 {
        font-size: 1.5rem;
    }
    
    .target-letter {
        font-size: 3rem;
    }
    
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .option-btn {
        font-size: 1.5rem;
        padding: 15px;
        min-height: 60px;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
    }
    
    .question-area {
        padding: 20px;
        min-width: auto;
        width: 100%;
    }
    
    .math-equation {
        font-size: 1.5rem;
        gap: 10px;
    }
    
    .word-slots {
        gap: 5px;
    }
    
    .letter-slot {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* Animations */
.celebration {
    animation: celebrate 0.6s ease-in-out;
}

@keyframes celebrate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .menu-btn:hover,
    .option-btn:hover,
    .back-btn:hover,
    .continue-btn:hover {
        transform: none;
    }
    
    .menu-btn:active {
        transform: scale(0.95);
    }
    
    .option-btn:active {
        transform: scale(0.95);
    }
}
/* Sub-menu styles */
.sub-menu {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.sub-menu-btn {
    background: white;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.sub-menu-btn.active {
    background: #667eea;
    color: white;
}

.sub-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* Audio button */
.audio-btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.audio-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

/* Word picture styles */
.word-picture {
    font-size: 3rem;
    margin: 20px 0;
    display: none;
}

.word-picture.active {
    display: block;
}

/* Memory Match Game Styles */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    background: white;
    border: 3px solid #667eea;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.memory-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.memory-card.flipped {
    background: #f0f8ff;
    border-color: #4caf50;
}

.memory-card.matched {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
    cursor: default;
}

.memory-card.matched:hover {
    transform: none;
}

.memory-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.memory-card.flipped .memory-card-back {
    transform: rotateY(180deg);
}

.memory-card-front {
    transition: transform 0.3s ease;
    transform: rotateY(180deg);
}

.memory-card.flipped .memory-card-front {
    transform: rotateY(0deg);
}

#memory-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-top: 10px;
}

/* Image Recognition Game Styles */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

.image-option {
    background: white;
    border: 3px solid transparent;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 120px;
    position: relative;
}

.image-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.image-option.correct {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.image-option.wrong {
    background: #ff9800;
    color: white;
    border-color: #ff9800;
}

.image-emoji {
    font-size: 3rem;
    line-height: 1;
}

.image-size-small .image-emoji {
    font-size: 2rem;
}

.image-size-big .image-emoji {
    font-size: 4rem;
}

.image-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

/* Footer Styles */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.app-footer a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.app-footer a:hover {
    color: #4caf50;
    text-decoration: underline;
}

/* Responsive adjustments for new elements */
@media (max-width: 768px) {
    .memory-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .memory-card {
        font-size: 1.5rem;
    }
    
    .images-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .image-emoji {
        font-size: 2.5rem;
    }
    
    .image-size-small .image-emoji {
        font-size: 1.5rem;
    }
    
    .image-size-big .image-emoji {
        font-size: 3.5rem;
    }
    
    .sub-menu {
        gap: 5px;
    }
    
    .sub-menu-btn {
        padding: 8px 15px;
        font-size: 0.8rem;
    }
    
    .game-header {
        margin-bottom: 20px;
    }
    
    .game-header h2 {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .memory-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .images-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
    }
    
    .sub-menu {
        flex-direction: column;
        align-items: center;
    }
    
    .sub-menu-btn {
        width: 200px;
    }
    
    .app-footer {
        padding: 8px;
    }
    
    .app-footer a {
        font-size: 0.8rem;
    }
}

/* Additional animations */
.flip-in {
    animation: flipIn 0.3s ease-out;
}

@keyframes flipIn {
    0% { transform: rotateY(90deg); opacity: 0; }
    100% { transform: rotateY(0deg); opacity: 1; }
}

.scale-up {
    animation: scaleUp 0.3s ease-out;
}

@keyframes scaleUp {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Game content padding adjustment for footer */
.game-content {
    padding-bottom: 60px;
}

.screen {
    padding-bottom: 60px;
}