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

body {
    font-family: 'Hiragino Sans', 'ヒラギノ角ゴシック', 'Yu Gothic', 'メイリオ', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #4a5568;
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

header p {
    color: #666;
    font-size: 1.2rem;
}

.chat-container {
    display: flex;
    gap: 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
    min-height: 600px;
}

.character-section {
    flex: 1;
    background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 10px;
}

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

.character-image {
    width: 240px;
    height: 380px;
    margin-bottom: 15px;
    position: relative;
    transition: transform 0.3s ease;
}

.character-image.talking {
    animation: bounce 0.5s ease-in-out;
}

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

.character-main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    border-radius: 20px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.character-image.talking .character-main-image {
    transform: scale(1.02);
}

.character-image.happy .character-main-image {
    animation: bounce-happy 0.8s ease-in-out;
}

.character-image.excited .character-main-image {
    animation: bounce-excited 1s ease-in-out;
}

.character-image.sad .character-main-image {
    animation: fade-in 0.5s ease-in-out;
}

.character-image.worried .character-main-image {
    animation: slight-shake 0.6s ease-in-out;
}

.character-image.thinking .character-main-image {
    animation: thinking-pulse 1.5s ease-in-out infinite;
}

@keyframes bounce-happy {
    0%, 100% { transform: translateY(0px) scale(1); }
    30% { transform: translateY(-8px) scale(1.03); }
    60% { transform: translateY(-4px) scale(1.01); }
}

@keyframes bounce-excited {
    0%, 100% { transform: translateY(0px) scale(1); }
    25% { transform: translateY(-10px) scale(1.04); }
    50% { transform: translateY(-5px) scale(1.02); }
    75% { transform: translateY(-7px) scale(1.03); }
}

@keyframes fade-in {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes slight-shake {
    0%, 100% { transform: translateX(0px); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

@keyframes thinking-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.placeholder-character {
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #81a8d8, #a8caba);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.face {
    position: relative;
}

.eyes {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.eye {
    width: 12px;
    height: 12px;
    background: #333;
    border-radius: 50%;
    animation: blink 3s infinite;
}

@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

.mouth {
    width: 20px;
    height: 10px;
    border: 2px solid #333;
    border-top: none;
    border-radius: 0 0 20px 20px;
}

.character-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #4a5568;
}

.chat-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-messages {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    animation: fadeInUp 0.3s ease;
}

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

.bot-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
}

.message-content {
    background: #f8f9ff;
    padding: 15px 20px;
    border-radius: 20px;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.message-time {
    font-size: 0.8rem;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.input-container {
    padding: 30px;
    background: #f8f9ff;
    display: flex;
    gap: 15px;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    border-color: #667eea;
}

#sendButton {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sendButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

#sendButton:active {
    transform: translateY(0);
}

.loading-indicator {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    align-items: center;
    gap: 10px;
}

.loading-indicator.show {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e1e5e9;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@media screen and (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .chat-container {
        flex-direction: column;
        min-height: 500px;
    }
    
    .character-section {
        flex: none;
        padding: 15px;
        min-height: 280px;
        padding-top: 5px;
    }
    
    .character-image {
        width: 200px;
        height: 280px;
    }
    
    .chat-section {
        height: 400px;
    }
    
    .chat-messages {
        padding: 20px;
    }
    
    .input-container {
        padding: 20px;
        flex-direction: column;
        gap: 10px;
    }
    
    #messageInput {
        width: 100%;
    }
    
    #sendButton {
        width: 100%;
    }
}

@media screen and (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .character-image {
        width: 180px;
        height: 240px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-content {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}
