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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #e4e4e7;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    padding: 30px 0;
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: #a1a1aa;
    font-size: 1rem;
}

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

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.welcome-message h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #f4f4f5;
}

.welcome-message p {
    color: #a1a1aa;
    margin-bottom: 20px;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.suggestion-tag {
    padding: 8px 16px;
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.4);
    border-radius: 20px;
    font-size: 0.9rem;
    color: #a5b4fc;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-tag:hover {
    background: rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message.user .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message.assistant .avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.message-content {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-left-radius: 4px;
}

.message.assistant .message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 0.85rem;
}

.message.assistant .message-content code {
    font-family: 'Fira Code', monospace;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a1a1aa;
    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); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

.input-area {
    padding: 20px 0;
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #1a1a2e 60%, transparent);
    padding-top: 40px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px 16px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e4e4e7;
    font-size: 1rem;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
}

#userInput::placeholder {
    color: #71717a;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.game-result {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-result h3 {
    color: #a5b4fc;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.game-result ul {
    list-style: none;
    padding: 0;
}

.game-result li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
    color: #d4d4d8;
}

.game-result li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4ade80;
}

.game-link {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.game-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        /* 适配移动端安全区域 */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .container {
        padding: 10px;
        padding-bottom: 0;
    }
    
    .header {
        padding: 15px 0;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .chat-container {
        padding: 10px 0;
        padding-bottom: 100px;
        gap: 15px;
    }
    
    .welcome-message {
        padding: 30px 15px;
        margin: 0 5px;
    }
    
    .welcome-icon {
        font-size: 3rem;
    }
    
    .welcome-message h2 {
        font-size: 1.2rem;
    }
    
    .welcome-message p {
        font-size: 0.9rem;
    }
    
    .suggestions {
        gap: 8px;
    }
    
    .suggestion-tag {
        padding: 10px 18px;
        font-size: 0.95rem;
        /* 更好的触摸体验 */
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .suggestion-tag:active {
        transform: scale(0.95);
        background: rgba(102, 126, 234, 0.4);
    }
    
    .message {
        gap: 8px;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .message-content {
        max-width: 85%;
        padding: 12px 14px;
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* 移动端输入区域固定底部 */
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        background: linear-gradient(to top, #1a1a2e 80%, transparent);
        z-index: 100;
    }
    
    .input-wrapper {
        padding: 10px 12px;
        border-radius: 12px;
    }
    
    #userInput {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
        min-width: 44px;
        min-height: 44px;
    }
    
    .send-btn:active {
        transform: scale(0.9);
    }
    
    .game-link {
        display: block;
        text-align: center;
        padding: 12px 20px;
        margin-top: 15px;
        /* 更好的触摸体验 */
        min-height: 44px;
        line-height: 20px;
    }
    
    .game-link:active {
        transform: scale(0.98);
    }
}

/* 小屏幕手机进一步优化 */
@media (max-width: 375px) {
    .header h1 {
        font-size: 1.3rem;
    }
    
    .welcome-message h2 {
        font-size: 1.1rem;
    }
    
    .suggestion-tag {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .message-content {
        max-width: 88%;
        font-size: 0.85rem;
    }
}

/* 横屏模式 */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 10px 0;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        display: none;
    }
    
    .welcome-message {
        padding: 20px 15px;
    }
    
    .welcome-icon {
        font-size: 2rem;
        margin-bottom: 10px;
    }
    
    .input-area {
        padding: 8px 10px;
    }
}
