* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 10%, #163e30 0%, #081b15 55%, #04100c 100%);
  color: #f3f7f5;
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  width: min(94vw, 880px);
}

.board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  background: #0b5d3b;
  border: 7px solid #173d2c;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.42),
    0 3px 0 rgba(255, 255, 255, 0.04) inset;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(0, 0, 0, 0.5);
  border-bottom: 1px solid rgba(0, 0, 0, 0.5);
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.04), transparent 38%),
    linear-gradient(135deg, #126b47, #0d5a3b);
}

.cell:nth-child(8n) {
  border-right: 0;
}

.cell:nth-last-child(-n + 8) {
  border-bottom: 0;
}

.scene {
  width: 78%;
  height: 78%;
  perspective: 700px;
}

.disc {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition:
    transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.25s ease;
  cursor: pointer;
  outline: none;
}

.disc:hover {
  filter: brightness(1.06);
}

.disc.flipped {
  transform: rotateY(180deg);
}

.disc.white-up {
  transform: rotateY(180deg);
}

.disc.white-up.flipped {
  transform: rotateY(0deg);
}

.disc:focus-visible {
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85);
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow:
    0 7px 10px rgba(0, 0, 0, 0.38),
    inset 0 2px 3px rgba(255, 255, 255, 0.22),
    inset 0 -3px 6px rgba(0, 0, 0, 0.3);
}

.face.black {
  background:
    radial-gradient(circle at 35% 28%, #585858 0%, #252525 28%, #090909 70%, #000 100%);
}

.face.white {
  background:
    radial-gradient(circle at 35% 28%, #fff 0%, #ededed 42%, #c9c9c9 72%, #aaa 100%);
  transform: rotateY(180deg);
}

.hint {
  margin: 0;
  min-height: 1.35em;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .disc {
    transition: none;
  }
}

/* --- panel sterowania i status ------------------------------------------- */

.panel {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

.setup,
.run {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.66);
}

.panel select,
.panel button {
  font: inherit;
  font-size: 14px;
  color: #f3f7f5;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  padding: 7px 11px;
  cursor: pointer;
}

.panel button:hover:not(:disabled),
.panel select:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Rozwinieta lista rysuje system, nie strona: bierze stad kolor tekstu, ale
   tlo maluje wlasne, jasne - jasnoszare napisy na bialym byly nieczytelne.
   color-scheme mowi przegladarce, ze motyw jest ciemny, wiec i liste rysuje
   ciemna. Kolory pozycji ustawiamy dodatkowo, bo nie kazda przegladarka
   uwzglednia samo color-scheme. */
.panel select {
  color-scheme: dark;
}

.panel select option {
  color: #f3f7f5;
  background: #1c2b24;
}

.panel button:disabled {
  opacity: 0.4;
  cursor: default;
}

.panel .auto {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.status-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.status {
  font-size: 15px;
}

.score {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

/* --- podpowiedzi na planszy ---------------------------------------------- */

/* Legalne ruchy pokazujemy tylko wtedy, gdy na ruchu jest czlowiek -
   decyduje o tym serwer, przysylajac liste pol. */
.cell.legal {
  cursor: pointer;
}

.cell.legal::after {
  content: "";
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16) inset;
  transition: transform 0.15s ease, background 0.15s ease;
}

.cell.legal:hover::after {
  transform: scale(1.35);
  background: rgba(255, 255, 255, 0.4);
}

/* Ostatni ruch - zeby nie zgubic wzrokiem, co wlasnie zagral silnik. */
.cell.last {
  box-shadow: inset 0 0 0 2px rgba(255, 214, 102, 0.75);
}

.board.waiting {
  pointer-events: none;
}

/* --- uklad: plansza z oznaczeniami obok listy ruchow --------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 18px;
  align-items: start;
}

/* Ramka: naroznik, etykiety kolumn, naroznik / etykiety wierszy, plansza,
   etykiety wierszy / i to samo od dolu. */
.board-frame {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px;
  grid-template-rows: 20px auto 20px;
  gap: 4px;
  align-items: center;
  justify-items: center;
}

.files,
.ranks {
  display: grid;
  width: 100%;
  height: 100%;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  user-select: none;
}

.files {
  grid-template-columns: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
}

.ranks {
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
}

/* --- lista wykonanych ruchow (zapis jak w szachach) --------------------- */

.moves {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 14px;
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.moves h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.move-list {
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  line-height: 1.55;
}

.move-row {
  display: grid;
  grid-template-columns: 26px 1fr 1fr;
  gap: 6px;
}

.move-row .no {
  color: rgba(255, 255, 255, 0.38);
  text-align: right;
}

/* Ostatni wykonany ruch podswietlamy, zeby latwo bylo znalezc miejsce
   w zapisie po dluzszej partii. */
.move-row .current {
  color: #ffd666;
  font-weight: 600;
}

.move-list .empty {
  color: rgba(255, 255, 255, 0.35);
}

/* Na waskim ekranie zapis schodzi pod plansze. */
@media (max-width: 720px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .moves {
    max-height: 200px;
  }
}

/* --- podglad turnieju ----------------------------------------------------- */

.score-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  padding-bottom: 4px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.score-row .count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #ffd666;
}

/* Partia rozstrzygnieta walkowerem ma gwiazdke; powod w podpowiedzi. */
.move-row [title] {
  cursor: help;
  color: rgba(255, 214, 102, 0.85);
}
