/* 사전 대화 모달 스타일 - 개선된 버전 */

#preConversationModal .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(31, 13, 47, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 80%, rgba(28, 11, 44, 0.3) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 50%, rgba(25, 9, 40, 0.25) 0%, transparent 65%),
        rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999 !important;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    will-change: opacity, visibility;
    transform: translate3d(0, 0, 0);
    contain: layout style paint;
}

#preConversationModal .modal-overlay.show {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

#preConversationModal .modal-container {
    background: rgba(26, 10, 42, 0.95);
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.6);
    overflow: hidden;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
}

/* 헤더 */
#preConversationModal .modal-header {
    padding: 20px;
    background: linear-gradient(135deg, rgba(26, 10, 42, 0.8) 0%, rgba(74, 58, 90, 0.8) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
}

.mascot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mascot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 215, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    animation: cheshireGrin 3s infinite;
    border: 2px solid rgba(255, 215, 0, 0.4);
}

@keyframes cheshireGrin {
    0%, 70% { 
        opacity: 1; 
        transform: scale(1); 
    }
    85% { 
        opacity: 0.3; 
        transform: scale(0.9); 
    }
    100% { 
        opacity: 1; 
        transform: scale(1); 
    }
}

.mascot-name .name {
    color: #FFD700;
    font-weight: bold;
    font-size: 16px;
    display: block;
    font-family: 'Playfair Display', serif;
}

.mascot-name .status {
    color: #B0C4DE;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Lora', serif;
}

.mascot-name .status.online::before {
    content: '✨';
    animation: sparkle 2s infinite;
}

@keyframes sparkle {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

#preConversationModal .close-btn {
    background: none;
    border: none;
    color: #FFD700;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#preConversationModal .close-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    color: #FFF700;
    transform: scale(1.1);
}

/* 대화 영역 */
.conversation-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 400px;
    background: rgba(0, 0, 0, 0.3);
}

.conversation-area::-webkit-scrollbar {
    width: 6px;
}

.conversation-area::-webkit-scrollbar-track {
    background: rgba(255, 215, 0, 0.1);
    border-radius: 3px;
}

.conversation-area::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 3px;
}

#preConversationModal .message {
    margin-bottom: 15px;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#preConversationModal .user-message {
    text-align: right;
}

#preConversationModal .user-message .message-content {
    background: rgba(176, 196, 222, 0.15);
    color: #E8E8E8;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-family: 'Lora', serif;
    border: 1px solid rgba(176, 196, 222, 0.3);
}

.mascot-message .message-content {
    background: rgba(255, 215, 0, 0.15);
    color: #E8E8E8;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2);
    font-family: 'Lora', serif;
    font-weight: 500;
    border: 1px solid rgba(255, 215, 0, 0.4);
}

#preConversationModal .message-time {
    font-size: 11px;
    color: rgba(176, 196, 222, 0.8);
    margin-top: 4px;
    font-family: 'Lora', serif;
}

#preConversationModal .user-message .message-time {
    text-align: right;
}

.mascot-message .message-time {
    text-align: left;
}

/* 입력 영역 */
#preConversationModal .input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 215, 0, 0.3);
}

#preConversationModal .input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    align-items: flex-end;
}

#preConvInput {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #4a3a5a;
    border-radius: 8px;
    padding: 16px 20px;
    color: #e0e0e0;
    font-size: 15px;
    font-family: 'Lora', serif;
    resize: vertical;
    min-height: 80px;
    max-height: 150px;
    line-height: 1.5;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#preConvInput:focus {
    outline: none;
    border-color: #FFD700;
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

#preConvInput::placeholder {
    color: #8a7a9a;
    font-style: italic;
}

#preConversationModal .send-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    border-radius: 8px;
    padding: 16px 24px;
    color: #1a0a2a;
    font-weight: bold;
    font-family: 'Lora', serif;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 90px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

#preConversationModal .send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #FFF700 0%, #FFB500 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.5);
}

#preConversationModal .send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#preConversationModal .loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 액션 버튼 */
#preConversationModal .action-buttons {
    text-align: center;
}

#preConversationModal .skip-btn {
    background: rgba(176, 196, 222, 0.1);
    border: 1px solid #B0C4DE;
    border-radius: 8px;
    padding: 12px 20px;
    color: #B0C4DE;
    font-size: 13px;
    font-family: 'Lora', serif;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preConversationModal .skip-btn:hover {
    background: #B0C4DE;
    color: #1a0a2a;
    border-color: #B0C4DE;
}

/* 상태 표시 */
#preConversationModal .conversation-status {
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 215, 0, 0.2);
    text-align: center;
}

#preConversationModal .token-usage {
    color: rgba(176, 196, 222, 0.8);
    font-size: 11px;
    font-family: 'Lora', serif;
}

/* 게임 해설창 스타일 메시지 */
#preConversationModal .narrator-message {
    text-align: center;
    margin: 20px 0;
    animation: fadeInUp 0.5s ease-out;
}

#preConversationModal .narrator-content {
    background: rgba(0, 0, 0, 0.6);
    color: #B0C4DE;
    padding: 10px 20px;
    border-radius: 20px;
    display: inline-block;
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 13px;
    border: 1px solid rgba(176, 196, 222, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    position: relative;
}

#preConversationModal .narrator-content::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #B0C4DE, transparent);
}

#preConversationModal .narrator-content::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #B0C4DE, transparent);
}

/* 체셔고양이 스윽 사라지는 효과 */
@keyframes cheshireDisappear {
    0% { 
        opacity: 1; 
        transform: scale(1); 
    }
    30% { 
        opacity: 0.7; 
        transform: scale(0.95); 
    }
    70% { 
        opacity: 0.2; 
        transform: scale(0.7); 
    }
    100% { 
        opacity: 0; 
        transform: scale(0.3); 
    }
}

#preConversationModal .narrator-message.disappearing .narrator-content {
    animation: cheshireDisappear 2s ease-out forwards;
}

/* 대화 완료 확인 버튼 스타일 */
.confirmation-buttons {
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.confirmation-buttons .button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.confirmation-buttons .confirm-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirmation-buttons .confirm-btn.proceed {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a0a2a;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.confirmation-buttons .confirm-btn.proceed:hover {
    background: linear-gradient(135deg, #FFE55C 0%, #FFB84D 100%);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    transform: translateY(-1px);
}

.confirmation-buttons .confirm-btn.continue {
    background: rgba(255, 255, 255, 0.1);
    color: #E8E8E8;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.confirmation-buttons .confirm-btn.continue:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.confirmation-buttons .confirm-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* AI 입력 모달의 사전 대화 옵션 스타일 */
#preConversationModal .checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

#preConversationModal .checkbox-group input[type="checkbox"] {
    margin-top: 2px;
    transform: scale(1.2);
    accent-color: #11998e;
}

#preConversationModal .checkbox-group label {
    cursor: pointer;
    color: #E8E8E8;
    font-size: 14px;
    line-height: 1.4;
    user-select: none;
}

#preConversationModal .help-text {
    color: #B0C4DE;
    font-size: 12px;
    line-height: 1.3;
    margin-left: 25px;
    font-style: italic;
}

/* 반응형 */
@media (max-width: 600px) {
    #preConversationModal .modal-container {
        width: 95%;
        max-height: 90vh;
        margin: 20px;
    }
    
    #preConversationModal .modal-header {
        padding: 15px;
    }
    
    #preConversationModal .conversation-area {
        padding: 15px;
        max-height: 300px;
    }
    
    #preConversationModal .input-area {
        padding: 15px;
    }
    
    .mascot-avatar {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .mascot-name .name {
        font-size: 14px;
    }
    
    #preConversationModal .message-content {
        max-width: 90% !important;
        font-size: 14px;
    }
    
    #preConvInput {
        min-height: 70px;
        padding: 14px 16px;
        font-size: 14px;
    }
    
    #preConversationModal .send-btn {
        min-width: 80px;
        min-height: 70px;
        padding: 14px 20px;
        font-size: 13px;
    }
    
    #preConversationModal .skip-btn {
        min-height: 40px;
        padding: 10px 16px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .confirmation-buttons {
        margin: 10px 0;
        padding: 12px;
    }
    
    .confirmation-buttons .confirm-btn {
        padding: 14px 16px;
        font-size: 13px;
    }
}