:root {
  color-scheme: light;
  --bg: #eef2ec;
  --surface: #ffffff;
  --surface-strong: #f8faf7;
  --ink: #17201c;
  --muted: #68736d;
  --line: #d5ddd5;
  --green: #176b45;
  --green-dark: #0f4e33;
  --gold: #d39c2d;
  --blue: #315c88;
  --red: #b44d4d;
  --shadow: 0 22px 70px rgba(23, 32, 28, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(23, 107, 69, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(49, 92, 136, 0.12), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic",
    "Segoe UI", sans-serif;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: #a8b5ac;
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(49, 92, 136, 0.24);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  min-height: 100vh;
  padding: 28px;
}

.board-area,
.side-panel {
  min-width: 0;
}

.board-area {
  display: grid;
  align-content: center;
  gap: 22px;
}

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

.eyebrow,
.game-header h1,
.side-panel h2,
.status-panel p {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.game-header h1 {
  margin-top: 4px;
  font-size: clamp(32px, 5vw, 58px);
  letter-spacing: 0;
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 124px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  padding: 8px 12px;
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(23, 32, 28, 0.07);
}

.board-wrap {
  width: min(78vh, 100%);
  max-width: 780px;
}

.board-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
}

.board-labels {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.board-labels-top {
  display: grid;
  grid-template-columns: 26px repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  padding-left: 34px;
}

.board-labels-side {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  justify-items: end;
}

.board-labels span {
  display: grid;
  place-items: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  overflow: hidden;
  border: 10px solid #173328;
  border-radius: 8px;
  background: #173328;
  box-shadow: var(--shadow);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 0;
  aspect-ratio: 1;
  border: 1px solid rgba(13, 52, 35, 0.9);
  border-radius: 0;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.09), transparent 32%),
    #178250;
  padding: 0;
  transform: none;
}

.cell:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.46);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.18);
  transform: none;
}

.cell.is-valid::before {
  content: "";
  width: 28%;
  height: 28%;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
}

.cell.is-last::after {
  content: "";
  position: absolute;
  top: 8%;
  right: 8%;
  width: 12%;
  height: 12%;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(23, 32, 28, 0.18);
}

.piece {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  box-shadow:
    inset 0 9px 14px rgba(255, 255, 255, 0.16),
    inset 0 -10px 16px rgba(0, 0, 0, 0.24),
    0 7px 12px rgba(0, 0, 0, 0.25);
}

.piece-black {
  background:
    radial-gradient(circle at 32% 28%, #67716a, transparent 20%),
    #121815;
}

.piece-white {
  background:
    radial-gradient(circle at 32% 28%, #ffffff, transparent 24%),
    #f1f4ef;
}

.disc {
  display: inline-block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.22);
}

.disc-black {
  background: #151a17;
}

.disc-white {
  border: 1px solid #cfd6ce;
  background: #f6f8f5;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.score-panel,
.status-panel,
.controls-panel,
.moves-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 34px rgba(23, 32, 28, 0.07);
}

.score-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.score-card {
  display: grid;
  gap: 4px;
  background: var(--surface);
  padding: 18px;
}

.score-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.score-card strong {
  font-size: 42px;
  line-height: 1;
}

.status-panel,
.controls-panel,
.moves-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.side-panel h2 {
  font-size: 15px;
}

.status-panel p {
  min-height: 52px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.65;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-toggle button.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--green-dark);
  background: var(--green-dark);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.move-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  margin: 0;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.move-list li {
  display: grid;
  grid-template-columns: 34px 38px 1fr 46px;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 800;
}

.move-number {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  border-radius: 6px;
  background: #e8efe8;
  color: var(--muted);
}

.move-player,
.move-flips {
  color: var(--muted);
}

.move-empty {
  grid-template-columns: 1fr !important;
  color: var(--muted);
}

@media (max-width: 960px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .board-area {
    align-content: start;
  }

  .board-wrap {
    width: min(100%, 720px);
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .moves-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .game-shell {
    gap: 18px;
    padding: 16px;
  }

  .game-header {
    align-items: start;
    flex-direction: column;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .board-row {
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 5px;
  }

  .board-labels-top {
    grid-template-columns: 20px repeat(8, 1fr);
    gap: 5px;
    padding-left: 25px;
  }

  .board {
    border-width: 6px;
  }

  .score-card strong {
    font-size: 36px;
  }
}
