:root {
  --board-size: min(92vw, 620px);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px 420px at 15% 15%, rgba(77, 111, 181, 0.16), transparent 60%),
    radial-gradient(560px 420px at 85% 5%, rgba(45, 81, 150, 0.18), transparent 65%);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
}

.topbar {
  position: static;
  padding: 12px 12px 10px;
}

.topbar__inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(233, 238, 252, 0.14);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(17, 26, 46, 0.85), rgba(12, 18, 34, 0.9));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

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

.logo {
  font-size: 20px;
  opacity: 0.9;
}

.topbar__titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar__title {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 16px;
}

.topbar__subtitle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}

.topbar__actions,
.topbar__status {
  display: none;
}

.pill {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  white-space: nowrap;
}

.pill.good {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}

.pill.warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
}

.home-btn {
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  border: 1px solid rgba(233, 238, 252, 0.28);
  background: rgba(17, 26, 46, 0.85);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.home-btn:hover { background: rgba(25, 38, 65, 0.9); }
.home-btn:active { transform: translateY(1px); }

.home-ico {
  font-size: 18px;
  font-weight: 700;
}

@media (max-width: 520px){
  .home-btn{
    padding: 0 12px;
  }
  .topbar__title { font-size: 15px; }
  .topbar__subtitle { font-size: 11px; }
}

@media (max-width: 720px){
  .topbar__inner {
    align-items: center;
  }
  .topbar__left { width: 100%; }
}

.side {
  width: 300px;
}

.btn.full {
  width: 100%;
}

.side-lockable.is-locked {
  pointer-events: none;
  opacity: 0.55;
  filter: saturate(0.8);
}

.side-lockable.is-locked .pill,
.side-lockable.is-locked .chip {
  opacity: 0.7;
}

.side-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.field-label {
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.select,
.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(7, 12, 24, 0.62);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.input::placeholder { color: rgba(230, 237, 247, 0.5); }

.btn.small {
  padding: 7px 12px;
  font-size: 12px;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.board, .board * {
  touch-action: none;
}

.chat-list {
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}
.chat-msg {
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 6px;
}
.chat-msg:last-child { margin-bottom: 0; }
.chat-meta { font-weight: 700; margin-right: 6px; }
.chat-meta.white { color: #e5e7eb; }
.chat-meta.black { color: #93c5fd; }
.chat-row { display: flex; gap: 6px; }
.chat-row .input { flex: 1; min-width: 0; }
.chat-note { font-size: 11px; opacity: 0.75; }

#rtStart,
#rtStartBtn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  opacity: 1;
  transition: all 0.2s ease;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
}

#rtStart:hover:not(:disabled),
#rtStartBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45);
}

#rtStart:disabled,
#rtStartBtn:disabled {
  background: linear-gradient(135deg, #475569, #334155);
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.9));
  border-color: rgba(59, 130, 246, 0.6);
  color: #eef2ff;
  box-shadow: 0 10px 18px rgba(30, 64, 175, 0.35);
}

.btn.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}

.modal.show {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 14, 0.68);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(92vw, 420px);
  padding: 20px;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(18, 27, 50, 0.95), rgba(10, 14, 26, 0.98));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.modal-winner {
  font-weight: 700;
  color: var(--text);
}

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

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.divider {
  height: 1px;
  width: 100%;
  background: var(--line);
  opacity: 0.7;
}

.rt-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rt-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.rt-row:nth-of-type(2) {
  grid-template-columns: 1fr auto;
}

.rt-row:nth-of-type(3) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.captures {
  gap: 12px;
}

.capture-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capture-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.capture-row.lead {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.12);
}

.board-card {
  padding: 18px;
  background: linear-gradient(180deg, rgba(18, 27, 50, 0.85), rgba(10, 14, 26, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.45);
}

body[data-game="dama"] .board {
  position: relative;
  border-radius: 14px;
  border: 2px solid #6a3e20;
  box-shadow:
    inset 0 0 0 2px #3b200e,
    inset 0 14px 30px rgba(0, 0, 0, 0.6),
    0 18px 30px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, #5a351d, #3e2414);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  overscroll-behavior: contain;
}

body[data-game="dama"] .board::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(120deg, rgba(255, 255, 255, 0.05), transparent 40%),
    linear-gradient(300deg, rgba(255, 255, 255, 0.04), transparent 45%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.07) 0 1px, transparent 1px 6px);
  pointer-events: none;
}

body[data-game="dama"] .cell.light {
  background-color: #d5a86d;
  background-image:
    linear-gradient(135deg, #deb277, #c89359),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 7px);
}

body[data-game="dama"] .cell.dark {
  background-color: #8b5629;
  background-image:
    linear-gradient(135deg, #8f582b, #6a3d1f),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0 1px, transparent 1px 7px);
}

body[data-game="dama"] .cell.selected {
  outline: 2px solid rgba(252, 211, 77, 0.9);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.4), 0 0 12px rgba(252, 211, 77, 0.35);
}

body[data-game="dama"] .cell.last {
  box-shadow: inset 0 0 0 2px rgba(125, 211, 252, 0.7), 0 0 12px rgba(56, 189, 248, 0.25);
}

body[data-game="dama"] .cell.move::after,
body[data-game="dama"] .cell.capture::after {
  width: 32%;
  height: 32%;
  border-radius: 999px;
}

body[data-game="dama"] .cell.move::after {
  background: rgba(34, 197, 94, 0.8);
  box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.25);
}

body[data-game="dama"] .cell.capture::after {
  background: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 0 7px rgba(239, 68, 68, 0.25);
}

body[data-game="dama"] .board.disabled {
  filter: saturate(0.7) brightness(0.9);
  pointer-events: none;
}

body[data-game="dama"] .cell.dragging .piece {
  opacity: 0.2;
}

body[data-game="dama"] .piece {
  position: relative;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  font-weight: 800;
  font-size: 18px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}

body[data-game="dama"] .piece.white::after {
  content: "HS";
  position: absolute;
  bottom: 10%;
  right: 12%;
  font-size: 9px;
  letter-spacing: 0.5px;
  opacity: 0.12;
  color: rgba(255, 255, 255, 0.8);
}

body[data-game="dama"] .piece.white {
  background:
    radial-gradient(circle at 30% 30%, #ffffff 0%, #dfe7f7 40%, #b7c2d9 100%);
  color: #1b2233;
  box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.65), 0 10px 18px rgba(0, 0, 0, 0.35);
}

body[data-game="dama"] .piece.black {
  background:
    radial-gradient(circle at 30% 30%, #67748c 0%, #2a3447 45%, #0c121b 100%);
  color: #f3f4f6;
  box-shadow: inset 0 3px 6px rgba(255, 255, 255, 0.15), 0 10px 18px rgba(0, 0, 0, 0.45);
}

body[data-game="dama"] .piece.king {
  border: 2px solid rgba(250, 204, 21, 0.85);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.18),
    0 0 18px rgba(250, 204, 21, 0.4);
}

body[data-game="dama"] .piece.white.king::after {
  opacity: 0.42;
  color: rgba(250, 204, 21, 0.9);
}

body[data-game="dama"] .piece.ghost {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  opacity: 0.92;
  transform: scale(1.08);
}

@media (max-width: 960px) {
  .side { width: min(92vw, 520px); }
}

@media (max-width: 720px) {
  .rt-row {
    grid-template-columns: 1fr;
  }
  .rt-row:nth-of-type(2),
  .rt-row:nth-of-type(3) {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .home-text { display: none; }
  .home-btn {
    width: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}