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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.app-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #2c3e50;
}

.app-header p {
    font-size: 1.1rem;
    color: #7f8c8d;
}

.expert-selection {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.expert-selection h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.expert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 40px;
}

.expert-card {
    padding: 20px;
    border: 2px solid #ecf0f1;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.expert-card:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
}

.expert-card.selected {
    border-color: #3498db;
    background: #e3f2fd;
    transform: translateY(-2px);
}

.expert-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.expert-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.expert-card p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.selected-experts {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.selected-experts h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

#selected-list {
    margin-bottom: 20px;
    min-height: 30px;
}

.selected-expert {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 8px 15px;
    margin: 5px;
    border-radius: 20px;
    font-size: 0.9rem;
}

#start-chat {
    background: #27ae60;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

#start-chat:enabled:hover {
    background: #219a52;
}

#start-chat:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.chat-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.active-experts {
    display: flex;
    gap: 10px;
}

.active-expert {
    background: #3498db;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
}

#new-discussion {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

#new-discussion:hover {
    background: #c0392b;
}

.discussion-settings {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
}

.setting-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.character-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 700px;
    display: flex;
    flex-direction: column;
}

.character-header {
    padding: 15px 20px;
    border-bottom: 1px solid #ecf0f1;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.current-topic {
    background: #e3f2fd;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-weight: 500;
    color: #1976d2;
    font-size: 0.9rem;
}

.current-discussion-info {
    flex: 1;
}

.current-topic-chat {
    background: #e3f2fd;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-weight: 500;
    color: #1976d2;
    font-size: 0.9rem;
}

.expert-profiles {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.expert-profile {
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 0.8rem;
    flex: 1;
    min-width: 200px;
}

.expert-profile .expert-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 3px;
}

.expert-profile .expert-details {
    color: #7f8c8d;
    line-height: 1.3;
}

.expert-roles {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.expert-role {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: #666;
}

.character-stage {
    flex: 1;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
    position: relative;
    overflow: hidden;
}

.character-display {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 100%;
    padding: 20px;
    position: relative;
}

.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.character.speaking {
    transform: scale(1.05);
    animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 60%, 100% { transform: scale(1.05) translateY(0); }
    40% { transform: scale(1.05) translateY(-10px); }
    80% { transform: scale(1.05) translateY(-5px); }
}

.character-sprite {
    width: 80px;
    height: 80px;
    background: #3498db;
    border-radius: 8px;
    position: relative;
    margin-bottom: 10px;
    image-rendering: pixelated;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.character-sprite::before,
.character-sprite::after {
    display: none;
}

.character[data-expert="scientist"] .character-sprite {
    background-image: url('scientist.png');
    background-color: transparent;
}

.character[data-expert="philosopher"] .character-sprite {
    background-image: url('philosopher.png');
    background-color: transparent;
}

.character[data-expert="engineer"] .character-sprite {
    background-image: url('engineer.png');
    background-color: transparent;
}

.character[data-expert="economist"] .character-sprite {
    background-image: url('economist.png');
    background-color: transparent;
}

.character[data-expert="psychologist"] .character-sprite {
    background-image: url('psychologist.png');
    background-color: transparent;
}

.character[data-expert="historian"] .character-sprite {
    background-image: url('historian.png');
    background-color: transparent;
}

.character[data-expert="doctor"] .character-sprite {
    background-image: url('doctor.png');
    background-color: transparent;
}

.character[data-expert="lawyer"] .character-sprite {
    background-image: url('lawyer.png');
    background-color: transparent;
}

.character[data-expert="artist"] .character-sprite {
    background-image: url('artist.png');
    background-color: transparent;
}

.character[data-expert="teacher"] .character-sprite {
    background-image: url('teacher.png');
    background-color: transparent;
}

.character[data-expert="journalist"] .character-sprite {
    background-image: url('journalist.png');
    background-color: transparent;
}

.character[data-expert="environmental"] .character-sprite {
    background-image: url('environmental.png');
    background-color: transparent;
}

.character-name {
    background: rgba(255,255,255,0.9);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #2c3e50;
    border: 1px solid #ddd;
}

.speech-bubble {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 2px solid #333;
    border-radius: 15px;
    padding: 12px 15px;
    max-width: 300px;
    min-width: 220px;
    font-size: 0.9rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10;
    word-wrap: break-word;
    text-align: left;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.speech-bubble.small-text {
    font-size: 1.1rem;
    font-weight: 500;
}

.speech-bubble.medium-text {
    font-size: 0.9rem;
}

.speech-bubble.large-text {
    font-size: 0.8rem;
    line-height: 1.3;
}

.speech-bubble.visible {
    opacity: 1;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 13px solid transparent;
    border-right: 13px solid transparent;
    border-top: 13px solid #333;
}

#active-experts-char {
    display: flex;
    gap: 10px;
}

#new-discussion-char {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

#new-discussion-char:hover {
    background: #c0392b;
}

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

.message {
    max-width: 80%;
    padding: 15px;
    border-radius: 12px;
    position: relative;
    animation: fadeIn 0.5s ease;
    margin-bottom: 10px;
}

.message-left {
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-right {
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.user {
    background: #3498db;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message.ai.message-left {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-left: 4px solid #3498db;
}

.message.ai.message-right {
    background: #f0f8ff;
    border: 1px solid #e9ecef;
    border-right: 4px solid #27ae60;
}

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

.message-header {
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.message.user .message-header {
    color: rgba(255,255,255,0.9);
}

.message.ai .message-header {
    color: #2c3e50;
}

.message-content {
    line-height: 1.5;
}

.typing-indicator {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 12px;
    align-self: flex-start;
    max-width: 80%;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #bdc3c7;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

.chat-input {
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    gap: 10px;
}

#topic-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#topic-input:focus {
    border-color: #3498db;
}

#send-topic {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

#send-topic:hover {
    background: #2980b9;
}

.discussion-summary-chat {
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.discussion-summary-chat h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

@media (max-width: 768px) {
    .expert-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .active-experts {
        justify-content: center;
    }
    
    .message {
        max-width: 95%;
    }
    
    .discussion-settings {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .character-display {
        flex-direction: column;
        justify-content: center;
        gap: 20px;
    }
    
    .character {
        transform: scale(0.8);
    }
    
    .character.speaking {
        transform: scale(0.9);
    }
    
    .speech-bubble {
        max-width: 220px;
        min-width: 160px;
        font-size: 0.75rem;
        padding: 10px 12px;
        bottom: 110px;
    }
}