/* ================= 全局 CSS 变量 ================= */
:root {
    --bg-main: #121212;
    --bg-card: #1e1e1e;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --accent: #f0c040;
    --accent-hover: #e5b230;
    --border-color: #333333;
    --danger: #ff5252;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ================= 顶部导航 ================= */
header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo { font-size: 18px; font-weight: bold; color: var(--accent); }
.tabs { display: flex; gap: 10px; }
.tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.3s;
}
.tab-btn.active {
    color: var(--accent);
    background: rgba(240, 192, 64, 0.1);
    border-color: rgba(240, 192, 64, 0.3);
}

/* ================= 主体与模块 ================= */
main { flex: 1; padding: 20px; max-width: 800px; margin: 0 auto; width: 100%; }
.module { display: none; animation: fadeIn 0.3s ease; }
.module.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.placeholder-box { text-align: center; padding: 80px 20px; color: var(--text-muted); border: 1px dashed var(--border-color); border-radius: 12px; margin-top: 20px; }

/* ================= 素材库专属 UI ================= */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
select, input[type="text"], textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    font-family: inherit;
}
select:focus, input[type="text"]:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 100px; }
.char-count { text-align: right; font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* 复选框行 */
.checkbox-row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* 按钮组 */
.generate-btn {
    background: var(--accent);
    color: #111;
    border: none;
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 10px;
}
.generate-btn:hover:not(:disabled) { background: var(--accent-hover); }
.generate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.upgrade-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 15px;
}
.upgrade-btn:hover { background: rgba(240, 192, 64, 0.1); }

/* ================= 结果展示区 ================= */
.result-container { margin-top: 30px; display: none; }
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
}
.result-title { color: var(--accent); font-size: 16px; font-weight: bold; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px;}
.result-content { font-size: 15px; line-height: 1.8; color: #ccc; white-space: pre-wrap; }
.copy-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}
.copy-btn:hover { background: #444; }

/* ================= 历史记录 ================= */
.history-section { margin-top: 40px; border-top: 1px dashed var(--border-color); padding-top: 20px; }
.history-title { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }
.history-item { background: #1a1a1a; padding: 10px; border-radius: 6px; font-size: 13px; color: #aaa; margin-bottom: 8px; cursor: pointer; }
.history-item:hover { background: #2a2a2a; color: #fff; }

/* ================= 模态框通用 ================= */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1000; justify-content: center; align-items: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; width: 100%; max-width: 400px; padding: 25px; }
.note-title { color: var(--accent); font-size: 18px; margin-bottom: 15px; text-align: center; font-weight: bold; }
.fb-label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 5px; }
.fb-input, .fb-textarea { width: 100%; background: #2a2a2a; border: 1px solid #444; color: #fff; padding: 12px; border-radius: 8px; margin-bottom: 15px; font-size: 14px; outline: none; }
.btn-group { display: flex; gap: 10px; margin-top: 10px; }
.btn-group button { flex: 1; padding: 12px; border-radius: 8px; cursor: pointer; font-size: 15px; border: none; }
.primary-btn { background: var(--accent); color: #111; font-weight: bold; }
.btn-cancel { background: #333; color: #fff; border: 1px solid #555; }

footer { text-align: center; padding: 20px; font-size: 12px; color: var(--text-muted); line-height: 1.8; margin-top: auto; }
footer .links { margin-top: 10px; }
footer .links span { cursor: pointer; color: var(--text-main); text-decoration: underline; }
footer .links span:hover { color: var(--accent); }
/* ================= 剧本杀选本大厅 ================= */
.script-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 20px;
}
@media (min-width: 600px) {
    .script-grid { grid-template-columns: 1fr 1fr; }
}

.script-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.script-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.script-title { font-size: 18px; font-weight: bold; color: var(--text-main); margin-bottom: 8px; }
.script-desc { 
    font-size: 13px; 
    color: var(--text-muted); 
    line-height: 1.5; 
    display: -webkit-box; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    /* 加上下面这行标准写法，虽然有些老浏览器兼容性稍差，但现代浏览器都认 */
    line-clamp: 2; 
    -webkit-line-clamp: 2; 
}

/* 难度标签 */
.tag-normal { background: rgba(76, 175, 80, 0.2); color: #4caf50; border: 1px solid #4caf50; }
.tag-hard { background: rgba(33, 150, 243, 0.2); color: #2196f3; border: 1px solid #2196f3; }
.tag-hell { background: rgba(255, 82, 82, 0.2); color: #ff5252; border: 1px solid #ff5252; animation: pulseHell 2s infinite; }
.diff-tag { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: bold; }

@keyframes pulseHell {
    0% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(255, 82, 82, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0); }
}

/* 地狱模式：全局背景变红特效 */
body.theme-hell {
    --bg-main: #180a0a;
    --bg-card: #261111;
    --accent: #ff5252;
    --border-color: #4a1c1c;
}
body.theme-hell .logo { color: #ff5252; }

/* 按钮禁用状态 */
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* ================= 游玩界面布局 ================= */
#module-play {
    display: none;
    flex-direction: column;
    height: calc(100vh - 60px); /* 减去顶部导航的高度 */
    padding: 0;
    margin: 0;
    max-width: 100%;
    background: var(--bg-main);
}
#module-play.active {
    display: flex;
}

/* 顶部信息 */
.play-header {
    background: var(--bg-card);
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}
.play-title { font-weight: bold; color: var(--accent); }
.play-status { color: var(--text-muted); font-size: 12px; }
.play-status span.danger { color: var(--danger); font-weight: bold; }

/* 聊天区域 */
.chat-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 消息气泡 */
.message { display: flex; flex-direction: column; max-width: 85%; }
.message.npc { align-self: flex-start; }
.message.player { align-self: flex-end; align-items: flex-end; }
.message.system { align-self: center; max-width: 90%; text-align: center; }

.msg-name { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.msg-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: popIn 0.2s ease;
}
.npc .msg-bubble { background: var(--bg-card); border: 1px solid var(--border-color); border-top-left-radius: 4px; }
.player .msg-bubble { background: var(--accent); color: #111; border-top-right-radius: 4px; }
.system .msg-bubble { background: rgba(255, 255, 255, 0.05); color: #aaa; font-size: 13px; padding: 8px 12px; border-radius: 20px; border: none;}

/* 底部操作区 */
.play-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 10px 15px 15px 15px;
    position: relative;
}

/* 快捷提问 */
.quick-ask {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}
.quick-ask button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}
.quick-ask button:hover { background: #333; color: #fff; }

/* NPC 选项卡 */
.npc-tabs { display: flex; gap: 10px; margin-bottom: 10px; overflow-x: auto; }
.npc-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
}
.npc-btn.active { background: #333; color: var(--accent); border-color: var(--accent); }

/* 输入框行 */
.input-row { display: flex; gap: 10px; margin-bottom: 10px; }
#play-input {
    flex: 1; background: var(--bg-main); border: 1px solid var(--border-color);
    color: #fff; padding: 12px; border-radius: 8px; font-size: 15px; outline: none;
}
#play-send-btn {
    background: var(--accent); color: #111; border: none; padding: 0 20px;
    border-radius: 8px; font-weight: bold; cursor: pointer;
}

/* 搜证与指认行 */
.action-row { display: flex; gap: 10px; }
.action-row button {
    flex: 1; padding: 10px; border-radius: 8px; font-size: 14px; cursor: pointer; border: none;
}
.btn-search { background: #333; color: #fff; }
.btn-search:hover { background: #444; }
.btn-accuse { background: rgba(255, 82, 82, 0.1); color: var(--danger); border: 1px solid var(--danger) !important; }
.btn-accuse:hover { background: rgba(255, 82, 82, 0.2); }

/* ================= 地狱模式专属 UI 特效（恐怖升级版） ================= */

/* 背景加一点微弱的血月红光渐变，不再死气沉沉 */
body.theme-hell {
    background: radial-gradient(circle at top, #2a0a0a 0%, #121212 70%) !important;
}

/* 顶部信息栏：加一条血红色的底线 */
body.theme-hell .play-header {
    border-bottom: 1px solid #ff5252;
    box-shadow: 0 2px 10px rgba(255, 0, 0, 0.2);
    background: #1a0a0a;
}
body.theme-hell .play-title {
    color: #ff4d4d;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.6); /* 文字发光 */
    font-weight: 900;
}

/* NPC 气泡：深灰背景 + 左侧血条 + 诡异阴影 */
body.theme-hell .npc .msg-bubble {
    background-color: #1f1f1f;
    border: 1px solid #3a1c1c;
    border-left: 3px solid #ff5252; /* 左侧红线 */
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.8);
    color: #d4d4d4;
}

/* 玩家气泡：高亮的深血色，文字带微光 */
body.theme-hell .player .msg-bubble {
    background-color: #8c1c1c;
    color: #ffe6e6;
    border: 1px solid #ff5252;
    box-shadow: 0 0 12px rgba(255, 82, 82, 0.4); /* 红光笼罩 */
}

/* 系统提示（线索）：像用血写在墙上的警告 */
body.theme-hell .system .msg-bubble {
    background-color: #1a0505;
    color: #ff6b6b;
    border: 1px dashed #ff5252;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

/* 底部操作区：暗色玻璃质感 */
body.theme-hell .play-footer {
    background-color: #110505;
    border-top: 1px solid #4a1c1c;
}

/* 快捷提问按钮：像老旧生锈的金属 */
body.theme-hell .quick-ask button {
    background: #1a0a0a;
    border: 1px solid #4a1c1c;
    color: #a3a3a3;
}
body.theme-hell .quick-ask button:hover {
    background: #2a1010;
    color: #ff5252;
}

/* 当前选中的 NPC：像被血点亮 */
body.theme-hell .npc-btn.active {
    border-color: #ff5252;
    color: #ff5252;
    background: #2a0a0a;
    box-shadow: inset 0 0 10px rgba(255, 0, 0, 0.3); /* 内发光 */
}

/* 发送按钮：亮血色 */
body.theme-hell #play-send-btn {
    background-color: #ff4d4d;
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.4);
}

/* 搜证按钮：深色 */
body.theme-hell .btn-search {
    background-color: #1a0a0a;
    border: 1px solid #4a1c1c;
    color: #ccc;
}

/* 指认凶手按钮：呼吸灯闪烁（极度压迫） */
body.theme-hell .btn-accuse {
    background-color: rgba(255, 82, 82, 0.15);
    color: #ff5252;
    border-color: #ff5252 !important;
    animation: pulseDanger 2s infinite; /* 呼吸闪烁 */
}

@keyframes pulseDanger {
    0% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.4); }
    50% { box-shadow: 0 0 10px 3px rgba(255, 82, 82, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0); }
}

/* ================= 手机端专属适配 ================= */
@media screen and (max-width: 768px) {
    /* 1. 顶部导航栏重排：允许折行，不再硬挤 */
    header {
        height: auto;
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .logo {
        font-size: 16px;
    }

    /* 2. 中间的 Tab 选项卡占满一行 */
    .tabs {
        order: 3; /* 放到最下面 */
        width: 100%;
        justify-content: space-around;
    }
    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 8px 0;
        font-size: 13px;
    }

    /* 3. 卡密输入区缩小，排成一行 */
    #card-area {
        margin-left: auto;
    }
    #card-input {
        width: 90px !important;
        font-size: 12px !important;
        padding: 4px !important;
    }
    #card-area button {
        padding: 4px 8px !important;
        font-size: 12px !important;
    }
    #balance-display {
        font-size: 12px !important;
        margin-left: 5px !important;
    }

    /* 4. 主体内容区减小内边距 */
    main {
        padding: 15px 10px;
    }

    /* 5. 剧本杀游玩界面的高度适配（解决手机键盘弹起遮挡问题） */
    #module-play {
        height: calc(100vh - 120px); /* 减去头部的高度 */
    }
    
    .chat-container {
        padding: 10px;
    }
    
    .message {
        max-width: 90%;
    }
}
/* ================= 充值中心卡片 ================= */
.recharge-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2a2a2a;
    border: 1px solid #444;
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.recharge-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 192, 64, 0.1);
}
/* 主推款的特效 */
.recharge-card.rc-pro {
    border-color: var(--accent);
    background: rgba(240, 192, 64, 0.05);
}
.rc-name { font-size: 16px; font-weight: bold; color: #fff; margin-bottom: 5px; }
.rc-desc { font-size: 12px; color: #aaa; }
.rc-price { font-size: 20px; font-weight: bold; color: var(--accent); }
.rc-tag {
    font-size: 10px;
    background: #ff5252;
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
    vertical-align: middle;
}