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

body {
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: #050510; color: #c8d0e0;
    overflow: hidden; height: 100vh; width: 100vw;
}
.app { display: flex; height: 100vh; width: 100vw; }

.sidebar {
    width: 368px; min-width: 368px;
    background: linear-gradient(180deg, #0a0a1a 0%, #0d0d20 100%);
    border-right: 1px solid #1a1a3a;
    display: flex; flex-direction: column; overflow-y: auto; z-index: 10;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a2a5a; border-radius: 2px; }

.sidebar-header { padding: 20px 16px 12px; border-bottom: 1px solid #1a1a3a; }
.sidebar-header h1 { font-size: 14px; font-weight: 600; color: #88aaff; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.sidebar-header .subtitle { font-size: 11px; color: #556; }

.mode-buttons { display: flex; gap: 4px; padding: 12px 16px; border-bottom: 1px solid #1a1a3a; }
.mode-btn {
    flex: 1; padding: 8px 4px; background: #111128; border: 1px solid #222248;
    border-radius: 6px; color: #778; font-size: 11px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; text-align: center;
}
.mode-btn:hover { background: #1a1a38; color: #aab; }
.mode-btn.active { background: #1a2248; border-color: #3355aa; color: #88aaff; box-shadow: 0 0 10px rgba(80,120,255,0.15); }

.panel-section { padding: 12px 16px; border-bottom: 1px solid #1a1a3a; }
.panel-section h3 { font-size: 10px; font-weight: 700; color: #556; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 10px; }

.control-buttons { display: flex; gap: 8px; margin-top: 8px; }
.btn-primary {
    flex: 1; padding: 10px; background: linear-gradient(135deg, #2255aa, #3366cc);
    border: none; border-radius: 8px; color: #fff; font-size: 13px; font-weight: 700;
    cursor: pointer; transition: all 0.2s; letter-spacing: 1px;
}
.btn-primary:hover { background: linear-gradient(135deg, #3366cc, #4477dd); box-shadow: 0 0 15px rgba(80,120,255,0.3); }
.btn-secondary { padding: 10px 16px; background: #1a1a2a; border: 1px solid #2a2a4a; border-radius: 8px; color: #88a; font-size: 13px; cursor: pointer; }
.btn-secondary:hover { background: #222238; border-color: #3a3a5a; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.toggle-row label { font-size: 12px; color: #99a; }
.toggle-switch { position: relative; width: 44px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #222238; border-radius: 11px; cursor: pointer; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; bottom: 2px; background: #556; border-radius: 50%; transition: 0.3s; }
input:checked + .toggle-slider { background: #2255aa; }
input:checked + .toggle-slider::before { transform: translateX(22px); background: #88ccff; }
.status-on { color: #44ff88; font-size: 11px; font-weight: 700; }
.status-off { color: #665; font-size: 11px; }

.slider-row { margin-bottom: 10px; }
.slider-row label { display: flex; justify-content: space-between; font-size: 11px; color: #778; margin-bottom: 4px; }
.slider-row label span { color: #aab; font-weight: 600; }
input[type="range"] { width: 100%; height: 4px; -webkit-appearance: none; appearance: none; background: #222238; border-radius: 2px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #4477cc; cursor: pointer; border: 2px solid #88aaff; }

.telemetry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tel-item { background: #0d0d1a; border: 1px solid #1a1a30; border-radius: 6px; padding: 8px 10px; }
.tel-item .label { font-size: 9px; color: #556; text-transform: uppercase; letter-spacing: 0.5px; }
.tel-item .val { font-size: 16px; font-weight: 700; color: #dde; font-family: 'Consolas', 'Courier New', monospace; }
.tel-item .unit { font-size: 9px; color: #556; margin-left: 2px; }
.tel-item.transparent-yes { border-color: #22aa55; background: #0a1a10; }
.tel-item.transparent-yes .val { color: #44ff88; }
.tel-item.transparent-no .val { color: #ff6644; }

.sim-status { padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; text-align: center; margin-top: 8px; }
.status-idle { background: #111128; color: #556; }
.status-running { background: #0a1a28; color: #44aaff; animation: pulse 1.5s infinite; }
.status-stuck { background: #2a0a0a; color: #ff4444; animation: blink 0.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.layer-track { display: flex; justify-content: space-between; font-size: 9px; color: #667; margin: -4px 0 10px; text-transform: uppercase; letter-spacing: 0.5px; }

.layer-list { display: flex; flex-direction: column; gap: 1px; margin: 8px 0 10px; border: 1px solid #1a1a30; border-radius: 8px; overflow: hidden; background: #0a0a16; }
.layer-row {
    display: flex; align-items: center; gap: 8px; padding: 5px 10px;
    font-size: 12px; color: #9aa4bb; cursor: pointer; transition: background 0.15s;
}
.layer-row:hover { background: #14142a; color: #c8d0e6; }
.layer-row.active { background: #1a2248; color: #cfe0ff; }
.layer-row .dot { width: 9px; height: 9px; min-width: 9px; border-radius: 50%; box-shadow: 0 0 6px rgba(255,255,255,0.15); }
.layer-row .lname { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-row .ldepth { font-size: 10px; color: #667; font-family: 'Consolas', monospace; white-space: nowrap; }
.layer-row.active .ldepth { color: #8899cc; }

.layer-info { background: #0d0d1a; border: 1px solid #1a1a30; border-radius: 8px; padding: 12px 14px; margin-top: 4px; }
.layer-info .layer-name { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: #a8c0ff; margin-bottom: 6px; }
.layer-info .layer-name .dot { width: 10px; height: 10px; border-radius: 50%; }
.layer-info .layer-desc { font-size: 12px; color: #8a94ab; line-height: 1.45; margin-bottom: 10px; }
.layer-info .layer-rows { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.layer-info .layer-rows div { display: flex; gap: 8px; font-size: 12px; line-height: 1.35; }
.layer-info .layer-rows .k { min-width: 92px; color: #667; }
.layer-info .layer-rows .v { flex: 1; color: #c2cade; }
.layer-info .layer-model { font-size: 10.5px; color: #6a7799; font-family: 'Consolas', monospace; border-top: 1px solid #1a1a30; padding-top: 7px; }

.fractal-info { background: #0d0d1a; border: 1px solid #1a1a30; border-radius: 6px; padding: 10px; text-align: center; }
.fractal-info .level { font-size: 28px; font-weight: 800; color: #88aaff; }
.fractal-info .name { font-size: 11px; color: #778; margin-top: 2px; }

.chart-container { margin-top: 8px; }
.chart-container canvas { width: 100%; background: #080818; border: 1px solid #1a1a30; border-radius: 6px; }

.scene-wrapper { flex: 1 1 0%; position: relative; overflow: hidden; min-width: 0; min-height: 0; }
#scene-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
#scene-container canvas { display: block; }

.hint-overlay {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(10,10,30,0.8); border: 1px solid #2a2a4a; border-radius: 8px;
    padding: 10px 20px; font-size: 12px; color: #778; pointer-events: none; z-index: 5;
}
.hint-overlay .key { display: inline-block; background: #1a1a38; border: 1px solid #333358; border-radius: 3px; padding: 1px 6px; font-size: 10px; color: #aab; margin: 0 2px; }

/* ── Кнопки эффектов ── */
.fx-buttons { display: flex; gap: 8px; margin: 4px 0 10px; }
.btn-fx {
    flex: 1; padding: 8px 6px; background: #14142e; border: 1px solid #2a2a55;
    border-radius: 8px; color: #9ab; font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all 0.2s;
}
.btn-fx:hover { background: #1e1e42; border-color: #4455aa; color: #cde; box-shadow: 0 0 12px rgba(90,120,255,0.2); }
.btn-fx.wide { width: 100%; margin-top: 10px; }
.dive-hint { font-size: 10.5px; color: #667; margin: 2px 0 8px; }

/* ── Карта вложенности миров ── */
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; }
.chain-chip {
    padding: 3px 9px; border: 1.5px solid #4d9fff; border-radius: 12px;
    font-size: 11px; color: #aab; cursor: pointer; background: #0d0d1e; transition: all 0.2s;
}
.chain-chip:hover { color: #dde; background: #1a1a38; }
.chain-chip.active { background: #1a2248; color: #cfe0ff; box-shadow: 0 0 10px rgba(90,130,255,0.35); }
.chain-arrow { color: #556; font-size: 11px; }

/* ── Радиопереговоры ── */
#radio-log {
    position: absolute; left: 16px; bottom: 16px; z-index: 6;
    display: flex; flex-direction: column; gap: 4px; max-width: min(430px, 70vw);
    pointer-events: none;
}
.radio-line {
    font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; line-height: 1.35;
    color: #9fd8c8; background: rgba(6, 12, 18, 0.72); border-left: 3px solid #2a6a5a;
    padding: 5px 10px; border-radius: 0 6px 6px 0;
    animation: radioIn 0.25s ease-out; transition: opacity 1.2s;
}
.radio-line.ok { color: #8fe8b0; border-left-color: #2a8a4a; }
.radio-line.warn { color: #ffd58a; border-left-color: #aa7722; }
.radio-line.alert { color: #ff9a8a; border-left-color: #aa2a22; }
.radio-line.old { opacity: 0.25; }
@keyframes radioIn { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Варп-вспышка перехода ── */
#warp-flash {
    position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: 0;
    background: radial-gradient(circle at 50% 50%, #fff 0%, #cfe4ff 35%, rgba(120,160,255,0.6) 65%, rgba(20,30,80,0.2) 100%);
    transition: opacity 0.4s ease;
}
#warp-flash.on { opacity: 1; }

/* ── Кабина ── */
#cockpit { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.cp-vignette {
    position: absolute; inset: 0;
    box-shadow: inset 0 0 140px 60px rgba(2, 4, 10, 0.95), inset 0 0 40px 12px rgba(2, 4, 10, 0.6);
    border-radius: 18px;
}
.cp-strut { position: absolute; background: linear-gradient(180deg, #0a0e18, #141a28 50%, #0a0e18); box-shadow: 0 0 14px rgba(0,0,0,0.8); }
.cp-strut.s1 { left: -4%; top: -12%; width: 13%; height: 130%; transform: rotate(14deg); }
.cp-strut.s2 { right: -4%; top: -12%; width: 13%; height: 130%; transform: rotate(-14deg); }
.cp-cracks { position: absolute; inset: 0; opacity: 0; transition: opacity 0.8s; }
.cp-cracks.c1 {
    background:
        linear-gradient(63deg, transparent 49.7%, rgba(210,230,255,0.5) 50%, transparent 50.25%),
        linear-gradient(118deg, transparent 49.8%, rgba(210,230,255,0.35) 50%, transparent 50.2%);
    background-size: 240% 240%, 300% 300%; background-position: 18% 30%, 60% 15%;
}
.cp-cracks.c2 {
    background:
        linear-gradient(41deg, transparent 49.75%, rgba(210,230,255,0.55) 50%, transparent 50.3%),
        linear-gradient(99deg, transparent 49.7%, rgba(210,230,255,0.4) 50%, transparent 50.25%),
        linear-gradient(151deg, transparent 49.8%, rgba(210,230,255,0.3) 50%, transparent 50.15%);
    background-size: 260% 260%, 220% 220%, 320% 320%; background-position: 75% 60%, 30% 75%, 55% 40%;
}
#cockpit.crack1 .cp-cracks.c1 { opacity: 0.75; }
#cockpit.crack2 .cp-cracks.c2 { opacity: 0.85; }
.cp-panel {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px; padding: 9px 14px;
    background: linear-gradient(180deg, rgba(12,16,28,0.92), rgba(6,8,16,0.95));
    border: 1px solid #26304a; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.cp-item { display: flex; flex-direction: column; align-items: center; min-width: 66px; }
.cp-item span { font-size: 8.5px; color: #566a8a; text-transform: uppercase; letter-spacing: 0.8px; }
.cp-item b { font-size: 14px; color: #bfe0ff; font-family: 'Consolas', monospace; font-weight: 700; }
.cp-item.cp-t b { color: #6fe8a8; }
#cockpit.alarm .cp-item.cp-t b { color: #ff7a6a; }
.cp-lamp { width: 14px; height: 14px; border-radius: 50%; background: #1c2436; border: 1px solid #2a3450; }
#cockpit.alarm .cp-lamp { background: #ff3322; box-shadow: 0 0 14px #ff3322; animation: blink 0.5s infinite; }
#cockpit.alarm .cp-vignette { box-shadow: inset 0 0 140px 60px rgba(40, 4, 6, 0.9), inset 0 0 40px 12px rgba(30, 2, 4, 0.6); }

/* ── 9 планет ── */
.planets-row { display: flex; flex-wrap: wrap; gap: 5px; }
.planet-chip {
    display: flex; align-items: center; gap: 6px; padding: 5px 10px;
    background: #10102a; border: 1px solid #22224a; border-radius: 14px;
    color: #9aa4bb; font-size: 11.5px; cursor: pointer; transition: all 0.18s;
}
.planet-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.planet-chip:hover { background: #1a1a3c; color: #cdd6ea; }
.planet-chip.active { background: #1a2248; border-color: #4466cc; color: #dfe8ff; box-shadow: 0 0 10px rgba(90,130,255,0.3); }

/* ── Катаклизмы ── */
.btn-fx.danger { border-color: #5a2a2a; color: #cc8877; }
.btn-fx.danger:hover { background: #2a1414; border-color: #aa4433; color: #ffaa88; box-shadow: 0 0 12px rgba(255,80,50,0.2); }
#cataclysm-buttons { margin-top: 6px; }

/* ── Вспышка удара ── */
#hit-flash {
    position: absolute; inset: 0; z-index: 22; pointer-events: none; opacity: 0;
    background: radial-gradient(circle, #fff 0%, #ffe8c8 45%, rgba(255,180,100,0.4) 100%);
    transition: opacity 0.5s ease;
}
#hit-flash.on { opacity: 0.95; transition: opacity 0.05s; }

/* ── Учебная карточка слоя ── */
#layer-card {
    position: absolute; right: 26px; top: 50%; transform: translateY(-50%);
    width: min(400px, calc(100% - 40px)); z-index: 16;
    background: linear-gradient(165deg, rgba(13,17,32,0.96), rgba(8,10,20,0.97));
    border: 1px solid #26304a; border-left: 4px solid #4d9fff; border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.65);
    animation: cardIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes cardIn { from { transform: translateY(-50%) translateX(40px); opacity: 0; } to { transform: translateY(-50%); opacity: 1; } }
.lc-inner { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.lc-head { display: flex; align-items: center; gap: 12px; }
.lc-dot { width: 16px; height: 16px; min-width: 16px; border-radius: 50%; box-shadow: 0 0 14px currentColor; }
.lc-name { font-size: 19px; font-weight: 800; color: #e8eeff; letter-spacing: 0.3px; }
.lc-depth { font-size: 12px; color: #7a86a5; font-family: 'Consolas', monospace; margin-top: 2px; }
.lc-desc { font-size: 13px; color: #a8b2c8; line-height: 1.5; }
.lc-grid { display: flex; flex-direction: column; gap: 7px; border-top: 1px solid #1e2740; padding-top: 11px; }
.lc-grid div { display: flex; gap: 10px; font-size: 12.5px; line-height: 1.4; }
.lc-grid .k { min-width: 128px; color: #66738f; }
.lc-grid .v { flex: 1; color: #cfd8ea; }
.lc-fact {
    display: flex; gap: 10px; align-items: flex-start;
    background: rgba(90, 130, 255, 0.07); border: 1px solid rgba(90,130,255,0.15);
    border-radius: 10px; padding: 10px 12px;
}
.lc-fact span { font-size: 16px; }
.lc-fact-text { font-size: 12.5px; color: #b8c4de; line-height: 1.5; font-style: italic; }
.lc-continue { margin-top: 2px; }

/* ── Мобильная вёрстка ── */
@media (max-width: 900px) {
    .app { flex-direction: column-reverse; }
    .sidebar {
        width: 100%; min-width: 0; max-height: 46vh;
        border-right: none; border-top: 1px solid #1a1a3a;
    }
    .scene-wrapper { height: 54vh; flex: none; }
    .hint-overlay { display: none; }
    .sidebar-header { padding: 12px 14px 8px; }
    .panel-section { padding: 10px 14px; }
    .telemetry-grid { grid-template-columns: repeat(3, 1fr); }
    .tel-item .val { font-size: 13px; }
    #radio-log { left: 8px; bottom: 8px; max-width: 80vw; }
    .radio-line { font-size: 10.5px; padding: 4px 8px; }
    .cp-panel { gap: 6px; padding: 7px 8px; bottom: 6px; max-width: 96vw; flex-wrap: wrap; justify-content: center; }
    .cp-item { min-width: 56px; }
    .cp-item b { font-size: 12px; }
    .cp-strut.s1, .cp-strut.s2 { width: 8%; }
    .mode-btn { padding: 10px 4px; font-size: 12px; }
    .btn-primary, .btn-secondary { padding: 12px; }
    #layer-card { right: 50%; transform: translate(50%, -50%); width: 92vw; }
    @keyframes cardIn { from { transform: translate(50%, -50%) scale(0.92); opacity: 0; } to { transform: translate(50%, -50%); opacity: 1; } }
    .lc-inner { padding: 14px 16px; gap: 9px; }
    .lc-name { font-size: 16px; }
    .planet-chip { font-size: 10.5px; padding: 4px 8px; }
}
