@font-face {
  font-family: "Russian Road Sign";
  src: url("fonts/russianroadsign_medium.otf") format("opentype");
}

/* =========================================== */
/* === ОСНОВНЫЕ СТИЛИ И СБРОСЫ === */
/* =========================================== */

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: white;
  background-color: #000;
  overscroll-behavior: none;
}

* {
  box-sizing: border-box;
}

#game-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.hidden {
  display: none;
}

/* =========================================== */
/* === ПАНОРАМА И ИНТЕРФЕЙС В САЛОНЕ === */
/* =========================================== */

.pano-iframe {
  position: absolute;
  top: -100px;
  left: -100px;
  width: calc(100% + 200px);
  height: calc(100% + 200px);
  border: none;
  transition: opacity 0.7s ease;
  pointer-events: none;
}
#pano0 {
  opacity: 1;
  z-index: 1;
}
#pano1 {
  opacity: 0;
  z-index: 2;
}

#dashboard {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45vh;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 20;
}
#steering-wheel {
  position: absolute;
  height: 380px;
  bottom: -152px;
  z-index: 10;
  transition: transform 0.5s ease-out;
}

/* --- Стрелки навигации --- */
#nav-arrows-container {
  position: relative;
  width: 400px;
  height: 300px;
  bottom: 10vh;
  pointer-events: all;
  z-index: 20;
}
.nav-arrow {
  position: absolute;
  width: 60px;
  height: 60px;
  cursor: pointer;
  transform: translate(-50%, -50%);
  opacity: 0.8;
  transition: opacity 0.2s ease;
}
.nav-arrow:hover {
  opacity: 1;
}
.nav-arrow .arrow-svg {
  width: 100%;
  height: 100%;
}
.nav-arrow .arrow-polyline {
  fill: none;
  stroke: white;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-arrow .arrow-outline {
  fill: none;
  stroke: black;
  stroke-width: 20;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-arrow.backward {
  left: 50%;
  top: 100%;
  transform: translate(-50%, -150%) rotate(180deg);
}
#arrow-tooltip {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.8);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 15px;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}

/* --- Гудок --- */
#horn-vote-area {
  position: absolute;
  left: 50%;
  bottom: -90px;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 120px;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  z-index: 30;
  transition: background-color 0.2s;
}
#horn-vote-area:hover {
  background-color: rgba(255, 255, 255, 0.2);
}
#horn-vote-area:active {
  background-color: rgba(255, 255, 255, 0.3);
}

/* --- Висюльки --- */
#pendant-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 10;
  pointer-events: none;
}
#pendant-container .draggable {
  visibility: hidden;
}

/* --- Стили для самих висюлек --- */
.draggable {
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
  user-select: none;
  pointer-events: auto;
}
.draggable:active {
  cursor: grabbing;
  z-index: 50;
}

.dice-flat {
  width: 50px;
  height: 50px;
  background-color: #fafafa;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15);
  display: grid;
  padding: 5px;
  box-sizing: border-box;
}
.dot {
  width: 10px;
  height: 10px;
  background-color: #333;
  border-radius: 50%;
  justify-self: center;
  align-self: center;
}
.face-2 {
  grid-template-areas: "a . ." ". . ." ". . b";
}
.face-2 .dot:nth-of-type(1) {
  grid-area: a;
}
.face-2 .dot:nth-of-type(2) {
  grid-area: b;
}
.face-3 {
  grid-template-areas: "a . ." ". b ." ". . c";
}
.face-3 .dot:nth-of-type(1) {
  grid-area: a;
}
.face-3 .dot:nth-of-type(2) {
  grid-area: b;
}
.face-3 .dot:nth-of-type(3) {
  grid-area: c;
}

#air-freshener {
  width: 70px;
  height: auto;
  filter: drop-shadow(2px 2px 5px rgba(0, 0, 0, 0.2));
}
#lines-svg {
  width: 100%;
  height: 100%;
}
#lines-svg line {
  stroke: #555;
  stroke-width: 1;
  stroke-linecap: round;
}

/* =========================================== */
/* === ВЕРХНИЙ ИНТЕРФЕЙС (ШАПКА) === */
/* =========================================== */

/* --- Общие стили для дорожных знаков --- */
.road-sign-container {
  padding: 3px;
  background: #cccccc;
  border-radius: 4px;
  filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.4));
}

/* --- Позиционирование элементов шапки (ДЕКСТОП > 900px) --- */
#location-display {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: top 0.3s ease, left 0.3s ease, transform 0.3s ease;
  width: 100%; /* Заставляем блок занимать всю ширину */
  max-width: 500px; /* Но не более 500px на больших экранах */
  padding: 0 20px;
}
.road-sign-blue {
  width: 100%; /* Занимает всю ширину родителя #location-display */
  display: -webkit-box;
  -webkit-line-clamp: 2; /* Ограничиваем двумя строками */
  line-clamp: 2; /* Стандартное свойство для ограничения строк */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  background-color: #0058a3;
  color: white;
  border: 2px solid white;
  border-radius: 5px;
  padding: 8px 25px;
  font-family: "Russian Road Sign", "Roboto Condensed", sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
  font-size: 20px;
  /* min-width: 200px; */
}
.road-sign-white-plate {
  background-color: white;
  color: black;
  border: 2px solid black;
  border-radius: 2px;
  padding: 5px 15px;
  font-family: "Russian Road Sign", "Roboto Condensed", sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
  font-size: 19px;
  /* min-width: 180px; */
  white-space: nowrap; /* Улица обычно короткая, не переносим */
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

#driver-count-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 51;
  background-color: #00a700;
  border: 3px solid white;
  border-radius: 5px;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 15px;
  font-size: 19px;
  font-family: "Russian Road Sign", sans-serif;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
  transition: top 0.3s ease, right 0.3s ease;
}

#voting-panel {
  position: absolute;
  top: 100px;
  right: 10px;
  width: 320px;
  z-index: 50;
  background-color: white;
  color: black;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
  font-family: "Russian Road Sign", sans-serif;
  border: 2px solid black;
  outline: 4px solid white;
  transition: top 0.3s ease, right 0.3s ease, left 0.3s ease,
    transform 0.3s ease;
}
#voting-panel h3 {
  color: black;
  margin: 0;
  padding: 5px 10px 8px 10px;
  font-size: 19px;
  font-weight: normal;
  text-align: center;
  border-bottom: 2px solid black;
}
#voting-options {
  list-style: none;
  margin: 10px 0 5px 0;
  padding: 0;
}
.voting-option {
  color: black;
  margin-bottom: 10px;
  font-size: 17px;
}
.option-label {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}
.option-name {
  display: flex;
  align-items: center;
  gap: 8px;
}
.option-votes {
  margin-left: auto;
  padding-left: 10px;
}
.progress-bar {
  background-color: #e0e0e0;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.progress-fill {
  background-color: black;
  height: 100%;
  width: 0%;
  transition: width 0.5s ease;
}
.direction-icon {
  font-family: "Material Icons";
  font-size: 20px;
  display: inline-block;
  color: black;
}

/* =========================================== */
/* === НИЖНИЕ ВИДЖЕТЫ (КАРТА, РАДИО) === */
/* =========================================== */

#map-container {
  width: 100%;
  height: 100%;
  border: 2px solid white;
  border-radius: 8px;
  overflow: hidden;
}
#custom-info-btn {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  background-color: rgba(255, 255, 255, 0.7);
  color: black;
  border-radius: 50%;
  cursor: pointer;
  z-index: 101;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
}
#custom-info-btn:hover {
  background-color: white;
}
#custom-attribution-panel {
  position: absolute;
  bottom: 5px;
  right: 32px;
  background-color: rgba(255, 255, 255, 0.8);
  color: black;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  z-index: 101;
}
#custom-attribution-panel p {
  margin: 0;
}
#custom-attribution-panel a {
  color: #0078a8;
  text-decoration: none;
}
#custom-attribution-panel a:hover {
  text-decoration: underline;
}
.car-icon-marker {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
}

#map-widget-container,
#right-dashboard-widgets {
  position: absolute;
  bottom: 10px;
  z-index: 50;
  transition: transform 0.4s ease-in-out;
}
#map-widget-container {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 250px;
  height: 180px;
  z-index: 50;
  transition: transform 0.4s ease-in-out;
}
#right-dashboard-widgets {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 50;
  transition: transform 0.4s ease-in-out;

  /* Эти стили нужны, чтобы обертка приняла размеры дочерних элементов */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
#top-widgets-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#donate-button-da {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.9;
}
#donate-button-da img {
  width: 100%;
  height: auto;
}

#odometer-container {
  display: flex;
  align-items: center; /* Выравниваем запятую и "км" по центру */
  background-color: #1a1a1a;
  padding: 5px 10px; /* Уменьшаем вертикальные отступы */
  border-radius: 5px;
  border: 1px solid #444; /* Делаем рамку тоньше */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  pointer-events: all;
  font-family: "Roboto Mono", monospace;
  font-weight: 700;
}
.odometer-digit {
  width: 15px; /* Уменьшаем ширину цифры */
  height: 25px; /* Уменьшаем высоту цифры */
  background-color: #000;
  border: 1px solid #333;
  color: #f0f0f0;
  font-size: 20px; /* Уменьшаем шрифт */
  line-height: 25px; /* Выравниваем по новой высоте */
  text-align: center;
  margin: 0 1px;
  perspective: 100px;
}
.odometer-digit-separator,
.odometer-unit {
  color: #f0f0f0;
  font-size: 24px;
  line-height: 30px;
  padding: 0 2px;
}
.odometer-unit {
  margin-left: 4px;
  font-size: 16px; /* "км" делаем еще меньше */
}
.digit-flip {
  animation: flip 0.4s ease-out;
}
@keyframes flip {
  from {
    transform: translateY(-50%) rotateX(90deg);
    opacity: 0;
  }
  to {
    transform: translateY(0) rotateX(0deg);
    opacity: 1;
  }
}

#radio-player {
  width: 280px;
  background-color: #1a1a1a;
  border: 2px solid #444;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  pointer-events: all;
}
#radio-screen {
  background-color: #002b00;
  color: #33ff33;
  font-family: "Courier New", Courier, monospace;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  margin-bottom: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#radio-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.radio-btn {
  background: #333;
  border: 1px solid #555;
  color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}
.radio-btn:active {
  background: #555;
}
.volume-control {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #888;
}
#volume-slider {
  width: 100px;
}

/* =========================================== */
/* === УВЕДОМЛЕНИЯ И ПРОЧЕЕ === */
/* =========================================== */

#vote-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  color: white;
  text-shadow: 0 0 5px black, 0 0 10px black, 1px 1px 1px black;
  font-family: "PT Sans Caption", sans-serif;
  font-size: 32px;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#vote-feedback.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.widget-toggle-btn {
  display: none; /* Скрыты на десктопе */
  position: absolute;
  top: 0;
  width: 40px;
  height: 50px;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: 2px solid white;
  cursor: pointer;
  z-index: 60;
  justify-content: center;
  align-items: center;
}
#map-toggle-btn {
  left: 100%;
  margin-left: -2px;
  border-radius: 0 10px 10px 0;
}
#radio-toggle-btn {
  right: 100%;
  margin-right: -2px;
  border-radius: 10px 0 0 10px;
}

/* =========================================== */
/* === ЭКРАН ОШИБКИ СОЕДИНЕНИЯ === */
/* =========================================== */

#connection-error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85); /* Полупрозрачный темный фон */
  z-index: 200; /* Поверх абсолютно всего */

  display: flex;
  justify-content: center;
  align-items: center;

  /* Плавное появление */
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

#connection-error-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.error-panel {
  color: white;
  text-align: center;
  font-family: "PT Sans Caption", sans-serif;
  max-width: 400px;
  padding: 20px;
}

.error-panel .material-icons {
  font-size: 80px;
  color: #ff5252; /* Красный цвет для иконки ошибки */
}

.error-panel h1 {
  margin-top: 10px;
  margin-bottom: 10px;
  font-size: 28px;
}

.error-panel p {
  font-family: sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #ccc;
}

#reconnect-btn {
  margin-top: 20px;
  padding: 12px 25px;
  font-size: 16px;
  font-family: "PT Sans Caption", sans-serif;
  font-weight: bold;
  color: black;
  background-color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#reconnect-btn:hover {
  background-color: #ccc;
}

#reconnect-btn:disabled {
  background-color: #555;
  color: #888;
  cursor: not-allowed;
}

#reconnect-timer {
  margin-top: 15px;
  font-size: 14px;
  color: #888;
  height: 20px; /* Резервируем место */
}

/* =========================================== */
/* === АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ === */
/* =========================================== */

@media (max-width: 900px) {
  /* --- Компоновка шапки --- */
  #driver-count-panel {
    padding: 4px 10px;
    font-size: 16px;
    gap: 6px;
  }
  #location-display {
    top: 52px;
  }
  .road-sign-blue {
    font-size: 16px;
    padding: 6px 15px;
    min-width: 150px;
  }
  .road-sign-white-plate {
    font-size: 15px;
    padding: 4px 12px;
    min-width: 130px;
  }

  #voting-panel {
    top: 160px; /* <-- Как у Нила, жесткий отступ сверху */
    right: 10px; /* Прижимаем к правому краю */
    left: auto; /* Сбрасываем центрирование */
    transform: none; /* Сбрасываем центрирование */
    width: 175px;
  }
  #voting-panel h3 {
    font-size: 16px;
  }
  /* .voting-option {
    font-size: 14px;
  } */
  .voting-option .option-name-text {
    display: none;
  }
  /* .direction-icon {
    font-size: 22px;
  } */

  /* --- Скрытие виджетов --- */
  .widget-toggle-btn {
    display: flex;
  }

  #map-widget-container {
    left: 0;
    bottom: 250px;
  }
  #right-dashboard-widgets {
    right: 0;
  }

  /* Прячем ОБЕРТКИ, а не внутренние блоки */
  #map-widget-container:not(.open) {
    /* Двигаем на ширину самого себя (250px) */
    transform: translateX(-250px);
  }
  #right-dashboard-widgets:not(.open) {
    /* Двигаем на ширину самого себя. Ширина радио = 280px */
    transform: translateX(280px);
  }

  #map-widget-container.open,
  #right-dashboard-widgets.open {
    transform: translateX(0);
  }
  /* Скрываем игральные кости */
  #dice1,
  #dice2 {
    display: none !important; /* Используем !important на всякий случай, если есть другие правила */
  }

  /* Скрываем веревочки для костей */
  #line_dice1,
  #line_dice2 {
    display: none !important;
  }
}
