@font-face {
    font-family: 'HuiWenFangSong';
    src: local('HuiWenFangSong'),
         local('汇文仿宋'),
         url('hwfs.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: inherit;
}

html, body {
    background-color: #121212;
    color: #c8c8c8;
    font-family: 'HuiWenFangSong', 'SimSun', '宋体', serif;
    height: 100%;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body {
    overscroll-behavior: none;
}

/* ===== 状态栏 ===== */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #151515;
    border-bottom: 1px solid #2a2a2a;
    font-size: 12px;
    z-index: 10;
    flex-shrink: 0;
    gap: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.stat-label {
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 10px;
    white-space: nowrap;
}

.stat-value {
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
}

.health-container {
    width: 70px;
    height: 16px;
    background: #1a1a1a;
    border: 1px solid #666;
    position: relative;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #2a0000, #8B0000, #DC143C);
    transition: width 0.6s ease;
    width: 100%;
}

.health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    text-shadow: 0 0 3px #000;
    color: #ccc;
    letter-spacing: 1px;
}

.sanity-display {
    color: #6a0dad;
}

.cycle-display {
    color: #8B7355;
}

.time-display {
    color: #666;
}

.help-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #666;
    background: #1a1a1a;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.help-btn:active {
    background: #2a0000;
    border-color: #3a0000;
    color: #aaa;
}

/* ===== 主游戏区域 ===== */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* ===== 地点列表 ===== */
.location-list {
    padding: 10px 14px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.location-list::-webkit-scrollbar {
    width: 3px;
}

.location-list::-webkit-scrollbar-track {
    background: transparent;
}

.location-list::-webkit-scrollbar-thumb {
    background: #2a0000;
}

.location {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
    position: relative;
    opacity: 0.7;
    font-family: 'HuiWenFangSong', 'SimSun', '宋体', serif;
}

.location:hover {
    opacity: 1;
}

.location:active {
    transform: translateX(4px);
    opacity: 1;
}

.location.active {
    border-color: #8B0000;
}

.location-child {
    margin-left: 28px;
    width: calc(100% - 28px);
    margin-bottom: 4px;
    padding: 10px 14px;
    opacity: 0.85;
}

.location-child .location-name {
    font-size: 12px;
}

.location-child .location-desc {
    font-size: 10px;
}

.location-icon {
    font-size: 22px;
    opacity: 0.8;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.location-text {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.location-name {
    font-size: 14px;
    letter-spacing: 2px;
    color: #aaa;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.location-desc {
    font-size: 11px;
    color: #666;
    font-style: italic;
    line-height: 1.4;
}

.location-arrow {
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
    padding: 4px 8px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.location-arrow:hover {
    color: #666;
}

/* 地点颜色 */
.location-barn {
    background: #251f18;
    border-color: #3a3020;
}
.location-barn:hover, .location-barn.active {
    border-color: #4a3520;
    background: #2a1f15;
}

.location-cornfield {
    background: #1f2518;
    border-color: #2a3a20;
}
.location-cornfield:hover, .location-cornfield.active {
    border-color: #2a3a1f;
    background: #2a3a20;
}

.location-well {
    background: #181f25;
    border-color: #202a3a;
}
.location-well:hover, .location-well.active {
    border-color: #1f2a3a;
    background: #202a3a;
}

.location-house {
    background: #251818;
    border-color: #3a2020;
}
.location-house:hover, .location-house.active {
    border-color: #3a2020;
    background: #3a2020;
}

.location-woods {
    background: #122212;
    border-color: #1a2a1a;
}
.location-woods:hover, .location-woods.active {
    border-color: #1a2a1a;
    background: #1a2a1a;
}

.location-graveyard {
    background: #1f181f;
    border-color: #2a1a2a;
}
.location-graveyard:hover, .location-graveyard.active {
    border-color: #2a1a2a;
    background: #2a1a2a;
}

.location-attic {
    background: #252518;
    border-color: #3a3a25;
}
.location-attic:hover, .location-attic.active {
    border-color: #3a3a25;
    background: #3a3a25;
}

.location-cellar {
    background: #121225;
    border-color: #1a1a2a;
}
.location-cellar:hover, .location-cellar.active {
    border-color: #1a1a2a;
    background: #1a1a2a;
}

.location-bottom-well {
    background: #122525;
    border-color: #1a2a2a;
}
.location-bottom-well:hover, .location-bottom-well.active {
    border-color: #1a2a2a;
    background: #1a2a2a;
}

.location-clearing {
    background: #18251f;
    border-color: #1f2a25;
}
.location-clearing:hover, .location-clearing.active {
    border-color: #1a2a1f;
    background: #1f2a25;
}

.location-nameless-tomb {
    background: #151515;
    border-color: #2a0000;
}
.location-nameless-tomb:hover, .location-nameless-tomb.active {
    border-color: #2a0000;
    background: #1a0505;
}

/* ===== 底部面板 ===== */
.bottom-panel {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #2a2a2a;
    background: #0f0f0f;
    flex-shrink: 0;
    max-height: 45vh;
}

/* ===== 物品栏 ===== */
.inventory-section {
    padding: 10px 14px;
    border-bottom: 1px solid #1a1a1a;
}

.section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #666;
    margin-bottom: 8px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.inventory-slot {
    aspect-ratio: 1;
    border: 1px solid #2a2a2a;
    background: #151515;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    position: relative;
    min-height: 44px;
}

.inventory-slot:active {
    transform: scale(0.95);
    background: #1a0505;
    border-color: #2a0000;
}

.inventory-slot.empty {
    opacity: 0.1;
    background: #080808;
}

.inventory-slot .item-count {
    position: absolute;
    bottom: 1px;
    right: 3px;
    font-size: 9px;
    color: #666;
    font-family: monospace;
}

/* ===== 消息日志 ===== */
.message-log {
    flex: 1;
    padding: 10px 14px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.6;
    max-height: 160px;
    background: #141414;
}

.message-log::-webkit-scrollbar {
    width: 3px;
}

.message-log::-webkit-scrollbar-track {
    background: #0f0f0f;
}

.message-log::-webkit-scrollbar-thumb {
    background: #2a0000;
}

.log-entry {
    margin-bottom: 6px;
    padding: 6px 10px;
    background: #151515;
    border-left: 2px solid #666;
    animation: fadeIn 0.3s ease;
    font-size: 12px;
}

.log-entry.tip {
    border-left-color: #1a3a5a;
    color: #4a7a9a;
    background: #0a1015;
}

.log-entry.warning {
    border-left-color: #3a3a1a;
    color: #8a8a4a;
    background: #15150a;
}

.log-entry.danger {
    border-left-color: #3a0000;
    color: #a04040;
    background: #1a0505;
}

.log-entry.event {
    border-left-color: #2a2a2a;
    background: #151515;
    color: #777;
}

.log-entry.item {
    border-left-color: #0f3a0f;
    color: #5a9a5a;
    background: #050f05;
}

.log-entry.special {
    border-left-color: #2a1a4a;
    color: #7a5a9a;
    background: #100a1a;
}

.log-entry.chain {
    border-left-color: #4a0000;
    color: #c06060;
    background: #1a0505;
}

.log-timestamp {
    color: #666;
    font-size: 10px;
    margin-right: 6px;
    font-family: monospace;
    letter-spacing: 1px;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* ===== 游戏结束遮罩 ===== */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    text-align: center;
    overflow-y: auto;
}

.game-over-overlay.active {
    display: flex;
}

.game-over-title {
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: 6px;
    margin-bottom: 16px;
    color: #8B0000;
    text-shadow: 0 0 20px rgba(139, 0, 0, 0.4);
}

.game-over-title.win {
    color: #4a8a4a;
    text-shadow: 0 0 20px rgba(74, 138, 74, 0.4);
}

.game-over-title.true-end {
    color: #6a5a9a;
    text-shadow: 0 0 20px rgba(106, 90, 154, 0.4);
}

.game-over-reason {
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
    max-width: 320px;
    line-height: 1.8;
    font-style: italic;
}

.game-over-stats {
    margin-bottom: 24px;
    text-align: left;
    color: #666;
    font-size: 12px;
    line-height: 1.8;
    border: 1px solid #2a2a2a;
    padding: 16px 20px;
    background: #151515;
    max-width: 340px;
    width: 100%;
}

.game-over-stats .stat-header {
    color: #666;
    border-bottom: 1px solid #2a2a2a;
    padding-bottom: 8px;
    margin-bottom: 12px;
    text-align: center;
    letter-spacing: 2px;
}

.game-over-stats .truth-item {
    margin-bottom: 8px;
    padding-left: 12px;
    border-left: 2px solid #1a1a1a;
}

.game-over-stats .truth-item.known {
    border-left-color: #3a0000;
    color: #777;
}

.game-over-stats .truth-item.unknown {
    border-left-color: #151515;
    color: #666;
}

.game-over-story {
    margin-bottom: 24px;
    text-align: left;
    color: #666;
    font-size: 12px;
    line-height: 2;
    border: 1px solid #2a0000;
    padding: 16px 20px;
    background: #0a0505;
    max-width: 340px;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
}

.game-over-story::-webkit-scrollbar {
    width: 3px;
}

.game-over-story::-webkit-scrollbar-thumb {
    background: #2a0000;
}

.restart-btn {
    padding: 14px 40px;
    background: #151515;
    border: 1px solid #2a0000;
    color: #666;
    font-family: inherit;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 48px;
}

.restart-btn:active {
    background: #2a0000;
    border-color: #2a0000;
    color: #888;
}

/* ===== 提示框 ===== */
.tooltip {
    position: fixed;
    background: #1a1a1a;
    border: 1px solid #666;
    padding: 8px 12px;
    font-size: 11px;
    pointer-events: none;
    z-index: 100;
    display: none;
    max-width: 200px;
    color: #888;
    line-height: 1.5;
}

/* ===== 闪烁效果 ===== */
@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.97; }
}

.atmosphere-flicker {
    animation: flicker 4s infinite;
}

/* ===== 防止双击缩放 ===== */
let lastTouchEnd = 0;
document.addEventListener('touchend', function(e) {
    const now = Date.now();
    if (now - lastTouchEnd <= 300) {
        e.preventDefault();
    }
    lastTouchEnd = now;
}, false);

/* ===== 横屏/平板适配 ===== */
@media (min-width: 600px) and (max-height: 500px) {
    .game-container {
        flex-direction: row;
    }
    .location-list {
        flex: 2;
    }
    .bottom-panel {
        flex: 1;
        border-top: none;
        border-left: 1px solid #2a2a2a;
        max-height: none;
    }
}

@media (min-width: 768px) {
    .game-container {
        flex-direction: row;
    }
    .location-list {
        flex: 2;
        padding: 16px 20px;
    }
    .location {
        padding: 18px 20px;
        margin-bottom: 8px;
    }
    .location-child {
        margin-left: 32px;
        width: calc(100% - 32px);
    }
    .bottom-panel {
        flex: 1;
        border-top: none;
        border-left: 1px solid #2a2a2a;
        max-height: none;
        max-width: 400px;
    }
    .inventory-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .inventory-slot {
        min-height: 56px;
        font-size: 22px;
    }
}

/* ===== 太阳（光球） ===== */
.sun {
    position: fixed;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ffeeaa, #eeaa44);
    box-shadow: 0 0 60px rgba(255, 200, 100, 0.5), 0 0 120px rgba(255, 160, 60, 0.3), 0 0 200px rgba(255, 140, 40, 0.15);
    z-index: -1;
    pointer-events: none;
    transition: top 1s ease, left 1s ease, background 1s ease;
}

.sun.night {
    background: radial-gradient(circle at 30% 30%, #aa7755, #442211);
    box-shadow: 0 0 40px rgba(150, 80, 40, 0.3), 0 0 80px rgba(100, 50, 30, 0.1);
}
