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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(to bottom, #fef3c7, #fed7aa);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 50%, #7c3aed 100%);
    color: white;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 0.875rem;
    color: #e0f2fe;
    margin-top: 0.25rem;
}

.sound-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.3s;
}

.sound-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.reset-button {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fef3c7;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.reset-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.back-button {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fef3c7;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.back-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    max-width: 100%;
    width: 100%;
    margin: 0;
    overflow: hidden;
    position: relative;
}

/* Character Panel */
.character-panel {
    width: 40%;
    background: linear-gradient(135deg, #ecfeff 0%, #e0f2fe 50%, #ddd6fe 100%);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-right: 4px solid #06b6d4;
    transition: all 0.5s ease;
}

.character-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(249, 115, 22, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.character-panel.scene-active {
    justify-content: flex-end;
    align-items: flex-start;
    padding: 1rem;
}

.scene-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.character-panel.scene-active .scene-bg-image {
    opacity: 0.95;
}

.character-container {
    width: 100%;
    max-width: 400px;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 10;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.character-panel.scene-active .character-container {
    max-width: 180px;
    margin-bottom: 1rem;
    margin-left: 1rem;
}

.character-image {
    width: 100%;
    height: auto;
    transition: all 0.5s ease;
    filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.2));
    animation: breathe 4s ease-in-out infinite;
    transform-origin: bottom center;
}

@keyframes breathe {
    0%, 100% {
        transform: translateY(0px) scale(1) rotate(0deg);
        filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.2));
    }
    50% {
        transform: translateY(-12px) scale(1.02) rotate(0.5deg);
        filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.15));
    }
}

.character-image.state-neutral {
    animation: idle-sway 6s ease-in-out infinite;
}

@keyframes idle-sway {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(5px) rotate(1deg); }
    75% { transform: translateX(-5px) rotate(-1deg); }
}

.character-image.state-thinking {
    animation: ponder 3s ease-in-out infinite;
}

@keyframes ponder {
    0%, 100% { transform: rotate(-2deg) translateY(0); }
    50% { transform: rotate(2deg) translateY(-5px); }
}

.character-image.state-excited {
    animation: excited-bounce 0.5s ease-in-out 4;
}

@keyframes excited-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-20px) scale(1.05) rotate(-2deg); }
    75% { transform: translateY(-20px) scale(1.05) rotate(2deg); }
}

.character-image.state-happy {
    animation: gentle-sway 3s ease-in-out infinite;
}

@keyframes gentle-sway {
    0%, 100% { transform: rotate(0deg) translateX(0); }
    50% { transform: rotate(2deg) translateX(5px); }
}

.character-image.state-teaching {
    animation: teaching-gesture 2s ease-in-out 2;
}

@keyframes teaching-gesture {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(8px) rotate(2deg); }
    75% { transform: translateX(-8px) rotate(-2deg); }
}

.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #fbbf24, transparent);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle-rise 1.5s ease-out forwards;
}

@keyframes sparkle-rise {
    0% {
        bottom: 20%;
        opacity: 1;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        bottom: 80%;
        opacity: 0;
        transform: scale(0.5);
    }
}

.character-status {
    text-align: center;
    transition: all 0.6s ease;
    z-index: 10;
    position: relative;
}

.character-panel.scene-active .character-status {
    background: rgba(255, 255, 255, 0.95);
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-left: 1rem;
}

.status-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0e7490;
    text-transform: capitalize;
    margin-bottom: 0.25rem;
}

.status-text {
    font-size: 0.75rem;
    color: #0c4a6e;
}

/* Chat Panel */
.chat-panel {
    width: 60%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #ffffff 0%, #fffbeb 100%);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.assistant-message {
    align-self: flex-start;
    background-color: white;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #e0f2fe;
}

.loading-message {
    align-self: flex-start;
    background-color: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #fde68a;
}

.loading-dots {
    display: flex;
    gap: 0.5rem;
}

.loading-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: #f59e0b;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}


/* Input Container */
.input-container {
    border-top: 1px solid #bae6fd;
    background-color: white;
    padding: 1rem;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.user-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #fde68a;
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.user-input:focus {
    outline: none;
    border-color: #f59e0b;
}

.user-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

.send-button {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.send-button:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    box-shadow: none;
}

.send-icon {
    font-size: 1.25rem;
}

.mic-button {
    background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
    color: white;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3);
}

.mic-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
}

.mic-button.listening {
    background-color: #ef4444;
    animation: pulse 1s infinite;
}

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

.typing-indicator {
    background-color: #3b82f6 !important;
    padding: 1rem !important;
}

.typing-dots {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

.input-hint {
    font-size: 0.75rem;
    color: #0c4a6e;
    text-align: center;
}

.suggestion-btn {
    background-color: #ecfeff;
    border: 2px solid #06b6d4;
    color: #0e7490;
    padding: 0.4rem 0.9rem;
    border-radius: 1.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.suggestion-btn:hover {
    background-color: #06b6d4;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: #fef3c7;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #fbbf24;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #f59e0b;
}

/* ===================== */
/* MOBILE RESPONSIVENESS */
/* ===================== */

@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .container {
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
    }

    /* Compact header */
    .header {
        padding: 0.6rem 0.75rem;
    }

    .header h1 {
        font-size: 1.15rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .back-button,
    .reset-button {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .sound-toggle {
        font-size: 1.2rem;
        padding: 0.3rem;
    }

    /* Stack vertically, scroll together */
    .main-content {
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Character panel: centered portrait section */
    .character-panel {
        width: 100%;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 1.5rem 1rem 1rem;
        border-right: none;
        border-bottom: 3px solid #06b6d4;
        min-height: auto;
        flex-shrink: 0;
    }

    .character-panel::before {
        display: none;
    }

    .character-container {
        width: 180px;
        max-width: 180px;
        margin-bottom: 0.75rem;
    }

    .character-image {
        animation: none !important;
        filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.15));
    }

    .character-status {
        text-align: center;
    }

    /* Scene images: show as hero banner on mobile */
    .scene-bg-image {
        position: relative;
        width: 100%;
        height: 200px;
        object-fit: cover;
        object-position: center;
        border-radius: 0.75rem;
        margin-bottom: 0.75rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .character-panel.scene-active .scene-bg-image {
        opacity: 1;
    }

    .character-panel.scene-active {
        justify-content: center;
        align-items: center;
        padding: 1rem;
    }

    .character-panel.scene-active .character-container {
        width: 100px;
        max-width: 100px;
        margin-left: 0;
    }

    .character-panel.scene-active .character-status {
        background: none;
        padding: 0;
        box-shadow: none;
        margin-left: 0;
    }

    /* Chat panel */
    .chat-panel {
        width: 100%;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .messages-container {
        flex: 1;
        padding: 0.75rem;
        min-height: 120px;
        overflow-y: auto;
    }

    .message {
        max-width: 92%;
        font-size: 0.9rem;
        padding: 0.6rem 0.85rem;
    }

    /* Input pinned to bottom */
    .input-container {
        padding: 0.6rem 0.75rem;
        border-top: 1px solid #e0e7ff;
        background: white;
        flex-shrink: 0;
    }

    .input-wrapper {
        gap: 0.35rem;
    }

    .user-input {
        font-size: 16px; /* prevents iOS zoom */
        padding: 0.6rem 0.75rem;
    }

    .send-button {
        padding: 0.6rem 0.85rem;
        font-size: 0.9rem;
    }

    .send-button span:first-child {
        display: none;
    }

    .mic-button {
        padding: 0.6rem 0.7rem;
        font-size: 1.2rem;
    }

    .suggestion-btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }

    .input-hint {
        font-size: 0.7rem;
    }
}



/* ============ v2: character motion + kiosk mode ============ */
.breathing { animation: breathe 4.5s ease-in-out infinite; transform-origin: center bottom; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012, 1.02); } }
.is-talking { animation: talkbob .42s ease-in-out infinite !important; transform-origin: center bottom; }
@keyframes talkbob { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3px) scale(1.005, 1.012); } }
#characterImage { transition: opacity .14s ease; }
#characterImage.swapping { opacity: 0; }
#attractOverlay { position: fixed; inset: 0; z-index: 999; background: rgba(20, 16, 40, .93); display: flex; align-items: center; justify-content: center; cursor: pointer; animation: attractFadeIn .6s ease; }
.attract-inner { text-align: center; color: #fff; padding: 24px; }
.attract-inner img { width: 230px; max-width: 60vw; border-radius: 50%; margin-bottom: 22px; animation: breathe 4.5s ease-in-out infinite; }
.attract-inner h2 { font-size: 2.6rem; margin-bottom: 12px; }
.attract-inner p { font-size: 1.15rem; opacity: .85; max-width: 34ch; margin: 0 auto; animation: attractPulse 2.4s ease-in-out infinite; }
@keyframes attractPulse { 0%, 100% { opacity: .85; } 50% { opacity: .45; } }
@keyframes attractFadeIn { from { opacity: 0; } to { opacity: 1; } }
body.kiosk .reset-button { display: none; }
@media (prefers-reduced-motion: reduce) {
  .breathing, .is-talking, .attract-inner img, .attract-inner p { animation: none !important; }
}
