/* Circuit Builder */

.circuit-container {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  min-height: 420px;
}

.circuit-wrapper {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 12px;
  margin-top: 20px;
  height: 920px;
}


.circuit-sidebar {
  width: 260px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 14px;
  border: 1px solid rgba(0, 255, 178, 0.3);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 18px rgba(0, 255, 178, 0.2);
  overflow: hidden;
}



.circuit-sidebar h4 {
  margin: 0 0 8px 0;
}

.circuit-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.circuit-tab {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  cursor: pointer;
  transition: 0.15s;
}

.circuit-tab.active {
  background: rgba(0, 255, 178, 0.15);
  color: #00ffd0;
  box-shadow: 0 0 0 1px rgba(0, 255, 178, 0.4);
}

.circuit-items-grid {
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
  padding-right: 4px;
  padding-bottom: 4px;
}

.circuit-tab-btn.active {
  background: rgba(0, 255, 178, 0.18);
  box-shadow: 0 0 12px rgba(0, 255, 178, 0.45);
}

.circuit-tab-btn {
  flex: 1 1 auto;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 178, 0.25);
  background: transparent;
  color: #dff;
  cursor: pointer;
  transition: 0.15s;
  text-align: center;
}

.components-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.component-item {
  padding: 10px;
  background: rgba(0,255,178,0.15);
  border: 1px solid rgba(0,255,178,0.4);
  border-radius: 8px;
  cursor: grab;
  transition: 0.2s;
  font-size: 14px;
}

.component-item:hover {
  background: rgba(0,255,178,0.25);
  box-shadow: 0 0 12px rgba(0,255,178,0.4);
}

.circuit-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.circuit-workspace {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(0,255,178,0.3);
}

#circuit-canvas {
  width: 100%;
  height: 100%;
  background: #050607;
  cursor: crosshair;
}

/* Контекстное меню конструктора */

.circuit-menu {
  position: fixed;
  z-index: 9999;
  background: rgba(0,0,0,0.9);
  border: 1px solid rgba(0,255,178,0.4);
  border-radius: 10px;
  min-width: 140px;
  padding: 6px 0;
  box-shadow: 0 0 20px rgba(0,255,178,0.3);
  backdrop-filter: blur(6px);
  animation: circuitFadeIn 0.12s ease;
}

.circuit-menu.hidden {
  display: none;
}

.menu-item {
  padding: 8px 14px;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  transition: 0.15s;
}

.menu-item:hover {
  background: rgba(0,255,178,0.15);
  color: var(--accent);
}

.menu-item.danger:hover {
  background: rgba(255,0,70,0.2);
  color: #ff4777;
}

@keyframes circuitFadeIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.circuit-hints {
  margin-top: 10px;
  top: 20px;
  right: 20px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(0,255,178,0.35);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #dff;
  backdrop-filter: blur(5px);
  z-index: 9000;
  pointer-events: none;
  box-shadow: 0 0 15px rgba(0,255,178,0.2);
}
.circuit-hints b {
  color: var(--accent);
}

.circuit-workspace:hover ~ #circuit-hints {
  box-shadow: 0 0 25px rgba(0,255,178,0.4);
}

.circuit-item {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(0, 255, 178, 0.15);
  padding: 4px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
  font-size: 11px;
  text-align: center;
  transition: 0.16s;
}

.circuit-item:hover {
  border-color: rgba(0, 255, 178, 0.6);
  box-shadow: 0 0 12px rgba(0, 255, 178, 0.22);
  transform: translateY(-1px);
}

.circuit-item-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(0, 255, 178, 0.4));
}

.circuit-item-name {
  margin-top: 3px;
}



.circuit-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  pointer-events: none;
}

.circuit-item-label {
  font-size: 10px;
  text-align: center;
  opacity: 0.8;
}

/* рабочее поле */
.circuit-workspace {
  border-radius: 18px;
  border: 1px solid rgba(0, 255, 178, 0.3);
  background: radial-gradient(circle at top, rgba(0, 255, 178, 0.04), transparent 55%),
              #050506;
  overflow: hidden;
  position: relative;
}

#circuit-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

/* ghost при перетаскивании из меню */
.circuit-drag-ghost {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0.9;
}

.circuit-drag-ghost img {
  width: 42px;
  height: 42px;
}


.circuit-context-menu {
  position: absolute;
  background: rgba(0, 0, 0, 0.96);
  border: 1px solid rgba(0, 255, 178, 0.45);
  padding: 6px 0;
  border-radius: 10px;
  z-index: 2000;
  width: 170px;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.8);
}

.circuit-context-menu.hidden {
  display: none;
}

.circuit-context-menu div {
  padding: 6px 12px;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  transition: 0.12s ease;
}

.circuit-context-menu div:hover {
  background: rgba(0,255,178,0.15);
  color: #00ffc8;
}

.circuit-context-menu hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 4px 0;
}

/* ---------- Тулбар над схемой ---------- */

.circuit-toolbar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.circuit-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  background: rgba(0, 255, 178, 0.12);
  color: #e9fffd;
  cursor: pointer;
  transition: 0.15s ease;
}

.circuit-btn:hover {
  background: rgba(0, 255, 178, 0.25);
  box-shadow: 0 0 12px rgba(0, 255, 178, 0.3);
}

.circuit-btn-danger {
  background: rgba(255, 60, 60, 0.18);
}

.circuit-btn-danger:hover {
  background: rgba(255, 60, 60, 0.32);
  box-shadow: 0 0 14px rgba(255, 60, 60, 0.4);
}

.circuit-status {
  margin-left: auto;
  font-size: 13px;
  opacity: 0.85;
}

/* --------- Тултип / мини-превью --------- */

.circuit-tooltip {
  position: fixed;
  max-width: 260px;
  background: rgba(0, 0, 0, 0.96);
  border-radius: 12px;
  border: 1px solid rgba(0,255,178,0.35);
  padding: 10px 12px;
  font-size: 13px;
  z-index: 3000;
  pointer-events: none;
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(0,0,0,0.8);
}

.circuit-tooltip.hidden {
  display: none;
}

.circuit-tooltip-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.circuit-tooltip-body {
  opacity: 0.86;
}

.circuit-tooltip-power {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.75;
}

/* ===== Модалка настройки Branch ===== */

.circuit-modal {
  position: fixed;
  z-index: 3000;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 260px;
  padding: 16px 18px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 255, 178, 0.4);
  background: radial-gradient(circle at top,
    rgba(0, 255, 178, 0.18),
    rgba(3, 5, 9, 0.98));
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.85);
  color: #f4f8ff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.circuit-modal.hidden {
  display: none;
}

.circuit-modal-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}

.circuit-modal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.circuit-modal-row input {
  width: 120px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 178, 0.4);
  background: #020505;
  color: #fff;
}

.circuit-modal-row input:focus {
  border-color: rgba(0, 255, 178, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 255, 178, 0.3);
}

.circuit-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.circuit-modal-actions button {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(0, 255, 178, 0.22);
  color: #eaffff;
  transition:
    background 0.15s ease,
    transform 0.1s ease,
    box-shadow 0.15s ease;
}

.circuit-modal-actions button:hover {
  background: rgba(0, 255, 178, 0.4);
  box-shadow: 0 0 12px rgba(0, 255, 178, 0.4);
  transform: translateY(-1px);
}

.circuit-modal-actions button:last-child {
  background: rgba(255, 255, 255, 0.06);
  color: #d7deff;
}

.circuit-modal-actions button:last-child:hover {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#branch-config {
  max-width: 360px;
  padding: 22px 24px 18px;
  background: rgba(10, 20, 20, 0.96);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(0, 255, 178, 0.25);
}

#branch-config-ok {
  background: var(--accent, #00f5b0);
  color: #020505;
}

#branch-config-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* =========================
   LEADERBOARD / TOP PLAYERS
   ========================= */

#leaderboard {
  position: relative;
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.lb-periods {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lb-period-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 255, 178, 0.4);
}

.lb-period-btn.active {
  background: radial-gradient(circle at 0 0, rgba(0, 255, 178, 0.25), transparent);
  box-shadow: 0 0 18px rgba(0, 255, 178, 0.8);
}

.lb-sort-select {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.85);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
}

/* Таблица */

.lb-table tbody tr:nth-child(2n) {
  background: rgba(8, 14, 16, 0.96);
}

/* Ячейка игрока */

.lb-player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(0, 255, 178, 0.7);
  box-shadow: 0 0 10px rgba(0, 255, 178, 0.6);
}

.lb-player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lb-player-name {
  font-weight: 600;
  font-size: 14px;
}

.lb-player-tag {
  font-size: 11px;
  opacity: 0.7;
}

/* Остальные колонки */

.lb-kd {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
}

.lb-playtime {
  font-size: 12px;
  opacity: 0.85;
}

.lb-rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(
    120deg,
    rgba(255, 215, 0, 0.16),
    rgba(0, 255, 178, 0.16)
  );
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.8);
  font-size: 12px;
}

.lb-rating-badge span {
  font-weight: 600;
}

/* LEADERBOARD */

.leaderboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.lb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.lb-period-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
}

.lb-period-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: 0.18s ease;
}

.lb-period-btn.active {
  background: var(--accent);
  color: #020308;
  border-color: var(--accent);
}

.lb-mode-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-mode-label {
  font-size: 16px;
  color: var(--text-muted);
}

.lb-mode-select {
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  padding: 5px 10px;
  background: rgba(104, 3, 3, 0.7);
  color: var(--text-main);
  border-color: red;
  font-size: 12px;
}



/* table */

.lb-table-wrapper {
  margin-top: 4px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: rgba(3, 4, 10, 0.95);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lb-table thead {
  background: rgba(0, 0, 0, 0.6);
}

.lb-table th,
.lb-table td {
  padding: 6px 10px;
  text-align: left;
}

.lb-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.lb-table tbody tr {
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.lb-table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.01);
}

.lb-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.2);
}

.lb-table tbody tr:hover {
  background: rgba(0, 255, 178, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.7);
}

.lb-row-best {
  box-shadow: 0 0 0 1px rgba(0,255,178,0.5) inset;
  background: linear-gradient(
    90deg,
    rgba(179, 255, 0, 0.171),
    rgba(165, 7, 7, 0.322)
  ) !important;
}

.lb-row-best td:first-child {
  font-weight: 700;
}

/* small dot legend */

.lb-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.lb-dot-pvp {
  background: var(--accent);
}



