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

body {
    font-family: 'Comic Neue', cursive;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.game-container {
    width: 90%;
    max-width: 800px;
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    max-height: 95vh;
}

.screen {
    padding: 40px 20px;
    text-align: center;
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.hidden {
    display: none !important;
}

h1 {
    font-size: 3em;
    color: #667eea;
    margin-bottom: 30px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.1);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.character {
    margin: 30px 0;
}

.character-face {
    width: 120px;
    height: 120px;
    background: #FFD93D;
    border-radius: 50%;
    position: relative;
    margin: 0 auto;
    animation: float 3s ease-in-out infinite;
    box-shadow: 0 10px 30px rgba(255, 217, 61, 0.4);
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

.eye {
    width: 20px;
    height: 20px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    top: 40px;
    animation: blink 3s infinite;
}

.eye.left { left: 30px; }
.eye.right { right: 30px; }

@keyframes blink {
    0%, 90%, 100% { height: 20px; }
    95% { height: 2px; }
}

.smile {
    width: 60px;
    height: 30px;
    border: 4px solid #333;
    border-top: none;
    border-radius: 0 0 60px 60px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.difficulty, .operation {
    margin: 20px 0;
}

h2 {
    font-size: 1.5em;
    color: #764ba2;
    margin-bottom: 15px;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    margin: 10px;
    border-radius: 25px;
    font-size: 1.1em;
    font-family: 'Comic Neue', cursive;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

button:active {
    transform: translateY(-1px);
}

button[data-level], button[data-op] {
    background: white;
    color: #667eea;
    border: 3px solid #667eea;
}

button[data-level].selected, button[data-op].selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.1);
}

.start-btn {
    margin-top: 30px;
    padding: 20px 50px;
    font-size: 1.3em;
    animation: pulse 2s infinite;
}

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

/* Game screen specific styling */
#game-screen {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    display: block;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 100%);
    border-bottom: 5px solid #667eea;
}

.score-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(102, 126, 234, 0.95);
    color: white;
    padding: 20px 30px;
    border-radius: 20px;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 25px;
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    z-index: 10;
    backdrop-filter: blur(10px);
    pointer-events: none;
}

.score-container > span {
    white-space: nowrap;
}

.question-container {
    padding: 30px;
}

.question {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 30px;
    font-weight: bold;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.answer-input {
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
}

#answer {
    padding: 15px 25px;
    font-size: 1.5em;
    border: 3px solid #667eea;
    border-radius: 15px;
    width: 200px;
    text-align: center;
    font-family: 'Comic Neue', cursive;
    transition: all 0.3s ease;
}

#answer:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
    transform: scale(1.05);
}

#submit-answer {
    padding: 15px 40px;
    font-size: 1.3em;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.result {
    margin: 30px 0;
    font-size: 1.5em;
}

.result p {
    margin: 15px 0;
    color: #333;
}

.result span {
    color: #667eea;
    font-weight: bold;
    font-size: 1.2em;
}

#play-again {
    margin-top: 30px;
    padding: 20px 50px;
    font-size: 1.3em;
}

.correct-animation {
    animation: correctPulse 0.5s ease-out;
}

@keyframes correctPulse {
    0% { transform: scale(1); background-color: white; }
    50% { transform: scale(1.1); background-color: #90EE90; }
    100% { transform: scale(1); background-color: white; }
}

.wrong-animation {
    animation: wrongShake 0.5s ease-out;
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Install PWA Button */
.install-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #FFD93D 0%, #FFA500 100%);
    color: #333;
    border: none;
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 1em;
    font-family: 'Comic Neue', cursive;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(255, 217, 61, 0.5);
    z-index: 1000;
    transition: all 0.3s ease;
    animation: slideInUp 0.5s ease-out;
}

.install-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 217, 61, 0.7);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Show Install Help Button */
.show-install-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 0.9em;
    font-family: 'Comic Neue', cursive;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
}

.show-install-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.6);
}

/* Install Instructions Modal */
.install-instructions {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.install-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.install-card h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.install-card ol {
    text-align: left;
    line-height: 1.8;
    color: #333;
}

.install-card li {
    margin: 10px 0;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f0f0f0;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    h1 {
        font-size: 2em;
        margin-bottom: 20px;
    }
    
    h2 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    
    .character-face {
        width: 80px;
        height: 80px;
    }
    
    .eye {
        width: 15px;
        height: 15px;
        top: 28px;
    }
    
    .eye.left { left: 20px; }
    .eye.right { right: 20px; }
    
    .smile {
        width: 40px;
        height: 20px;
        bottom: 15px;
    }
    
    .difficulty, .operation {
        margin: 15px 0;
    }
    
    button {
        padding: 12px 20px;
        margin: 8px 5px;
        font-size: 0.95em;
    }
    
    .start-btn {
        padding: 15px 35px;
        font-size: 1.1em;
    }
    
    .screen {
        padding: 30px 15px;
    }
    
    .score-container {
        padding: 15px 20px;
        font-size: 0.95em;
        gap: 15px;
        flex-wrap: nowrap;
    }
    
    .canvas-wrapper {
        height: 200px;
    }
    
    .question {
        font-size: 2em;
        margin-bottom: 20px;
    }
    
    .question-container {
        padding: 20px 15px;
    }
    
    .answer-input {
        flex-direction: column;
        gap: 10px;
    }
    
    #answer {
        width: 100%;
        max-width: 250px;
        padding: 12px 20px;
        font-size: 1.3em;
    }
    
    #submit-answer {
        padding: 12px 30px;
        font-size: 1.1em;
    }
    
    .result {
        font-size: 1.2em;
    }
    
    #play-again {
        padding: 15px 35px;
        font-size: 1.1em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6em;
    }
    
    .game-container {
        width: 95%;
        border-radius: 20px;
    }
    
    button {
        padding: 10px 15px;
        margin: 6px 3px;
        font-size: 0.9em;
    }
    
    .question {
        font-size: 1.6em;
    }
    
    .score-container {
        font-size: 0.8em;
        padding: 12px 15px;
        gap: 12px;
    }
    
    .canvas-wrapper {
        height: 180px;
    }
    
    .question {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
}
