:root {
  color-scheme: light;
  --bg: #eef4ef;
  --panel: #ffffff;
  --ink: #172018;
  --muted: #5e6b61;
  --line: #000000;
  --board: #b9e8a7;
  --board-edge: #6fa562;
  --accent: #146c43;
  --accent-2: #d44638;
  --shadow: 0 18px 55px rgba(32, 45, 33, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(20, 108, 67, 0.12), transparent 42%),
    var(--bg);
  color: var(--ink);
  display: flex;
  font-family: Arial, Helvetica, sans-serif;
  justify-content: center;
  padding: 24px;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 310px;
  max-width: 1180px;
  width: 100%;
}

.game-panel,
.controls {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(28, 48, 31, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.game-panel {
  min-width: 0;
  padding: 18px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 3vw, 2.6rem);
  line-height: 1;
}

h2 {
  font-size: 0.95rem;
}

.status-card {
  align-items: center;
  background: #f4faf3;
  border: 1px solid rgba(20, 108, 67, 0.18);
  border-radius: var(--radius);
  display: flex;
  font-weight: 700;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  text-align: right;
}

.board-wrap {
  aspect-ratio: 1;
  margin: 0 auto;
  max-width: min(78vh, 780px);
  position: relative;
  width: 100%;
}

.board {
  background: var(--board);
  border: 3px solid var(--line);
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  height: 100%;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.cell {
  align-items: center;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 0;
  padding: 0;
  position: relative;
}

.cell:nth-child(11n) {
  border-right: 0;
}

.cell:nth-last-child(-n + 11) {
  border-bottom: 0;
}

.cell:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: -4px;
  z-index: 2;
}

.cell:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.stone {
  border-radius: 50%;
  display: block;
  height: 76.923%;
  width: 76.923%;
}

.stone.white {
  background:
    radial-gradient(circle at 34% 30%, #ffffff 0 18%, #f5f5f5 35%, #dcdcdc 100%);
  border: 1px solid rgba(0, 0, 0, 0.72);
  box-shadow: inset -5px -6px 10px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.18);
}

.stone.black {
  background:
    radial-gradient(circle at 32% 26%, #747474 0 10%, #1e1e1e 42%, #000000 100%);
  border: 1px solid #000;
  box-shadow: inset 4px 5px 10px rgba(255, 255, 255, 0.12), 0 2px 4px rgba(0, 0, 0, 0.25);
}

.last-move::after {
  background: var(--accent-2);
  border-radius: 50%;
  content: "";
  height: 16%;
  left: 42%;
  position: absolute;
  top: 42%;
  width: 16%;
}

.win-line {
  background: var(--accent-2);
  border-radius: 999px;
  height: 6px;
  left: var(--line-left);
  pointer-events: none;
  position: absolute;
  top: var(--line-top);
  transform: translate(-50%, -50%) rotate(var(--line-angle));
  transform-origin: center;
  width: var(--line-width);
  z-index: 4;
}

.controls {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.control-group {
  border-bottom: 1px solid rgba(23, 32, 24, 0.1);
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
}

.control-group:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.segmented,
.color-choice,
.actions {
  display: grid;
  gap: 8px;
}

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

.segmented.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented input,
.color-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span,
.color-choice span,
.actions button {
  align-items: center;
  background: #f6f8f5;
  border: 1px solid rgba(23, 32, 24, 0.16);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 9px 10px;
  text-align: center;
}

.segmented input:checked + span,
.color-choice input:checked + span {
  background: #dff1d6;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

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

.color-choice span {
  gap: 8px;
}

.piece-dot {
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 18px;
  width: 18px;
}

.piece-dot.white {
  background: #ffffff;
  border: 1px solid #111;
}

.piece-dot.black {
  background: #050505;
  border: 1px solid #050505;
}

.actions {
  grid-template-columns: 48px 48px 1fr;
}

.actions button {
  border-color: rgba(23, 32, 24, 0.2);
}

.actions button:hover:not(:disabled) {
  background: #e8f4e3;
}

.actions button:disabled {
  color: #9da69f;
  cursor: not-allowed;
}

.actions #resetBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.info dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.info dl > div {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.info dt {
  color: var(--muted);
}

.info dd {
  font-weight: 700;
  margin: 0;
}

@media (max-width: 900px) {
  body {
    align-items: flex-start;
    padding: 14px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 620px) {
  body {
    padding: 8px;
  }

  .game-panel,
  .controls {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .status-card {
    justify-content: flex-start;
    text-align: left;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .segmented span,
  .color-choice span,
  .actions button {
    min-height: 40px;
    padding: 8px;
  }
}
