/* Стили онлайн-платформы: лобби (#onlineGameView) и партия (#gameRouteView). */

/* Атрибут hidden должен побеждать наши display: flex/grid. */
#onlineGameView [hidden],
#gameRouteView [hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- Лобби -- */

.ol-lobby {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.ol-header h1 {
  margin: 4px 0 0;
}

.ol-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ol-conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  cursor: default;
  white-space: nowrap;
}

.ol-conn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.ol-conn[data-state="on"]::before {
  background: #5dd39e;
  box-shadow: 0 0 8px rgba(93, 211, 158, 0.8);
}

.ol-conn[data-state="connecting"]::before {
  background: #e8c266;
  animation: ol-pulse 1.1s ease-in-out infinite;
}

.ol-conn[data-state="off"] {
  cursor: pointer;
}

.ol-conn[data-state="off"]::before {
  background: var(--danger);
}

@keyframes ol-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.ol-profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.ol-profile:hover {
  background: var(--button-hover);
  border-color: var(--accent);
}

.ol-profile-name {
  font-weight: 600;
}

.ol-profile-rating {
  font-weight: 800;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.ol-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(122, 162, 247, 0.55);
  background: rgba(122, 162, 247, 0.1);
  border-radius: var(--radius);
  font-weight: 600;
}

.ol-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.ol-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ol-card h2 {
  margin: 0;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ol-quick { grid-column: 1; }
.ol-custom { grid-column: 1; }
.ol-challenges { grid-column: 2; grid-row: 1; }
.ol-live { grid-column: 2; }
.ol-players { grid-column: 2; }
.ol-top { grid-column: 1; }

.ol-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.ol-tc-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.ol-tc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.ol-tc-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--button-hover);
}

.ol-tc-tile.waiting {
  border-color: var(--accent);
  background: var(--button-active);
  animation: ol-pulse 1.4s ease-in-out infinite;
}

.ol-tc-label {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ol-tc-kind {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ol-queue {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(122, 162, 247, 0.07);
}

.ol-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(122, 162, 247, 0.3);
  border-top-color: var(--accent);
  animation: ol-spin 0.9s linear infinite;
  flex: none;
}

@keyframes ol-spin {
  to { transform: rotate(360deg); }
}

/* Кнопки */

.ol-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  background: var(--button-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease, transform 130ms ease;
  white-space: nowrap;
}

.ol-button:hover:not(:disabled) {
  background: var(--button-hover);
  border-color: var(--accent);
}

.ol-button:active:not(:disabled) {
  transform: translateY(1px);
}

.ol-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ol-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131c;
}

.ol-button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.ol-button.danger {
  border-color: rgba(239, 107, 115, 0.55);
  color: var(--danger);
}

.ol-button.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.ol-button.ghost {
  background: transparent;
}

.ol-button.small {
  padding: 6px 12px;
  font-size: 0.84rem;
}

/* Форма своей партии */

.ol-form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.ol-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.ol-select,
.ol-input {
  padding: 9px 12px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.ol-select:focus,
.ol-input:focus {
  outline: none;
  border-color: var(--accent);
}

.ol-color-picker {
  display: inline-flex;
  gap: 6px;
}

.ol-color-option {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.ol-color-option:hover {
  background: var(--button-hover);
}

.ol-color-option.active {
  border-color: var(--accent);
  background: var(--button-active);
}

.ol-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  padding-bottom: 10px;
}

.ol-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.ol-form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.ol-link-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: rgba(122, 162, 247, 0.06);
}

.ol-link-output {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  word-break: break-all;
  user-select: all;
}

.ol-lan-hint {
  word-break: break-all;
}

.ol-status {
  font-size: 0.82rem;
  color: var(--accent-strong);
}

/* Списки лобби */

.ol-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.ol-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.ol-row.compact {
  padding: 7px 12px;
}

.ol-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ol-row-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-row-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.ol-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 12px 0;
}

.ol-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--button-active);
  padding: 2px 9px;
  border-radius: 999px;
}

.ol-top-list {
  margin: 0;
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ol-top-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}

.ol-top-list strong {
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.ol-offline-note {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid rgba(239, 107, 115, 0.45);
  background: var(--danger-soft);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
}

.ol-offline-note code {
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 5px;
}

/* Диалоги */

.ol-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(10, 12, 16, 0.66);
  backdrop-filter: blur(3px);
}

.ol-dialog {
  width: min(440px, calc(100vw - 40px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow);
}

.ol-dialog h2 {
  margin: 0;
}

/* ---------------------------------------------------------------- Партия -- */

.ol-game {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ol-game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ol-game-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.ol-game-tc {
  font-weight: 700;
  color: var(--text);
}

.ol-game-pending {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 60px 0;
  color: var(--muted);
}

.ol-game-layout {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(280px, 360px);
  gap: 20px;
  align-items: start;
  justify-content: center;
}

.ol-board-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.ol-board {
  width: min(70vmin, 640px);
}

.ol-board .piece {
  cursor: default;
}

.ol-board .piece.can-move {
  cursor: pointer;
}

.ol-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.ol-player-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px rgba(122, 162, 247, 0.12);
}

.ol-player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5dd39e;
  flex: none;
}

.ol-player-dot[data-connected="false"] {
  background: var(--danger);
}

.ol-player-piece {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex: none;
  border: 2px solid var(--border);
}

.ol-player-piece[data-side="white"] {
  background: radial-gradient(circle at 32% 30%, #fff, var(--white-piece) 58%, var(--white-piece-edge));
}

.ol-player-piece[data-side="black"] {
  background: radial-gradient(circle at 32% 30%, #4a5160, var(--black-piece) 58%, var(--black-piece-edge));
}

.ol-player-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-player-rating {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ol-player-clock {
  margin-left: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.ol-player-clock.running {
  color: var(--text);
  border-color: var(--accent);
  background: var(--button-active);
}

.ol-player-clock.low {
  color: var(--danger);
  border-color: var(--danger);
  animation: ol-pulse 0.6s ease-in-out infinite;
}

/* Боковая панель партии */

.ol-side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ol-side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ol-side-heading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.ol-moves,
.ol-chat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ol-move-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.ol-move-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 5px;
}

.ol-move-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.025);
}

.ol-move-num {
  color: var(--muted);
}

.ol-game-actions {
  display: flex;
  gap: 10px;
}

.ol-game-actions .ol-button {
  flex: 1;
}

.ol-offer-box {
  padding: 12px 14px;
  border: 1px solid rgba(122, 162, 247, 0.55);
  background: rgba(122, 162, 247, 0.1);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-weight: 600;
}

.ol-chat {
  flex: 1;
  min-height: 180px;
}

.ol-chat-log {
  flex: 1;
  min-height: 110px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.86rem;
}

.ol-chat-line {
  display: flex;
  gap: 7px;
  align-items: baseline;
}

.ol-chat-author {
  font-weight: 700;
  color: var(--muted);
  flex: none;
}

.ol-chat-author[data-side="white"] {
  color: #e8e3d2;
}

.ol-chat-author[data-side="black"] {
  color: var(--accent-strong);
}

.ol-chat-text {
  word-break: break-word;
}

.ol-chat-form {
  display: flex;
  gap: 8px;
}

.ol-chat-form .ol-input {
  flex: 1;
  min-width: 0;
}

/* Итог партии */

.ol-result-card {
  text-align: center;
  align-items: center;
}

.ol-result-card h2 {
  font-size: 1.6rem;
}

.ol-result-rating {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--danger);
}

.ol-result-rating[data-positive="true"] {
  color: #5dd39e;
}

/* Тост */

.ol-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  z-index: 80;
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.ol-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Адаптивность */

@media (max-width: 1080px) {
  .ol-grid {
    grid-template-columns: 1fr;
  }

  .ol-quick,
  .ol-custom,
  .ol-challenges,
  .ol-live,
  .ol-players,
  .ol-top {
    grid-column: 1;
    grid-row: auto;
  }

  .ol-game-layout {
    grid-template-columns: 1fr;
  }

  .ol-board {
    width: min(92vw, 92vmin);
    margin: 0 auto;
  }

  .ol-tc-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}

@media (max-width: 560px) {
  .ol-player-clock {
    font-size: 1.05rem;
  }

  .ol-card {
    padding: 14px;
  }
}
