/* ========== 容器 ========== */
#ai-game-wrapper {
    max-width: 800px;
    margin: 30px auto;
    border-radius: 16px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

/* ========== 顶栏 ========== */
#ai-chat-header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    gap: 14px;
}

#ai-chat-header-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

#ai-chat-header-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

#ai-chat-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

/* ========== 聊天区 ========== */
#ai-chat-box {
    height: 520px;
    overflow-y: auto;
    padding: 24px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

#ai-chat-box::-webkit-scrollbar {
    width: 6px;
}

#ai-chat-box::-webkit-scrollbar-track {
    background: transparent;
}

#ai-chat-box::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* ========== 开始界面 ========== */
#ai-start-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 24px;
    position: relative;
    overflow: hidden;
}

#ai-start-screen::before {
    content: '';
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.12) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    animation: ai-glow-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes ai-glow-pulse {
    0%, 100% { transform: translate(-50%, -60%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; }
}

#ai-start-icon {
    font-size: 56px;
    margin-bottom: 8px;
    position: relative;
    animation: ai-start-float 3s ease-in-out infinite;
}

@keyframes ai-start-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

#ai-start-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    animation: ai-fade-up 0.6s ease-out both;
    animation-delay: 0.1s;
}

#ai-start-desc {
    font-size: 15px;
    color: #666;
    text-align: center;
    line-height: 1.6;
    max-width: 320px;
    animation: ai-fade-up 0.6s ease-out both;
    animation-delay: 0.2s;
}

@keyframes ai-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== 模式切换 ========== */
#ai-mode-toggle {
    display: flex;
    background: #e8e8ed;
    border-radius: 20px;
    padding: 3px;
    gap: 0;
    margin-top: 8px;
    animation: ai-fade-up 0.6s ease-out both;
    animation-delay: 0.3s;
}

.ai-mode-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 17px;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.ai-mode-btn.ai-mode-active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-mode-btn:not(.ai-mode-active):hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

#ai-start-btn {
    margin-top: 16px;
    padding: 14px 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 28px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
    letter-spacing: 1px;
    animation: ai-fade-up 0.6s ease-out both;
    animation-delay: 0.4s;
}

#ai-start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
}

#ai-start-btn:active {
    transform: scale(0.97);
}

/* ========== 消息气泡 ========== */
.ai-msg {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 75%;
    line-height: 1.6;
    font-size: 15px;
    word-wrap: break-word;
    animation: ai-msg-in 0.3s ease-out;
    position: relative;
}

@keyframes ai-msg-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.ai-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ========== 提示消息 ========== */
.ai-msg.hint {
    background: #fff8e1;
    color: #1a1a2e;
    border-left: 3px solid #f0ad4e;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* ========== 诊断消息 ========== */
.ai-msg.diagnosis {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border: none;
}

/* ========== 成功消息 ========== */
.ai-msg.success {
    align-self: center;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #065f46;
    text-align: center;
    max-width: 85%;
    font-weight: 600;
    font-size: 16px;
    padding: 16px 24px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.3);
    animation: ai-success-in 0.5s ease-out;
}

@keyframes ai-success-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========== 打字动画 ========== */
.ai-typing-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

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

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

.ai-typing-dots span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes ai-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== 输入区 ========== */
#ai-input-area {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #e8e8ed;
    background: #fff;
}

/* ========== 快捷标签 ========== */
#ai-quick-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 0;
    flex-wrap: wrap;
}

.ai-quick-tag {
    padding: 4px 12px;
    background: #f0f2f5;
    border: 1px solid #e8e8ed;
    border-radius: 14px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-quick-tag:hover {
    background: #e8e8ed;
    color: #333;
}

/* ========== 提示按钮 ========== */
#ai-hint-btn {
    padding: 4px 12px;
    background: transparent;
    border: 1px dashed #f0ad4e;
    border-radius: 14px;
    font-size: 12px;
    color: #f0ad4e;
    cursor: pointer;
    transition: all 0.2s;
}

#ai-hint-btn:hover {
    background: rgba(240, 173, 78, 0.1);
}

#ai-hint-btn:disabled {
    border-color: #ccc;
    color: #ccc;
    cursor: not-allowed;
    background: transparent;
}

/* ========== 回合计数 ========== */
#ai-turn-counter {
    margin-left: auto;
    font-size: 12px;
    color: #999;
    white-space: nowrap;
    transition: color 0.3s, font-weight 0.3s;
}

#ai-turn-counter.ai-turns-warning {
    color: #f0ad4e;
    font-weight: 700;
}

#ai-turn-counter.ai-turns-critical {
    color: #e74c3c;
    font-weight: 700;
    animation: ai-pulse-urgent 1s ease-in-out infinite;
}

@keyframes ai-pulse-urgent {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

#ai-give-up-btn {
    margin-left: 8px;
    font-size: 12px;
    color: #ccc;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

#ai-give-up-btn:hover {
    color: #e74c3c;
}

#ai-give-up-btn.ai-disabled {
    color: #e8e8ed;
    pointer-events: none;
}

#ai-input-area.ai-diagnosis-mode #ai-quick-tags {
    display: none;
}

#ai-input-row {
    display: flex;
    align-items: center;
    padding: 12px 20px 16px;
    gap: 12px;
}

#ai-user-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e8e8ed;
    border-radius: 24px;
    outline: none;
    font-size: 15px;
    transition: border-color 0.25s, box-shadow 0.25s;
    background: #f8f9fa;
}

#ai-user-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    background: #fff;
}

#ai-user-input:disabled {
    background: #f0f0f0;
    color: #999;
}

#ai-send-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

#ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#ai-send-btn:active {
    transform: scale(0.95);
}

#ai-send-btn:disabled {
    background: #ccd0d8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ========== 诊断按钮 ========== */
#ai-diagnosis-btn {
    padding: 8px 14px;
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.25s;
}

#ai-diagnosis-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

#ai-diagnosis-btn:disabled {
    border-color: #ccc;
    color: #ccc;
    cursor: not-allowed;
    background: transparent;
}

#ai-input-area.ai-diagnosis-mode #ai-user-input {
    border-color: #e74c3c;
}

#ai-input-area.ai-diagnosis-mode #ai-user-input:focus {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

#ai-input-area.ai-diagnosis-mode #ai-diagnosis-btn {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

/* ========== 系统提示消息 ========== */
.ai-msg.info {
    align-self: center;
    background: #e8e8ed;
    color: #666;
    text-align: center;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 12px;
    max-width: 85%;
}

/* ========== 结算卡片 ========== */
.ai-settlement-card {
    align-self: center;
    background: #fff;
    border-radius: 16px;
    padding: 24px 32px;
    text-align: center;
    width: 260px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    animation: ai-success-in 0.5s ease-out;
}

.ai-settlement-icon {
    font-size: 40px;
}

.ai-settlement-title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 8px 0 16px;
}

.ai-settlement-stats {
    text-align: left;
}

.ai-settlement-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f2f5;
    font-size: 14px;
}

.ai-settlement-label {
    color: #999;
}

.ai-settlement-value {
    font-weight: 600;
    color: #1a1a2e;
}

.ai-settlement-mode {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
}

.ai-settlement-mode.normal {
    background: #e8f5e9;
    color: #2e7d32;
}

.ai-settlement-mode.hard {
    background: #fce4ec;
    color: #c62828;
}

.ai-settlement-rating {
    font-size: 52px;
    font-weight: 800;
    margin-top: 12px;
    line-height: 1;
    animation: ai-rating-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    animation-delay: 0.4s;
    text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
}

@keyframes ai-rating-pop {
    0% { opacity: 0; transform: scale(0.3) rotate(-12deg); }
    60% { transform: scale(1.15) rotate(3deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ========== 图鉴入口 ========== */
#ai-gallery-btn {
    font-size: 14px;
    color: #667eea;
    text-decoration: none;
    margin-top: 8px;
    transition: opacity 0.2s;
    animation: ai-fade-up 0.6s ease-out both;
    animation-delay: 0.5s;
}

#ai-gallery-btn:hover {
    opacity: 0.7;
}

/* ========== 图鉴界面 ========== */
#ai-gallery-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    overflow-y: auto;
}

#ai-gallery-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
}

#ai-gallery-tabs {
    display: flex;
    background: #e8e8ed;
    border-radius: 16px;
    padding: 2px;
    margin: 12px 0 16px;
}

.ai-gallery-tab {
    padding: 6px 16px;
    border: none;
    border-radius: 14px;
    background: transparent;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-gallery-tab-active {
    background: #fff;
    color: #1a1a2e;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#ai-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    width: 100%;
    flex: 1;
    align-content: start;
}

.ai-gallery-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.ai-gallery-card-rating {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.ai-gallery-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 8px 0 4px;
}

.ai-gallery-card-rounds {
    font-size: 12px;
    color: #999;
}

/* ========== 图鉴锁定卡片 ========== */
.ai-gallery-card-locked {
    background: #f0f2f5;
    border: 2px dashed #ddd;
    box-shadow: none;
}

.ai-gallery-card-locked .ai-gallery-card-rating {
    color: #ccc;
    font-size: 24px;
}

.ai-gallery-card-locked .ai-gallery-card-name {
    color: #bbb;
    font-weight: 500;
}

.ai-gallery-card-locked .ai-gallery-card-rounds {
    color: #ccc;
    font-size: 11px;
}

/* ========== 图鉴进度 ========== */
.ai-gallery-progress {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px 4px;
}

.ai-gallery-progress-text {
    font-size: 13px;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
}

.ai-gallery-progress-bar {
    flex: 1;
    height: 6px;
    background: #e8e8ed;
    border-radius: 3px;
    overflow: hidden;
}

.ai-gallery-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.ai-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #999;
    padding: 40px 0;
    font-size: 14px;
}

#ai-gallery-back {
    margin-top: 16px;
    padding: 10px 32px;
    background: transparent;
    border: 2px solid #e8e8ed;
    border-radius: 20px;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

#ai-gallery-back:hover {
    border-color: #667eea;
    color: #667eea;
}

/* ========== 再来一局按钮 ========== */
#ai-restart-btn {
    margin: 0;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: opacity 0.2s;
}

#ai-restart-btn:hover {
    opacity: 0.9;
}

#ai-restart-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    #ai-game-wrapper {
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-width: 100%;
    }

    #ai-chat-box {
        height: auto;
        flex: 1;
    }

    .ai-msg {
        max-width: 85%;
    }
}

