:root {
    --bg-color: #050510;
    --panel-bg: rgba(10, 15, 30, 0.9);
    --panel-border: #3a5080;
    --text-main: #e0e6ed;
    --text-accent: #4da6ff;
    --btn-bg: #1a2a4c;
    --btn-hover: #2a4070;
    --btn-border: #4da6ff;
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Roboto', sans-serif;
    
    --top-bar-height: 20px; /* Small tab */
    --bottom-bar-height: 50px;
    --sidebar-width: 180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ---------------------------------------------------
   MOBILE BLOCKER
--------------------------------------------------- */
#mobile-blocker {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; color: #ff4d4d; z-index: 9999;
    flex-direction: column; justify-content: center; align-items: center;
    text-align: center; padding: 20px;
}

#mobile-blocker h1 { font-family: var(--font-heading); margin-bottom: 20px; }
#mobile-blocker p { font-size: 16px; line-height: 1.5; color: #ccc; }

/* Смартфоны БОЛЬШЕ НЕ блокируются: начинаем поэтапную адаптацию интерфейса под
   телефоны — игра пока отображается как есть, доработки идут шаг за шагом.
   Разметка #mobile-blocker оставлена в index.php (base display:none), чтобы при
   необходимости заглушку можно было мгновенно вернуть одной строкой CSS. */

/* ---------------------------------------------------
   MAIN GAME CONTAINER
--------------------------------------------------- */
#game-container { position: relative; width: 100%; height: 100%; }

#galaxy-canvas {
    display: block; width: 100%; height: 100%; cursor: grab;
}
#galaxy-canvas:active { cursor: grabbing; }

/* Смартфон: canvas не должен перекрывать нижнее меню */
@media (max-width: 899px) {
    #galaxy-canvas { height: calc(100% - var(--bottom-bar-height)); }
}

/* ---------------------------------------------------
   ONBOARDING / REGISTRATION
--------------------------------------------------- */
#onboarding-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(5, 5, 16, 0.4);
    background: url('../mainbg.jpg') center center / cover no-repeat;

    backdrop-filter: blur(15px);
    display: flex; justify-content: center; align-items: center;
    z-index: 100;
    transition: opacity 1.5s ease, backdrop-filter 1.5s ease;
}
#onboarding-layer.hidden {
    opacity: 0; pointer-events: none; backdrop-filter: blur(0px);
}

.game-title {
    font-family: var(--font-heading); color: white; font-size: 32px;
    letter-spacing: 2px; text-shadow: 0 0 20px var(--text-accent); margin-bottom: 30px;
}
.game-title span { font-size: 16px; color: var(--text-accent); letter-spacing: 5px; }

.menu-buttons { display: flex; flex-direction: column; gap: 15px; }

.onboarding-panel {
    background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 12px;
    padding: 40px; width: max-content; min-width: 500px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9), inset 0 0 15px rgba(77, 166, 255, 0.1);
    text-align: center; transition: all 0.3s ease;
    /* НИКОГДА не шире/выше экрана — на минимальном планшете (768px) панель раньше
       вылезала за край (шаг рас 800px + 2×40px паддинга ≈ 880px). */
    box-sizing: border-box;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    overflow-x: hidden;
}

.onboarding-step {
    display: none; flex-direction: column; gap: 20px; animation: fadeIn 0.5s ease; width: 100%;
}
.onboarding-step.active { display: flex; }

/* Желаемая ширина, но всегда в пределах панели (а панель — в пределах экрана).
   Компактные overrides для узких экранов — В КОНЦЕ файла (иначе базовые правила,
   объявленные ниже, перебили бы их при равной специфичности). */
.onboarding-step.race-selection-step { width: 800px; max-width: 100%; }

.onboarding-step h1 { font-family: var(--font-heading); color: var(--text-accent); font-size: 24px; margin-bottom: 10px; }
.onboarding-step p { color: #aaa; font-size: 14px; margin-bottom: 20px; }
.onboarding-step input {
    width: 100%; padding: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-border);
    color: white; font-family: var(--font-body); font-size: 16px; border-radius: 6px; outline: none; transition: border 0.3s;
}
.onboarding-step input:focus { border-color: var(--text-accent); }

/* Races Grid */
.races-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 20px;
    max-height: 50vh; overflow-y: auto; padding-right: 10px;
}
.races-grid::-webkit-scrollbar { width: 6px; }
.races-grid::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
.races-grid::-webkit-scrollbar-thumb { background: var(--text-accent); border-radius: 4px; }

.race-card {
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(77, 166, 255, 0.3); border-radius: 8px;
    padding: 15px; cursor: pointer; transition: all 0.2s ease; text-align: left;
}
.race-card:hover { background: rgba(77, 166, 255, 0.1); border-color: var(--text-accent); }
.race-card.selected {
    background: rgba(77, 166, 255, 0.2); border-color: var(--text-accent);
    box-shadow: 0 0 15px rgba(77, 166, 255, 0.5);
}

.race-name { font-family: var(--font-heading); font-size: 16px; color: white; margin-bottom: 5px; }
.race-trait { font-size: 12px; color: #4da6ff; margin-bottom: 3px; }
.race-desc { font-size: 11px; color: #999; margin-top: 8px; }

/* ── Cosmic Loader ──────────────────────────────────────────── */
.loader {
    position: relative;
    width: 80px; height: 80px;
    margin: 0 auto 20px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loader::before {
    content: '';
    position: absolute;
    width: 60px; height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #4da6ff, #1a3a6a, #0a1a2a);
    box-shadow: 0 0 30px rgba(77, 166, 255, 0.6), 0 0 60px rgba(77, 166, 255, 0.3), inset 0 0 20px rgba(255,255,255,0.15);
    animation: pulseGlow 1.5s ease-in-out infinite;
}
.loader::after {
    content: '';
    position: absolute;
    width: 100px; height: 100px;
    border-radius: 50%;
    border: 2px solid rgba(77, 166, 255, 0.15);
    border-top: 2px solid rgba(77, 166, 255, 0.6);
    border-bottom: 2px solid rgba(77, 166, 255, 0.3);
    animation: spin 2s linear infinite;
}
.loader .loader-ring {
    position: absolute;
    width: 120px; height: 120px;
    border-radius: 50%;
    border: 1px dashed rgba(77, 166, 255, 0.1);
    animation: spin 3s linear infinite reverse;
}
.loader .loader-particle {
    position: absolute;
    width: 3px; height: 3px;
    border-radius: 50%;
    background: #4da6ff;
    box-shadow: 0 0 6px #4da6ff;
    animation: particleOrbit 2s ease-in-out infinite;
}
.loader .loader-particle:nth-child(2) { animation-delay: 0.3s; width: 2px; height: 2px; }
.loader .loader-particle:nth-child(3) { animation-delay: 0.7s; width: 4px; height: 4px; background: #7fc4ff; }
.loader .loader-particle:nth-child(4) { animation-delay: 1.1s; width: 2px; height: 2px; }
.loader .loader-particle:nth-child(5) { animation-delay: 1.5s; width: 3px; height: 3px; background: #a8d8ff; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulseGlow {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(77,166,255,0.6), 0 0 60px rgba(77,166,255,0.3); }
    50% { transform: scale(1.08); box-shadow: 0 0 50px rgba(77,166,255,0.8), 0 0 100px rgba(77,166,255,0.4); }
}
@keyframes particleOrbit {
    0% { transform: rotate(0deg) translateX(40px) rotate(0deg); opacity: 0.2; }
    50% { opacity: 1; }
    100% { transform: rotate(360deg) translateX(40px) rotate(-360deg); opacity: 0.2; }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------
   GALAXY LOADING OVERLAY (in-game, after login)
   Reuses the cosmic .loader in a darker, deep-space variant.
--------------------------------------------------- */
#galaxy-loader {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    /* Полупрозрачный тёмный фон (~50%): сквозь него видно, как подгружается карта/интерфейс. */
    background: radial-gradient(ellipse at center, rgba(7, 10, 22, 0.42) 0%, rgba(3, 4, 10, 0.55) 100%);
    z-index: 150;
    opacity: 1;
    transition: opacity 0.55s ease;
}
#galaxy-loader.hidden {
    opacity: 0; pointer-events: none;
}
/* Fully removed from layout once faded out, so it can never eat clicks. */
#galaxy-loader.gone { display: none; }
#galaxy-loader #galaxy-loader-text {
    margin-top: 30px;
    color: #6f8fd0;
    font-size: 13px;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(60, 110, 210, 0.35);
    animation: pulseGlow 2.4s ease-in-out infinite;
}
/* Darker, dimmer variant of the cosmic loader. */
.loader--galaxy::before {
    background: radial-gradient(circle at 35% 35%, #2a6bd4, #12264a, #05101f);
    box-shadow: 0 0 22px rgba(42, 107, 212, 0.4), 0 0 46px rgba(42, 107, 212, 0.2), inset 0 0 18px rgba(255,255,255,0.08);
}
.loader--galaxy::after {
    border: 2px solid rgba(42, 107, 212, 0.12);
    border-top: 2px solid rgba(42, 107, 212, 0.45);
    border-bottom: 2px solid rgba(42, 107, 212, 0.22);
}
.loader--galaxy .loader-ring { border: 1px dashed rgba(42, 107, 212, 0.08); }
.loader--galaxy .loader-particle {
    background: #3a72c8;
    box-shadow: 0 0 6px #3a72c8;
}
.loader--galaxy .loader-particle:nth-child(3) { background: #5a8fe0; }
.loader--galaxy .loader-particle:nth-child(5) { background: #7fa8ec; }

/* ---------------------------------------------------
   GAME UI LAYERS (MOO2 STYLE)
--------------------------------------------------- */
#ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5;
}
#ui-layer.hidden { display: none; }

/* Metallic Frame Overlay */
#game-frame {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 10;
    box-sizing: border-box;
    box-shadow: inset 0 0 20px #000;
}

/* Top Tab Container */
#top-game-tab-container {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1001; text-align: center;
    pointer-events: auto;
}

/* Top Tab */
#top-game-tab {
    background: linear-gradient(to bottom, #878c96, #4a4e57);
    color: #1a1c20; font-family: 'Arial', sans-serif; font-size: 14px; font-weight: 900;
    padding: 2px 40px; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px;
    border: 2px solid #5a5e66; border-top: none; 
    border-bottom: 2px solid #33363f; border-right: 2px solid #33363f; border-left: 2px solid #9ba0ab;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
    letter-spacing: 2px;
    cursor: pointer;
    transition: 0.1s;
}
#top-game-tab:hover {
    background: linear-gradient(to bottom, #9ba0ab, #5a5e66);
}
#top-game-tab:active {
    background: linear-gradient(to bottom, #5a5e66, #3a3e45);
}

/* Dropdown Menu MOO2 Style */
.dropdown-menu-moo {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    margin-top: 5px;
    background: #1a1c20;
    border: 2px solid #5a5e66;
    border-top-color: #9ba0ab; border-left-color: #9ba0ab;
    border-bottom-color: #33363f; border-right-color: #33363f;
    border-radius: 4px;
    padding: 10px;
    display: flex; flex-direction: column; gap: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    min-width: 180px;
}
.dropdown-menu-moo hr {
    border: 0; height: 2px; background: #33363f; margin: 5px 0;
}
.dropdown-menu-moo .menu-btn {
    background: linear-gradient(to bottom, #4a4e57, #2a2c33);
    color: #aeb3bd; font-family: 'Arial', sans-serif; font-size: 12px; font-weight: bold;
    border: 1px solid #5a5e66; padding: 6px 10px; border-radius: 2px;
    cursor: pointer; transition: 0.2s;
    text-transform: uppercase;
}
.dropdown-menu-moo .menu-btn:hover {
    background: linear-gradient(to bottom, #5a5e66, #3a3c45); color: #fff;
}
.dropdown-menu-moo .menu-btn.danger {
    color: #ff6666;
}
.dropdown-menu-moo .menu-btn.danger:hover {
    background: linear-gradient(to bottom, #802020, #501010); color: #ff9999;
}

/* Bottom Menu Bar - MOO2 Original Style */
#bottom-menu-bar {
    position: absolute; bottom: 0; left: 0; width: calc(100% - var(--sidebar-width)); height: var(--bottom-bar-height);
    background: transparent; 
    border-top: none;
    display: flex; justify-content: stretch; align-items: stretch; pointer-events: auto; z-index: 11;
    padding: 0 4px 0 0; /* added 4px right padding for gap */
    box-sizing: border-box;
}
.bottom-buttons {
    display: flex; flex-grow: 1; padding: 0; gap: 4px;
}
.btn.bottom-nav {
    flex-grow: 1; 
    position: relative;
    border: 2px solid #5a5e66;
    border-top: 2px solid #9ba0ab;
    border-left: 2px solid #9ba0ab;
    border-bottom: 2px solid #33363f;
    border-right: 2px solid #33363f;
    border-radius: 4px 4px 0 0;
    
    /* Top half smooth, bottom half ribbed */
    background: 
        linear-gradient(to bottom, #aeb3bd 0%, #878c96 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #4a4e57 0px, #4a4e57 2px, #2a2c33 2px, #2a2c33 4px);
    
    color: #1a1c20; 
    font-family: 'Arial', sans-serif; font-size: 13px; font-weight: 900; letter-spacing: 1px;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
    
    display: flex; align-items: center; justify-content: center;
    padding-top: 0;
    margin: 0; 
    cursor: pointer; transition: 0.1s;
}
.btn.bottom-nav:hover { 
    background: 
        linear-gradient(to bottom, #c2c8d4 0%, #9ba0ab 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #5a5e66 0px, #5a5e66 2px, #3a3c45 2px, #3a3c45 4px);
    color: #000;
}
.btn.bottom-nav:active {
    border-top: 2px solid #33363f;
    border-left: 2px solid #33363f;
    border-bottom: 2px solid #9ba0ab;
    border-right: 2px solid #9ba0ab;
    padding-top: 2px; /* shift text down */
    background: 
        linear-gradient(to bottom, #7a7e87 0%, #686c75 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #3a3e45 0px, #3a3e45 2px, #1a1c22 2px, #1a1c22 4px);
}

.zoom-controls {
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    background: linear-gradient(to bottom, #878c96, #4a4e57);
    border: 2px solid #5a5e66;
    border-top: 2px solid #9ba0ab; border-left: 2px solid #9ba0ab;
    border-bottom: 2px solid #33363f; border-right: 2px solid #33363f;
    border-radius: 4px 4px 0 0;
    margin: 0 2px; width: 40px;
    color: #1a1c20; font-family: 'Arial', sans-serif; font-size: 10px; font-weight: 900;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
}
.btn.zoom-btn { 
    background: transparent; border: none;
    color: #1a1c20; width: 100%; height: 16px; line-height: 16px; padding: 0; font-size: 14px; font-weight: bold;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
}
.btn.zoom-btn:hover { color: #000; background: rgba(255,255,255,0.2); }
.btn.zoom-btn:active { padding-top: 2px; }

/* Right Sidebar */
#right-sidebar {
    position: absolute; top: 0; right: 0;
    width: var(--sidebar-width); height: 100%;
    background: #4a4e57;
    border-left: none;
    display: flex; flex-direction: column; pointer-events: auto; z-index: 9;
    padding: 6px; box-sizing: border-box;
}

/* Stardate */
#sidebar-stardate {
    height: 24px; 
    border: 2px solid #5a5e66;
    border-top-color: #33363f; border-left-color: #33363f;
    border-bottom-color: #9ba0ab; border-right-color: #9ba0ab;
    display: flex; justify-content: center; align-items: center;
    background: #111; color: #aeb3bd; font-family: 'Arial', sans-serif; font-size: 13px; font-weight: bold;
    margin-bottom: 4px;
}

/* Resource Boxes */
#sidebar-resources {
    flex-grow: 1; display: flex; flex-direction: column; padding: 0; gap: 4px;
}
.res-box {
    flex-grow: 1; 
    background: linear-gradient(to bottom, #2a2c33, #1a1c20); 
    border: 2px solid #5a5e66;
    border-top: 2px solid #1a1c20; border-left: 2px solid #1a1c20;
    border-bottom: 2px solid #6c7078; border-right: 2px solid #6c7078;
    border-radius: 0;
    display: flex; align-items: center; padding: 5px; position: relative; overflow: hidden;
    color: #fff; font-family: 'Arial', sans-serif; font-size: 12px; font-weight: bold;
}
.res-icon {
    font-size: 24px; margin-right: 10px; text-shadow: 0 0 5px rgba(0,0,0,1);
}
.res-values {
    display: flex; flex-direction: column; font-family: var(--font-heading); font-size: 11px; color: #ccc;
}
.res-values div:first-child { font-size: 12px; color: #fff; margin-bottom: 2px; }

/* Info Panel (Floating Popup like MOO2 - Centered) */
#system-popup {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: #111520; padding: 20px; border: 2px solid #556; border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.9), inset 0 0 15px rgba(77, 166, 255, 0.1);
    z-index: 100; width: auto; min-width: 400px; max-width: 80%;
    pointer-events: auto;
}

.popup-header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid #334; padding-bottom: 5px; margin-bottom: 10px; }
.popup-header h2 { font-family: var(--font-heading); font-size: 18px; color: var(--text-accent); margin: 0; }
.sys-type { font-size: 12px; color: #aaa; margin: 0; }
.sys-owner { font-size: 14px; font-weight: bold; color: #fff; margin-bottom: 15px; text-transform: uppercase; }

.planets-container { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }

.planet-item {
      background: transparent; padding: 10px; border-radius: 6px;
      border: 1px solid transparent; display: flex; flex-direction: column; align-items: center; text-align: center;
      width: 80px;
      cursor: pointer;
      transition: all 0.2s ease-in-out;
  }
  .planet-item:hover { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(77, 166, 255, 0.3); }
  .planet-item.selected {
      background: rgba(77, 166, 255, 0.15);
      border: 1px solid rgba(77, 166, 255, 0.8);
      box-shadow: 0 0 10px rgba(77, 166, 255, 0.4);
  }
  .planet-info h4 { margin: 5px 0 2px 0; font-size: 11px; }
  .planet-desc { font-size: 9px; color: #999; margin: 0; line-height: 1.2; }
  .planet-icon { width: 50px; height: 50px; border-radius: 50%; background: transparent; box-shadow: none; margin-bottom: 5px; }

/* Popup Actions */
.popup-actions {
    display: flex; flex-direction: column; gap: 8px; margin-top: 15px;
}
.popup-actions .btn.action {
    flex-grow: 1;
    padding: 13px 16px;
    font-size: 12px;
    letter-spacing: 1.5px;
    border-radius: 5px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.15);
    color: #c8cdd8;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.popup-actions .btn.action::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
    transform: translateX(-100%);
    transition: transform 0.4s ease;
}
.popup-actions .btn.action:hover::before { transform: translateX(100%); }
.popup-actions .btn.action:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.35);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(77,166,255,0.2), inset 0 0 8px rgba(77,166,255,0.05);
    transform: translateY(-1px);
}
.popup-actions .btn.action:active { transform: translateY(0); }

/* Special colored action buttons */
.popup-actions .btn.action[style*="#ff4d4d"]:hover {
    box-shadow: 0 0 14px rgba(255,77,77,0.35), inset 0 0 8px rgba(255,77,77,0.1) !important;
    background: rgba(255,77,77,0.1) !important;
}
.popup-actions .btn.action[style*="#4da6ff"]:hover {
    box-shadow: 0 0 14px rgba(77,166,255,0.35), inset 0 0 8px rgba(77,166,255,0.1) !important;
    background: rgba(77,166,255,0.1) !important;
}

/* ── Toast Notification ────────────────────────────────── */
#moo-toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.moo-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 18, 28, 0.95);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 14px 20px;
    min-width: 280px;
    max-width: 450px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    animation: mooToastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    font-family: var(--font-main, 'Rajdhani', sans-serif);
}
.moo-toast.hide {
    animation: mooToastOut 0.3s ease forwards;
}
.moo-toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}
.moo-toast-body {
    flex: 1;
}
.moo-toast-title {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 2px;
    font-family: var(--font-heading, 'Play', sans-serif);
}
.moo-toast-msg {
    font-size: 13px;
    color: #c8cdd8;
    line-height: 1.4;
}
.moo-toast-close {
    background: none; border: none; color: #666; font-size: 16px;
    cursor: pointer; padding: 0 0 0 8px; flex-shrink: 0; line-height: 1;
    transition: color 0.2s;
}
.moo-toast-close:hover { color: #fff; }

/* Toast types */
.moo-toast.info   { border-left: 3px solid #4da6ff; }
.moo-toast.info .moo-toast-title { color: #4da6ff; }
.moo-toast.error  { border-left: 3px solid #ff6446; }
.moo-toast.error .moo-toast-title { color: #ff6446; }
.moo-toast.warn   { border-left: 3px solid #ffaa00; }
.moo-toast.warn .moo-toast-title { color: #ffaa00; }
.moo-toast.success { border-left: 3px solid #4dff91; }
.moo-toast.success .moo-toast-title { color: #4dff91; }

@keyframes mooToastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mooToastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(10px) scale(0.95); }
}

/* Generic Utils */
.mt-10 { margin-top: 10px; }
.hidden { display: none !important; }

/* Buttons Generic */
.btn {
    background: var(--btn-bg); color: var(--text-main); border: 1px solid var(--btn-border);
    padding: 8px 16px; border-radius: 4px; font-family: var(--font-heading); font-size: 12px;
    cursor: pointer; transition: all 0.2s ease; text-transform: uppercase;
}
.btn:hover { background: var(--btn-hover); box-shadow: 0 0 10px rgba(77, 166, 255, 0.5); }
.btn:disabled { background: #333; border-color: #555; color: #888; cursor: not-allowed; box-shadow: none; }
.btn.large { padding: 12px 24px; font-size: 14px; width: 100%; }
.btn.close { background: transparent; border: none; color: #aaa; font-size: 16px; padding: 0; }
.btn.close:hover { color: #fff; box-shadow: none; }

/* Global Modal Overlay */
#modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000; display: flex; justify-content: center; align-items: center;
    pointer-events: auto;
}

/* MOO2 Modal Window */
.moo2-modal {
    width: 600px; max-width: 90%; min-height: 400px;
    background: rgba(17, 21, 32, 0.95);
    border: 2px solid #5a5f6b; border-radius: 6px;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    display: flex; flex-direction: column;
}
.modal-header {
    background: #2a2e37; border-bottom: 2px solid #5a5f6b;
    border-top-left-radius: 4px; border-top-right-radius: 4px;
    padding: 15px; display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 {
    margin: 0; color: #ffaa00; font-family: 'Play', sans-serif; font-size: 20px; font-weight: bold;
    text-shadow: none; letter-spacing: 1px;
}
.modal-close-btn {
    background: transparent !important; border: none !important; box-shadow: none !important;
    color: #8a96a3 !important; font-size: 24px !important; font-weight: bold; padding: 0 10px !important;
    cursor: pointer; line-height: 1; transition: color 0.2s;
}
.modal-close-btn:hover {
    color: #ffffff !important; text-shadow: 0 0 10px rgba(255,255,255,0.5);
}
.modal-content {
    flex-grow: 1; padding: 25px;
    color: #aeb3bd; background: transparent;
    overflow-y: auto;
    display: flex; flex-direction: column; justify-content: flex-start;
}

/* MOO2 Bottom Menu Modal Style */
.moo2-menu-modal {
    width: 700px; max-width: 90%; min-height: 300px; max-height: 80%;
    background: linear-gradient(to bottom, #2a2c33, #1a1c20);
    border: 3px solid #5a5e66;
    border-top-color: #9ba0ab; border-left-color: #9ba0ab;
    border-bottom-color: #33363f; border-right-color: #33363f;
    border-radius: 4px;
    box-shadow: 0 0 25px rgba(0,0,0,0.9), inset 0 0 15px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
}

.moo2-menu-modal .modal-header {
    background: 
        linear-gradient(to bottom, #aeb3bd 0%, #878c96 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #4a4e57 0px, #4a4e57 2px, #2a2c33 2px, #2a2c33 4px);
    border-bottom: 2px solid #33363f;
    padding: 10px 15px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.moo2-menu-modal .modal-header h2 {
    color: #1a1c20;
    font-family: 'Arial', sans-serif;
    font-size: 18px;
    font-weight: 900;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.moo2-menu-modal .modal-close-btn {
    color: #1a1c20 !important;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
}

.moo2-menu-modal .modal-close-btn:hover {
    color: #000 !important;
    text-shadow: 0 0 8px rgba(255,255,255,0.6);
}

.moo2-menu-modal .modal-content {
    padding: 15px;
    background: rgba(10, 12, 18, 0.95);
    color: #e0e6ed;
    justify-content: flex-start;
}

.btn.menu-modal-btn {
    background: 
        linear-gradient(to bottom, #aeb3bd 0%, #878c96 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #4a4e57 0px, #4a4e57 2px, #2a2c33 2px, #2a2c33 4px);
    color: #1a1c20;
    font-family: 'Arial', sans-serif;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4);
    text-transform: uppercase;
    border: 2px solid #5a5e66;
    border-top-color: #9ba0ab; border-left-color: #9ba0ab;
    border-bottom-color: #33363f; border-right-color: #33363f;
    border-radius: 4px;
    padding: 10px 16px;
    cursor: pointer;
    transition: 0.1s;
}

.btn.menu-modal-btn:hover {
    background: 
        linear-gradient(to bottom, #c2c8d4 0%, #9ba0ab 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #5a5e66 0px, #5a5e66 2px, #3a3c45 2px, #3a3c45 4px);
    color: #000;
}

.btn.menu-modal-btn:active {
    border-top-color: #33363f; border-left-color: #33363f;
    border-bottom-color: #9ba0ab; border-right-color: #9ba0ab;
    background: 
        linear-gradient(to bottom, #7a7e87 0%, #686c75 45%, transparent 45%),
        repeating-linear-gradient(to bottom, #3a3e45 0px, #3a3e45 2px, #1a1c22 2px, #1a1c22 4px);
}

/* Color Picker Grid */
.color-picker-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border: 3px solid #ffffff;
    box-shadow: 0 0 15px currentColor;
    transform: scale(1.15);
}

/* Colony Screen Overlay */
#colony-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000; background-color: #000;
}

#colony-3d-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1; pointer-events: none;
}

#colony-ui-top {
    position: absolute; top: 0; left: 0; width: 100%; height: auto; max-height: 45%;
    z-index: 2; display: flex; align-items: stretch;
    background: rgba(17, 21, 32, 0.95);
    border-bottom: 2px solid #556;
    padding: 10px; box-sizing: border-box; gap: 10px;
}

.colony-panel {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #4a4e57; border-radius: 6px;
    padding: 10px; box-sizing: border-box; display: flex; flex-direction: column;
}

.colony-info-panel { flex: 1; flex-direction: row; align-items: center; gap: 15px; }
#colony-planet-icon { width: 80px; height: 80px; border-radius: 50%; box-shadow: inset -10px -10px 20px rgba(0,0,0,0.8); }
.colony-details h2 { margin: 0 0 5px 0; color: #fff; font-size: 20px; text-transform: uppercase; }
.colony-details div { color: #aaa; font-size: 13px; margin-bottom: 3px; }
.colony-details .pop-text { color: #4da6ff; font-weight: bold; margin-top: 5px; }

.colony-management-panel { flex: 2; justify-content: space-evenly; gap: 4px; overflow-y: auto; }
.management-row { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.row-icon { font-size: 18px; width: 24px; text-align: center; display: flex; align-items: center; justify-content: center; min-height: 28px; }
.row-output-icons { flex: 1; max-width: 250px; min-width: 60px; display: flex; flex-wrap: nowrap; gap: 0; min-height: 28px; border-right: 1px solid rgba(255,255,255,0.1); padding-right: 8px; align-items: center; align-content: center; overflow: hidden; }
.out-icon { font-size: 14px; width: 16px; text-align: center; }
.row-slots { flex: 3; display: flex; flex-wrap: nowrap; gap: 0; min-height: 28px; background: rgba(255,255,255,0.05); padding: 2px 4px; border-radius: 4px; align-items: center; overflow: hidden; }

@media (max-width: 1100px) {
    .row-output-icons { flex: 0 1 75px; }
}
.row-output { width: 55px; text-align: right; font-weight: bold; font-family: var(--font-heading); color: #fff; margin-right: 7px; }
.output-farming { color: #aaffaa; }
.output-industry { color: #ffaaaa; }
.output-science { color: #aaaaff; }

.pop-unit {
    width: 20px; height: 24px; border-radius: 4px;
    cursor: grab; transition: transform 0.1s, filter 0.1s;
    display: flex; align-items: center; justify-content: center; font-size: 18px;
    background: transparent; border: none;
    user-select: none;
    touch-action: none; -webkit-touch-callout: none;
}
.pop-unit:active { cursor: grabbing; }
@media (hover: hover) {
    .pop-unit:hover { transform: scale(1.2); z-index: 10; position: relative; }
    .pop-empty:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
}
.pop-empty { cursor: pointer; background: rgba(0,0,0,0.3); border: 1px dashed rgba(255,255,255,0.1); color: transparent; width: 20px; height: 24px; box-sizing: border-box; border-radius: 2px; }
.pop-farmer { filter: drop-shadow(0 0 4px rgba(85,255,85,0.8)); }
.pop-worker { filter: drop-shadow(0 0 4px rgba(255,85,85,0.8)); }
.pop-scientist { filter: drop-shadow(0 0 4px rgba(85,85,255,0.8)); }
.row-slots.drag-over { background: rgba(255,255,255,0.15); box-shadow: inset 0 0 10px rgba(255,255,255,0.2); }

.colony-build-panel { flex: 1; align-items: stretch; justify-content: space-between; }
.colony-build-panel h3 { margin: 0 0 10px 0; color: #aeb3bd; font-size: 14px; text-align: center; border-bottom: 1px solid #4a4e57; padding-bottom: 5px;}
.build-current { display: flex; align-items: center; justify-content: center; gap: 10px; flex-grow: 1; margin: 5px 0; }
.build-wireframe-small { width: 50px; height: 50px; border: 1px solid #4da6ff; background: rgba(77, 166, 255, 0.1); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: inset 0 0 10px rgba(77, 166, 255, 0.2); }
.build-current-name { color: #fff; font-size: 14px; font-weight: bold; }
.build-current-turns { color: #aaffaa; font-size: 12px; margin-top: 2px; }
.build-actions { display: flex; gap: 10px; width: 100%; margin-top: 10px;}
.build-actions .btn { flex: 1; padding: 5px; font-size: 11px; }

/* --- BUILD SCREEN MODAL (MOO2 Style) --- */
#build-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2500; background-color: rgba(0, 0, 0, 0.85);
    display: flex; align-items: center; justify-content: center;
}

.build-modal {
    width: 90%; max-width: 1000px; height: 85%;
    display: flex; gap: 10px;
}

.build-col {
    background: rgba(17, 21, 32, 0.95);
    border: 2px solid #5a5f6b; border-radius: 6px;
    display: flex; flex-direction: column;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.build-col-left, .build-col-right { flex: 1; }
.build-col-center { flex: 1.5; }

.build-col-header {
    background: #2a2e37; border-bottom: 2px solid #5a5f6b;
    padding: 10px; text-align: center; font-weight: bold; color: #ffaa00;
    font-size: 16px; letter-spacing: 1px;
}

.build-col-content {
    flex-grow: 1; padding: 10px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 5px;
}

/* Category Headers in lists */
.build-category-header {
    color: #aeb3bd; font-size: 12px; border-bottom: 1px solid #4a4e57;
    margin: 10px 0 5px 0; padding-bottom: 2px; text-transform: uppercase;
}
.build-category-header:first-child { margin-top: 0; }

/* Preview Box (Center Top) */
.build-preview-box {
    display: flex; gap: 15px; padding: 15px; border-bottom: 1px solid #4a4e57;
    background: rgba(0,0,0,0.3); min-height: 120px;
}
.build-preview-icon {
    width: 80px; height: 80px; border: 1px solid #4da6ff;
    background: rgba(77, 166, 255, 0.1); border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 40px; box-shadow: inset 0 0 15px rgba(77, 166, 255, 0.2);
}
.build-preview-details { flex-grow: 1; display: flex; flex-direction: column; }
.preview-name { color: #fff; font-size: 18px; font-weight: bold; margin-bottom: 5px; color: #ffaa00;}
.preview-cost { color: #ccc; font-size: 13px; margin-bottom: 2px; }
.preview-turns { color: #aaffaa; font-size: 13px; font-weight: bold; margin-bottom: 5px; }
.preview-desc { color: #aaa; font-size: 12px; line-height: 1.3; }

/* Production Info */
.build-production-info {
    padding: 10px 15px; background: rgba(255, 170, 0, 0.1);
    color: #ffaa00; font-weight: bold; font-size: 13px;
    border-bottom: 1px solid #4a4e57; text-align: center;
}

/* Queue Section (Center Bottom) */
.build-queue-section { flex-grow: 1; display: flex; flex-direction: column; min-height: 0; }
.build-queue-header {
    background: #2a2e37; padding: 8px 15px; display: flex;
    justify-content: space-between; align-items: center;
    border-bottom: 1px solid #4a4e57;
}
.build-queue-header span { color: #ffaa00; font-weight: bold; font-size: 14px; }
.build-queue-list { flex-grow: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 5px; }
.build-queue-empty { text-align: center; color: #666; font-style: italic; padding: 20px; }

/* Queue Item */
.build-queue-item {
    background: rgba(255,255,255,0.05); border: 1px solid #4a4e57; border-radius: 4px;
    padding: 8px; display: flex; flex-direction: column; gap: 5px;
}
.queue-item-info { display: flex; justify-content: space-between; align-items: center; }
.queue-item-name { color: #fff; font-weight: bold; font-size: 13px; }
.queue-item-cost { color: #aaa; font-size: 11px; }
.queue-item-turns { color: #aaffaa; font-size: 12px; font-weight: bold; }
.queue-progress-bar { width: 100%; height: 4px; background: #222; border-radius: 2px; overflow: hidden; }
.queue-progress-fill { height: 100%; background: #4da6ff; }
.queue-item-actions { display: flex; justify-content: flex-end; gap: 5px; margin-top: 2px;}
.queue-item-actions .btn { padding: 2px 8px; font-size: 10px; background: #333; }
.queue-item-actions .btn:hover { background: #555; }
.queue-remove-btn { color: #ff5555; }

/* Bottom Actions */
.build-bottom-actions {
    padding: 15px; border-top: 2px solid #5a5f6b;
    display: flex; justify-content: space-between; background: #1a1e24;
}
.build-bottom-actions .btn { padding: 10px 30px; font-size: 14px; }

#btn-colony-return,
#btn-colony-build {
    position: absolute; bottom: 20px; z-index: 2;
    padding: 20px 40px;
    font-size: 18px;
}
#btn-colony-return { right: 20px; }
#btn-colony-build { left: 20px; }

/* ---------------------------------------------------
   BUILD SCREEN (MOO2 style overlay)
--------------------------------------------------- */
#build-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 3000; background: rgba(0, 0, 0, 0.7);
    display: flex; align-items: center; justify-content: center;
}
.build-screen-panel {
    width: 90%; max-width: 1000px; height: 80%; max-height: 700px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 8px;
    display: flex; flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(77, 166, 255, 0.05);
}
.build-screen-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.3);
}
.build-screen-header h2 {
    font-family: var(--font-heading);
    color: var(--text-accent);
    font-size: 18px;
    letter-spacing: 2px;
}
.build-screen-body { flex: 1; display: flex; overflow: hidden; }
.build-left {
    flex: 1; display: flex; flex-direction: column;
    border-right: 1px solid rgba(58, 80, 128, 0.5);
    padding: 10px; overflow: hidden;
}
.build-left h3, .build-right h3 {
    font-family: var(--font-heading); font-size: 13px; color: var(--text-accent);
    letter-spacing: 1px; margin-bottom: 8px; flex-shrink: 0;
}
#build-production {
    font-size: 12px; color: var(--text-main); margin-bottom: 10px; padding: 5px 8px;
    background: rgba(255, 255, 255, 0.05); border-radius: 4px;
    border-left: 3px solid var(--text-accent); flex-shrink: 0;
}
.build-available-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.build-right { flex: 1; display: flex; flex-direction: column; padding: 10px; overflow: hidden; }
.build-queue-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.build-queue-empty { color: #666; text-align: center; padding: 20px; font-style: italic; }

/* Category headers */
.build-category-header {
    color: var(--text-accent); font-family: var(--font-heading); font-size: 11px;
    letter-spacing: 1px; padding: 6px 4px 2px 4px;
    border-bottom: 1px solid rgba(58, 80, 128, 0.3); margin-top: 4px;
}

/* Build item buttons */
.build-item-btn {
    display: block; background: transparent; border: none; padding: 4px 8px;
    cursor: pointer; color: #ffd085; font-family: var(--font-body); font-size: 14px;
    text-align: left; transition: color 0.15s, background 0.15s; width: 100%;
}
.build-item-btn:hover:not(:disabled) { color: #fff; background: rgba(255, 170, 0, 0.15); }
.build-item-btn.selected { color: #fff; background: rgba(255, 170, 0, 0.3); }
.build-item-btn:disabled, .build-item-btn.build-item-disabled { opacity: 0.4; cursor: not-allowed; }
.build-item-name { font-weight: 500; color: inherit; font-size: 14px; letter-spacing: 0.5px; }
.build-item-cost { display: none; }
.build-item-desc { width: 100%; color: #999; font-size: 11px; }

/* Queue items */
.build-queue-item {
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(58, 80, 128, 0.3);
    border-radius: 4px; padding: 6px 8px;
}
.queue-item-info { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.queue-item-name { font-weight: bold; color: #fff; font-size: 13px; flex: 1; }
.queue-item-cost { color: #ffaa66; font-size: 11px; }
.queue-item-turns { color: #aaaaff; font-size: 11px; }
.queue-progress-bar { height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.queue-progress-fill { height: 100%; background: linear-gradient(90deg, #4da6ff, #66ffaa); border-radius: 3px; transition: width 0.3s; }
.queue-item-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Admin Background Controls */
.admin-bg-controls { display: none; position: absolute; top: 5px; right: 5px; z-index: 10; gap: 5px; }
body.show-admin-bgs .admin-bg-controls { display: flex; }
.res-box { position: relative; background-size: cover; background-position: center; overflow: hidden; }
.admin-bg-btn { cursor: pointer; background: rgba(0,0,0,0.6); color: white; border: 1px solid #555; padding: 2px 5px; border-radius: 3px; font-size: 12px; transition: 0.2s; }
.admin-bg-btn:hover { background: rgba(255,255,255,0.2); }
.res-box::before { content: ''; position: absolute; top:0; left:0; right:0; bottom:0; background: rgba(0,0,0,0.5); z-index: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.res-box.has-bg::before { opacity: 1; }
.res-box > * { position: relative; z-index: 1; }
.bg-video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; pointer-events: none; }

/* ---------------------------------------------------
   COMPACT FLEET PANEL (MOO2 style, draggable)
--------------------------------------------------- */
#fleet-panel {
    position: fixed; bottom: 60px; left: 10px; width: 320px;
    background: #0a0e1a; border: 2px solid #5a5e66; border-radius: 6px;
    z-index: 200; pointer-events: auto;
    box-shadow: 0 0 20px rgba(0,0,0,0.8), inset 0 0 10px rgba(0,0,0,0.5);
    user-select: none; transition: box-shadow 0.2s;
}
#fleet-panel.hidden { display: none; }
#fleet-panel-header {
    background: linear-gradient(to bottom, #3a3e45, #2a2c33);
    border-bottom: 2px solid #5a5e66; padding: 5px 10px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: move; border-top-left-radius: 4px; border-top-right-radius: 4px; min-height: 28px;
}
#fleet-panel-title {
    color: #4CAF50; font-family: 'Orbitron', sans-serif; font-size: 13px; font-weight: bold;
    text-shadow: 0 0 5px #4CAF50; text-transform: uppercase; letter-spacing: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
#fleet-panel-ships { display: block; padding: 8px; max-height: 220px; overflow-y: auto; overflow-x: hidden; }
#fleet-panel-ships::-webkit-scrollbar { width: 6px; }
#fleet-panel-ships::-webkit-scrollbar-track { background: #0a0e1a; }
#fleet-panel-ships::-webkit-scrollbar-thumb { background: #5a5e66; border-radius: 3px; }
.fleet-ships-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fleet-ship-slot {
    border: 2px solid #555; background: #151821; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 2px; cursor: pointer; transition: all 0.15s; min-height: 90px; aspect-ratio: 1 / 1;
}
.fleet-ship-slot:hover { border-color: #777; background: #1a1d26; }
.fleet-ship-slot.selected {
    border-color: #4da6ff; background: radial-gradient(circle at center, #001155 0%, #000033 60%, #000 100%);
    box-shadow: inset 0 0 25px rgba(77,166,255,0.5), 0 0 15px rgba(77,166,255,0.7), 0 0 30px rgba(77,166,255,0.3);
}
.fleet-ship-slot.empty {
    background: repeating-linear-gradient(180deg, #111, #111 4px, #222 4px, #222 8px);
    box-shadow: inset 0 0 10px #000; cursor: default;
}
.fleet-ship-slot.empty:hover { border-color: #555; box-shadow: inset 0 0 10px #000; }
.fleet-ship-name {
    position: absolute; top: 3px; width: 100%; text-align: center; color: #fff;
    font-size: 10px; font-weight: bold; text-shadow: 1px 1px 2px #000;
    font-family: 'Orbitron', sans-serif; letter-spacing: 0.5px;
}
.fleet-ship-icon { width: 60px; height: 60px; object-fit: contain; }
.fleet-ship-count {
    position: absolute; bottom: 3px; right: 6px; color: #00ff00;
    font-weight: bold; font-size: 14px; text-shadow: 0 0 5px #00ff00;
    font-family: 'Orbitron', sans-serif;
}
#fleet-panel-footer {
    background: #000; border-top: 2px solid #444; padding: 6px 10px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom-left-radius: 4px; border-bottom-right-radius: 4px;
}
#fleet-panel-footer .btn.action {
    background: linear-gradient(to bottom, #d4d4d4, #7a7a7a); color: #000;
    border: 2px solid #eee; border-radius: 2px; font-weight: bold;
    padding: 4px 20px; font-size: 12px; box-shadow: 1px 1px 3px #000;
    cursor: pointer; font-family: 'Orbitron', sans-serif; letter-spacing: 1px;
}
#fleet-panel-footer .btn.action:hover { background: linear-gradient(to bottom, #e8e8e8, #999); }
#fleet-panel-footer .btn.action:active { background: linear-gradient(to bottom, #aaa, #666); }
.fleet-ship-slot.flying { border-color: #ffaa00; box-shadow: inset 0 0 15px rgba(255,170,0,0.2); }
.fleet-ship-slot.flying .fleet-ship-count { color: #ffaa00; text-shadow: 0 0 5px #ffaa00; }
.fleet-eta-inline {
    position: absolute; bottom: 3px; left: 4px; color: #ffaa00;
    font-size: 9px; font-family: 'Orbitron', sans-serif;
}

/* ── Cosmic Load Error ─────────────────────────────────── */
#load-error {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 10, 20, 0.95);
    border: 1px solid rgba(255, 100, 70, 0.3);
    border-left: 3px solid #ff6446;
    color: #e0c8c0;
    padding: 15px 30px;
    border-radius: 8px;
    z-index: 99999;
    font-family: 'Rajdhani', sans-serif;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 70, 40, 0.2), inset 0 0 20px rgba(255, 70, 40, 0.05);
    backdrop-filter: blur(10px);
    max-width: 400px;
    font-size: 14px;
    line-height: 1.4;
}

/* ── Combat List Widget ─────────────────────────────────── */
#combat-list-widget {
    position: absolute;
    top: 50px;
    right: 300px;
    width: 250px;
    background: rgba(10, 15, 30, 0.9);
    border: 1px solid #4CAF50;
    border-radius: 4px;
    color: white;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}
#combat-list-widget.hidden { display: none; }
#combat-list-header {
    background: rgba(76, 175, 80, 0.3);
    padding: 8px; cursor: move; font-weight: bold;
    border-bottom: 1px solid #4CAF50; text-align: center;
}
#combat-list-content { padding: 8px; max-height: 300px; overflow-y: auto; }
.combat-list-item-btn {
    width: 100%; text-align: left; background: rgba(255, 255, 255, 0.05);
    border: 1px solid #555; color: #ffaa00; padding: 8px; margin-bottom: 5px;
    cursor: pointer; border-radius: 3px; display: flex; justify-content: space-between;
}
.combat-list-item-btn:hover { background: rgba(255, 170, 0, 0.2); border-color: #ffaa00; }

/* ── Admin Item Button ──────────────────────────────────── */
.admin-item-btn {
    display: none; position: absolute; top: -5px; right: -5px;
    cursor: pointer; background: rgba(0,0,0,0.6); color: white;
    border: 1px solid #555; padding: 2px 5px; border-radius: 3px;
    font-size: 12px; transition: 0.2s; z-index: 10;
}
.admin-item-btn:hover { background: rgba(255, 255, 255, 0.2); }
body.show-admin-bgs .admin-item-btn { display: inline-block; }
/* Main-menu reveal after the session-check loader (see onboarding.js showMenu) */
.menu-reveal { animation: menuFadeIn 0.4s ease; }
@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

/* ── CRT "старый монитор" поверх правых HUD-блоков ─────────────────────────
   Каждый .res-box читается как маленький выпуклый экран: блик выпуклого
   стекла сверху, затемнённые скруглённые углы (виньетка кинескопа), бегущие
   строки развёртки и едва заметное мерцание. Чистый CSS-оверлей (::after,
   ::before занят затемнением фона), клики проходят насквозь, админ-кнопки
   (z-index 10) остаются поверх. */
.res-box::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    /* лёгкая "бочка" стекла по углам */
    border-radius: 8px / 12px;
    background:
        /* блик выпуклой линзы — светлое пятно слева сверху */
        radial-gradient(ellipse 130% 95% at 30% 16%,
            rgba(255, 255, 255, 0.13),
            rgba(255, 255, 255, 0.04) 38%,
            rgba(255, 255, 255, 0) 62%),
        /* виньетка кинескопа — затемнение к краям/углам */
        radial-gradient(ellipse 108% 108% at 50% 50%,
            rgba(0, 0, 0, 0) 60%,
            rgba(0, 0, 0, 0.42) 100%),
        /* строки развёртки */
        repeating-linear-gradient(to bottom,
            rgba(0, 0, 0, 0.15) 0px,
            rgba(0, 0, 0, 0.15) 1px,
            rgba(0, 0, 0, 0) 2px,
            rgba(0, 0, 0, 0) 3px);
    box-shadow:
        inset 0 0 18px rgba(0, 0, 0, 0.55),          /* глубина за стеклом */
        inset 0 0 3px rgba(160, 200, 255, 0.22);     /* холодный отсвет люминофора */
    animation: crtFlicker 9s infinite;
}
@keyframes crtFlicker {
    0%, 91%, 100% { opacity: 1; }
    92%           { opacity: 0.95; }
    93%           { opacity: 1; }
    96%           { opacity: 0.97; }
    97%           { opacity: 1; }
}

/* Текст и иконки блоков — ПОВЕРХ CRT-эффекта: экранное стекло (z-index 2) лежит на
   фоне-картинке, а показания приборов читаются чисто, без сканлайнов по буквам. */
.res-box > * { z-index: 3; }

/* ── Портреты рас на экране выбора расы (онбординг) ────────────────────────
   Крупный портрет 84×84 с рамкой цвета расы; имя и черта справа от него,
   описание под ними. Без загруженного фото остаётся цветная буква-плитка. */
/* Описание живёт СПРАВА от портрета, под именем и чертой — не под фото. */
.race-card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 0; }
.race-portrait {
    position: relative; overflow: hidden; flex-shrink: 0;
    width: 84px; height: 84px; border-radius: 10px;
    border: 2px solid rgba(77, 166, 255, 0.5);
    background: rgba(0, 0, 0, 0.35);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading); font-size: 34px; font-weight: bold;
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.6);
}
.race-card-headtext { min-width: 0; }
.race-card-headtext .race-name { margin-bottom: 4px; }
.race-card-headtext .race-trait { margin-bottom: 0; }
.race-card.selected .race-portrait {
    box-shadow: 0 0 14px rgba(77, 166, 255, 0.6), inset 0 0 14px rgba(0, 0, 0, 0.6);
}
.race-card .race-desc { margin-top: 4px; }

/* ── Онбординг на узких экранах (минимальный планшет 768px) ────────────────
   Держится В САМОМ КОНЦЕ файла: медиа-правила при равной специфичности должны
   идти после базовых, иначе базовые их перекрывают. Компактнее паддинги,
   портреты и шрифты — обе колонки рас помещаются целиком, ничего не режется. */
@media (max-width: 900px) {
    .onboarding-panel { padding: 22px; min-width: 0; }
    /* Узко по ширине → ОДНА карточка в строку: аватар расы наоборот КРУПНЕЕ
       (места в строке полно), а списку отдаём почти всю высоту экрана —
       остаются только заголовок и кнопка "Начать экспансию". */
    .races-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-right: 6px;
        max-height: calc(100vh - 250px);
    }
    .race-portrait { width: 104px; height: 104px; font-size: 40px; }
    .race-card { padding: 12px; }
    .race-card-head { gap: 14px; }
    .game-title { font-size: 26px; }
}

/* ── СМАРТФОН: правое меню ресурсов ────────────────────────────────────────
   Узкая колонка (180px − 40% = 108px), каждый блок: иконка СВЕРХУ, текст ПОД
   ней, всё по центру. Держать в конце файла — медиа-правила при равной
   специфичности должны идти после базовых. */
@media (max-width: 899px) {
    :root { --sidebar-width: 108px; }

    .res-box {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 4px 3px;
        text-align: center;
    }
    .res-icon {
        margin-right: 0;
        margin-bottom: 3px;
        font-size: 20px;
    }
    .res-values {
        align-items: center;
        text-align: center;
        font-size: 10px;
    }
    .res-values div:first-child { font-size: 11px; }
    #sidebar-stardate { font-size: 11px; }
}

/* ── СМАРТФОН: нижнее меню ИКОНКАМИ вместо текста ─────────────────────────
   Металлический стиль кнопок сохраняется, но подпись схлопывается
   (font-size:0) и вместо неё ::before рисует иконку. На планшете/ПК — текст,
   как раньше. Тач-цель ≥ 40px высотой. */
@media (max-width: 899px) {
    .btn.bottom-nav {
        font-size: 0;          /* прячем текстовую подпись */
        letter-spacing: 0;
        text-shadow: none;
        min-width: 40px;
        padding-left: 2px;
        padding-right: 2px;
    }
    /* Эмодзи-иконки: лёгкая светлая тень-обводка 1-2px вокруг, как тонкая линия. */
    .btn.bottom-nav::before {
        font-size: 20px;
        line-height: 1;
        text-shadow: none;
        filter: drop-shadow(0 0 1px #aeb3bd) drop-shadow(0 0 1px #aeb3bd);
    }
    .btn.bottom-nav:active::before {
        filter: drop-shadow(0 0 1px #8b909a) drop-shadow(0 0 1px #8b909a);
    }
    #btn-nav-colonies::before { content: '\1F3DB\FE0F'; } /* 🏛️ колонии */
    #btn-nav-planets::before  { content: '\1FA90'; }      /* 🪐 планеты */
    #btn-nav-fleets::before   { content: '\1F680'; }      /* 🚀 флоты */
    #btn-nav-leaders::before  { content: '\1F396\FE0F'; } /* 🎖️ лидеры */
    #btn-nav-races::before    { content: '\1F47D'; }      /* 👽 расы */
    #btn-nav-info::before     { content: '\2139\FE0F'; }  /* ℹ️ информация */

    /* Зум-блок тоже компактнее */
    #btn-zoom-center { font-size: 8px !important; }
}

/* ── СМАРТФОН: нижнее меню на всю ширину, правая колонка заканчивается НАД ним ── */
@media (max-width: 899px) {
    #bottom-menu-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 1002;
        /* iPhone safe-area (notch/home indicator) */
        padding-bottom: env(safe-area-inset-bottom, 0px);
        height: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom, 0px));
    }
    #right-sidebar { height: calc(100% - var(--bottom-bar-height) - env(safe-area-inset-bottom, 0px)); }
}

/* ── СМАРТФОН: "ухо" — прятать/выдвигать правую колонку ────────────────────
   Кнопка по центру левого края колонки, в её же металлическом стиле. Тап:
   колонка плавно уезжает вправо за экран, ухо остаётся торчать у края
   (оно — ребёнок колонки, но шире её transform-а на свою ширину). Стрелка:
   ▶ когда открыто (спрятать вправо), ◀ когда спрятано (вернуть). */
#sidebar-toggle { display: none; }

@media (max-width: 899px) {
    #right-sidebar { transition: transform 0.35s ease; }
    #right-sidebar.collapsed { transform: translateX(100%); }

    /* Ухо в стиле ВЕРХНИХ вкладок ("ГРА" / конверт), только повёрнутое: у тех — светлый
       металл сверху у места крепления, тёмный к свободному краю, скруглённые свободные
       углы, тёмная "выбитая" надпись. Здесь крепление СПРАВА (к панели), свободный
       край слева. */
    /* Размер ≈ как у кнопки почты (конверта), тона — под корпус правой панели
       (её борт #4a4e57 с фасками #9ba0ab / #33363f), а не под светлые верхние вкладки. */
    #sidebar-toggle {
        display: flex;
        position: absolute;
        left: -26px;
        top: 50%;
        transform: translateY(-50%);
        width: 26px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: linear-gradient(to left, #5d616a, #40444c);
        border: 2px solid #5a5e66;
        border-right: none;                    /* сторона крепления к панели */
        border-top: 2px solid #8b909a;        /* светлая фаска сверху, чуть глуше */
        border-left: 2px solid #33363f;       /* тёмные — к свободному краю */
        border-bottom: 2px solid #33363f;
        border-radius: 8px 0 0 8px;           /* скруглены свободные углы, как у вкладок */
        color: #1a1c20;                        /* тёмная стрелка, как текст вкладок */
        font-size: 11px;
        font-weight: 900;
        text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);  /* гравировка, чуть мягче */
        cursor: pointer;
        z-index: 10;
        box-shadow: -2px 0 6px rgba(0, 0, 0, 0.45);
        user-select: none;
        transition: 0.1s;
    }
    #sidebar-toggle:hover { background: linear-gradient(to left, #6a6e78, #4a4e57); color: #000; }
    #sidebar-toggle:active {
        background: linear-gradient(to left, #44484f, #33363d);
        padding-top: 2px;                      /* стрелка "вдавливается", как на вкладках */
    }
}

/* ── СМАРТФОН: экран выбора расы не вылезает за высоту viewport ───────────
    Панель занимает 90% высоты экрана и 100% ширины ТОЛЬКО на шаге выбора расы;
    остальные окна онбординга остаются компактными по центру. */
@media (max-width: 899px) {
    .onboarding-panel.race-step-active {
        width: 100%;
        max-width: 100%;
        height: 80vh;
        max-height: 80vh;
        min-width: 0;
        border-radius: 12px;
        padding: 16px 14px;
        margin: auto;
    }
    .onboarding-panel.race-step-active .onboarding-step.race-selection-step {
        width: 100%;
        height: 100%;
        gap: 8px;
        justify-content: flex-start;
        overflow: hidden;
    }
    .onboarding-panel.race-step-active .race-selection-step h1 {
        font-size: 16px;
        margin: 0;
        flex-shrink: 0;
        line-height: 1.2;
    }
    .onboarding-panel.race-step-active .races-grid {
        grid-template-columns: 1fr;
        gap: 6px;
        padding-right: 4px;
        flex-shrink: 1;
        min-height: 0;
        /* Заголовок ~26px, кнопка ~44px, паддинги/отступы ~60px */
        max-height: calc(80vh - 130px);
    }
    .onboarding-panel.race-step-active .race-portrait {
        width: 70px;
        height: 70px;
        font-size: 30px;
        border-width: 2px;
    }
    .onboarding-panel.race-step-active .race-card { padding: 8px; }
    .onboarding-panel.race-step-active .race-card-head { gap: 10px; align-items: center; }
    .onboarding-panel.race-step-active .race-name { font-size: 16px; margin-bottom: 3px; }
    .onboarding-panel.race-step-active .race-trait { font-size: 12px; margin-bottom: 2px; }
    .onboarding-panel.race-step-active .race-desc { font-size: 11px; margin-top: 2px; }
    .onboarding-panel.race-step-active #btn-step-3 {
        flex-shrink: 0;
        width: 100%;
        padding: 10px;
        font-size: 13px;
        margin-top: 0;
    }
}

/* ── ОЧЕНЬ УЗКИЕ СМАРТФОНЫ (<400px): модальные окна компактнее на 30% ─────
   Внутри модалок почти все размеры заданы в px инлайном — обычный font-size
   их не уменьшит. zoom масштабирует всё содержимое окна целиком (шрифты,
   кнопки, отступы) ровно на нужные 30%, окно перестаёт распирать экран. */
@media (max-width: 399px) {
    .moo2-modal { zoom: 0.7; }
    /* zoom не поддерживается в старом Firefox — там мягкий запасной вариант
       масштабом шрифта для текста, который всё же наследует размер */
    @supports not (zoom: 0.7) {
        .moo2-modal { font-size: 70%; }
    }
}

/* ── СМАРТФОН: увеличиваем верхние кнопки "ИГРА" и конверт для тача ── */
@media (max-width: 899px) {
    #top-game-tab {
        font-size: 16px;
        padding: 6px 44px;
    }
    #top-game-tab-container #env-icon {
        font-size: 16px;
        padding: 6px 16px;
    }
    #top-game-tab-container #env-icon .env-badge {
        min-width: 18px;
        height: 18px;
        font-size: 12px;
        line-height: 18px;
    }
}

/* ── СМАРТФОН: окно РАСЫ — кнопки "Дипломатия" и "Обзор" друг под другом ── */
.race-list-actions { display: flex; gap: 10px; }
@media (max-width: 899px) {
    /* Кнопки друг под другом, но по ширине контента (обе = ширине более широкой),
       НЕ растягиваются на всю карточку. */
    .race-list-actions { flex-direction: column !important; width: auto; align-items: stretch; margin-top: 0; flex-shrink: 0; }
    .race-list-actions .btn { width: auto; padding: 8px 14px; font-size: 13px; white-space: nowrap; }
}

/* ── Список рас в окне РАСЫ: растягивается на всю высоту модального окна ── */
.race-list-scroll {
    flex-grow: 1;
    min-height: 0;
}

/* ── Индикатор загрузки в окне почты/дипломатии ── */
.diplo-loader {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(77, 166, 255, 0.2);
    border-top-color: #4da6ff;
    border-radius: 50%;
    animation: diploLoaderSpin 0.9s linear infinite;
    box-shadow: 0 0 10px rgba(77, 166, 255, 0.3);
}
@keyframes diploLoaderSpin {
    to { transform: rotate(360deg); }
}

/* ── СМАРТФОН: модальные окна не ограничиваем по высоте, даём 90% высоты экрана ── */
@media (max-width: 899px) {
    .moo2-modal,
    .moo2-menu-modal {
        width: 96%;
        max-width: 96%;
        min-height: 90vh;
        max-height: 90vh;
    }
}

/* ── СМАРТФОН: экран колонии и окно строительства ──────────────────────────
   Колония: (1) инфо о планете — одна строка на всю ширину, (2) полный блок
   рабочих на всю ширину, (3) компактная полоса «Строительство» под ним.
   Окно строительства: верхняя половина — табы ПОСТРОЙКИ/ФЛОТ со списком,
   нижняя половина — превью + очередь + кнопки. */
#build-mobile-tabs { display: none; }

@media (max-width: 899px) {
    /* ── Экран колонии ── */
    #colony-ui-top {
        flex-direction: column;
        max-height: 62%;
        overflow-y: auto;
        gap: 8px;
        padding: 8px;
    }
    /* 1) Планета — одна компактная строка */
    .colony-info-panel { width: 100%; padding: 6px 10px; gap: 10px; }
    #colony-planet-icon { width: 46px; height: 46px; flex-shrink: 0; }
    .colony-details { display: flex; flex-wrap: wrap; column-gap: 12px; row-gap: 2px; align-items: baseline; }
    .colony-details h2 { font-size: 15px; margin: 0; }
    .colony-details div { font-size: 11px; margin: 0; }
    .colony-details .pop-text { margin: 0; }
    /* 2) Рабочие — на всю ширину */
    .colony-management-panel { width: 100%; }
    /* 3) Строительство — компактная горизонтальная полоса:
       [иконка 34px] [название + время] [ЗМІНИТИ] [КУПИТИ] в одну строку */
    .colony-build-panel { width: 100%; flex-direction: row; align-items: center; gap: 8px; padding: 5px 8px; }
    .colony-build-panel h3 { display: none; }
    .colony-build-panel .build-current { flex: 1; margin: 0; min-width: 0; gap: 10px; justify-content: flex-start; }
    /* Кнопки встали столбиком — иконке проекта достаётся больше места: 52px */
    .colony-build-panel .build-wireframe-small { width: 52px; height: 52px; font-size: 26px; flex-shrink: 0; overflow: hidden; }
    .colony-build-panel .build-wireframe-small img {
        width: 100% !important; height: 100% !important;
        transform: none !important; object-fit: contain;
    }
    .colony-build-panel .build-current-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .colony-build-panel .build-current-turns { font-size: 10px; margin-top: 0; }
    /* ЗМІНИТИ над КУПИТИ, одинаковой ширины */
    .colony-build-panel .build-actions { display: flex; flex-direction: column; width: 92px; margin: 0; gap: 4px; flex-shrink: 0; }
    .colony-build-panel .build-actions .btn { width: 100%; padding: 5px 0; font-size: 11px; margin: 0; }

    /* Нижние кнопки колонии — компактная пара на всю ширину, а не гиганты 20px×40px */
    #btn-colony-build, #btn-colony-return {
        bottom: 8px;
        padding: 10px 0;
        font-size: 13px;
        width: calc(50% - 12px);
        margin: 0;
    }
    #btn-colony-build { left: 8px; }
    #btn-colony-return { right: 8px; }

    /* ── Окно строительства ── */
    .build-modal { flex-direction: column; width: 96%; height: 96%; gap: 6px; }

    /* Табы вместо шапок колонок — КОМПАКТНЫЕ, всегда оба сверху */
    #build-mobile-tabs { display: flex; gap: 6px; flex: 0 0 auto; }
    #build-mobile-tabs .btn { flex: 1; padding: 6px 0; font-size: 12px; margin: 0; }
    #build-mobile-tabs .btn.active {
        background: #2a4070;
        border-color: #4da6ff;
        color: #fff;
        box-shadow: 0 0 10px rgba(77, 166, 255, 0.4);
    }

    /* Верхняя половина: показывается ОДИН список — по активному табу.
       В DOM колонка кораблей идёт ПОСЛЕ центральной — порядок на телефоне задаём
       через order: табы(0) → активный список(1) → центр с очередью(2), иначе
       список флота рендерился ВНИЗУ окна. */
    #build-mobile-tabs { order: 0; }
    /* Табы + список вместе занимают ~40% высоты окна — очереди достаётся больше */
    .build-col-left, .build-col-right {
        display: none;
        order: 1;
        flex: 0 0 auto;
        height: calc(40% - 34px);
        width: 100%;
    }
    .build-modal.show-structures .build-col-left { display: flex; }
    .build-modal.show-ships .build-col-right { display: flex; }
    .build-col-left .build-col-header,
    .build-col-right .build-col-header { display: none; } /* заменены табами */

    /* Нижняя половина: превью + очередь + кнопки — ВСЁ КОМПАКТНО */
    .build-col-center { order: 2; flex: 1 1 auto; min-height: 0; width: 100%; }

    /* Превью: маленькая иконка, без подсказки-описания, всё в одну плотную полосу */
    .build-preview-box { padding: 6px 8px; gap: 8px; min-height: 0; align-items: center; }
    .build-preview-icon { width: 38px; height: 38px; font-size: 20px; flex-shrink: 0; overflow: hidden; }
    /* РЕМОНТ иконки проекта: getItemIconHtml вставляет <img> с инлайновым width/height
       в 64px и hull-масштабом transform — на телефоне картинка выпирала из рамки 38px.
       Принудительно вписываем её в бокс и глушим масштаб-трансформацию. */
    .build-preview-icon img {
        width: 100% !important;
        height: 100% !important;
        transform: none !important;
        object-fit: contain;
    }
    .preview-name { font-size: 13px; margin-bottom: 1px; }
    .preview-cost { font-size: 11px; margin-bottom: 0; }
    .preview-turns { font-size: 11px; margin-bottom: 0; }
    .preview-desc { display: none; } /* подсказка занимает пол-экрана — на телефоне не нужна */

    /* Производство — тонкая строка */
    .build-production-info { padding: 4px 8px; font-size: 11px; }

    /* Очередь — вся оставшаяся высота, компактная шапка */
    .build-queue-header { padding: 5px 8px; }
    .build-queue-header span { font-size: 12px; }
    .build-queue-header .btn { padding: 4px 10px; font-size: 11px; margin: 0; }
    .build-queue-list { padding: 6px; }
    .build-queue-empty { padding: 10px; font-size: 12px; }

    /* ОТМЕНА / ОК — компактная нижняя полоса */
    .build-bottom-actions { padding: 8px; }
    .build-bottom-actions .btn { padding: 7px 18px; font-size: 12px; margin: 0; }

    /* ── ЖЁСТКАЯ ПРОКРУТКА, дизайн не сжимается ──
       Полная flex-цепочка: фиксированные полосы (превью, производство, шапка очереди,
       кнопки) объявлены несжимаемыми, растёт ТОЛЬКО список очереди — и он же скроллится.
       То же для списков споруд/флота в их 40%-блоке. */
    .build-preview-box,
    .build-production-info,
    .build-queue-header,
    .build-bottom-actions { flex-shrink: 0; }
    .build-queue-section { flex: 1 1 auto; min-height: 0; }
    .build-queue-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

    .build-col-left, .build-col-right { min-height: 0; overflow: hidden; }
    .build-col-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}

/* ── Android/iOS: настоящая видимая высота экрана ──────────────────────────
   На мобильных браузерах 100vh ВКЛЮЧАЕТ область за адресной строкой — всё,
   что прижато к низу (кнопки колонии, нижнее меню), оказывалось за краем
   видимой части. 100dvh — динамическая высота видимого окна; браузеры без
   поддержки остаются на 100vh (строка выше). */
html, body {
    height: 100vh;
    height: 100dvh;
}
#game-container {
    height: 100%;
}
@media (max-width: 899px) {
    /* нижние кнопки колонии — с учётом системной полосы жестов */
    #btn-colony-build, #btn-colony-return {
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* ── СМАРТФОН: нижнее меню — корпус как у правого меню, кнопки как ПК ───────
   Берём фон/бордер #right-sidebar (#4a4e57 + боковые фаски), а сами кнопки
   оставляем в базовом ПК-стиле .btn.bottom-nav. Пустые места между кнопками
   заполнены общим корпусом, как у правой панели. */
@media (max-width: 899px) {
    :root { --bottom-bar-height: 58px; }

    #bottom-menu-bar {
        padding-right: 0;
        background: #4a4e57;
        border-top: 2px solid #6c7078;
        box-shadow: inset 0 1px 0 #9ba0ab, 0 -2px 6px rgba(0, 0, 0, 0.4);
    }
    .bottom-buttons {
        display: flex;
        gap: 2px;
        padding: 3px 1px;
        align-items: stretch;
        height: 100%;
    }
    .btn.bottom-nav {
        flex: 1 1 0;
        aspect-ratio: 1 / 1;
        min-width: 0;
        min-height: 0;
        padding: 0;
        border-width: 1px;
        /* Фон как у зум-контрола (только фон) */
        background: linear-gradient(to bottom, #878c96, #4a4e57);
        border: 2px solid #5a5e66;
        border-top-color: #9ba0ab;
        border-left-color: #9ba0ab;
        border-bottom-color: #33363f;
        border-right-color: #33363f;
        border-radius: 4px 4px 0 0;
    }
    .btn.bottom-nav::before {
        /* иконки без эффектов: 90% видимость + 10% серого */
        color: rgba(0, 0, 0, 0.9);
        text-shadow: none;
        filter: grayscale(10%);
    }
    .btn.bottom-nav:active::before {
        color: rgba(0, 0, 0, 0.9);
        filter: grayscale(10%);
    }
    .btn.bottom-nav:active {
        background: linear-gradient(to bottom, #686c75, #3a3e45);
        border-top-color: #33363f;
        border-left-color: #33363f;
        border-bottom-color: #9ba0ab;
        border-right-color: #9ba0ab;
    }
}

