:root {
    --bg-color: #000000;
    --text-color: #e0e0e0;
    --accent-color: #8b0000;
    --accent-hover: #ff1a1a;
    --panel-bg: rgba(10, 10, 10, 0.7);
    --font-main: 'Cairo', sans-serif;
    --font-heading: 'Tajawal', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
    user-select: none;
}

#canvas-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; }

.crt-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 3px, 3px 100%;
    z-index: 10; pointer-events: none; opacity: 0.15;
}

.vignette {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle, rgba(0,0,0,0) 30%, rgba(0,0,0,0.95) 100%);
    z-index: 11; pointer-events: none;
}

#damage-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle, rgba(255,0,0,0) 50%, rgba(255,0,0,0.7) 100%);
    z-index: 12; pointer-events: none; opacity: 0; transition: opacity 0.2s;
}
#damage-overlay.active { opacity: 1; }

/* Menu Screens */
.menu-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, #1a0000 0%, #000 100%);
    z-index: 3000; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    transition: opacity 0.5s ease-in-out;
}
.menu-screen.hidden { opacity: 0; pointer-events: none; display: none !important; }

.game-title {
    font-size: 7rem; color: #ff1a1a; font-family: var(--font-heading);
    text-shadow: 0 0 30px #ff0000; margin-bottom: 60px;
    animation: heartbeat 2s infinite; letter-spacing: 5px;
}
@keyframes heartbeat {
    0% { transform: scale(1); text-shadow: 0 0 20px #ff0000; } 
    10% { transform: scale(1.05); text-shadow: 0 0 40px #ff0000; } 
    20% { transform: scale(1); text-shadow: 0 0 20px #ff0000; }
}

.menu-header { font-size: 3rem; color: #fff; margin-bottom: 40px; font-family: var(--font-heading); }

.settings-box {
    background: rgba(20,0,0,0.6); border: 2px solid var(--accent-color);
    padding: 30px 50px; border-radius: 12px; margin-bottom: 40px;
    box-shadow: 0 0 30px rgba(139,0,0,0.5);
}
.setting-row {
    margin-bottom: 25px; font-size: 1.5rem; display: flex; gap: 30px; 
    align-items: center; justify-content: space-between; width: 450px;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-row select, .setting-row input[type="checkbox"] {
    padding: 10px; font-size: 1.2rem; background: #111; color: #fff; 
    border: 1px solid var(--accent-color); outline: none; border-radius: 6px; cursor: pointer;
}
.setting-row input[type="checkbox"] { width: 25px; height: 25px; accent-color: var(--accent-hover); }

/* Cutscene */
#cutscene {
    position: fixed; top:0; left:0; width:100vw; height:100vh;
    background: #000; z-index: 2000; display:flex; flex-direction:column;
    justify-content:center; align-items:center;
    transition: opacity 1.5s ease-in-out;
}
#cutscene.hidden { opacity: 0; pointer-events:none; }
#cutscene-text {
    color: white; font-size: 2rem; text-align:center; max-width: 800px; line-height:2;
    white-space: pre-wrap; font-family: var(--font-heading);
    text-shadow: 0 0 10px rgba(255,255,255,0.5); margin-bottom: 40px;
}

#blocker {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.85);
    z-index: 100; display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center;
    color: white; cursor: pointer; backdrop-filter: blur(5px);
}
#instructions { font-size: 20px; line-height: 1.8; font-family: var(--font-heading); }

#crosshair {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.5); font-size: 24px; z-index: 20; pointer-events: none;
}
#interact-prompt {
    position: absolute; top: 55%; left: 50%; transform: translate(-50%, -50%);
    color: #fff; font-size: 1.5rem; font-family: var(--font-heading);
    text-shadow: 0 0 5px #000; z-index: 20; pointer-events: none;
}

/* UI overlay */
.ui-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 30; pointer-events: none; padding: 20px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.header {
    display: flex; justify-content: space-between;
    background: var(--panel-bg); padding: 15px 25px;
    border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
    pointer-events: auto; width: 100%; backdrop-filter: blur(5px);
}
.stat-box { display: flex; align-items: center; gap: 15px; font-size: 1.2rem; font-family: var(--font-heading); }
.hp-bar-container { width: 250px; height: 22px; background: #222; border-radius: 11px; overflow: hidden; position: relative; }
.hp-bar { height: 100%; background: linear-gradient(90deg, #00b300, #00ff00); width: 100%; transition: width 0.3s ease-out; }

.side-panel { align-self: flex-end; width: 350px; display: flex; flex-direction: column; gap: 15px; pointer-events: auto; }
.inventory, .logs { background: var(--panel-bg); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 20px; flex: 1; max-height: 250px; overflow-y: auto; backdrop-filter: blur(5px); }
.logs::-webkit-scrollbar, .inventory::-webkit-scrollbar { width: 5px; }
.logs::-webkit-scrollbar-thumb, .inventory::-webkit-scrollbar-thumb { background: #555; border-radius: 5px;}

h3 { border-bottom: 1px solid #444; padding-bottom: 5px; margin-bottom: 10px; font-family: var(--font-heading); color: #ccc;}
ul { list-style: none; }
li { padding: 5px 0; border-bottom: 1px dashed #333; display: flex; justify-content: space-between; font-size: 1rem;}

#game-logs { display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem;}
.log-entry { animation: fadeIn 0.3s; }
.log-entry.damage { color: #ff6666; } .log-entry.heal { color: #66ff66; } .log-entry.info { color: #66ccff; } .log-entry.alert { color: #ffcc00; }

.btn {
    background: rgba(0, 0, 0, 0.6); color: #fff; border: 1px solid var(--accent-color);
    padding: 12px 25px; font-size: 1.2rem; font-family: var(--font-heading); cursor: pointer;
    border-radius: 6px; transition: all 0.3s; text-transform: uppercase; pointer-events: auto;
}
.btn-large { font-size: 1.6rem; padding: 15px 50px; border-width: 2px; }
.btn:hover { background: var(--accent-color); box-shadow: 0 0 25px rgba(255, 26, 26, 0.8); transform: scale(1.05); }

.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Mobile Controls CSS */
#mobile-controls {
    position: fixed;
    bottom: 30px;
    left: 30px;
    right: 30px;
    z-index: 2000;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}

#joystick-zone {
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, 0.08);
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    position: relative;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

#joystick-thumb {
    width: 55px;
    height: 55px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.mobile-btns {
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.mbtn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(20, 0, 0, 0.7);
    border: 2px solid var(--accent-color);
    color: white;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(139, 0, 0, 0.5);
    touch-action: none;
    outline: none;
}

.mbtn:active {
    background: var(--accent-hover);
    box-shadow: 0 0 25px var(--accent-hover);
    transform: scale(0.9);
}

@media (max-width: 800px) {
    .game-title { font-size: 4rem; margin-bottom: 30px; }
    .settings-box { padding: 15px 25px; width: 90vw; }
    .setting-row { width: 100%; font-size: 1.1rem; }
    .header { padding: 10px 15px; }
    .hp-bar-container { width: 150px; }
    .side-panel { display: none !important; } /* Hide panel on mobile to save space */
}

