/* ========== 全局变量与重置 ========== */
:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* ========== 屏幕切换 ========== */
.screen {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}
.screen.active { display: flex; }

/* ========== 开始菜单 ========== */
#title-screen {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.title-container {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.game-title {
    font-size: 4rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.15em;
    text-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
    margin-bottom: 0.5rem;
}

.game-subtitle {
    color: #a5b4fc;
    font-size: 1.1rem;
    margin-bottom: 3rem;
    letter-spacing: 0.05em;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.menu-btn {
    padding: 0.75rem 2.5rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.08);
    color: #e0e7ff;
    font-size: 1.05rem;
    cursor: pointer;
    transition: var(--transition);
    min-width: 200px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.05em;
}
.menu-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}
.menu-btn.primary {
    background: var(--primary);
    border-color: var(--primary-light);
    color: #fff;
    font-weight: 600;
}
.menu-btn.primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

/* ========== 姓名输入 ========== */
#name-screen {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    justify-content: center;
    align-items: center;
}

.name-container {
    text-align: center;
    animation: fadeInUp 0.6s ease;
}
.name-container h2 {
    color: #fff;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.name-hint {
    color: #a5b4fc;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

#player-name-input {
    display: block;
    width: 280px;
    margin: 0 auto 1.5rem;
    padding: 0.8rem 1.2rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 1.2rem;
    text-align: center;
    outline: none;
    transition: var(--transition);
}
#player-name-input::placeholder { color: rgba(255,255,255,0.4); }
#player-name-input:focus {
    border-color: var(--primary-light);
    background: rgba(255,255,255,0.15);
}

/* ========== 游戏主界面 ========== */
#game-screen {
    flex-direction: column;
    background: var(--bg);
}

/* 顶部栏 */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 10;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.top-bar-left .divider { color: var(--border); }
#current-position { font-weight: 600; color: var(--primary); }
#current-salary { color: var(--success); font-weight: 500; }

.top-bar-right { display: flex; gap: 0.5rem; }
.icon-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}
.icon-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* 主区域 */
#game-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========== 左侧属性栏 ========== */
#stats-panel {
    width: 220px;
    min-width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.2rem;
    overflow-y: auto;
}
.panel-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.stat-item {
    margin-bottom: 0.9rem;
}
.stat-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
}
.stat-name { color: var(--text-secondary); font-weight: 500; }
.stat-value { color: var(--text); font-weight: 600; }
.stat-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background-color 0.3s ease;
}
.stat-bar-fill.coding { background: var(--info); }
.stat-bar-fill.social { background: #8b5cf6; }
.stat-bar-fill.connection { background: #06b6d4; }
.stat-bar-fill.reputation { background: var(--success); }
.stat-bar-fill.stress { background: var(--danger); }
.stat-bar-fill.workload { background: var(--warning); }

/* ========== 好感度系统 ========== */
.affection-title {
    color: #ec4899;
    border-bottom-color: #fce7f3;
}

.affection-item {
    margin-bottom: 0.8rem;
}

.affection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.affection-char {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.affection-avatar-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.affection-avatar-text {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.affection-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.affection-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.affection-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.affection-status {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
}
.status-known { background: #f1f5f9; color: #64748b; }
.status-friend { background: #dbeafe; color: #2563eb; }
.status-ambiguous { background: #fce7f3; color: #db2777; }
.status-lover { background: #fda4af; color: #9f1239; }

.affection-bar {
    height: 5px;
}

.stat-bar-fill.affection-xiaomei { background: linear-gradient(90deg, #a855f7, #ec4899); }
.stat-bar-fill.affection-xiaoli { background: linear-gradient(90deg, #f59e0b, #fb923c); }
.stat-bar-fill.affection-zhoujie { background: linear-gradient(90deg, #dc2626, #f87171); }

/* ========== 中央场景区 ========== */
#scene-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 2rem;
    overflow-y: auto;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* 场景标题 */
#scene-header {
    text-align: center;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.5s ease;
}
#scene-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}
#scene-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* 角色显示 */
#character-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.5s ease;
}

/* 角色立绘 */
#character-portrait {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
    transition: var(--transition);
}

#character-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

#character-info {
    display: flex;
    flex-direction: column;
}
#character-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
#character-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 对话框 */
#dialogue-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    box-shadow: var(--shadow);
    min-height: 80px;
}
#dialogue-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
}
#dialogue-indicator {
    position: absolute;
    bottom: 0.5rem;
    right: 1rem;
    color: var(--primary-light);
    animation: blink 1s infinite;
    font-size: 0.8rem;
}

/* 旁白 */
#narration-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid var(--info);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1rem 1.2rem;
    margin-bottom: 1.2rem;
}
#narration-text {
    font-size: 0.95rem;
    line-height: 1.8;
    color: #334155;
    font-style: italic;
}

/* 选项区 */
#choices-container {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.5rem;
    animation: fadeInUp 0.4s ease;
}

.choice-btn {
    padding: 1rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    box-shadow: var(--shadow);
}
.choice-btn:hover:not(.locked) {
    border-color: var(--primary);
    background: #f0f0ff;
    transform: translateX(4px);
    box-shadow: var(--shadow-lg);
}
.choice-btn:active:not(.locked) {
    transform: translateX(2px);
}

.choice-index {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.choice-content { flex: 1; }
.choice-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.5;
}
.choice-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

.choice-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
}
.choice-btn.locked .choice-index {
    background: #94a3b8;
}
.choice-btn.locked .choice-text {
    color: #94a3b8;
}
.choice-lock-reason {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.2rem;
}

/* ========== 通知 ========== */
#notification-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideInRight 0.3s ease, fadeOut 0.5s ease 2s forwards;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}
.notification.positive {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.notification.negative {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.notification.neutral {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ========== 存档弹窗 ========== */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}
.modal-content h3 {
    font-size: 1.2rem;
    margin-bottom: 1.2rem;
    text-align: center;
    color: var(--text);
}

#save-slots {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 1.5rem;
}

.save-slot {
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.save-slot:hover {
    border-color: var(--primary);
    background: #f0f0ff;
}
.save-slot-info {
    display: flex;
    flex-direction: column;
}
.save-slot-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}
.save-slot-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}
.save-slot-empty {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.85rem;
}

#btn-close-modal {
    display: block;
    margin: 0 auto;
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
    min-width: 120px;
}
#btn-close-modal:hover {
    background: #e2e8f0;
    color: var(--text);
}

/* ========== 结局画面 ========== */
#ending-screen {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 2rem;
}

.ending-container {
    text-align: center;
    max-width: 600px;
    animation: fadeInUp 1s ease;
}

/* 结局立绘 */
#ending-portrait {
    width: 280px;
    height: 280px;
    border-radius: var(--radius);
    object-fit: cover;
    margin: 0 auto 1.5rem;
    display: block;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

#ending-badge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
}

#ending-title {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

#ending-description {
    color: #cbd5e1;
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    text-align: left;
}

#ending-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}
.ending-stat-item {
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
}
.ending-stat-label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.ending-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-top: 0.2rem;
}

#ending-evaluation {
    color: #a5b4fc;
    font-size: 0.95rem;
    font-style: italic;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.ending-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ========== 角色头像配色 ========== */
.avatar-jinzong { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.avatar-laoli { background: linear-gradient(135deg, #6d28d9, #8b5cf6); }
.avatar-xiaomei { background: linear-gradient(135deg, #059669, #34d399); }
.avatar-xiaochen { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.avatar-xiaoshuai { background: linear-gradient(135deg, #16a34a, #4ade80); }
.avatar-xiaopang { background: linear-gradient(135deg, #7c3aed, #c084fc); }
.avatar-xiaozhuang { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.avatar-xiaozhang { background: linear-gradient(135deg, #16a34a, #86efac); }
.avatar-xiaoli { background: linear-gradient(135deg, #059669, #6ee7b7); }
.avatar-zhoujie { background: linear-gradient(135deg, #9333ea, #c084fc); }
.avatar-narrator { background: linear-gradient(135deg, #475569, #94a3b8); }

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.fade-in { animation: fadeIn 0.5s ease; }
.fade-in-up { animation: fadeInUp 0.5s ease; }

.hidden { display: none !important; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .game-title { font-size: 2.5rem; }

    #game-main { flex-direction: column; }

    #stats-panel {
        width: 100%;
        min-width: unset;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.8rem 1rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: flex-start;
    }
    .panel-title {
        display: none;
    }
    .stat-item {
        flex: 1 1 calc(33% - 0.5rem);
        min-width: 90px;
        margin-bottom: 0;
    }

    #scene-area {
        padding: 1rem;
    }

    .choice-btn {
        padding: 0.8rem 1rem;
    }
}

@media (max-width: 480px) {
    .game-title { font-size: 2rem; }
    #scene-title { font-size: 1.1rem; }
    .stat-item { flex: 1 1 calc(50% - 0.5rem); }
}
