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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    min-height: 100vh;
}

/* ============ Auth Pages ============ */
.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.hostile { border-left: 3px solid #e74c3c !important; }
.dead { opacity: 0.4; text-decoration: line-through; }

.auth-card {
    background: white;
    border-radius: 20px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.logo {
    font-size: 48px;
    margin-bottom: 8px;
}

.auth-header h1 {
    font-size: 26px;
    color: #333;
    margin-bottom: 4px;
}

.subtitle {
    color: #888;
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    background: #f5f5f7;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.tab.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e0e0e5;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: #667eea;
}

.btn-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    margin-top: 8px;
}

.btn-primary:hover {
    opacity: 0.92;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-msg {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    min-height: 20px;
}

.form-msg.error {
    color: #e74c3c;
}

.form-msg.success {
    color: #27ae60;
}

/* ============ Top Nav ============ */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: white;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-sm {
    font-size: 22px;
}

.site-name {
    font-size: 17px;
    font-weight: 600;
    color: #333;
}

.back-btn {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.back-btn:hover {
    text-decoration: underline;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.welcome {
    font-size: 14px;
    color: #666;
}

.btn-logout {
    padding: 7px 16px;
    background: #f5f5f7;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #e8e8ec;
}

.btn-change-pwd {
    padding: 7px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-change-pwd:hover {
    opacity: 0.9;
}

.pwd-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pwd-modal-content {
    background: white;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.pwd-modal-content h3 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.pwd-modal-btns {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.pwd-modal-btns .btn-secondary {
    flex: 1;
    padding: 10px;
    background: #f5f5f7;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.pwd-modal-btns .btn-secondary:hover {
    background: #e8e8ec;
}

.pwd-modal-btns .btn-primary {
    flex: 1;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.pwd-modal-btns .btn-primary:hover {
    opacity: 0.9;
}

/* ============ Home Page ============ */
.home-page {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.home-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 24px;
}

.home-title {
    text-align: center;
    margin-bottom: 50px;
}

.home-title h2 {
    font-size: 32px;
    color: #333;
    margin-bottom: 8px;
}

.home-title p {
    color: #888;
    font-size: 15px;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.feature-card {
    background: white;
    border-radius: 20px;
    padding: 36px 28px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transition: transform 0.25s, box-shadow 0.25s;
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

.card-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.card-icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

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

.tarot-icon {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.tank-icon {
    background: linear-gradient(135deg, #e8a0ff 0%, #f8d384 100%);
}

.jianghu-icon {
    background: linear-gradient(135deg, #c0392b 0%, #8e44ad 100%);
}

.feature-card h3 {
    font-size: 20px;
    color: #333;
    margin-bottom: 8px;
}

.feature-card p {
    color: #888;
    font-size: 14px;
    line-height: 1.6;
}

.card-arrow {
    position: absolute;
    top: 36px;
    right: 32px;
    font-size: 22px;
    color: #ccc;
    transition: color 0.2s, transform 0.2s;
}

.feature-card:hover .card-arrow {
    color: #667eea;
    transform: translateX(4px);
}

/* ============ Chat Page ============ */
.chat-page {
    background: #f0f2f5;
}

.chat-container {
    max-width: 760px;
    margin: 0 auto;
    height: calc(100vh - 68px);
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: white;
    gap: 12px;
    border-bottom: 1px solid #eee;
}

.chat-header .avatar {
    font-size: 28px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header h1 {
    font-size: 17px;
    font-weight: 600;
}

.chat-header .status {
    font-size: 12px;
    color: #27ae60;
}

.btn-clear {
    margin-left: auto;
    padding: 7px 14px;
    background: #f5f5f7;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-clear:hover {
    background: #e8e8ec;
}

.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f7f8fc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.chat-box::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 82%;
    animation: msgFade 0.3s ease;
}

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

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

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

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

.user-message .message-avatar {
    background: #667eea;
}

.ai-message .message-avatar {
    background: #e0e0e0;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

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

.ai-message .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}

.suggestion {
    display: inline-block;
    background: #f0f2ff;
    color: #667eea;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    margin: 4px 4px 0 0;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion:hover {
    background: #667eea;
    color: white;
}

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

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.input-area {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid #eee;
    background: white;
    align-items: flex-end;
}

textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 10px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}

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

#send-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    height: 42px;
}

#send-btn:hover {
    opacity: 0.9;
}

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

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============ Tarot Page ============ */
.tarot-page {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: calc(100vh - 68px);
    color: white;
}

.tarot-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px;
}

.tarot-header {
    text-align: center;
    margin-bottom: 32px;
}

.tarot-header h1 {
    font-size: 34px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #f8d384, #e8a0ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tarot-header p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
}

.question-area {
    display: flex;
    gap: 12px;
    margin-bottom: 36px;
}

.question-area input {
    flex: 1;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.question-area input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.question-area input:focus {
    border-color: rgba(255, 255, 255, 0.5);
}

#ask-btn {
    padding: 0 28px;
    background: linear-gradient(135deg, #e8a0ff, #f8d384);
    color: #1a1a2e;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    white-space: nowrap;
}

#ask-btn:hover {
    opacity: 0.9;
}

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

.spread-area {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 36px;
    perspective: 1000px;
}

.tarot-slot {
    text-align: center;
}

.slot-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.card-placeholder {
    width: 120px;
    height: 200px;
    background: linear-gradient(135deg, #2d2d5f, #4a3f7a);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    transition: transform 0.6s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.card-placeholder.flipped {
    background: linear-gradient(135deg, #f8d384, #e8a0ff);
    border-color: rgba(255, 255, 255, 0.3);
    color: #1a1a2e;
}

.card-placeholder.flipped .card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    text-align: center;
}

.card-placeholder.flipped .card-emoji {
    font-size: 36px;
}

.card-placeholder.flipped .card-name {
    font-size: 12px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.3;
}

.card-placeholder.flipped.is-reversed .card-emoji {
    transform: rotate(180deg);
}

.card-placeholder.shuffling {
    animation: shuffle 0.6s ease;
}

@keyframes shuffle {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg) translateY(-5px); }
    50% { transform: rotate(10deg) translateY(5px); }
    75% { transform: rotate(-5deg); }
    100% { transform: rotate(0deg); }
}

.card-placeholder.flipping {
    animation: flipCard 0.8s ease forwards;
}

@keyframes flipCard {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(180deg); }
}

.tarot-result {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 24px;
    min-height: 120px;
    backdrop-filter: blur(10px);
}

.tarot-result .hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

.tarot-result .interpretation {
    font-size: 14px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.9);
    white-space: pre-wrap;
}

.tarot-result .loading {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

.tarot-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.btn-secondary {
    padding: 10px 22px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
    .spread-area {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .card-placeholder {
        width: 100px;
        height: 160px;
    }

    .home-title h2 {
        font-size: 24px;
    }

    .tarot-header h1 {
        font-size: 26px;
    }
}