/* --- ОСНОВНЫЕ НАСТРОЙКИ --- */
body { margin: 0; overflow: hidden; background-color: #050505; color: white; font-family: 'Courier New', Courier, monospace; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#game-container { position: relative; width: 100vw; height: 100vh; background: linear-gradient(to bottom, #0a0a10 0%, #1a1a20 80%, #eee 100%); }

/* --- UI --- */
#ui-layer { position: absolute; top: 20px; left: 20px; z-index: 100; pointer-events: none; }
.bar-container { margin-bottom: 10px; background: #333; width: 200px; height: 20px; border: 2px solid #555; }
#hp-bar { background: #d32f2f; width: 100%; height: 100%; transition: width 0.2s;}
#stamina-bar { background: #1976d2; width: 100%; height: 100%; transition: width 0.1s;}
#timer-display { position: absolute; top: 20px; right: 20px; font-size: 24px; color: #ffeb3b; z-index: 100; }
#night-ui-header { position: absolute; top: -10px; left: 50%; transform: translateX(-50%) translate(-20px, 0); font-size: 28px; font-weight: bold; color: #d32f2f; text-shadow: 2px 2px 4px #000; width: 200px; text-align: center; pointer-events: none; }

/* --- ДЕБАГ --- */
#debug-toggle-btn { position: absolute; bottom: 10px; left: 10px; z-index: 300; background: rgba(0,0,0,0.7); color: lime; border: 1px solid lime; padding: 5px; cursor: pointer; }
#debug-menu { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 400px; background: rgba(0,0,0,0.9); border: 2px solid lime; color: lime; z-index: 300; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.debug-section { border: 1px solid #333; padding: 10px; margin-bottom: 5px; }
.debug-section button { margin: 2px; padding: 5px; cursor: pointer; background: #333; color: white; border: none; }
.debug-section button:hover { background: #555; }
.debug-radius-attack { position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); border: 2px dashed red; border-radius: 50%; pointer-events: none; opacity: 0.5; }
.debug-radius-light { position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); border: 2px dashed yellow; border-radius: 50%; pointer-events: none; opacity: 0.5; }

/* --- ЭФФЕКТЫ АТМОСФЕРЫ --- */
#frost-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 80; box-shadow: inset 0 0 150px rgba(180, 220, 255, 0.3); opacity: 0.8; animation: breath 6s infinite ease-in-out; mix-blend-mode: screen; }
#snow-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 75; overflow: hidden; }
.snowflake { position: absolute; top: -10px; background: white; border-radius: 50%; opacity: 0.8; animation: fall linear infinite; }

/* Эффект удара */
.sound-wave { position: absolute; bottom: 0px; left: 50%; transform: translateX(-25%) translate(-25%, 50%); width: 20px; height: 20px; border-radius: 50%; background: transparent; box-shadow: 0 0 20px 10px rgba(255, 255, 255, 0.8); z-index: 4; pointer-events: none; opacity: 1; }
.impact-particle { position: absolute; width: 6px; height: 6px; background: #fff; border-radius: 50%; pointer-events: none; z-index: 5; box-shadow: 0 0 5px #fff; }

/* --- НОЧНОЙ РЕЖИМ --- */
#night-layer { position: absolute; width: 100%; height: 100%; top: 0; left: 0; }
#tower { position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); width: 80px; height: 300px; background: #2c2c2c; border: 2px solid #111; display: flex; justify-content: center; align-items: flex-end; z-index: 2; }
.window { width: 20px; height: 30px; background: #ffaa00; margin-bottom: 150px; opacity: 0.5; box-shadow: 0 0 10px #ffaa00; animation: flicker 3s infinite; }
#generator { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 40px; height: 30px; background: #4caf50; border: 2px solid #000; z-index: 6; cursor: pointer; box-shadow: 0 0 5px #000; display: flex; justify-content: center; align-items: center; font-size: 10px; color: black; font-weight: bold; touch-action: manipulation; }
#generator.broken { background: #d32f2f; cursor: not-allowed; }
#light-barrier { position: absolute; bottom: 50px; left: 50%; transform: translateX(-50%); width: 300px; height: 200px; background: radial-gradient(circle, rgba(255, 255, 200, 0.4) 0%, rgba(255, 200, 0, 0) 70%); z-index: 4; pointer-events: none; display: none; opacity: 0; transition: opacity 0.5s; }
#light-barrier.active { display: block; opacity: 1; }
#metal-rail { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); width: 40px; height: 100px; background: linear-gradient(90deg, #555, #888, #555); border: 1px solid #000; z-index: 5; cursor: pointer; box-shadow: 0 0 5px #000; touch-action: manipulation; }
#metal-rail:active { transform: translateX(-50%) scale(0.95); background: #aaa; }
#metal-rail::after { content: "БЕЙ!"; position: absolute; top: -30px; left: -10px; color: white; font-size: 14px; font-weight: bold; animation: bounce 1s infinite; }

/* ВРАГИ */
.enemy { position: absolute; bottom: 50px; width: 40px; height: 30px; background: black; border-radius: 50% 50% 0 0; z-index: 3; transition: transform 0.1s; }
.enemy::before, .enemy::after { content: ''; position: absolute; top: 10px; width: 4px; height: 4px; background: red; border-radius: 50%; box-shadow: 0 0 4px red; }
.enemy::before { left: 10px; } .enemy::after { right: 10px; }
.enemy.small { width: 30px; height: 20px; background: #222; bottom: 50px; }
.enemy.small::before, .enemy.small::after { width: 3px; height: 3px; top: 6px; box-shadow: 0 0 2px #ff00ff; background: #ff00ff; }
.enemy.small::before { left: 6px; } .enemy.small::after { right: 6px; }
.enemy.heavy { width: 50px; height: 45px; background: #111; bottom: 50px; border-top: 3px solid #333; }
.enemy.heavy::before, .enemy.heavy::after { width: 6px; height: 6px; top: 12px; }
.enemy.heavy::before { left: 12px; } .enemy.heavy::after { right: 12px; }
.enemy.heavy.hit-flash { background: #555 !important; }

#train { position: absolute; bottom: 0; left: -2000px; width: 1500px; height: 400px; background: #000; z-index: 20; display: flex; align-items: center; }
.headlight { position: absolute; right: 0; top: 250px; width: 50px; height: 50px; background: white; border-radius: 50%; box-shadow: 0 0 500px 200px white; }

/* --- ЭКРАНЫ --- */
#intro-screen, #start-screen, #game-over-screen, #win-screen, #night-start-screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 100; text-align: center; padding: 20px; box-sizing: border-box; }

/* ФОН МЕНЮ (ПРИМЕР) */
/* Если у вас есть файл img/menu_bg.jpg, он отобразится здесь */
#main-menu { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #1a1a1a url('img/menu_bg.png') no-repeat center center; background-size: cover; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding-left: 10%; z-index: 200; }

.game-title { font-size: 80px; color: #d32f2f; text-shadow: 4px 4px 0 #000; margin-bottom: 50px; letter-spacing: 5px; }
.menu-buttons button { display: block; width: 300px; text-align: left; margin: 15px 0; padding: 15px 20px; background: rgba(0,0,0,0.8); border: 2px solid #555; color: white; font-size: 24px; cursor: pointer; transition: all 0.2s; }
.menu-buttons button:hover { background: #d32f2f; border-color: #d32f2f; padding-left: 30px; }
#tutorial-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 90; display: flex; justify-content: center; align-items: center; }
.tutorial-box { position: absolute; background: rgba(255, 255, 255, 0.95); color: black; padding: 20px; max-width: 300px; border-radius: 5px; box-shadow: 0 0 20px black; text-align: center; animation: bounce 2s infinite; }
.tutorial-box p { margin: 0 0 10px 0; font-weight: bold; }
.pos-rail { bottom: 250px; left: 60%; } .pos-rail::after { content: "↙"; font-size: 40px; position: absolute; bottom: -30px; left: 10px; color: white; }
.pos-gen { bottom: 100px; right: 55%; } .pos-gen::after { content: "↘"; font-size: 40px; position: absolute; bottom: -30px; right: 10px; color: white; }
.pos-hp { top: 90px; left: 100px; } .pos-hp::after { content: "↑"; font-size: 40px; position: absolute; top: -40px; left: 20px; color: white; }
.pos-stamina { top: 160px; left: 100px; } .pos-stamina::after { content: "↑"; font-size: 40px; position: absolute; top: -40px; left: 20px; color: white; }
#intro-text { font-size: 22px; max-width: 600px; line-height: 1.5; margin-bottom: 30px; min-height: 100px; text-shadow: 1px 1px 2px #000; }
.game-btn { padding: 15px 30px; font-size: 20px; background: #d32f2f; color: white; border: none; cursor: pointer; margin-top: 20px; font-family: inherit; }

/* ВИЗУАЛЬНАЯ НОВЕЛЛА */
.vn-image { width: 80vw; max-width: 800px; aspect-ratio: 16/9; object-fit: cover; border: 2px solid #555; margin-bottom: 20px; box-shadow: 0 0 20px #000; }

/* --- ДНЕВНОЙ РЕЖИМ --- */
#day-screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 50; display: flex; flex-direction: column; justify-content: center; align-items: center; transition: background 1s; }
#sky-sun { position: absolute; width: 60px; height: 60px; border-radius: 50%; box-shadow: 0 0 30px rgba(255,255,255,0.8); transition: all 1s ease-in-out; z-index: 1; }
#day-screen.morning { background: linear-gradient(to right, #2c3e50, #fd746c, #ff9a9e); }
#day-screen.morning #sky-sun { background: #ffaa00; left: 15%; top: 60%; }
#day-screen.noon { background: linear-gradient(to bottom, #87CEEB 0%, #E0F7FA 100%); }
#day-screen.noon #sky-sun { background: #ffffaa; left: 50%; top: 10%; box-shadow: 0 0 50px #fff; transform: translateX(-50%); }
#day-screen.evening { background: linear-gradient(to left, #0f2027, #203a43, #2c5364); }
#day-screen.evening #sky-sun { background: #ff4500; left: 85%; top: 70%; opacity: 0.8; }
#day-ui-header { position: absolute; top: 20px; left: 0; width: 100%; text-align: center; color: white; font-size: 28px; font-weight: bold; pointer-events: none; text-shadow: 2px 2px 4px #000; z-index: 60; }
#day-tower-wrapper { display: flex; flex-direction: column; align-items: center; z-index: 10; transform: scale(0.9); }
.tower-section { width: 300px; position: relative; border: 4px solid #3e2723; margin-bottom: -4px; box-shadow: 5px 5px 15px rgba(0,0,0,0.5); overflow: hidden; background: #5d4037; }
.room-label { font-size: 10px; color: rgba(255,255,255,0.6); position: absolute; top: 2px; left: 5px; z-index: 2; text-shadow: 1px 1px 0 #000; pointer-events: none; }
.btn-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 20; background: rgba(0,0,0,0.1); opacity: 0; transition: opacity 0.2s; }
.tower-section:hover .btn-overlay, .btn-overlay:hover { opacity: 1; background: rgba(0,0,0,0.4); }
.room-visual { position: relative; width: 100%; height: 100%; background: #6d4c41; }
.stairs { position: absolute; right: 10px; top: 0; width: 20px; height: 100%; background: repeating-linear-gradient(45deg, #3e2723, #3e2723 5px, #4e342e 5px, #4e342e 10px); border-left: 2px solid #281915; opacity: 0.7; }
#room-attic { height: 90px; border-radius: 60px 60px 0 0; background: transparent; border: none; }
#room-attic .room-visual { background: #4e342e; border: 4px solid #3e2723; border-radius: 60px 60px 0 0; }
.attic-window { position: absolute; top: 30px; width: 20px; height: 30px; background: #87CEEB; border: 2px solid #3e2723; }
.attic-window.left { left: 40px; } .attic-window.right { right: 60px; }
.chair-bed { position: absolute; bottom: 5px; left: 80px; width: 50px; height: 15px; background: #8d6e63; border-radius: 3px; }
.table-small { position: absolute; bottom: 5px; right: 40px; width: 20px; height: 20px; background: #3e2723; }
#room-living { height: 140px; }
.split-room { display: flex; }
.zone { flex: 1; border-right: 1px solid rgba(0,0,0,0.3); position: relative; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; }
.zone-bed-m { background: rgba(0,0,0,0.1); } .zone-kitchen { flex: 1.2; background: rgba(0,0,0,0.05); } .zone-bed-f { background: rgba(0,0,0,0.1); }
.bed { width: 40px; height: 20px; background: #558b2f; border: 2px solid #33691e; position: relative; }
.wounded-guy { position: absolute; top: -5px; left: 5px; width: 30px; height: 10px; background: #fff; border-radius: 5px; border: 1px solid #ccc; }
.flower-pot { position: absolute; bottom: 20px; right: 5px; font-size: 14px; }
.stove { width: 30px; height: 30px; background: #212121; margin-right: 5px; }
.stove-pipe { position: absolute; bottom: 30px; left: 30px; width: 6px; height: 100px; background: #212121; }
.table-dinner { width: 30px; height: 20px; background: #795548; border-top: 4px solid #4e342e; }
#room-main { height: 130px; }
.hanging-rail { position: absolute; left: 40px; top: 10px; width: 6px; height: 80px; background: linear-gradient(#555, #333); border: 1px solid #111; }
.diesel-gen { position: absolute; right: 50px; bottom: 5px; width: 40px; height: 40px; background: #388e3c; border: 2px solid #1b5e20; display: flex; justify-content: center; align-items: center; color: white; font-size: 12px; }
.workbench-table { position: absolute; left: 30px; bottom: 5px; width: 80px; height: 30px; background: #5d4037; border-top: 5px solid #8d6e63; }
#room-basement { height: 90px; border-radius: 0 0 10px 10px; }
.basement-style { background: #281915; }
#room-basement .stairs { display: none; }
.shelf { position: absolute; background: #4e342e; height: 5px; width: 60px; }
.shelf-1 { top: 20px; left: 10px; } .shelf-2 { top: 50px; left: 10px; }
.box { position: absolute; width: 20px; height: 20px; background: #8d6e63; border: 1px solid #4e342e; }
.box-1 { bottom: 5px; right: 50px; } .box-2 { bottom: 5px; right: 20px; }
.activity-btn { background: rgba(0,0,0,0.6); border: 1px solid #fff; color: white; padding: 5px 10px; font-size: 12px; cursor: pointer; margin: 3px; transition: transform 0.1s; width: 140px; text-transform: uppercase; font-weight: bold; }
.activity-btn:hover { transform: scale(1.05); background: #d32f2f; }
#mini-game-modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 300; display: flex; flex-direction: column; justify-content: center; align-items: center; color: white; }
.mg-content { background: #333; padding: 20px; border: 2px solid #888; text-align: center; width: 90%; max-width: 400px; position: relative; }
.mg-game-area { width: 100%; height: 300px; background: #222; margin: 20px 0; border: 1px solid #555; position: relative; overflow: hidden; user-select: none; }
.hidden { display: none !important; }
#scavenge-header { height: 40px; background: #333; display: flex; align-items: center; justify-content: center; border-bottom: 2px solid #555; gap: 10px; }
.target-preview { width: 25px; height: 25px; border: 1px solid #fff; opacity: 0.5; }
.target-preview.found { opacity: 1; border-color: #4caf50; box-shadow: 0 0 5px #4caf50; }
#flashlight { position: absolute; width: 100px; height: 100px; border-radius: 50%; box-shadow: 0 0 0 1000px black; pointer-events: none; transform: translate(-50%, -50%); border: 2px solid rgba(255,255,255,0.2); z-index: 10; }
.scav-obj { position: absolute; z-index: 5; cursor: pointer; box-sizing: border-box; }
.shape-square { width: 30px; height: 30px; }
.shape-circle { width: 30px; height: 30px; border-radius: 50%; }
.shape-triangle { width: 0; height: 0; border-left: 15px solid transparent; border-right: 15px solid transparent; border-bottom: 30px solid currentColor; background: transparent !important; }
.bolt-container { display: flex; justify-content: center; align-items: flex-end; height: 100%; padding-bottom: 20px; }
.bolt-column { width: 40px; height: 200px; background: repeating-linear-gradient(45deg, #555, #555 5px, #444 5px, #444 10px); border: 2px solid #777; border-radius: 5px 5px 0 0; margin: 0 20px; position: relative; display: flex; flex-direction: column-reverse; align-items: center; cursor: pointer; }
.nut { width: 50px; height: 20px; margin-bottom: 2px; border-radius: 4px; border: 2px solid rgba(0,0,0,0.5); z-index: 2; transition: transform 0.2s; }
.nut.red { background: #e53935; } .nut.blue { background: #1e88e5; }
.nut.selected { border-color: white; transform: scale(1.1); box-shadow: 0 0 10px white; }
.lab-table { display: flex; justify-content: space-around; align-items: flex-end; height: 100%; padding-bottom: 30px; }
.lab-tool { width: 60px; height: 60px; border: 2px dashed #666; display: flex; justify-content: center; align-items: center; font-size: 10px; cursor: pointer; background: #333; transition: all 0.2s; }
.lab-tool.selected { border-color: #00bcd4; background: #004d40; }
.icon-tap::after { content: "🚰 КРАН"; font-size: 20px; } .icon-sink::after { content: "🚽 СЛИВ"; font-size: 20px; }
.flask { width: 60px; height: 150px; border: 3px solid rgba(255,255,255,0.5); border-top: none; border-radius: 0 0 10px 10px; position: relative; background: rgba(0,0,0,0.3); cursor: pointer; transition: transform 0.2s; }
.flask.selected { border-color: #00bcd4; transform: scale(1.05); }
.liquid { position: absolute; bottom: 0; left: 0; width: 100%; background: rgba(0, 188, 212, 0.8); transition: height 0.5s ease-in-out; border-radius: 0 0 7px 7px; }
.flask-label { position: absolute; width: 100%; text-align: center; top: 50%; transform: translateY(-50%); text-shadow: 0 0 3px black; pointer-events: none; }
.target-line { position: absolute; width: 100%; height: 2px; background: #f44336; z-index: 10; left: 0; }
.inv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; width: 200px; margin: 20px auto; background: #3e2723; border: 4px solid #5d4037; padding: 2px; }
.inv-cell { width: 48px; height: 48px; background: #281915; border: 1px solid #3e2723; }
.inv-cell.filled { background: #8d6e63; border-color: #a1887f; box-shadow: inset 0 0 5px #000; }
.inv-items-pool { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.inv-item-source { background: #8d6e63; border: 2px solid #fff; cursor: pointer; position: relative; }
.inv-item-source.selected { border-color: #ffeb3b; transform: scale(1.1); }
@media (max-width: 768px) { #tower { width: 55px; } #generator { width: 35px; height: 25px; bottom: 5px; } .game-title { font-size: 40px; margin-bottom: 20px; } #main-menu { padding-left: 20px; align-items: center; } .menu-buttons button { width: 80vw; font-size: 18px; padding: 12px; text-align: center; } .tower-section { width: 90vw; } }
@keyframes flicker { 0% {opacity:0.5;} 50% {opacity:0.8;} 100% {opacity:0.5;} }
@keyframes bounce { 0%, 100% {transform: translateY(0);} 50% {transform: translateY(-5px);} }
@keyframes shockwave { 
    0% { width: 20px; height: 20px; opacity: 1; border-width: 10px; box-shadow: 0 0 20px 10px rgba(255,255,255,1); } 
    100% { width: 800px; height: 800px; opacity: 0; border-width: 0px; box-shadow: 0 0 100px 50px rgba(255,255,255,0); } 
}
@keyframes fall {
    0% { transform: translateY(-10px) translateX(0); }
    50% { transform: translateY(50vh) translateX(20px); }
    100% { transform: translateY(110vh) translateX(-20px); }
}
@keyframes breath {
    0%, 100% { opacity: 0.6; box-shadow: inset 0 0 100px rgba(180, 220, 255, 0.2); }
    50% { opacity: 0.9; box-shadow: inset 0 0 200px rgba(180, 220, 255, 0.4); }
}