/* 間取り - Madori Horror */
/* 完整版样式：论坛 + 推理 + 调查员对话 */

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

body {
    font-family: "Microsoft YaHei", "Hiragino Sans", sans-serif;
    background: #0a0a0c;
    color: #e8e6e1;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container { width: 100%; height: 100%; position: relative; overflow: hidden; }
.hidden { display: none !important; }

/* ==================== 开始界面 ==================== */
#start-screen {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    justify-content: flex-start; align-items: center;
    background: linear-gradient(180deg, #0a0a0c 0%, #1a1a1c 100%);
    padding: 20px;
    padding-top: 40px;
    padding-bottom: 80px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.title-container { text-align: center; margin-bottom: 30px; }

.game-title {
    font-size: 56px; font-weight: 300; letter-spacing: 14px;
    text-shadow: 0 0 30px rgba(139, 0, 0, 0.5);
    animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 30px rgba(139, 0, 0, 0.3); }
    50% { text-shadow: 0 0 50px rgba(139, 0, 0, 0.6); }
}

.game-subtitle { font-size: 14px; color: #888; letter-spacing: 5px; margin-top: 10px; }
.story-select-wrapper { width: 100%; max-width: 800px; }
.select-title { text-align: center; font-size: 15px; color: #999; margin-bottom: 20px; letter-spacing: 2px; }

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.story-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #333;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    gap: 16px;
}

.story-card:hover {
    background: rgba(139, 0, 0, 0.15);
    border-color: rgba(139, 0, 0, 0.5);
    transform: translateY(-3px);
}

.story-thumb {
    font-size: 42px;
    width: 65px; height: 65px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    flex-shrink: 0;
}

.story-info { flex: 1; }
.story-info h3 { font-size: 17px; margin-bottom: 5px; }
.story-subtitle { font-size: 11px; color: #c4a000; font-style: italic; margin-bottom: 10px; }
.story-desc { font-size: 12px; color: #999; line-height: 1.6; margin-bottom: 10px; }
.difficulty { font-size: 11px; color: #ff9999; }
.game-hint { text-align: center; font-size: 11px; color: #666; margin-top: 20px; }

/* ==================== 游戏界面 ==================== */
#game-screen {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    background: #12121a;
}

#tab-bar {
    display: flex; align-items: center;
    padding: 10px 15px;
    background: #0a0a0c;
    border-bottom: 1px solid #2a2a2a;
    gap: 10px;
    flex-wrap: wrap;
}

.back-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #444;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.back-btn:hover { color: #fff; border-color: #666; }

.story-title-display {
    font-size: 13px; color: #c4a000;
    margin-right: 15px; padding-left: 12px;
    border-left: 1px solid #333;
}

.tab-btn {
    padding: 7px 14px;
    background: transparent;
    border: 1px solid #333;
    color: #888;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover { color: #e8e6e1; border-color: #555; }
.tab-btn.active { color: #fff; background: rgba(139,0,0,0.25); border-color: rgba(139,0,0,0.5); }

.tab-btn.has-new::after {
    content: '!';
    position: absolute;
    top: -5px; right: -5px;
    background: #ff4444;
    color: #fff;
    width: 16px; height: 16px;
    border-radius: 50%;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.tab-stats {
    margin-left: auto;
    display: flex; gap: 12px;
    font-size: 11px;
}

.tab-stats .stat.real { color: #4CAF50; }
.tab-stats .stat.red { color: #ff6b6b; }
.tab-stats .stat.ded { color: #64b5f6; }

#round-display {
    background: rgba(139,0,0,0.3);
    padding: 4px 10px;
    border-radius: 4px;
    color: #ff9999;
}

/* ==================== 户型图视图 ==================== */
#investigation-view {
    flex: 1;
    display: flex; justify-content: center; align-items: center;
    position: relative;
    background: #1a1a1c;
    overflow: auto;
    padding-bottom: 60px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

#floor-plan-canvas { 
    max-width: 95%; 
    max-height: calc(100vh - 120px); 
    touch-action: manipulation;
    cursor: pointer;
}

#toolbar {
    position: fixed;
    bottom: 15px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 6px;
    background: rgba(15,15,18,0.95);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #333;
}

.tool-btn {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid #444;
    color: #888;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.tool-btn:hover { color: #fff; border-color: #666; }
.tool-btn.active { color: #fff; background: rgba(139,0,0,0.3); border-color: rgba(139,0,0,0.5); }

/* ==================== 论坛视图 ==================== */
#forum-view {
    flex: 1;
    overflow-y: auto;
    background: #f0ebe6;
    padding-bottom: 80px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

#forum-container { max-width: 700px; margin: 0 auto; padding: 15px; }

.forum-header {
    background: linear-gradient(135deg, #8b0000, #660000);
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px 6px 0 0;
}

.forum-title { font-size: 14px; font-weight: bold; }
.forum-subtitle { font-size: 10px; opacity: 0.8; margin-top: 3px; }

/* 论坛锁定提示 */
.forum-locked-hint {
    font-size: 11px;
    color: #ffcc00;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(255, 204, 0, 0.1);
    border-radius: 4px;
    border: 1px dashed rgba(255, 204, 0, 0.3);
}

.forum-posts {
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
}

.forum-post {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.forum-post:last-child { border-bottom: none; }
.forum-post.new-post { background: rgba(196,160,0,0.1); border-left: 3px solid #c4a000; }

.post-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
    font-size: 11px; color: #666;
}

.post-num {
    background: #8b0000;
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
}

.post-author { font-weight: bold; color: #333; }
.post-time { margin-left: auto; color: #999; }

.post-content {
    font-size: 13px;
    line-height: 1.7;
    color: #333;
}

/* 初始样式确保 span 标签可见 */
.clue-click { 
    display: inline; 
    padding: 2px 4px; 
    border-radius: 2px; 
    cursor: pointer; 
    color: #0066cc; 
    background: rgba(0,102,204,0.1); 
}
.clickable { padding: 2px 4px; border-radius: 2px; cursor: pointer; transition: all 0.2s; }
.clickable.real { color: #0066cc; background: rgba(0,102,204,0.1); }
.clickable.real:hover { background: rgba(0,102,204,0.2); }
.clickable.red_herring { color: #cc3300; background: rgba(204,51,0,0.1); }
.clickable.red_herring:hover { background: rgba(204,51,0,0.2); }
.clickable.hidden { color: #9900cc; background: rgba(153,0,204,0.1); }
.clickable.collected { opacity: 0.5; text-decoration: line-through; cursor: default; }

/* 帖子线索按钮 */
.post-clue-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #9900cc 0%, #6600aa 100%);
    color: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    display: inline-block;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(153, 0, 204, 0.3);
}
.post-clue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(153, 0, 204, 0.5);
}
.post-clue-btn.collected {
    background: #666;
    cursor: default;
    box-shadow: none;
}
.post-clue-btn.collected:hover {
    transform: none;
}

/* ==================== 推理视图 ==================== */
#deduction-view {
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(180deg, #12121a 0%, #1a1a20 100%);
    padding: 20px;
    padding-bottom: 80px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

#deduction-container { max-width: 700px; margin: 0 auto; }

.deduction-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

.deduction-header h3 { font-size: 18px; margin-bottom: 8px; }
.deduction-header p { font-size: 12px; color: #888; }

.deduction-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 30px; }

.deduction-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s;
}

.deduction-item.locked { opacity: 0.5; }
.deduction-item.available { cursor: pointer; border-color: #c4a000; }
.deduction-item.available:hover { background: rgba(196,160,0,0.1); transform: translateY(-2px); }
.deduction-item.correct { border-color: #4CAF50; background: rgba(76,175,80,0.1); }
.deduction-item.wrong { border-color: #f44336; background: rgba(244,67,54,0.1); }

.deduction-requires {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 10px;
}

.deduction-requires .req {
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 11px;
}

.req.has { background: #4CAF50; color: #fff; }
.req.need { background: #444; color: #999; }

.deduction-result {
    font-size: 14px;
    color: #e8e6e1;
    font-weight: bold;
}

.deduction-detail {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: #999;
    line-height: 1.6;
}

.collected-clues {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 15px;
}

.collected-clues h4 { font-size: 13px; margin-bottom: 12px; color: #999; }

.clue-list { display: flex; flex-wrap: wrap; gap: 8px; }

.collected-clue {
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 11px;
    cursor: help;
}

.collected-clue.real { background: rgba(76,175,80,0.2); color: #4CAF50; }
.collected-clue.red_herring { background: rgba(244,67,54,0.2); color: #f44336; }
.collected-clue.hidden { background: rgba(153,0,204,0.2); color: #bb66ff; }

/* ==================== 调查员对话视图 ==================== */
#investigator-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0f0f12 0%, #1a1a1e 100%);
    overflow: hidden;
}

.investigator-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0;
}

.investigator-avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    overflow: hidden;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #444;
    flex-shrink: 0;
}

/* 调查员人影剪影 */
.silhouette {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #333 0%, #1a1a1a 100%);
    position: relative;
}

.silhouette::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #444;
    border-radius: 50%;
}

.silhouette::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 24px;
    background: #444;
    border-radius: 16px 16px 0 0;
}

.investigator-info { flex: 1; }

.investigator-name {
    font-size: 15px;
    font-weight: bold;
    color: #e8e6e1;
}

.status {
    font-size: 11px;
    margin-top: 4px;
}

.status.online { color: #4CAF50; }
.status.online::before { content: '● '; }
.status.offline { color: #f44336; }
.status.offline::before { content: '○ '; }
.status.new { color: #ffc107; animation: pulse 1s infinite; }
.status.new::before { content: '● '; }

/* 对话容器 - 居中显示 */
#dialogue-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* 对话内容区域 - 可滚动 */
.dialogue-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}

.dialogue-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 10px;
}

/* 底部操作区 - 固定在底部 */
.dialogue-actions {
    flex-shrink: 0;
    padding: 15px 20px;
    padding-bottom: calc(15px + 60px);
    padding-bottom: calc(15px + 60px + env(safe-area-inset-bottom, 0px));
    background: rgba(0,0,0,0.5);
    border-top: 1px solid #333;
}

.dialogue-empty {
    text-align: center;
    color: #666;
    padding: 50px 20px;
}

.dialogue-empty p { margin-bottom: 10px; }
.dialogue-empty .hint { font-size: 11px; color: #555; }
.dialogue-empty .unlock-hint {
    color: #c4a000;
    background: rgba(196, 160, 0, 0.1);
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px dashed rgba(196, 160, 0, 0.3);
    margin-top: 15px;
}

/* 消息样式 */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.message.investigator .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #222;
    border: 1px solid #444;
}

.message.investigator .avatar .silhouette::before {
    top: 7px;
    width: 14px;
    height: 14px;
}

.message.investigator .avatar .silhouette::after {
    width: 24px;
    height: 18px;
}

.message .bubble {
    background: #252528;
    border-radius: 15px 15px 15px 3px;
    padding: 12px 16px;
    border: 1px solid #333;
}

.message .name {
    font-size: 10px;
    color: #888;
    margin-bottom: 5px;
}

.message .text {
    font-size: 14px;
    line-height: 1.7;
    color: #e8e6e1;
}

.message.player-choice {
    align-self: flex-end;
}

.message.player-choice .bubble {
    background: rgba(139, 0, 0, 0.2);
    border: 1px solid rgba(139, 0, 0, 0.4);
    border-radius: 15px 15px 3px 15px;
}

.message.player-choice .text {
    font-size: 13px;
    color: #c4a000;
}

.message.system {
    align-self: center;
    max-width: 90%;
}

.message.system .text {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px 25px;
    font-size: 13px;
    color: #999;
    text-align: center;
    font-style: italic;
}

/* 选项按钮 - 在底部固定区域 */
.dialogue-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.choice-btn {
    background: rgba(139, 0, 0, 0.15);
    border: 1px solid rgba(139, 0, 0, 0.3);
    color: #e8e6e1;
    padding: 12px 18px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s;
    width: 100%;
}

.choice-btn:hover {
    background: rgba(139, 0, 0, 0.3);
    border-color: rgba(139, 0, 0, 0.5);
    transform: translateX(3px);
}

/* 锁定的选项按钮 */
.choice-btn.locked {
    background: rgba(80, 80, 80, 0.15);
    border-color: rgba(80, 80, 80, 0.3);
    color: #888;
    cursor: not-allowed;
}

.choice-btn.locked:hover {
    background: rgba(80, 80, 80, 0.2);
    transform: none;
}

.choice-btn .choice-hint {
    display: block;
    font-size: 10px;
    color: #c4a000;
    margin-top: 4px;
}

/* 点击继续按钮 */
.dialogue-continue {
    text-align: center;
    padding: 15px;
    background: rgba(139, 0, 0, 0.1);
    border: 1px dashed rgba(139, 0, 0, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.dialogue-continue:hover {
    background: rgba(139, 0, 0, 0.2);
    border-style: solid;
}

.dialogue-continue-text {
    color: #999;
    font-size: 13px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.dialogue-end {
    text-align: center;
}

.dialogue-end .choice-btn {
    display: inline-block;
    width: auto;
    min-width: 150px;
}

/* 等待线索的卡点状态 */
.dialogue-waiting {
    text-align: center;
    padding: 25px 20px;
    background: rgba(196, 160, 0, 0.1);
    border: 2px dashed rgba(196, 160, 0, 0.4);
    border-radius: 12px;
}

.dialogue-waiting .waiting-icon {
    font-size: 36px;
    margin-bottom: 12px;
    animation: pulse 2s infinite;
}

.dialogue-waiting .waiting-text {
    font-size: 15px;
    color: #c4a000;
    font-weight: bold;
    margin-bottom: 8px;
}

.dialogue-waiting .waiting-hint {
    font-size: 12px;
    color: #888;
}

/* ==================== 消息面板 ==================== */
#message-panel {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center; align-items: center;
    z-index: 400;
}

.panel-box {
    background: #1a1a1c;
    border: 1px solid #333;
    border-radius: 10px;
    width: 90%;
    max-width: 450px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(139,0,0,0.2);
    border-bottom: 1px solid #333;
}

.panel-header span { font-size: 15px; font-weight: bold; }
.close-btn {
    background: none; border: none;
    color: #888; font-size: 22px;
    cursor: pointer;
}
.close-btn:hover { color: #fff; }

.panel-body {
    padding: 20px;
    max-height: 50vh;
    overflow-y: auto;
}

.panel-body p {
    font-size: 13px;
    line-height: 1.8;
    color: #ccc;
}

.panel-footer {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #333;
}

.small-btn {
    background: rgba(139,0,0,0.3);
    border: 1px solid rgba(139,0,0,0.5);
    color: #e8e6e1;
    padding: 8px 30px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 13px;
}

.small-btn:hover { background: rgba(139,0,0,0.5); }

/* ==================== Toast ==================== */
#toast {
    position: fixed;
    bottom: 60px; left: 50%;
    transform: translateX(-50%) translateY(15px);
    background: rgba(20,20,22,0.95);
    color: #e8e6e1;
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid #444;
    font-size: 12px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 300;
    pointer-events: none;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==================== 结局 ==================== */
#ending-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(180deg, #0a0a0c 0%, #1a0808 100%);
    display: flex;
    justify-content: center; align-items: center;
    z-index: 500;
}

.ending-content {
    text-align: center;
    max-width: 500px;
    padding: 25px;
}

.ending-content h2 {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: 10px;
    color: #8b0000;
    margin-bottom: 20px;
}

.ending-text-box {
    background: rgba(0,0,0,0.3);
    padding: 25px 30px;
    border-radius: 8px;
    border: 1px solid rgba(139,0,0,0.3);
    margin-bottom: 25px;
    max-height: 50vh;
    overflow-y: auto;
}

#ending-text {
    font-size: 13px;
    line-height: 2;
    color: #ccc;
    text-align: left;
}

.main-btn {
    background: transparent;
    border: 1px solid #555;
    color: #e8e6e1;
    padding: 12px 35px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}

.main-btn:hover { background: rgba(139,0,0,0.2); border-color: #8b0000; }

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a1c; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

#forum-view::-webkit-scrollbar-track { background: #e0dbd6; }
#forum-view::-webkit-scrollbar-thumb { background: #aaa; }

/* ==================== 响应式 ==================== */
@media (max-width: 700px) {
    .game-title { font-size: 40px; letter-spacing: 8px; }
    .story-grid { grid-template-columns: 1fr; }
    
    #tab-bar { padding: 8px 10px; gap: 6px; }
    .tab-btn { padding: 5px 10px; font-size: 11px; }
    .tab-stats { font-size: 10px; gap: 8px; }
    
    .message { max-width: 95%; }
    .choice-btn { padding: 12px 15px; font-size: 13px; }
}
