:root {
  color-scheme: dark;
  --ink: #f8f3e8;
  --muted: #b9ad9f;
  --gold: #e5b95c;
  --panel: #1d1816;
  --line: #4d4038;
}
* {
  box-sizing: border-box;
}
button,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(
    circle at 50% 0,
    #654c39 0,
    #30231e 42%,
    #171210 100%
  );
  color: var(--ink);
  font:
    16px/1.45 ui-rounded,
    'SF Pro Rounded',
    system-ui,
    sans-serif;
  user-select: none;
}
.app {
  width: min(760px, 100%);
  margin: auto;
  padding: 14px clamp(12px, 3vw, 28px) 30px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 16px;
}
header > a,
header button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #211a17;
  color: #fff;
  text-decoration: none;
  font-size: 20px;
}
.brand {
  text-align: center;
  letter-spacing: 0.16em;
}
.brand b {
  display: block;
  color: #f0c96e;
  font-size: 17px;
}
.brand span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}
.header-actions select {
  width: auto;
  min-width: 58px;
  height: 42px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #211a17;
  color: #fff;
  font-size: 12px;
}
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid #69533f;
  border-radius: 22px;
  background: linear-gradient(135deg, #3c2c25, #241b18);
  box-shadow: 0 14px 40px #0004;
}
.hero > div:first-child {
  display: flex;
  align-items: center;
  gap: 13px;
}
.stones {
  white-space: nowrap;
  font:
    700 clamp(26px, 7vw, 48px) Georgia,
    serif;
}
.hero h1 {
  margin: 0;
  font-size: clamp(21px, 5vw, 34px);
}
.hero p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.score {
  min-width: 74px;
  padding: 8px 12px;
  border-left: 1px solid #6e5847;
  text-align: center;
}
.score span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
}
.score b {
  color: #f0c96e;
  font-size: 24px;
}
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}
.toolbar label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.toolbar select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1f1916;
  color: #fff;
}
.new-game {
  min-height: 43px;
  padding: 0 17px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #f1d184, #c79235);
  color: #24170d;
  font-weight: 900;
}
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 36px;
  margin-bottom: 8px;
  color: #eadfcd;
}
.stone {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow:
    inset 3px 3px 6px #fff3,
    0 2px 5px #0006;
}
.stone.black {
  background: #171717;
}
.stone.white {
  background: #f5f2e9;
  border: 1px solid #aaa;
}
.board-frame {
  width: min(100%, 610px);
  margin: auto;
  padding: clamp(7px, 2vw, 13px);
  border: 1px solid #a3763e;
  border-radius: 17px;
  background: linear-gradient(145deg, #ddb269, #be8847);
  box-shadow:
    0 18px 45px #0008,
    inset 0 0 20px #6e431533;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #d9aa62;
  cursor: crosshair;
  touch-action: none;
}
.message {
  min-height: 27px;
  margin: 10px 0 4px;
  text-align: center;
  font-weight: 800;
  color: #f6cf73;
}
.message.win {
  color: #ffe37d;
  text-shadow: 0 0 15px #e6a92c77;
}
.message.loss {
  color: #ff9d8c;
}
.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.controls button {
  min-width: 115px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #211a17;
  color: #eee1d2;
  font-weight: 700;
}
.controls button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.footer {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 520px) {
  .app {
    padding-top: 8px;
  }
  .hero {
    padding: 12px;
  }
  .hero p {
    display: none;
  }
  .score {
    min-width: 62px;
    padding-right: 4px;
  }
  .toolbar {
    grid-template-columns: 1fr;
  }
  .new-game {
    width: 100%;
  }
  .board-frame {
    border-radius: 12px;
  }
  .footer {
    padding: 0 15px;
  }
}
@media (max-width: 350px) {
  .brand {
    letter-spacing: 0.08em;
  }
  .header-actions select {
    min-width: 49px;
  }
  .hero h1 {
    font-size: 19px;
  }
}
