.text-box {
    padding: 8px 15px;
    background-color: rgba(255, 255, 255, 0.9);
    color: black;
    border-radius: 4px;
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    border: 2px solid black;
    box-shadow: 3px 3px 0px black;
    font-size: clamp(13px, 2vw, 15px);
    text-align: center;
    z-index: 200;
    opacity: 1;
    transition: opacity 0.3s ease-in-out, bottom 0.3s ease-in-out, box-shadow 0.2s ease;
}

#instruction-text {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

#social-links {
    position: absolute;
    bottom: 5px;
    right: 5px;
    text-align: left;
    max-width: 350px;
}

#logo-container {
    position: absolute;
    top: 10px;
    left: 10px;
}

#video-link {
    position: absolute;
    bottom: 10px;
    left: 10px;
}

#logo {
    font-size: 2em;
}

/* Name Input Screen */
.name-input {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.name-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.name-form input {
    padding: 15px 25px;
    font-size: 20px;
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    border: 3px solid black;
    border-radius: 8px;
    box-shadow: 4px 4px 0px black;
    width: 300px;
    text-align: center;
}

.name-form input:focus {
    outline: none;
    border-color: #764ba2;
}

/* Character Selection Screen */
.character-selection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.selection-title {
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    font-size: clamp(32px, 6vw, 56px);
    font-weight: bold;
    color: white;
    margin-bottom: 50px;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.3);
}

.character-cards {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    max-width: 90%;
}

.character-card {
    background: white;
    border: 4px solid black;
    border-radius: 12px;
    padding: 30px;
    width: 300px;
    box-shadow: 6px 6px 0px black;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.character-card:hover {
    transform: translateY(-5px);
    box-shadow: 8px 8px 0px black;
}

.character-preview {
    width: 100%;
    height: 250px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 3px solid black;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.character-card h2 {
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    font-size: 28px;
    font-weight: bold;
    color: black;
    margin: 10px 0 20px 0;
    text-transform: capitalize;
}

.select-btn {
    padding: 12px 30px;
    font-size: 18px;
    font-weight: bold;
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    background-color: #667eea;
    color: white;
    border: 3px solid black;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 4px 4px 0px black;
    transition: all 0.2s ease;
}

.select-btn:hover {
    background-color: #764ba2;
    transform: translateY(-2px);
    box-shadow: 5px 5px 0px black;
}

.select-btn:active {
    transform: translateY(2px);
    box-shadow: 2px 2px 0px black;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 30px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-title {
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    font-size: clamp(28px, 5vw, 48px);
    font-weight: bold;
    margin: 0 0 10px 0;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.3);
}

.loading-subtitle {
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    font-size: clamp(16px, 3vw, 24px);
    margin: 0;
    opacity: 0.9;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.2);
}

/* Background Selection Screen */
.background-selection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.background-cards {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    max-width: 90%;
}

.background-card {
    background: white;
    border: 4px solid black;
    border-radius: 12px;
    padding: 30px;
    width: 300px;
    box-shadow: 6px 6px 0px black;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.background-card:hover {
    transform: translateY(-5px);
    box-shadow: 8px 8px 0px black;
}

.background-preview {
    width: 100%;
    height: 250px;
    background-size: cover;
    background-position: center;
    border: 3px solid black;
    border-radius: 8px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.background-card h2 {
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    font-size: 28px;
    font-weight: bold;
    color: black;
    margin: 10px 0 20px 0;
    text-transform: capitalize;
}

/* Speech Bubble Talking Animation */
@keyframes bubble-talk {
    0%, 100% {
        transform: translateX(-50%) translateY(0px) scale(1.15);
    }
    25% {
        transform: translateX(-50%) translateY(-3px) scale(1.18);
    }
    50% {
        transform: translateX(-50%) translateY(0px) scale(1.15);
    }
    75% {
        transform: translateX(-50%) translateY(-2px) scale(1.17);
    }
}

.speech-bubble-talking {
    animation: bubble-talk 0.6s ease-in-out infinite !important;
}

@media (max-width: 768px) {
    .character-cards {
        gap: 20px;
    }

    .character-card {
        width: 250px;
        padding: 20px;
    }

    .character-preview {
        height: 200px;
    }

    .background-cards {
        gap: 20px;
    }

    .background-card {
        width: 250px;
        padding: 20px;
    }

    .background-preview {
        height: 200px;
    }

    .loading-spinner {
        width: 60px;
        height: 60px;
        border-width: 5px;
    }
}

#mic-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
}

#mic-status-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 3px solid black;
    border-radius: 30px;
    box-shadow: 4px 4px 0px black;
    font-family: "Arial", "Helvetica Neue", Helvetica, sans-serif;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

#mic-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

#mic-status-text {
    color: black;
    white-space: nowrap;
}

/* State: Idle */
#mic-status.state-idle #mic-status-content {
    background-color: rgba(200, 200, 200, 0.9);
}

#mic-status.state-idle #mic-status-icon {
    background-color: #888;
}

/* State: Listening */
#mic-status.state-listening #mic-status-content {
    background-color: rgba(76, 175, 80, 0.95);
    animation: pulse-listening 1.5s ease-in-out infinite;
}

#mic-status.state-listening #mic-status-icon {
    background-color: #4CAF50;
    animation: pulse-icon 1.5s ease-in-out infinite;
}

#mic-status.state-listening #mic-status-text {
    color: white;
}

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

@keyframes pulse-icon {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
}

/* State: Processing */
#mic-status.state-processing #mic-status-content {
    background-color: rgba(255, 193, 7, 0.95);
}

#mic-status.state-processing #mic-status-icon {
    background-color: #FFC107;
    animation: spin 1s linear infinite;
}

#mic-status.state-processing #mic-status-text {
    color: black;
}

/* State: Talking */
#mic-status.state-talking #mic-status-content {
    background-color: rgba(33, 150, 243, 0.95);
    animation: bounce-talking 0.6s ease-in-out infinite;
}

#mic-status.state-talking #mic-status-icon {
    background-color: #2196F3;
    animation: bounce-icon 0.6s ease-in-out infinite;
}

#mic-status.state-talking #mic-status-text {
    color: white;
}

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

@keyframes bounce-icon {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Hidden state */
#mic-status.hidden {
    display: none;
}

@media (max-width: 768px) {
    #mic-status-content {
        padding: 10px 20px;
        font-size: 14px;
        gap: 10px;
    }
    
    #mic-status-icon {
        width: 20px;
        height: 20px;
    }
}