body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #1a1a1a;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

canvas {
    display: block;
    background-color: #2b6da5; /* Ocean Blue (Default) */
    cursor: crosshair;
}

/* UI Overlays */
#ui-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 150px;
    background: rgba(0, 0, 0, 0.9);
    border-top: 2px solid #444;
    display: none;
    flex-direction: row;
    padding: 10px;
    box-sizing: border-box;
    pointer-events: auto;
    z-index: 10;
}

.panel {
    border-right: 1px solid #555;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#info-panel { width: 220px; font-size: 13px; }

#build-panel { 
    flex-grow: 1; 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    grid-template-rows: repeat(2, 1fr);
    gap: 5px; 
    overflow: hidden;
}

#controls-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding-left: 10px;
    width: 120px;
}

#selection-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: calc(100% - 150px);
    background: rgba(8, 12, 18, 0.95);
    border-left: 2px solid #2e475f;
    z-index: 12;
    transition: transform 0.2s ease;
    display: none;
}
#selection-sidebar.collapsed { transform: translateX(284px); }
#selection-sidebar-toggle {
    position: absolute;
    left: -32px;
    top: 12px;
    width: 32px;
    height: 44px;
    border: 1px solid #4c677f;
    background: #132334;
    color: #c3ddff;
    cursor: pointer;
}
#selection-sidebar-content {
    height: 100%;
    overflow-y: auto;
    padding: 12px;
    box-sizing: border-box;
}
.selection-image-block {
    border: 1px solid #355069;
    background: #0f1822;
    padding: 8px;
    margin-bottom: 12px;
}
#selection-image-preview {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: #111;
    display: none;
}
#selection-image-empty {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6a8298;
    font-size: 12px;
    border: 1px dashed #47637c;
}
#selection-sidebar-info { font-size: 12px; color: #d6e7f8; }
#selection-sidebar-info h4 { margin: 8px 0 4px; color: #79bfff; font-size: 12px; text-transform: uppercase; }
#selection-sidebar-info .line { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
#selection-sidebar-info .line b { color: #fff; }

.btn-toggle {
    background: #333;
    border: 1px solid #555;
    color: #aaa;
    padding: 8px 10px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 11px;
    width: 100%;
    text-align: center;
}
.btn-toggle:hover { background: #444; color: #fff; }
.btn-toggle.active {
    background: #d4a017;
    color: #000;
    border-color: #ffd700;
}

/* Zone Sub-Menu */
#zone-panel {
    display: none; /* Flex when active */
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 100px;
    border-right: 1px solid #555;
    padding: 0 10px;
}
.btn-zone {
    background: #222; border: 1px solid #444; color: #ccc;
    padding: 5px; font-size: 10px; cursor: pointer; text-align: center;
}
.btn-zone:hover { background: #333; color: #fff; }
.btn-zone.active { border-color: #fff; font-weight: bold; }

h3 { margin: 0 0 5px 0; color: #4faaff; font-size: 15px; text-transform: uppercase; }
p { margin: 2px 0; color: #ccc; }

.stat-row { display: flex; justify-content: space-between; }
.res-text { color: #ffd700; font-weight: bold; font-size: 16px; }

.btn-build {
    background: #333;
    border: 1px solid #555;
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: background 0.2s;
    position: relative;
    border-radius: 4px;
}

.btn-build:hover { background: #444; border-color: #888; }
.btn-build:active { background: #222; }
.btn-build.edit-mode { border-color: #d4a017; border-style: dashed; }

.btn-icon { font-size: 20px; margin-bottom: 2px; display: flex; align-items: center; justify-content: center; }
.cost { color: #ffd700; font-weight: bold; }

.icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4em;
    height: 1.4em;
    line-height: 1;
}
.icon-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.icon-fallback {
    display: none;
    line-height: 1;
}
.icon-image + .icon-fallback {
    display: none;
}
.icon-wrapper .icon-fallback:first-child {
    display: inline;
}
.icon-medium { width: 1.3em; height: 1.3em; }
.icon-large { width: 1.5em; height: 1.5em; margin-right: 4px; vertical-align: middle; }

/* Modal Styles */
.modal {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    border: 2px solid #444;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    z-index: 50;
    padding: 20px;
    flex-direction: column;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid #444; padding-bottom: 10px;}
.modal-title { font-size: 20px; color: #4faaff; font-weight: bold; text-transform: uppercase; }
.btn-close { background: #c33; border: none; color: white; padding: 5px 10px; cursor: pointer; font-weight: bold;}

/* Loadout Styles */
#loadout-modal { width: 700px; }
#plane-schematic {
    width: 100%; height: 350px; position: relative;
    background: #1a1a1a; border: 1px solid #333; margin-bottom: 15px;
    display: flex; justify-content: center; align-items: center; overflow: hidden;
}
.schematic-body { width: 40px; height: 200px; background: #333; border-radius: 20px 20px 5px 5px; position: relative; z-index: 1; transition: all 0.3s; }
.schematic-wing { position: absolute; top: 60px; width: 220px; height: 50px; background: #333; left: -90px; z-index: 0; transform: skewY(-10deg); }
.schematic-wing.right { left: auto; right: -90px; transform: skewY(10deg); }
.schematic-tail { position: absolute; bottom: 10px; width: 80px; height: 25px; background: #333; left: -20px; z-index: 0; }
.schematic-rotor { position: absolute; top: 100px; left: -105px; width: 250px; height: 10px; background: rgba(255,255,255,0.1); border-radius: 50%; border: 2px solid #555; display:none; }

.slot {
    position: absolute; width: 80px; height: 35px; background: #000; border: 1px solid #555;
    color: #fff; font-size: 9px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; text-align: center; z-index: 10; box-shadow: 0 0 5px rgba(0,0,0,0.5);
}
.slot:hover { border-color: #ffd700; background: #222; z-index: 11; }
.slot-name { color: #888; font-size: 8px; position: absolute; top: -10px; width: 100%; }

#weapon-selector { min-height: 100px; background: #111; padding: 10px; display: flex; gap: 10px; overflow-x: auto; align-items: center; }
.weapon-option {
    min-width: 80px; height: 80px; background: #222; border: 1px solid #444;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    font-size: 9px; cursor: pointer; padding: 5px; text-align: center; position: relative;
}
.weapon-option:hover { background: #333; border-color: #888; }
.weapon-option.selected { border-color: #4faaff; background: #1a2a3a; }
.weapon-option.locked { opacity: 0.5; cursor: not-allowed; border-color: #500; }
.lock-icon { position: absolute; top: 2px; right: 2px; font-size: 10px; color: #f44; }
.weapon-cap { color: #ffd700; font-size: 10px; margin-top: 2px; }

#slot-config-panel {
    min-height: 46px;
    margin-top: 10px;
    background: #111;
    border: 1px solid #333;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.slot-config-title { color: #aaa; font-size: 12px; }
.slot-ammo-controls { display: flex; align-items: center; gap: 8px; }
.btn-ammo {
    width: 26px;
    height: 26px;
    background: #333;
    color: #fff;
    border: 1px solid #666;
    cursor: pointer;
    font-weight: bold;
}
.btn-ammo:hover { background: #444; }
.slot-ammo-value { min-width: 70px; text-align: center; color: #ffd700; font-weight: bold; }

/* Research Styles */
#research-modal { width: 850px; }
#construction-modal { width: 560px; }
#construction-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.construction-option {
    min-height: 76px;
    background: #1b1b1b;
    border: 1px solid #444;
    color: #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
}
.construction-option:hover { border-color: #4faaff; background: #222a33; }
.construction-option.selected { border-color: #ffd700; box-shadow: 0 0 8px rgba(255,215,0,0.35); }
.construction-option .left { display:flex; align-items:center; gap:8px; }
.construction-option.disabled { opacity: 0.5; cursor: not-allowed; }
#construction-hint { margin-top: 12px; color: #8fb8dd; font-size: 12px; }
.tech-category { margin-bottom: 20px; }
.tech-category h4 { color: #888; border-bottom: 1px solid #333; margin: 0 0 10px 0; padding-bottom: 2px; }
.tech-row { display: flex; gap: 15px; }
.tech-node {
    width: 120px; height: 80px; background: #151515; border: 1px solid #444;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 5px; text-align: center; font-size: 10px; cursor: pointer; position: relative;
}
.tech-node:hover { background: #222; }
.tech-node.unlocked { border-color: #4f4; color: #4f4; background: #1a2a1a; }
.tech-node.available { border-color: #ffd700; color: #fff; }
.tech-node.locked { opacity: 0.4; pointer-events: none; border-color: #333; }
.tech-arrow { color: #555; font-size: 20px; align-self: center; }

/* Menu Screens */
.menu-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 60;
}
.menu-title { font-size: 72px; color: #fff; text-transform: uppercase; letter-spacing: 5px; text-shadow: 0 0 10px #4faaff; margin-bottom: 20px; }
.menu-btn {
    background: #222; color: #fff; border: 2px solid #444; padding: 15px 40px;
    font-size: 24px; margin: 10px; cursor: pointer; transition: all 0.2s; width: 300px; text-align: center;
}
.menu-btn:hover { background: #4faaff; color: #000; border-color: #fff; }
.setup-group { margin: 15px 0; text-align: center; width: 400px; display:flex; justify-content: space-between; align-items: center; }
.setup-label { color: #aaa; font-size: 18px; }
select, input[type=range], input[type=text] { background: #333; color: white; padding: 5px 10px; border: 1px solid #555; font-size: 16px; width: 200px; box-sizing: border-box; }
.setup-status { color: #8fd4ff; font-size: 14px; }

#encyclopedia-content {
    width: min(920px, 90vw);
    max-height: 70vh;
    background: rgba(10, 18, 26, 0.95);
    border: 2px solid #2e4b63;
    padding: 16px;
    margin: 8px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#encyclopedia-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.encyclopedia-tab {
    background: #1a2734;
    border: 1px solid #43617a;
    color: #a6c5dd;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
}
.encyclopedia-tab.active {
    background: #4faaff;
    color: #001729;
    border-color: #8cd3ff;
}
#encyclopedia-entry-card {
    background: #101820;
    border: 1px solid #2f475b;
    padding: 14px;
    min-height: 280px;
}
#encyclopedia-entry-title { font-size: 28px; color: #fff; font-weight: 700; }
#encyclopedia-entry-subtitle { font-size: 14px; color: #8fd4ff; margin: 3px 0 10px; text-transform: uppercase; }
#encyclopedia-entry-description { color: #d7e3ed; margin-bottom: 12px; line-height: 1.4; }
#encyclopedia-entry-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}
.encyclopedia-stat {
    background: #152433;
    border: 1px solid #2b465d;
    color: #bcd5e8;
    padding: 6px 8px;
    font-size: 13px;
}
#encyclopedia-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.encyclopedia-nav-btn {
    background: #203548;
    color: #d2e7f7;
    border: 1px solid #4a7090;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: bold;
}
#encyclopedia-progress { color: #9dc6e1; font-size: 13px; }

#overlay {
    position: absolute; inset: 0;
    text-align: center; display: none; z-index: 100;
    background: rgba(0, 0, 0, 0.65);
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}
#overlay h1 { font-size: 64px; margin: 0; text-shadow: 2px 2px 4px #000; }
.overlay-card {
    min-width: 420px;
    background: rgba(10, 14, 20, 0.95);
    border: 2px solid #4faaff;
    padding: 28px;
    box-shadow: 0 0 24px rgba(0,0,0,0.5);
}
#overlay-submsg { color: #d2e8ff; margin: 10px 0 24px; }
.overlay-btn { width: auto; font-size: 18px; margin: 0 auto; }

#tooltip {
    position: absolute; background: rgba(0,0,0,0.9); border: 1px solid #777;
    padding: 5px 10px; pointer-events: none; display: none; z-index: 200; font-size: 12px; white-space: pre-line;
}

#tutorial-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
}
#tutorial-message {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 34px;
    font-weight: 900;
    text-shadow: 0 0 10px #000, 0 0 18px #000;
    background: rgba(0,0,0,0.45);
    border: 2px solid #ff5555;
    border-radius: 12px;
    padding: 10px 16px;
}
#tutorial-highlight {
    position: fixed;
    border: 4px solid #ff2222;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.4), 0 0 18px rgba(255,0,0,0.8);
}

/* Camera Help */
#cam-help {
    position: absolute; top: 10px; right: 10px; color: #666; font-size: 12px;
}
