/* Combat Layer Styles - MOO2 Style */
#combat-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    /* Android/iOS: 100vh включает область за адресной строкой браузера — консоль,
       прижатая к низу, уезжала под системное меню. 100dvh = реальная видимая высота;
       старые браузеры остаются на 100vh (строка выше). */
    height: 100vh;
    height: 100dvh;
    background: #000;
    z-index: 1000; /* above everything */
    display: flex;
    flex-direction: column;
}

#combat-layer.hidden {
    display: none !important;
}

#combat-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: linear-gradient(to bottom, #1a2a44, #0a1122);
    border-bottom: 2px solid #4a6a99;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    color: #aaccff;
    font-family: 'Orbitron', sans-serif;
    z-index: 10;
}

#combat-title {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
}

#combat-timer {
    font-size: 24px;
    color: #ffaa44;
    font-weight: bold;
}

#btn-combat-close {
    background: #4a1111;
    border: 1px solid #ff4444;
    color: #ffaaaa;
    padding: 4px 12px;
    font-size: 14px;
    cursor: pointer;
}
#btn-combat-close:hover {
    background: #aa2222;
    color: #ffffff;
}

#combat-canvas {
    flex: 1;
    width: 100%;
    display: block;
    /* Cursor is managed by JS (combat.js drawCursorReticle): hidden only while a custom
       reticle/ghost is being drawn in its place, ordinary otherwise. */
    /* Tablets: disable the browser's own scroll/zoom gestures on the battlefield so our
       pinch-zoom / one-finger-pan handlers (combat.js onTouch*) get the raw events. */
    touch-action: none;
}

/* Bottom UI Panel — MOO2-style beveled metal console */
#combat-ui {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 880px;
    max-width: 96vw;
    height: 210px;
    background: linear-gradient(to bottom, #33363e, #1a1c20 55%, #15171b);
    border: 3px solid #5a5e66;
    border-top-color: #9ba0ab;
    border-left-color: #9ba0ab;
    border-right-color: #33363f;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), inset 0 0 25px rgba(0,0,0,0.6), 0 -6px 18px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: row;
    box-sizing: border-box;
    padding: 10px;
    padding-top: 14px;
    gap: 10px;
    font-family: 'Orbitron', sans-serif;
    z-index: 10;
}

/* MOO2-style corner rivets on the console frame */
#combat-ui::before,
#combat-ui::after {
    content: '';
    position: absolute;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #c9ced9, #4a4e57 65%, #23252b);
    box-shadow: inset 0 -1px 2px rgba(0,0,0,0.7), 0 1px 1px rgba(255,255,255,0.15);
    pointer-events: none;
}
#combat-ui::before { left: 7px; }
#combat-ui::after { right: 7px; }

/* Scrollbars styled to match the console (weapons list, systems rows) */
#combat-ui ::-webkit-scrollbar {
    width: 9px;
}
#combat-ui ::-webkit-scrollbar-track {
    background: #0a0c10;
    border-left: 1px solid #23252b;
    border-radius: 2px;
}
#combat-ui ::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #7a7f89, #4a4e57);
    border: 1px solid #2a2d33;
    border-top-color: #9ba0ab;
    border-radius: 2px;
}
#combat-ui ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #8a8f99, #5a5e68);
}
#combat-ui .weapons-list {
    scrollbar-width: thin;              /* Firefox */
    scrollbar-color: #5a5e66 #0a0c10;   /* Firefox */
}

.combat-panel {
    /* Inset bevel: dark top/left, light bottom/right — a "sunken" MOO2 console cell */
    border: 2px solid;
    border-color: #0d0f13 #4a4e57 #4a4e57 #0d0f13;
    background: linear-gradient(to bottom, #060a12, #0a1120);
    padding: 6px;
    border-radius: 3px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Shared metallic title strip (ship name / "Systems") */
.panel-titlebar {
    background: linear-gradient(to bottom, #4a6a9a, #1c2c4a);
    border: 1px solid #6a8ab8;
    border-bottom-color: #101a2e;
    color: #d8e8ff;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.7);
    padding: 3px 8px;
    margin-bottom: 6px;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    flex-shrink: 0;
}

/* Ship panel: name strip on top, portrait in the middle, HP strip below — exactly the
   MOO2 left-block anatomy (Nemesis → portrait with shield contour → colored damage strip).
   A standalone console panel; the gap to the arsenal panel is the natural console seam. */
.ship-panel {
    width: 134px;
    flex: 0 0 auto;
}
.ship-panel .panel-titlebar {
    margin-bottom: 4px;
}

/* Arsenal panel: WEAPONS | SPECIALS tabs + list — its own console block */
.arsenal-panel {
    flex: 1.6;
}

.ship-portrait {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Uniform dark frame — the beveled light-gray bottom/right edges cut across the shield
       ring and cheapened the "viewport into space" look. */
    border: 1px solid #0d0f13;
    background: radial-gradient(circle at 50% 35%, #10203a, #05080f 80%);
    border-radius: 3px;
    padding: 4px;
    box-sizing: border-box;
    margin-bottom: 4px;
    min-height: 0;
    overflow: hidden;
}

/* MOO2's green shield contour around the ship — opacity driven by JS as shields/HP drain.
   Fixed 1:1 aspect + centering = a perfectly even circle no matter the portrait's shape
   (inset-based sizing followed the box and stretched into an uneven ellipse). */
.shield-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 78%;
    max-width: 96px;
    aspect-ratio: 1 / 1;
    border: 2px solid rgba(0, 255, 120, 0.75);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 255, 120, 0.5), inset 0 0 10px rgba(0, 255, 120, 0.25);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.ship-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 6px #4da6ff);
}

/* MOO2-style blue SHIELD strip — sits right above the HP strip; drains before the hull */
.shield-bar {
    width: 100%;
    height: 7px;
    position: relative;
    background: #101318;
    border: 1px solid #33363f;
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
    margin-bottom: 2px;
}
.shield-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(to bottom, #6ab8ff, #2a6adf);
    transition: width 0.3s ease;
}
.shield-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(5, 8, 12, 0.9) 5px 6px);
    pointer-events: none;
}

/* MOO2-style segmented damage strip under the portrait */
.hp-bar {
    width: 100%;
    height: 9px;
    position: relative;
    background: #101318;
    border: 1px solid #33363f;
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}
.hp-bar-fill {
    height: 100%;
    width: 100%;
    background: #44dd44;
    transition: width 0.3s ease, background 0.3s ease;
}
/* Segment separators drawn OVER the fill — reads as the MOO2 tick strip */
.hp-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(5, 8, 12, 0.9) 5px 6px);
    pointer-events: none;
}

.ship-tabs {
    display: flex;
    gap: 3px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.ship-tab {
    flex: 1;
    padding: 3px 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 2px;
    /* Inactive: recessed gray, like MOO2's unselected SPECIALS tab */
    background: linear-gradient(to bottom, #5a5e68, #33363f);
    border: 1px solid;
    border-color: #2a2d33 #7a7f89 #7a7f89 #2a2d33;
    color: #aab0bc;
    text-shadow: 0 1px 1px rgba(0,0,0,0.6);
}
.ship-tab:hover {
    color: #e0e6f0;
}
.ship-tab.active {
    /* Active: the MOO2 blue strip with white engraved text */
    background: linear-gradient(to bottom, #3355bb, #16245a);
    border-color: #6a8ae0 #101a3e #101a3e #6a8ae0;
    color: #ffffff;
    text-shadow: 0 0 4px rgba(120, 160, 255, 0.8);
}

.weapons-list {
    flex: 1;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #88ff88;
    padding: 2px 4px;
    border: 1px solid rgba(74, 106, 153, 0.25);
    border-radius: 2px;
    background: rgba(0, 8, 4, 0.5);
    min-height: 0;
}

.weapon-item {
    cursor: pointer;
    padding: 2px 4px;
}
.weapon-item:hover {
    background: rgba(0, 255, 0, 0.2);
}
.weapon-item.selected {
    background: rgba(0, 255, 0, 0.4);
    color: #ffffff;
    font-weight: bold;
}

/* Center Panel: single compact column of buttons */
.center-panel {
    flex: 0 0 auto;
    width: 122px;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

.combat-btn-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* MOO2 raised gray button: light top/left bevel, dark bottom/right, dark engraved text */
.combat-btn {
    background: linear-gradient(to bottom, #8a8f99, #4a4e57);
    border: 2px solid;
    border-color: #b9bec9 #2a2d33 #2a2d33 #b9bec9;
    color: #14171d;
    padding: 3px 0;
    width: 104px;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.35);
    border-radius: 2px;
}

.combat-btn:hover {
    background: linear-gradient(to bottom, #a0a5b0, #5a5e68);
}

.combat-btn:active {
    background: linear-gradient(to bottom, #3a3e45, #5a5e66);
    border-color: #2a2d33 #b9bec9 #b9bec9 #2a2d33; /* inverted bevel = pressed in */
}

.combat-btn:disabled,
.combat-btn[disabled] {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    filter: grayscale(0.6);
}

/* Not-yet-implemented buttons keep the disabled look permanently (tooltip explains).
   :disabled needed to out-specify the generic .combat-btn:disabled pointer-events:none —
   without hover events the title tooltip never shows. */
.combat-btn-nyi:disabled {
    pointer-events: auto !important;
}

/* Right console panel: systems view by default, enemy-target view while hovering an enemy */
.systems-panel {
    flex: 1.1;
}

.right-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#combat-right-systems .panel-titlebar {
    font-size: 10px;
    padding: 2px 6px;
    margin-bottom: 4px;
}

.system-rows {
    flex: 1;
    overflow-y: auto;
}

/* AUTO (server-side auto battle) active — pressed-in green, mirrors the SCAN active look */
.combat-btn.auto-active {
    background: linear-gradient(to bottom, #2a7a3a, #164a22);
    border-color: #101a10 #6adf8a #6adf8a #101a10;
    color: #d8ffd8;
    text-shadow: 0 0 5px rgba(120, 255, 150, 0.9);
    box-shadow: 0 0 8px rgba(77, 200, 100, 0.6);
}

/* SCAN mode active — the button stays visibly "pressed in" and glowing */
.combat-btn.scan-active {
    background: linear-gradient(to bottom, #2a5a8a, #16324a);
    border-color: #101a2e #6a9adf #6a9adf #101a2e;
    color: #cfe8ff;
    text-shadow: 0 0 5px rgba(120, 190, 255, 0.9);
    box-shadow: 0 0 8px rgba(77, 166, 255, 0.6);
}

/* MOO2-style scan info card (SCAN mode + click on a ship) */
#combat-scan-modal {
    position: absolute;
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 440px;
    max-width: 92vw;
    max-height: 74vh;
    overflow-y: auto;
    z-index: 600;
    display: none;
    flex-direction: column;
    background: linear-gradient(to bottom, #141824, #0a0d16);
    border: 3px solid #5a5e66;
    border-top-color: #9ba0ab;
    border-left-color: #9ba0ab;
    border-radius: 6px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(0, 0, 0, 0.5);
    font-family: 'Orbitron', sans-serif;
    color: #cfe4ff;
}

#combat-scan-modal .scan-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, #4a6a9a, #1c2c4a);
    border-bottom: 2px solid #101a2e;
    padding: 6px 12px;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #eaf2ff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    flex-shrink: 0;
}

#combat-scan-modal .scan-titlebar button {
    background: transparent;
    border: none;
    color: #aac4e8;
    font-size: 17px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
#combat-scan-modal .scan-titlebar button:hover {
    color: #ffffff;
}

#combat-scan-modal .scan-body {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#combat-scan-modal .scan-top {
    display: flex;
    gap: 12px;
    align-items: center;
}

#combat-scan-modal .scan-icon {
    width: 84px;
    height: 84px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #0d0f13;
    background: radial-gradient(circle at 50% 35%, #10203a, #05080f 80%);
    border-radius: 3px;
}

#combat-scan-modal .scan-bonuses {
    flex: 1;
    min-width: 0;
}

#combat-scan-modal .scan-sec-title {
    color: #9adcff;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #33506f;
    padding-bottom: 2px;
    margin-top: 4px;
}

#combat-scan-modal .scan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
}

#combat-scan-modal .scan-weapons {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #88ff88;
    padding: 2px 4px;
}

#combat-scan-modal .scan-noshield {
    color: #8fa8c8;
    font-size: 11px;
    padding: 2px;
}

.radar-panel {
    /* Square block sized by the console height; zero padding so the radar screen fills the
       panel edge-to-edge and reads as large as possible. */
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
    padding: 0;
    overflow: hidden;
    background: #001100;
    box-shadow: inset 0 0 14px rgba(0, 60, 0, 0.6);
}

#combat-radar-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;      /* it's an interactive minimap — press/drag scrolls the view */
    touch-action: none;     /* our own touch handlers drive it on tablets */
}

/* Systems readout rows — now live in the left block's SYSTEMS tab (MOO2 anatomy: your own
   ship's systems under the tab, the right block shows the TARGET ship). */
.system-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
    padding: 1px 2px;
    font-family: 'Roboto', sans-serif;
    font-size: 11px;
    border-bottom: 1px dotted rgba(74, 106, 153, 0.25);
}
.system-row span:first-child {
    color: #8fa8c8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.system-row span:last-child {
    color: #cfe4ff;
    font-weight: bold;
    white-space: nowrap;
}

/* Active Combats List Widget (MOO2 Admin Style) — dark burgundy, no scrollbars: the
   widget simply grows with its list (it's draggable, and simultaneous fights are few). */
#combat-list-widget {
    position: absolute;
    top: 50px;
    left: 20px;
    /* Grows with its content (long ruler/race names are shown in FULL, no ellipsis) —
       clamped so a pathological name can't push it past the screen edge. */
    width: max-content;
    min-width: 270px;
    max-width: min(92vw, 560px);
    background: linear-gradient(to bottom, #2e0a12, #1b060b); /* тёмно-бордовый */
    border: 2px solid #6e1a26;
    border-radius: 8px;
    z-index: 101; /* Above UI, below combat overlay */
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,0.85), inset 0 1px 0 rgba(255,120,120,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* clip children to the rounded corners */
}

#combat-list-header {
    background: linear-gradient(to bottom, #571323, #3a0c16);
    padding: 7px 10px;
    cursor: move; /* Draggable */
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #7e2132;
    user-select: none;
}

#combat-list-title {
    color: #ffd9d9;
    font-size: 13px;
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(255, 80, 80, 0.6), 1px 1px 2px #000;
}

#combat-list-content {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* No max-height / overflow scrolling — the widget grows with the list instead of
       ever showing a scrollbar. */
}

.combat-list-item-btn {
    background: linear-gradient(to bottom, #43101c, #260710);
    border: 1px solid #7a2434;
    color: #fff;
    padding: 7px 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    border-radius: 5px;
    transition: 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* The widget itself is width:max-content now, so the button never needs to clip its
       content — names show in full and the panel widens instead. min-width:0 stays so the
       button can still shrink once the widget hits its max-width clamp. */
    min-width: 0;
}

.combat-list-item-btn:hover {
    background: linear-gradient(to bottom, #5c1826, #3a0c16);
    border-color: #b0404f;
}

.combat-timer-text {
    color: #ffaa44;
    font-weight: bold;
    font-size: 14px;
}

/* Waiting-for-server overlay (see combat.js sendAction) */
#combat-waiting-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500; /* above canvas/ships, below combat-header (10 is lower but header has its own stacking context via position:absolute + z-index:10 inside #combat-layer; overlay is a sibling so needs to clear the canvas, not the header) */
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(10, 17, 34, 0.85);
    border: 1px solid #4a8aef;
    border-radius: 8px;
    padding: 14px 18px;
    box-shadow: 0 0 20px rgba(74, 138, 239, 0.5);
}

#combat-waiting-overlay.hidden {
    display: none;
}

#combat-waiting-hourglass {
    font-size: 36px;
    line-height: 1;
    animation: combatHourglassFlip 1s linear infinite;
    filter: drop-shadow(0 0 6px #ffaa44);
}

@keyframes combatHourglassFlip {
    0%   { transform: rotate(0deg); }
    45%  { transform: rotate(180deg); }
    55%  { transform: rotate(180deg); }
    100% { transform: rotate(360deg); }
}

/* Real OS "busy" cursor over the battlefield while an action is in flight — matches the
   overlay above so the wait state reads clearly even before the eye catches the icon. */
#combat-layer.combat-action-pending #combat-canvas,
#combat-layer.combat-action-pending .combat-btn {
    cursor: wait !important;
}

/* ── СМАРТФОН: тактический бой ──────────────────────────────────────────────
   Шапка: только чей ход + таймер + X. Поле боя не трогаем.
   Консоль: кнопки лентой в 2 ряда (без ЧЕКАТИ) → табы КОРАБЛЬ | РАДАР →
   контент таба: КОРАБЛЬ = портрет + арсенал, РАДАР = системы + радар. */
#combat-mobile-tabs { display: none; }

@media (max-width: 767px) {
    /* Шапка — одна строка */
    #combat-title { display: none; }
    #combat-header { padding: 0 10px; gap: 8px; }
    #combat-timer {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: left;
        font-size: 13px;
    }

    /* Консоль превращается в вертикальную стопку с переносом */
    #combat-ui {
        flex-wrap: wrap;
        width: 100%;
        max-width: 100%;
        height: auto;
        padding: 6px;
        padding-top: 8px;
        gap: 6px;
    }
    #combat-ui::before, #combat-ui::after { display: none; } /* заклёпки не нужны */

    /* 1) Кнопки действий — ОДИН ряд из 4 кнопок, компактные как табы */
    .center-panel { order: 0; width: 100%; flex: 0 0 auto; background: none; border: none; padding: 0; }
    .combat-btn-col { flex-direction: row; flex-wrap: nowrap; gap: 6px; height: auto; }
    .combat-btn-col .combat-btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 0;
        font-size: 11px;
        margin: 0;
        padding: 7px 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #btn-combat-wait { display: none !important; } /* ЧЕКАТИ на телефоне не выдаём */

    /* 2) Табы КОРАБЛЬ | СКАН | РАДАР (СКАН переносится сюда JS-ом на телефоне) */
    #combat-mobile-tabs { display: flex; order: 1; width: 100%; gap: 6px; flex: 0 0 auto; }
    #combat-mobile-tabs .btn { flex: 1; padding: 6px 0; font-size: 12px; margin: 0; }
    /* СКАН в ряду табов: УЗКАЯ кнопка (не тянется), но в родном металлическом стиле
       .combat-btn — как АВТО/ВІДСТУПИТИ; табы по бокам делят остальное. */
    #combat-mobile-tabs .combat-btn {
        flex: 0 0 auto;
        min-width: 0;
        min-height: 0;
        margin: 0;
        padding: 6px 14px;
        font-size: 12px;
        white-space: nowrap;
    }
    #combat-mobile-tabs .btn.active {
        background: #2a4070;
        border-color: #4da6ff;
        color: #fff;
        box-shadow: 0 0 10px rgba(77, 166, 255, 0.4);
    }

    /* 3) Контент табов: по умолчанию все панели скрыты, активный таб включает пару */
    .ship-panel, .arsenal-panel, .systems-panel, .radar-panel {
        display: none;
        order: 2;
        height: 185px;
        min-height: 0;
        overflow: hidden;
    }
    #combat-ui.mob-ship .ship-panel { display: flex; width: 42%; flex: 0 0 auto; }
    #combat-ui.mob-ship .arsenal-panel { display: flex; flex: 1 1 auto; min-width: 0; }
    #combat-ui.mob-radar .systems-panel { display: flex; flex: 1 1 auto; min-width: 0; }
    #combat-ui.mob-radar .radar-panel {
        display: flex;
        width: 46%;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
    }
    #combat-ui.mob-radar .radar-panel canvas { max-width: 100%; max-height: 100%; }
}

/* ── Ухо консоли боя (только смартфон) ─────────────────────────────────────
   Металлическая вкладка по центру ВЕРХНЕЙ кромки консоли, в тонах бортов
   (как ухо правого меню, но «лёжа»: крепление снизу, скруглён верх).
   ▼ = спрятать контент табов, ▲ = вернуть. Кнопки и табы не прячутся. */
#combat-ui-ear { display: none; }

@media (max-width: 767px) {
    #combat-ui-ear {
        display: flex;
        position: absolute;
        top: -24px;
        left: 50%;
        transform: translateX(-50%);
        width: 48px;
        height: 22px;
        align-items: center;
        justify-content: center;
        background: linear-gradient(to top, #5d616a, #40444c);
        border: 2px solid #5a5e66;
        border-bottom: none;                   /* сторона крепления к консоли */
        border-top-color: #8b909a;             /* светлая фаска сверху */
        border-left-color: #8b909a;
        border-right-color: #33363f;
        border-radius: 8px 8px 0 0;
        color: #1a1c20;
        font-size: 11px;
        font-weight: 900;
        text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
        cursor: pointer;
        z-index: 11;
        box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.45);
        user-select: none;
        transition: 0.1s;
    }
    #combat-ui-ear:active {
        background: linear-gradient(to top, #44484f, #33363d);
        padding-top: 2px;
    }

    /* Плавное сворачивание контента табов: панели остаются в потоке (display:flex от
       правил mob-*), но схлопываются по высоте с прозрачностью. */
    .ship-panel, .arsenal-panel, .systems-panel, .radar-panel {
        transition: height 0.3s ease, opacity 0.3s ease,
                    padding 0.3s ease, border-width 0.3s ease;
    }
    #combat-ui.panels-hidden.mob-ship .ship-panel,
    #combat-ui.panels-hidden.mob-ship .arsenal-panel,
    #combat-ui.panels-hidden.mob-radar .systems-panel,
    #combat-ui.panels-hidden.mob-radar .radar-panel {
        height: 0;
        min-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-top-width: 0;
        border-bottom-width: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
    }
}
