:root { 
    --green: #39FF14; 
    --dark: #000000; 
    --red: #ff3b30; 
    --yellow: #FFD60A; 
    --blue: #00BFFF; 
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body { 
    background: var(--dark); 
    color: #a1b57d; 
    font-family: 'Courier New', monospace; 
    margin: 0; 
    height: 100dvh; 
    display: flex; 
    justify-content: center; 
    overflow: hidden; 
    overscroll-behavior: none; 
}

/* --- ФОН ТА ЕФЕКТИ --- */
#matrixCanvas { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -10; opacity: 0.8; background: #000; }
.scanlines { position: fixed; inset: 0; pointer-events: none; z-index: 1000; background: linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.1) 50%), linear-gradient(90deg, rgba(255,0,0,0.03), rgba(0,255,0,0.01), rgba(0,0,255,0.03)); background-size: 100% 3px, 2px 100%; opacity: 0.5; }

.hidden { display: none !important; }

/* --- ГОЛОВНІ КОНТЕЙНЕРИ --- */
.app-container { width: 100%; max-width: 100%; height: 100dvh; display: flex; flex-direction: column; background: transparent; position: relative; z-index: 10; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.screen-container { position: absolute !important; inset: 0; width: 100vw; height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #000; z-index: 10000; }
.main-app-layout { flex-direction: column; height: 100%; position: relative; z-index: 10; display: flex; }

/* --- ЕКРАНИ АВТОРИЗАЦІЇ ТА БЛОКУВАННЯ --- */
.dialer-container { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 20px; width: 100%; max-width: 500px; margin: 0 auto; box-sizing: border-box; }
.tactical-panel { width: 90%; max-width: 350px; background: rgba(5,5,5,0.85); border: 1px solid #333; padding: 20px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.8); backdrop-filter: blur(4px); }
.glitch-title { color: var(--yellow); letter-spacing: 3px; text-shadow: 0 0 10px var(--yellow); margin-bottom: 30px; text-align: center; }

/* --- ПОЛЯ ВВОДУ ТА КНОПКИ --- */
.tactical-input { width: 100%; box-sizing: border-box; background: rgba(0,0,0,0.5); padding: 15px; font-size: 16px; outline: none; border-radius: 4px; margin-bottom: 15px; transition: 0.3s; color: var(--green); border: 1px solid var(--green); text-align: center; font-family: monospace;}
.target-input { font-size: 20px; letter-spacing: 2px; }
.sms-input { border-color: #fff; color: #fff; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.tactical-btn { background: rgba(0,0,0,0.6); padding: 15px 10px; font-family: monospace; font-weight: bold; font-size: 14px; cursor: pointer; border-radius: 4px; outline: none; display: flex; align-items: center; justify-content: center; text-align: center; transition: 0.2s; border: 1px solid #333; color: var(--green); }
.tactical-btn:active { transform: scale(0.98); }
.primary-btn { border-color: var(--green); color: var(--green); }
.secondary-btn { border-color: var(--blue); color: var(--blue); }
.danger-btn { border-color: var(--red); color: var(--red); }
.full-width { width: 100%; }

/* --- ТОП БАР ТА СТАТУС --- */
.top-bar { flex: 0 0 auto; padding: 10px 15px; background: rgba(0,0,0,0.85); border-bottom: 1px solid rgba(57,255,20,0.3); display: flex; justify-content: space-between; align-items: center; font-size: 12px; position: relative; z-index: 100; gap: 10px;}
#netBadge { font-size: 9px; padding: 2px 4px; border: 1px solid var(--blue); background: var(--blue); color: #000; border-radius: 2px; margin: 0 4px; font-weight: bold; }

/* --- ЗОЛОТИЙ СТАНДАРТ: АКТИВНИЙ ДЗВІНОК --- */
.active-call-layout { flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; background: transparent; }

.video-grid {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.85);
    border-bottom: 1px solid rgba(57,255,20,0.3);
    z-index: 20;
}

#remoteVideo, #localVideo {
    width: 45%; 
    max-width: 200px;
    height: 140px;
    object-fit: cover;
    border: 2px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #050505;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#remoteVideo { border-color: var(--green); }
#localVideo { border-color: var(--yellow); }

/* --- КАРТИНКА В КАРТИНЦІ (PiP) ТА FULLSCREEN ПО КЛІКУ --- */
.video-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 1000000 !important; 
    object-fit: contain !important; 
    background: #000 !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.video-pip-overlay {
    position: fixed !important;
    bottom: 180px !important; 
    right: 20px !important;
    width: 100px !important;
    height: 140px !important;
    z-index: 1000001 !important; 
    border: 2px solid var(--yellow) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8) !important;
    object-fit: cover !important;
}

/* --- ІНФО-БАР ТА ПРОГРЕС --- */
.call-info-bar { background: rgba(0,0,0,0.85); padding: 8px 12px; border-bottom: 1px dashed rgba(57,255,20,0.3); display: flex; justify-content: space-between; font-size: 12px; z-index: 15; }
.timer-text { color: var(--green); font-weight: bold; }

.progress-container { padding: 10px; background: rgba(0,0,0,0.85); border-bottom: 1px solid #1a1a1a; z-index: 15; }
.progress-header { display: flex; justify-content: space-between; font-size: 10px; color: var(--green); margin-bottom: 5px; }
.progress-track { width: 100%; height: 4px; background: #111; border-radius: 2px; overflow: hidden; }
.progress-fill { width: 0%; height: 100%; background: var(--green); transition: width 0.3s; }

/* --- ЧАТ ТА ПОВІДОМЛЕННЯ --- */
.chat-box { flex: 1 1 auto; overflow-y: auto; padding: 10px; background: rgba(0,0,0,0.3); scroll-behavior: smooth; z-index: 10; }

.chat-input-area { display: flex; flex-direction: column; padding: 10px; gap: 8px; background: rgba(0,0,0,0.85); border-top: 1px solid rgba(57,255,20,0.3); z-index: 15; }
.msg-input-field { flex: 1; padding: 12px; font-size: 14px; border: 1px solid #333; background: rgba(0,0,0,0.5); color: var(--green); border-radius: 4px; margin: 0; }
.send-msg-btn { width: 60px; padding: 0; margin: 0; }

.msg { padding: 8px 12px; border-radius: 6px; margin-bottom: 8px; max-width: 85%; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.msg.self { background: rgba(57,255,20,0.15); border: 1px solid rgba(57,255,20,0.4); color: var(--green); align-self: flex-end; margin-left: auto; }
.msg.peer { background: rgba(0,191,255,0.15); border: 1px solid rgba(0,191,255,0.4); color: var(--blue); align-self: flex-start; margin-right: auto; }
.img-msg img { display: block; margin-top: 5px; max-width: 200px; border-radius: 8px; border: 1px solid #333; cursor: pointer; }

/* --- НИЖНІ КНОПКИ КЕРУВАННЯ --- */
.call-controls { flex: 0 0 auto; padding: 10px 10px calc(15px + env(safe-area-inset-bottom)) 10px; background: rgba(0,0,0,0.9); display: flex; flex-wrap: wrap; gap: 8px; z-index: 15; }
.btn-sub { font-size: 11px; padding: 12px 5px; flex: 1; background: rgba(0,0,0,0.6); color: var(--green); border: 1px solid #333; border-radius: 4px; font-weight: bold; transition: 0.2s; cursor: pointer; }
.hang-btn-style { background: rgba(255,59,48,0.1) !important; color: var(--red) !important; border-color: var(--red) !important; flex: 1.5; }

/* --- ОВЕРЛЕЇ (ДЗВІНКИ ТА SMS) --- */
.incoming-overlay { position: fixed !important; inset: 0; z-index: 1000000 !important; display: flex; flex-direction: column; justify-content: center; align-items: center; background: rgba(0,0,0,0.95) !important; }
.incoming-panel { width: 90%; max-width: 320px; text-align: center; background: #050505; border: 1px solid var(--yellow); padding: 30px; border-radius: 12px; box-shadow: 0 0 40px rgba(255,214,10,0.2); }
.caller-id-display { font-size: 32px; color: var(--green); letter-spacing: 3px; margin: 15px 0; font-weight: bold; }

.sms-overlay-box { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 92%; max-width: 450px; background: #000; border: 1px solid var(--blue); padding: 25px; z-index: 1000000; border-radius: 8px; display: flex; flex-direction: column; gap: 15px; box-shadow: 0 0 30px rgba(0,191,255,0.2); }
.sms-header { border-bottom: 1px dashed var(--blue); padding-bottom: 10px; text-align: center; }
.sms-content-box { background: transparent; padding: 10px 0; color: #fff; font-size: 16px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; max-height: 40vh; overflow-y: auto; }

/* =========================================
   ТАКТИЧНА ДІАГНОСТИКА ТА АНІМАЦІЇ (НОВЕ)
   ========================================= */

/* Анімація критичної помилки (Red Alert) */
@keyframes criticalPulse {
    from { background-color: rgba(0,0,0,1); }
    to { background-color: rgba(139,0,0,0.6); }
}

/* Глітч-ефект для режиму Survival */
@keyframes glitch {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 1px) }
    40% { transform: translate(-1px, -1px) }
    60% { transform: translate(2px, 1px) }
    80% { transform: translate(1px, -1px) }
    100% { transform: translate(0) }
}

/* Консоль логів (нижній лівий кут) */
.diag-log-container {
    position: fixed;
    bottom: 90px;
    left: 10px;
    font-family: monospace;
    font-size: 9px;
    color: var(--green);
    pointer-events: none;
    z-index: 9999;
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 8px;
    border-radius: 4px;
    border-left: 2px solid var(--green);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Пульсуючий індикатор сервера */
#wsPulse {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-left: 8px;
    transition: box-shadow 0.2s ease, background 0.2s ease;
}

/* --- АДАПТАЦІЯ ДЛЯ ПК (ШИРОКІ ЕКРАНИ) --- */
@media (min-width: 1024px) {
    .video-grid { padding: 20px; gap: 20px; }
    #remoteVideo, #localVideo { width: 250px; height: 180px; max-width: none; }
    
    .video-pip-overlay {
        width: 180px !important;
        height: 135px !important;
        bottom: 120px !important;
        right: 40px !important;
    }

    .chat-box, .chat-input-area, .call-info-bar, .call-controls, .progress-container { 
        max-width: 800px; 
        margin: 0 auto; 
        width: 100%; 
        border-left: 1px solid rgba(57,255,20,0.2); 
        border-right: 1px solid rgba(57,255,20,0.2); 
    }
}
