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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.input-container {
    margin-bottom: 20px;
}

textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: vertical;
    font-size: 16px;
}

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

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

#stop-btn {
    background-color: #f44336;
}

#stop-btn:hover {
    background-color: #d32f2f;
}

.animation-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    background-color: lime;
    border-radius: 10px;
}

.face {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: lime;
    border-radius: 10px;
}

.mouth-container {
    width: 100px;
    height: 60px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; 
}

.mouth-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#mouth, #mouth-transition {
    position: absolute;
    width: auto;
    height: auto;
    max-width: 90%; 
    max-height: 90%; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    left: 50%; 
    top: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center;
    opacity: 1;
}

#mouth[src*="[O, Q, R, U, W] Open.png"], 
#mouth-transition[src*="[O, Q, R, U, W] Open.png"] {
    width: 50px; 
    height: 40px; 
    max-width: none; 
    max-height: none;
    transform: translate(-50%, -50%); 
}

#mouth[src*="[L] Open.png"], 
#mouth[src*="[C, D, G, K, S, T, X, Z] Closed.png"], 
#mouth[src*="[F, V] Closed.png"],
#mouth[src*="[E, A, I, H] Open.png"], 
#mouth[src*="[O, Q, R, U, W] Open.png"], 
#mouth-transition[src*="[L] Open.png"], 
#mouth-transition[src*="[C, D, G, K, S, T, X, Z] Closed.png"], 
#mouth-transition[src*="[F, V] Closed.png"],
#mouth-transition[src*="[E, A, I, H] Open.png"], 
#mouth-transition[src*="[O, Q, R, U, W] Open.png"] {
    transition: 
        width 0.3s cubic-bezier(0.45, 0.05, 0.55, 0.95), 
        height 0.3s cubic-bezier(0.45, 0.05, 0.55, 0.95),
        opacity 0.3s ease-in-out;
    transform-origin: center center;
}

#mouth-transition {
    opacity: 0;
}

.mouth-wrapper.morphing #mouth,
.mouth-wrapper.morphing #mouth-transition {
    transition: height 0.3s cubic-bezier(0.45, 0.05, 0.55, 0.95), 
                width 0.3s cubic-bezier(0.45, 0.05, 0.55, 0.95),
                opacity 0.3s ease-in-out,
                transform 0.3s ease-in-out; 
    opacity: 0.5; 
}

.mouth-wrapper.morphing #mouth[src*="[B, M, N, P, resting] Closed.png"],
.mouth-wrapper.morphing #mouth-transition[src*="[B, M, N, P, resting] Closed.png"] {
    opacity: 1; 
    transition: transform 0.3s ease-in-out; 
}

.color-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.color-control label {
    white-space: nowrap;
}

#background-color-picker {
    width: 50px;
    height: 30px;
    border: none;
    padding: 0;
    cursor: pointer;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#speed-slider {
    cursor: pointer;
}

.animation-display {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2em;
    min-height: 1.5em;
}

.animated-text .highlight {
    background-color: #ffff00;
    color: black;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
}

.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

#test-text-btn {
    background-color: #2196F3;
}

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

.disclaimer {
    text-align: center;
    color: #666;
    margin-bottom: 10px;
    font-style: italic;
}

.disclaimer small {
    display: block;
    font-size: 0.8em;
    opacity: 0.8;
    margin-bottom: 5px; 
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }
    
    .mouth-container {
        width: 80px;
        height: 50px;
    }
    
    .controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .speed-control {
        width: 100%;
        justify-content: space-between;
    }
    
    #stop-btn {
        width: 100%;
    }
    
    .animation-display {
        font-size: 1em;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    #test-text-btn {
        width: 100%;
    }
    
    .disclaimer small {
        font-size: 0.7em;
    }
}