/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --secondary: #A29BFE;
    --accent: #FD79A8;
    --success: #00B894;
    --warning: #FDCB6E;
    --danger: #E17055;
    --info: #74B9FF;
    --dark: #2D3436;
    --gray: #636E72;
    --light: #DFE6E9;
    --white: #FFFFFF;
    --bg: #F5F6FA;
    --shadow: 0 4px 20px rgba(0,0,0,0.1);
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== 屏幕管理 ==================== */
.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ==================== 开场画面 ==================== */
#intro-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    justify-content: center;
    align-items: center;
    text-align: center;
}

.intro-content {
    animation: fadeInUp 0.8s ease;
}

.game-title {
    font-size: 4rem;
    color: var(--white);
    text-shadow: 0 4px 20px rgba(0,0,0,0.3);
    margin-bottom: 0.5rem;
    letter-spacing: 0.2em;
}

.game-subtitle {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 3rem;
    letter-spacing: 0.3em;
}

.intro-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.version-info {
    position: absolute;
    bottom: 2rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
}

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

/* ==================== 按钮样式 ==================== */
.btn {
    padding: 0.8rem 2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: var(--white);
    border: 2px solid rgba(255,255,255,0.5);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

.btn-info {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

/* ==================== 角色创建 ==================== */
#create-screen {
    background: var(--bg);
    padding: 2rem;
}

.create-container {
    max-width: 600px;
    margin: 0 auto;
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.create-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--light);
}

.create-section h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--light);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: normal;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: background 0.3s;
}

.radio-group label:hover {
    background: var(--bg);
}

.radio-group input[type="radio"] {
    accent-color: var(--primary);
}

.points-remaining {
    float: right;
    color: var(--accent);
    font-weight: bold;
}

.stat-allocation {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-item label {
    font-weight: 600;
    min-width: 80px;
}

.stat-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--light);
    color: var(--dark);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.stat-btn:hover {
    background: var(--primary);
    color: var(--white);
}

.stat-value {
    min-width: 50px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
}

.create-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.create-actions .btn {
    min-width: 150px;
}

/* ==================== 主游戏界面 ==================== */
#game-screen {
    background: var(--bg);
    height: 100vh;
    overflow: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 100;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary);
}

.player-info {
    font-size: 0.85rem;
    color: var(--gray);
}

.header-center {
    flex: 1;
    text-align: center;
}

.game-time {
    font-weight: 600;
    color: var(--dark);
    background: var(--bg);
    padding: 0.4rem 1rem;
    border-radius: 20px;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.game-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 1rem;
    gap: 1rem;
}

.game-left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.game-right-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

/* ==================== 场景显示 ==================== */
.scene-display {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    flex: 1;
    overflow-y: auto;
}

.scene-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--bg);
}

.scene-location {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary);
}

.scene-time {
    color: var(--gray);
    font-size: 0.9rem;
}

.scene-content {
    line-height: 1.8;
}

.scene-narrative {
    margin-bottom: 1rem;
    color: var(--dark);
}

.scene-dialogue {
    margin: 0.8rem 0;
    padding: 0.8rem 1rem;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.scene-dialogue .speaker {
    font-weight: bold;
    color: var(--primary);
    margin-right: 0.5rem;
}

.scene-action {
    font-style: italic;
    color: var(--gray);
    margin: 0.5rem 0;
}

.scene-choice {
    margin: 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #667eea15, #764ba215);
    border-radius: 8px;
}

/* ==================== 行动面板 ==================== */
.action-panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.action-panel h3 {
    font-size: 0.95rem;
    color: var(--gray);
    margin-bottom: 0.8rem;
}

.action-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.6rem 1.2rem;
    border: 2px solid var(--light);
    border-radius: 20px;
    background: var(--white);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.action-btn:hover {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}

.action-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
}

/* ==================== 右侧面板 ==================== */
.panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.panel h3 {
    font-size: 0.95rem;
    color: var(--gray);
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 状态条 */
.status-bars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-label {
    min-width: 40px;
    font-size: 0.85rem;
    color: var(--gray);
}

.bar {
    flex: 1;
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.bar-fill.health { background: var(--success); }
.bar-fill.mood { background: var(--warning); }
.bar-fill.hunger { background: var(--danger); }
.bar-fill.stress { background: var(--accent); }

.status-value {
    min-width: 30px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: bold;
}

/* 快速统计 */
.quick-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--light);
}

.quick-stat {
    text-align: center;
}

.qs-label {
    display: block;
    font-size: 0.75rem;
    color: var(--gray);
}

.qs-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary);
}

/* NPC列表 */
.npc-count {
    background: var(--primary);
    color: var(--white);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.8rem;
}

.npc-list {
    max-height: 200px;
    overflow-y: auto;
}

.npc-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.npc-item:hover {
    background: var(--bg);
}

.npc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: var(--light);
}

.npc-info {
    flex: 1;
}

.npc-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.npc-relation {
    font-size: 0.75rem;
    color: var(--gray);
}

.npc-affection {
    font-size: 0.8rem;
    color: var(--accent);
}

/* 目标面板 */
.goal-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.goal-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.goal-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.goal-item.completed .goal-checkbox {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.goal-item.completed .goal-text {
    text-decoration: line-through;
    color: var(--gray);
}

/* ==================== 底部输入区 ==================== */
.game-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--white);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

#custom-command {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid var(--light);
    border-radius: 8px;
    font-size: 1rem;
}

#custom-command:focus {
    outline: none;
    border-color: var(--primary);
}

.game-input-area .btn {
    min-width: auto;
    padding: 0.8rem 1.5rem;
}

/* ==================== 模态框 ==================== */
.modal-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-container {
    background: var(--white);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.3s ease;
}

.modal-container.small {
    max-width: 400px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--light);
}

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--danger);
    color: var(--white);
}

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 70px);
}

/* 背包样式 */
.backpack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
}

.backpack-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.backpack-item:hover {
    background: var(--light);
    transform: translateY(-2px);
}

.backpack-item .item-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.backpack-item .item-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.backpack-item .item-count {
    font-size: 0.75rem;
    color: var(--gray);
}

/* NPC详情 */
.npc-detail-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.npc-detail-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.npc-detail-basic {
    flex: 1;
}

.npc-detail-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
}

.npc-detail-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.npc-tag {
    padding: 0.2rem 0.6rem;
    background: var(--bg);
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--gray);
}

.npc-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.npc-stat-box {
    background: var(--bg);
    padding: 0.8rem;
    border-radius: 8px;
}

.npc-stat-label {
    font-size: 0.75rem;
    color: var(--gray);
}

.npc-stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--dark);
}

.affection-bar {
    height: 10px;
    background: var(--light);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 0.3rem;
}

.affection-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--danger));
    border-radius: 5px;
    transition: width 0.5s;
}

/* 帮助界面 */
.help-section {
    margin-bottom: 1.5rem;
}

.help-section h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.help-section p {
    color: var(--gray);
    margin-bottom: 0.3rem;
}

/* 菜单按钮 */
.menu-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: none;
    border-radius: 8px;
    background: var(--bg);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.menu-btn:hover {
    background: var(--primary);
    color: var(--white);
}

/* ==================== 提示消息 ==================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: var(--dark);
    color: var(--white);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--dark); }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .game-main {
        flex-direction: column;
    }

    .game-right-panel {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
    }

    .game-right-panel .panel {
        min-width: 250px;
    }

    .game-title {
        font-size: 2.5rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}
