body {
    font-family: Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

#app {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    min-height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    padding-top: 14px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    position: relative;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

h1 {
    text-align: center;
    color: #333;
    margin-top: 4px;
    margin-bottom: 10px;
    font-size: 22px;
}

#level-display, #streak-display {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
}

#final-level-banner {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 auto 12px;
    width: fit-content;
    max-width: calc(100% - 20px);
    padding: 10px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, #fff4cc, #ffd54f);
    color: #5d4200;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 18px rgba(255, 193, 7, 0.25);
    opacity: 0;
    transform: translateY(-18px) scale(0.92);
    pointer-events: none;
}

#final-level-banner.show {
    animation: final-level-banner-pop 1.8s ease forwards;
}

#level-display.final-level-glow {
    animation: final-level-display-glow 1.4s ease;
}

#question-container {
    margin: 20px 0;
}

#question {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
    text-align: center;
    word-break: break-word;
}

#options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.option {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #212529;
    padding: 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    transition: background-color 0.3s, border-color 0.3s;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option:hover:not(:disabled) {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.option:disabled {
    cursor: not-allowed;
}

#feedback {
    margin-top: 20px;
    text-align: center;
}

#result {
    font-size: 20px;
    margin-bottom: 14px;
}

button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

button:hover {
    background-color: #45a049;
}

#next-question {
    background-color: #2E7D32;
    font-size: 17px;
    display: block;
    width: min(240px, 100%);
    margin: 10px auto 0;
}

#next-question:hover {
    background-color: #1B5E20;
}

#new-sentence {
    background-color: white;
    border: 2px solid #4CAF50;
    color: #4CAF50;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

#play-audio {
    background-color: #1565C0;
}

#play-audio:hover:not(:disabled) {
    background-color: #0D47A1;
}

#play-audio:disabled {
    background-color: #90A4AE;
    cursor: not-allowed;
}

#sample-sentence {
    margin-top: 6px;
}

#sentence-text {
    margin-bottom: 14px;
    line-height: 1.35;
}

#sample-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

@media (hover: hover) and (pointer: fine) {
    #new-sentence:hover:not(:active) {
        background-color: #2E7D32;
        color: white;
    }
}

#new-sentence:active {
    background-color: white;
    color: #4CAF50;
    transform: scale(0.95);
    box-shadow: inset 0 0 0 999px rgba(76, 175, 80, 0.12);
}

#new-sentence.animate-click {
    background-color: white;
    border: 2px solid #4CAF50;
    color: #4CAF50;
}

#instructions-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    margin: 0;
}

#instructions-btn:hover {
    background-color: #1976D2;
}

#instructions {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

#instructions.show {
    display: flex;
}

#instructions-content {
    background-color: white;
    border-radius: 12px;
    padding: 25px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#instructions h2 {
    margin-top: 0;
    color: #333;
    font-size: 22px;
}

#instructions ul {
    padding-left: 20px;
}

#instructions li {
    margin-bottom: 8px;
    line-height: 1.6;
}

#close-instructions {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 5px;
    margin-top: 15px;
    cursor: pointer;
    font-size: 14px;
}

#close-instructions:hover {
    background-color: #e0e0e0;
}

#said-sentence, #show-example {
    display: inline-block;
}

@keyframes final-level-banner-pop {
    0% {
        opacity: 0;
        transform: translateY(-18px) scale(0.92);
    }
    18% {
        opacity: 1;
        transform: translateY(0) scale(1.04);
    }
    30% {
        transform: translateY(0) scale(1);
    }
    82% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
}

@keyframes final-level-display-glow {
    0% {
        text-shadow: none;
        transform: scale(1);
    }
    35% {
        text-shadow: 0 0 12px rgba(255, 193, 7, 0.9);
        transform: scale(1.06);
    }
    100% {
        text-shadow: none;
        transform: scale(1);
    }
}

@media (max-width: 600px) {
    body {
        padding: 8px;
        min-height: 100dvh;
    }
    #app {
        padding: 10px 10px calc(40px + env(safe-area-inset-bottom, 0px));
        min-height: calc(100dvh - 16px);
        max-height: calc(100dvh - 16px);
    }
    h1 {
        font-size: 18px;
        margin-top: 0;
        margin-bottom: 6px;
    }
    #question {
        font-size: 22px;
        margin-bottom: 12px;
    }
    .option {
        padding: 9px;
        font-size: 16px;
        min-height: 44px;
    }
    button {
        padding: 8px 16px;
        font-size: 14px;
        margin: 3px;
    }
    #result {
        font-size: 16px;
        margin-bottom: 15px;
    }
    #instructions-content {
        max-width: 95%;
        padding: 20px;
    }
    #instructions-content h2 {
        font-size: 18px;
    }
    #instructions-content p {
        font-size: 14px;
    }
    #instructions-content ul {
        font-size: 14px;
    }
    #level-display, #streak-display {
        font-size: 14px;
        margin-bottom: 6px;
    }
    #final-level-banner {
        font-size: 13px;
        padding: 9px 14px;
    }
    #question-container {
        margin: 12px 0;
    }
    #feedback {
        margin-top: 12px;
    }
    #sample-actions {
        gap: 8px;
    }
    #sample-actions button {
        flex: 1 1 140px;
        max-width: 220px;
    }
}
