:root {
  --ink: #17211f;
  --muted: #67716c;
  --cream: #f7f4ec;
  --board: #dca95c;
  --line: #724d26;
  --orange: #df6539;
  --machine: #f3efe5;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
}

button { font: inherit; }

.app-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 56px;
}

.hero { margin-bottom: 38px; }

.eyebrow, .label {
  margin: 0;
  color: var(--orange);
  font-family: Arial, sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(2.55rem, 7vw, 4.5rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.game-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.game-panel { padding-top: 12px; }

.status-card {
  border-bottom: 1px solid #d5d0c4;
  padding-bottom: 18px;
}

.status { margin: 7px 0 0; font-size: 1.7rem; }

.score-card {
  display: grid;
  gap: 12px;
  margin: 23px 0;
  font-family: Arial, sans-serif;
}

.score-card div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-name { display: inline-flex; align-items: center; gap: 8px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; }
.score-card strong { font-family: Georgia, serif; font-size: 1.35rem; }

.stone { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.stone.player { background: var(--ink); }
.stone.machine { background: var(--machine); border: 1px solid #b8b2a8; }

.controls { display: grid; gap: 9px; }

.primary-button {
  cursor: pointer;
  border: 0;
  padding: 12px 16px;
  color: white;
  background: var(--orange);
  font-weight: 700;
}

.primary-button:hover, .primary-button:focus-visible { background: #c9502c; }

.text-button {
  width: max-content;
  cursor: pointer;
  border: 0;
  padding: 6px 0;
  color: var(--muted);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover, .text-button:focus-visible { color: var(--ink); }

.rules { margin-top: 38px; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.rules p:last-child { margin: 8px 0; }

.board-frame {
  width: min(100%, 720px);
  padding: clamp(10px, 2vw, 18px);
  background: #5a3b20;
  box-shadow: 7px 8px 0 #c7c1b5;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background-color: var(--board);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: calc(100% / 15) calc(100% / 15);
  background-position: calc(100% / 30) calc(100% / 30);
}

.cell {
  position: relative;
  z-index: 1;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: transparent;
}

.cell:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.cell:disabled { cursor: default; }

.cell::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  content: "";
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  transition: opacity 120ms ease, transform 120ms ease;
}

.cell.player::after {
  opacity: 1;
  background: radial-gradient(circle at 35% 30%, #4a5551, var(--ink) 64%);
  box-shadow: 1px 2px 2px #69441f;
  transform: translate(-50%, -50%) scale(1);
}

.cell.machine::after {
  opacity: 1;
  background: radial-gradient(circle at 32% 28%, #fff, #e1dccf 68%);
  box-shadow: 1px 2px 2px #69441f;
  transform: translate(-50%, -50%) scale(1);
}

.cell.last-move::before {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 22%;
  height: 22%;
  border: 2px solid var(--orange);
  border-radius: 50%;
  content: "";
  pointer-events: none;
  transform: translate(-50%, -50%);
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 28px, 600px); padding-top: 30px; }
  .game-layout { grid-template-columns: 1fr; gap: 24px; }
  .game-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; padding: 0; }
  .status-card, .rules { margin: 0; }
  .score-card { margin: 0; align-self: center; }
  .controls { grid-column: 1 / -1; grid-template-columns: max-content max-content; align-items: center; margin-top: 19px; }
  .rules { grid-column: 1 / -1; margin-top: 22px; }
}

@media (max-width: 430px) {
  .game-panel { display: block; }
  .score-card { margin: 20px 0; }
  .board-frame { padding: 8px; }
}
