/* Checkers: a wooden board, stone pieces (or bright ones). */

:root {
  --plate: #b98a5a;
  --plate-edge: #8e6238;
  --plate-shine: rgba(255, 240, 210, 0.35);
  --hole: #efe2c8;
  --foot: #7a5230;
  --p1: #2b2a2e;
  --p1-edge: #0f0f12;
  --p1-shine: #6b6a70;
  --p2: #f4efe4;
  --p2-edge: #c9bfa9;
  --p2-shine: #ffffff;
  --win: #ffcf3d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --plate: #5a4029;
    --plate-edge: #3a2817;
    --plate-shine: rgba(255, 220, 170, 0.18);
    --hole: #1d1a17;
    --foot: #2d1f13;
  }
}
:root[data-theme='dark'] {
  --plate: #5a4029;
  --plate-edge: #3a2817;
  --plate-shine: rgba(255, 220, 170, 0.18);
  --hole: #1d1a17;
  --foot: #2d1f13;
}
body[data-discs='bright'] {
  --p1: #ec5a3c;
  --p1-edge: #a93520;
  --p1-shine: #ff9c84;
  --p2: #f5c02e;
  --p2-edge: #b98700;
  --p2-shine: #ffe7a1;
  --win: #ffffff;
}
/* Hallows: a plum board in candlelight, pumpkin and moonstone discs. */
:root[data-theme='hallows'] {
  --plate: #3a2a4f;
  --plate-edge: #1c1330;
  --plate-shine: rgba(232, 176, 74, 0.2);
  --hole: #140e24;
  --foot: #1c1330;
  --win: #ffe29a;
}
body[data-discs='hallows'] {
  --p1: #f08a24;
  --p1-edge: #a4520a;
  --p1-shine: #ffc27a;
  --p2: #cdd6ef;
  --p2-edge: #8791b3;
  --p2-shine: #ffffff;
}
:root[data-theme='hallows'] .hw-candle {
  display: none;
}
:root[data-theme='hallows'] .title h1 {
  font-family: var(--font-display);
  letter-spacing: 0;
}

body {
  min-height: var(--app-height);
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
#announce {
  margin: 0;
  top: 0;
}
.app {
  display: flex;
  flex-direction: column;
  height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom));
  min-height: 480px;
  max-width: 760px;
  margin: 0 auto;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 4px;
  flex-wrap: wrap;
}
.title h1 {
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.title small {
  color: var(--text-muted);
  font-size: 0.82rem;
}
.players {
  display: flex;
  gap: 6px;
}
.player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s ease;
}
.player.turn {
  box-shadow: 0 0 0 2px var(--accent);
}
.player-disc,
.result-disc {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.player-disc.p1,
.result-disc.p1 {
  background: radial-gradient(circle at 36% 30%, var(--p1-shine), var(--p1) 55%, var(--p1-edge));
}
.player-disc.p2,
.result-disc.p2 {
  background: radial-gradient(circle at 36% 30%, var(--p2-shine), var(--p2) 55%, var(--p2-edge));
}
.result-disc.draw {
  background: linear-gradient(90deg, var(--p1) 50%, var(--p2) 50%);
}
.player-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.player-text b {
  font-size: 0.9rem;
  white-space: nowrap;
}
.player-text small {
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.status {
  margin: 4px 16px 0;
  min-height: 2.8em;
  font-size: 0.92rem;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: balance;
}

/* ---------- Board ---------- */

.stage {
  flex: 1 1 0;
  display: grid;
  place-items: center;
  padding: 4px 12px;
  min-height: 260px;
  container-type: size;
}
.board-wrap {
  width: min(100cqw, 100cqh, 600px);
  aspect-ratio: 1;
}
.ck-board {
  --light-sq: #ecd9b6;
  --dark-sq: #9a6a3c;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--plate) 85%, #fff), var(--plate) 40%, var(--plate-edge));
  box-shadow: 0 16px 30px -14px rgba(30, 15, 0, 0.5);
}
:root[data-theme='hallows'] .ck-board {
  --light-sq: #3a2d52;
  --dark-sq: #1c1330;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']):not([data-theme='hallows']) .ck-board {
    --light-sq: #8a7458;
    --dark-sq: #4a3522;
  }
}
.ck-sq {
  position: relative;
  appearance: none;
  border: 0;
  padding: 0;
  background: var(--light-sq);
  cursor: default;
}
.ck-sq.dark {
  background: var(--dark-sq);
  cursor: pointer;
}
.ck-sq.from {
  box-shadow: inset 0 0 0 3px var(--win);
}
.ck-sq.to::after {
  content: '';
  position: absolute;
  inset: 34%;
  border-radius: 50%;
  background: var(--win);
  opacity: 0.75;
}
.ck-sq.hint {
  box-shadow: inset 0 0 0 3px var(--accent);
}
.ck-sq.last {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--win) 60%, transparent);
}
.ck-sq.sel .ck-piece {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 0 0 3px var(--win), 0 6px 10px rgba(0, 0, 0, 0.45);
}
.ck-sq.movable .ck-piece {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--win) 70%, transparent), 0 3px 5px rgba(0, 0, 0, 0.45);
}
.ck-piece {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease;
}
.ck-piece.p1 {
  background: radial-gradient(circle at 36% 30%, var(--p1-shine), var(--p1) 55%, var(--p1-edge));
}
.ck-piece.p2 {
  background: radial-gradient(circle at 36% 30%, var(--p2-shine), var(--p2) 55%, var(--p2-edge));
}
.ck-piece::before {
  content: '';
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.ck-piece.p2::before {
  border-color: rgba(0, 0, 0, 0.15);
}
.ck-piece svg {
  width: 52%;
  height: 52%;
  fill: var(--win);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}
.ck-piece.fresh {
  animation: land 0.25s ease;
}
@keyframes land {
  from {
    transform: scale(1.25);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ck-piece,
  .ck-piece.fresh {
    transition: none;
    animation: none;
  }
}

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 8px 8px 12px;
}
.tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 54px;
  min-height: 52px;
  padding: 6px 6px;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.tool svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool:hover:not(:disabled) {
  background: var(--accent-soft);
}
.tool:disabled {
  opacity: 0.38;
  cursor: default;
}
.tool:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- Dialogs ---------- */

.setup .field[hidden] {
  display: none;
}
.small {
  font-size: 0.85rem;
}
.rules ul {
  padding-left: 1.2em;
}
.rules li {
  margin: 6px 0;
}
.result {
  display: flex;
  align-items: center;
  gap: 16px;
}
.result .result-disc {
  width: 56px;
  height: 56px;
}

/* Landscape phones: players and controls beside the board. */
@media (orientation: landscape) and (max-height: 560px) {
  .app {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(200px, 1fr) auto;
    grid-template-rows: min-content 1fr min-content;
    column-gap: 12px;
    min-height: 0;
  }
  .topbar {
    grid-column: 1;
    flex-direction: column;
    align-items: stretch;
  }
  .players {
    flex-direction: column;
  }
  .status {
    grid-column: 1;
    grid-row: 2;
  }
  .toolbar {
    grid-column: 1;
    grid-row: 3;
    flex-wrap: wrap;
  }
  .stage {
    grid-column: 2;
    grid-row: 1 / span 3;
    container-type: normal;
    min-height: 0;
  }
  .board-wrap {
    /* As tall as the screen allows, but never wider than the room beside the side panel. */
    width: min(calc(var(--app-height) - var(--safe-top) - var(--safe-bottom) - 16px), calc(100vw - var(--safe-left) - var(--safe-right) - 240px));
  }
}
/* Your pieces always start at the bottom. */
.ck-board.flipped {
  transform: rotate(180deg);
}
.ck-board.flipped .ck-piece svg {
  transform: rotate(180deg);
}
