/* Пиксельный шрифт для подписей камер.
   CSS проверяет несколько распространённых имён файла, чтобы шрифт
   загрузился независимо от названия скачанного TTF. */
@font-face {
  font-family: 'VCR OSD Pixel';
  src:
    local('VCR OSD Mono RUS+VHS Icons'),
    local('VCR OSD Mono RUS'),
    local('VCR OSD Mono'),
    url('fonts/VCR_OSD_MONO_RUS%2BVHS_ICONS.ttf') format('truetype'),
    url('fonts/VCR_OSD_MONO_RUS_VHS_ICONS.ttf') format('truetype'),
    url('fonts/VCR_OSD_MONO_RUS.ttf') format('truetype'),
    url('fonts/VCR_OSD_MONO_1.001.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Microsoft Yi Baiti', 'Segoe UI', sans-serif !important;
}

body {
  overflow: hidden;
  background-color: #ffffff;
}

.menu-button,
button,
.setup-actions button,
.web-link-button {
  font-family: 'Microsoft Yi Baiti', 'Segoe UI', sans-serif !important;
  font-size: 1.15rem !important;
  letter-spacing: 0.5px;
  font-weight: 600;
  text-decoration: none;
  padding: 5px 10px;
}

/* ЭКРАН ИНТРО */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #ffffff;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.boot-screen.fade-away {
  opacity: 0;
  visibility: hidden;
}

.boot-logo-img {
  width: 85%;
  max-width: 500px;
  height: auto;
  opacity: 0;
  transform: scale(0.93);
  animation: logo-entrance 1.8s ease 0.3s forwards;
}

@keyframes logo-entrance {
  0% {
    opacity: 0;
    transform: scale(0.93);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ЦВЕТА СИСТЕМЫ */
body,
#setupModal,
#app,
.monitor-shell,
.topbar,
.sidebar,
.ticker-wrap,
.ticker-label,
.ticker,
#sidePanel,
.camera {
  background-color: #ffffff !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

h1,
h2,
h3,
p,
span,
b,
label,
.panel-title,
.panel-copy,
#clock,
#userBadge,
.status,
.ticker-text {
  color: #000000 !important;
}

.status-rec {
  color: #ff0000 !important;
  animation: blink 1s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

input {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
  padding: 10px;
}

button,
.menu-button {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover,
.menu-button:hover span,
.menu-button:hover b {
  background-color: #000000 !important;
  color: #ffffff !important;
}

.recording-active {
  border-color: #ff0000 !important;
  color: #ff0000 !important;
  background: rgba(255, 0, 0, 0.05) !important;
}

.monitor-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 4% 1fr 4%;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  grid-column: 1 / span 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 15px;
  border-bottom: 2px solid #000;
  font-size: 1.5vw;
}

/* ИСПРАВЛЕННАЯ СЕТКА КАМЕР (СТРОГИЙ МАСШТАБ БЕЗ СЪЕЗДОВ) */
.camera-stage {
  grid-column: 1;
  grid-row: 2;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.camera-stage.multi {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: 35% 25% 40%;
  grid-template-areas:
    "top-wide top-wide top-wide"
    "middle-left middle-center middle-right"
    "bottom-wide bottom-wide bottom-wide";
  aspect-ratio: calc(815/880);
  margin: auto;
  padding: 2px 0px;
  gap: 0px;
}

.cam-top-wide {
  grid-area: top-wide;
}

.cam-middle-left {
  grid-area: middle-left;
}

.cam-middle-center {
  grid-area: middle-center;
}

.cam-middle-right {
  grid-area: middle-right;
}

.cam-bottom-wide {
  grid-area: bottom-wide;
}

/* РЕЖИМ ОДНОЙ КАМЕРЫ */
.camera-stage.mono {
  display: block !important;
  padding: 0;
  height: 100%;
}

.camera-stage.mono .camera {
  display: none !important;
}

.camera-stage.mono .camera.selected {
  display: flex !important;
  width: 100%;
  height: 100%;
}

.camera-stage.mono .camera.selected .camera-video {
  margin: auto;
  width: 100%;
  /* height: auto; */
  border: 1px solid #000;
  object-fit: contain;
}


.camera {
  position: relative;
  border: 0;
  background: #000000;
  overflow: hidden;
  cursor: zoom-in;
  height: 100%;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-video.force-16-9 {
  aspect-ratio: 16 / 9 !important;
  object-fit: fill !important;
}

.vcr-overlay {
  font-family: 'VCR OSD Pixel', 'Courier New', monospace !important;
  font-weight: 400 !important;
  font-style: normal !important;
  font-synthesis: none;
  font-variant-ligatures: none;
  position: absolute;
  z-index: 10;
  color: #ffffff !important;
  font-size: 0.725vw;
  line-height: 1;
  letter-spacing: 0.2px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.72);
  padding: 5px 9px 4px;
  border: 1px solid #ffffff;
  pointer-events: none;

  /* Более жёсткое, VHS-подобное отображение глифов. */
  text-rendering: optimizeSpeed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ЗАСТАВКА «СВЯЗЬ ПРОПАЛА» (ПО ДИЗАЙНУ ИЗ СКРИНШОТА) */
.no-signal-overlay {
  position: absolute;
  inset: 0;
  background-color: #3a3a3a !important;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.camera.signal-lost .no-signal-overlay {
  display: flex !important;
}

.no-signal-icon {
  width: 4vw;
  aspect-ratio: 1 / 1;
  border: 4px solid #ffffff !important;
  border-radius: 50%;
  color: #ffffff !important;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2vw;
  font-weight: bold;
  font-family: 'Segoe UI', Arial, sans-serif !important;
  margin-bottom: 6px;
}

.no-signal-text {
  color: #ffffff !important;
  font-size: 1.4vw;
  font-weight: 500;
  letter-spacing: 0.5px;
  font-family: 'Segoe UI', Arial, sans-serif !important;
}

/* САЙДБАР С КВАДРАТАМИ */
.sidebar {
  grid-column: 2;
  grid-row: 2;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start;
  align-items: center;
  border-left: 2px solid #000;
  padding: 10px;
  gap: 12px;
  overflow-y: auto;
}

.menu-button {
  width: 7rem;
  aspect-ratio: 1 / 1 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 8px;
  text-align: center;
  padding: 8px !important;
  box-sizing: border-box;
  font-weight: 800 !important;
}

.sidebar .menu-button,
.sidebar .menu-button * {
  font-weight: 800 !important;
}

.menu-button b {
  font-size: 0.9rem;
  line-height: 1.1;
  display: block;
  font-weight: 800 !important;
}

.menu-button span {
  font-size: 1.5rem;
  line-height: 1.1;
  display: block;
  font-weight: 800 !important;
}

.ticker-wrap {
  grid-column: 1 / span 2;
  display: flex;
  border-top: 2px solid #000;
  background: #fff;
}

.ticker-label {
  padding: 0 15px;
  font-weight: bold;
  font-size: 1.1rem;
  border-right: 2px solid #000;
  display: flex;
  align-items: center;
}

.ticker {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 40px;
  /* фиксированная высота */
}

.ticker-text {
  display: inline-block;
  white-space: nowrap;
  vertical-align: middle;
  height: 100%;
  padding: 0;
  position: absolute;
  font-size: 1.1rem;
  top: 22px;
  transform: translateY(-50%);
  left: 100%;
}

/* Класс, который запускает анимацию */
.ticker-text.animate {
  animation: ticker-move 25s linear infinite;
}

@keyframes ticker-move {
  0% {
    /* Начинаем справа за пределами контейнера */
    transform: translateY(-50%) translateX(0);
    left: 100%;
  }

  100% {
    /* Заканчиваем слева за пределами контейнера */
    transform: translateY(-50%) translateX(0);
    left: -100%;
  }
}

/* ОКНО ВХОДА */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.85) !important;
}

.modal.hidden {
  display: none !important;
}

.setup-card {
  background: #fff !important;
  border: 2px solid #000;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 320px;
  text-align: center;
}

.window-title {
  font-size: 1.5rem;
  font-weight: bold;
  border-bottom: 2px solid #000;
  padding-bottom: 5px;
}

/* БОКОВАЯ ПАНЕЛЬ */
.side-panel {
  position: fixed;
  top: 4vh;
  right: 0;
  bottom: 4vh;
  width: 320px;
  z-index: 990;
  border-left: 2px solid #000;
  padding: 20px;
  background: #fff;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel.open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 1.8rem;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
}

.qr-container {
  background: #e5e5e5 !important;
  border: 2px dashed #000000 !important;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
  margin: 1.5rem 0;
  min-height: 230px;
}

.donation-qr {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: contain;
  border: 2px solid #000000 !important;
  padding: 6px;
  background-color: #ffffff !important;
  background-image: linear-gradient(45deg, #cbcbcb 25%, transparent 25%), linear-gradient(-45deg, #cbcbcb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #cbcbcb 75%), linear-gradient(-45deg, transparent 75%, #cbcbcb 75%) !important;
  background-size: 16px 16px !important;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0 !important;
}

.web-link-button {
  width: 100%;
  aspect-ratio: unset !important;
  height: 50px;
  display: flex !important;
  flex-direction: row !important;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}

/* ДОПОЛНИТЕЛЬНЫЕ ПАНЕЛИ */
.info-copy {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 28px;
  font-family: 'Segoe UI', Arial, sans-serif !important;
  line-height: 1.45;
}

.info-copy p,
.info-copy b {
  font-family: inherit !important;
}

.audio-blocked::after {
  content: "CLICK TO ENABLE AMBIENT";
  position: fixed;
  left: 12px;
  bottom: 48px;
  z-index: 1200;
  padding: 5px 8px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 11px;
  pointer-events: none;
}


/* СКРЫТАЯ ПОДСТРОЙКА СИНХРОНИЗАЦИИ АУДИО */
#audioSyncIndicator {
  position: fixed;
  left: 12px;
  bottom: 48px;
  z-index: 1300;
  padding: 6px 9px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  font-family: 'Segoe UI', Arial, sans-serif !important;
  font-size: 12px;
  letter-spacing: 0.3px;
  opacity: 0;
  transform: translateY(5px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#audioSyncIndicator.visible {
  opacity: 1;
  transform: translateY(0);
}

body.audio-blocked #audioSyncIndicator {
  bottom: 76px;
}


/* Усиленное начертание для латинских подписей бокового меню */
#recBtn>b,
#infoBtn>b {
  font-family: 'Microsoft Yi Baiti', 'Segoe UI', Arial, sans-serif !important;
  font-weight: 900 !important;
  -webkit-text-stroke: 0.55px currentColor;
  paint-order: stroke fill;
  text-shadow: 0.35px 0 currentColor, -0.35px 0 currentColor;
}


/* ===== ЧАТ ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100% - 50px);
  margin-top: 20px;
  border: 2px solid #000;
  background: #f5f5f5;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  min-height: 300px;
  max-height: 100%;
  background: #ffffff;
}

.chat-message {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-left: 3px solid #000;
  background: #fafafa;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message .msg-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 4px;
}

.chat-message .msg-username {
  font-weight: bold;
  color: #000;
}

.chat-message .msg-time {
  font-size: 0.7rem;
  color: #999;
}

.chat-message .msg-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-message.system {
  background: #f0f0f0;
  border-left-color: #999;
  color: #666;
  font-style: italic;
}

.chat-loading {
  text-align: center;
  color: #999;
  padding: 20px;
}

.chat-input-area {
  padding: 10px;
  background: #fff;
  border-top: 2px solid #000;
}

.chat-status {
  font-size: 0.8rem;
  margin-bottom: 5px;
  min-height: 20px;
}

.chat-status.error {
  color: #ff0000;
}

.chat-status.success {
  color: #00aa00;
}

.chat-status.banned {
  color: #ff0000;
  font-weight: bold;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

#chatInput {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #000;
  font-size: 0.95rem;
  background: #fff;
  color: #000;
}

#chatInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border: 2px solid #000;
  background: #fff;
  color: #000;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-send-btn:hover:not(:disabled) {
  background: #000;
  color: #fff;
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-limits {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #666;
  margin-top: 5px;
  padding: 0 4px;
}

#charCounter {
  color: #666;
}

#charCounter.near-limit {
  color: #ff9900;
}

#charCounter.over-limit {
  color: #ff0000;
}


/* МОБИЛЬНЫЙ АДАПТИВ */
@media (max-width: 1080px) {
  .vcr-overlay {
    font-size: 0.8rem;
  }
}

@media (max-width: 885px) {
  .camera-stage.multi {
    height: 86vw;
  }

  .topbar {
    font-size: 1.5rem;
  }
}

/* МОБИЛЬНЫЙ АДАПТИВ */
@media (max-width: 768px) {
  .monitor-shell {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
  }

  .camera-stage.multi {
    height: 100vw;
  }

  .vcr-overlay {
    font-size: 0.8rem;
  }

  .sidebar {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around;
    width: 100% !important;
    border-top: 2px solid #000;
    border-left: none !important;
    gap: 10px !important;
    padding: 10px !important;
    overflow: hidden;
  }


  .side-panel {
    top: 40px;
    bottom: 80px;
    width: 100%;
  }

  .topbar {
    font-size: 1rem;
  }

  .ticker-text.animate {
    animation: ticker-move 15s linear infinite;
  }

  .chat-messages {
    min-height: 200px;
    max-height: 300px;
  }

  #chatInput {
    font-size: 0.9rem;
  }

  .chat-send-btn {
    width: 40px;
    height: 40px;
  }
}


/* МОБИЛЬНЫЙ АДАПТИВ */
@media (max-width: 560px) {
  .camera-stage.multi {
    height: 110vw;
  }

  .vcr-overlay {
    font-size: 0.6rem;
  }

  .sidebar .menu-button {
    flex: none !important;
    width: 60px !important;
  }

  .sidebar .menu-button b {
    font-size: 0.6rem;
  }
}