/* =============================================
   文字冒险RPG游戏 - 暗色金色主题
   泽盛赋能 出品
   ============================================= */

/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a28;
    --bg-card-hover: #22223a;
    --bg-input: #16162a;
    --gold-primary: #d4a843;
    --gold-light: #f0d060;
    --gold-dark: #b8922e;
    --gold-glow: rgba(212, 168, 67, 0.3);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a80;
    --border-color: #2a2a3a;
    --border-gold: rgba(212, 168, 67, 0.3);
    --danger: #e74c3c;
    --success: #2ecc71;
    --info: #3498db;
    --warning: #f39c12;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-gold: 0 0 20px rgba(212, 168, 67, 0.15);
    --transition: all 0.3s ease;
    --font-main: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--gold-light); }

img { max-width: 100%; height: auto; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ===== Auth Page ===== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #1a1a3a 0%, var(--bg-primary) 60%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-gold);
}

.auth-header { text-align: center; margin-bottom: 32px; }
.brand-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gold-primary);
    text-shadow: 0 0 20px rgba(212, 168, 67, 0.3);
}
.brand-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 8px; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border-color); }
.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
}
.auth-tab.active {
    background: var(--gold-primary);
    color: #000;
    font-weight: 600;
}

.auth-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 13px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px var(--gold-glow);
}
.form-group input::placeholder { color: var(--text-muted); }

.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
    color: #000;
    box-shadow: 0 4px 15px rgba(212, 168, 67, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
    box-shadow: 0 6px 20px rgba(212, 168, 67, 0.4);
    transform: translateY(-1px);
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { border-color: var(--gold-primary); background: var(--bg-card-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--gold-primary); border: 1px solid var(--border-gold); }
.btn-ghost:hover { background: rgba(212, 168, 67, 0.1); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 17px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ===== Alert ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: rgba(231, 76, 60, 0.15); border: 1px solid rgba(231, 76, 60, 0.3); color: #e74c3c; }
.alert-success { background: rgba(46, 204, 113, 0.15); border: 1px solid rgba(46, 204, 113, 0.3); color: #2ecc71; }
.alert-info { background: rgba(52, 152, 219, 0.15); border: 1px solid rgba(52, 152, 219, 0.3); color: #3498db; }

/* ===== Navbar ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
}
.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.navbar-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-nav { display: flex; align-items: center; gap: 8px; }
.navbar-nav a, .navbar-nav button {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
}
.navbar-nav a:hover, .navbar-nav button:hover { color: var(--gold-primary); background: rgba(212, 168, 67, 0.1); }
.navbar-nav a.active { color: var(--gold-primary); }
.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== Main Layout ===== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ===== Home Page ===== */
.hero-section {
    text-align: center;
    padding: 60px 0 40px;
}
.hero-title {
    font-size: 42px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary), var(--gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}
.hero-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 40px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--border-gold), transparent);
}

/* ===== Template Cards ===== */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 48px;
}
.template-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}
.template-card:hover {
    transform: translateY(-4px);
    border-color: var(--gold-primary);
    box-shadow: var(--shadow-gold);
}
.template-card-bg {
    padding: 32px 24px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.template-card-emoji { font-size: 48px; margin-bottom: 12px; }
.template-card-name { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.template-card-desc { font-size: 14px; color: rgba(255, 255, 255, 0.7); line-height: 1.5; }

/* ===== Save Cards ===== */
.save-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.save-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
}
.save-card:hover {
    border-color: var(--gold-primary);
    background: var(--bg-card-hover);
}
.save-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.save-card-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.save-card-time { font-size: 12px; color: var(--text-muted); }
.save-card-info { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); }
.save-card-info span { display: flex; align-items: center; gap: 4px; }
.save-card-scene { margin-top: 8px; font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ===== Game Page ===== */
.game-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    min-height: calc(100vh - 96px);
}

.game-main { display: flex; flex-direction: column; }

.scene-header {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.scene-emoji { font-size: 36px; }
.scene-title { font-size: 20px; font-weight: 700; color: var(--gold-primary); }
.scene-turn { font-size: 13px; color: var(--text-muted); }

.scene-image-container {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
    max-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}
.scene-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.scene-image-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 14px;
}

.narrative-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
    min-height: 120px;
}
.narrative-box h2 { font-size: 20px; color: var(--gold-primary); margin: 20px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.narrative-box h3 { font-size: 17px; color: var(--gold-light); margin: 16px 0 10px; }
.narrative-box h4 { font-size: 15px; color: var(--text-primary); margin: 12px 0 8px; }
.narrative-box strong { color: var(--gold-primary); }
.narrative-box em { color: var(--text-secondary); font-style: italic; }
.narrative-box ul, .narrative-box ol { margin: 8px 0; padding-left: 24px; }
.narrative-box li { margin-bottom: 4px; }
.narrative-box p { margin-bottom: 12px; }
.narrative-box p:last-child { margin-bottom: 0; }
.narrative-box hr { border: none; border-top: 1px solid var(--border-color); margin: 16px 0; }
.narrative-box blockquote { border-left: 3px solid var(--gold-primary); padding-left: 16px; margin: 12px 0; color: var(--text-secondary); font-style: italic; }
.narrative-box .typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--gold-primary);
    animation: blink 1s infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

.options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.option-btn {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}
.option-btn:hover {
    border-color: var(--gold-primary);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-gold);
    transform: translateX(4px);
}
.option-btn:disabled { opacity: 0.5; cursor: wait; transform: none !important; }
.option-emoji { font-size: 20px; flex-shrink: 0; }
.option-text { flex: 1; }

.custom-input-area {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.custom-input-area input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}
.custom-input-area input:focus { border-color: var(--gold-primary); box-shadow: 0 0 0 3px var(--gold-glow); }

/* ===== Sidebar ===== */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}
.sidebar-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gold-primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Player Stats */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}
.stat-label { color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.stat-value { color: var(--text-primary); font-weight: 600; }
.stat-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}
.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}
.stat-bar-health { background: linear-gradient(to right, #e74c3c, #2ecc71); }
.stat-bar-stamina { background: linear-gradient(to right, #3498db, #2ecc71); }
.stat-bar-exp { background: linear-gradient(to right, var(--gold-dark), var(--gold-light)); }

/* Inventory */
.inventory-list { max-height: 200px; overflow-y: auto; }
.inventory-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.inventory-item:last-child { border-bottom: none; }
.inventory-item-emoji { font-size: 16px; }
.inventory-item-name { flex: 1; color: var(--text-primary); }
.inventory-item-qty { color: var(--text-muted); }

/* Quest List */
.quest-list { max-height: 200px; overflow-y: auto; }
.quest-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}
.quest-item:last-child { border-bottom: none; }
.quest-item-header { display: flex; align-items: center; gap: 6px; }
.quest-item-name { color: var(--text-primary); font-weight: 500; }
.quest-item-type { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--bg-secondary); color: var(--text-muted); }
.quest-item-desc { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.quest-completed .quest-item-name { text-decoration: line-through; color: var(--text-muted); }

/* ===== Achievements Page ===== */
.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.achievement-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.achievement-card.unlocked {
    border-color: var(--gold-primary);
    box-shadow: var(--shadow-gold);
}
.achievement-card.locked { opacity: 0.5; }
.achievement-emoji { font-size: 36px; flex-shrink: 0; }
.achievement-info { flex: 1; }
.achievement-name { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.achievement-desc { font-size: 13px; color: var(--text-secondary); }
.achievement-time { font-size: 12px; color: var(--gold-primary); margin-top: 8px; }
.achievement-progress {
    text-align: center;
    margin-bottom: 32px;
    font-size: 18px;
    color: var(--text-secondary);
}
.achievement-progress strong { color: var(--gold-primary); font-size: 24px; }

/* ===== Achievement Toast ===== */
.achievement-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1000;
    background: var(--bg-card);
    border: 2px solid var(--gold-primary);
    border-radius: var(--radius);
    padding: 16px 24px;
    box-shadow: var(--shadow-gold);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.5s ease, fadeOut 0.5s ease 3s forwards;
    max-width: 360px;
}
.achievement-toast-emoji { font-size: 32px; }
.achievement-toast-text { font-size: 14px; }
.achievement-toast-label { color: var(--gold-primary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.achievement-toast-name { color: var(--text-primary); font-weight: 600; margin-top: 2px; }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; pointer-events: none; }
}

/* ===== Loading ===== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--gold-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    flex-direction: column;
    gap: 16px;
}
.loading-overlay .loading-spinner { width: 40px; height: 40px; border-width: 3px; }
.loading-text { color: var(--text-secondary); font-size: 16px; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-emoji { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 16px; margin-bottom: 24px; }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 24px;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow);
}
.modal-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ===== Chat History ===== */
.chat-history {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
}
.chat-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
}
.chat-message.user {
    background: rgba(212, 168, 67, 0.15);
    border: 1px solid var(--border-gold);
    margin-left: 40px;
}
.chat-message.assistant {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    margin-right: 40px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
    .game-sidebar { order: -1; }
    .hero-title { font-size: 28px; }
    .hero-subtitle { font-size: 15px; }
    .template-grid { grid-template-columns: 1fr; }
    .save-grid { grid-template-columns: 1fr; }
    .navbar-inner { padding: 0 12px; }
    .main-container { padding: 16px 12px; }
    .auth-container { padding: 24px; margin: 16px; }
    .achievement-grid { grid-template-columns: 1fr; }
}
