:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: #2b271f;
  background: #f4efe7;
  font-synthesis: none;
  --green: #24614b;
  --muted: #6e6355;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 10%, #fffcf6, #f4efe7 68%);
}
.app {
  width: min(100%, 590px);
  margin: 0 auto;
  padding: 20px 18px max(20px, env(safe-area-inset-bottom));
}
.masthead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 2px 19px;
}
.mark {
  display: block;
  position: relative;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  background: #e8c697;
  box-shadow: inset 0 0 0 1px #ae793f30;
}
.mark span {
  position: absolute;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  box-shadow: 0 2px 4px #51340750;
}
.mark span:first-child { left: 9px; top: 8px; background: #252522; }
.mark span:last-child { right: 8px; bottom: 8px; background: #fffaf1; }
.heading { min-width: 0; }
h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: .04em; }
.heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.heading p, .player strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.round {
  flex: none;
  margin-left: auto;
  color: #664b2f;
  background: #f1e5d5;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}
.players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.player {
  min-width: 0;
  border: 1px solid #e7ded2;
  background: #fffdf8;
  border-radius: 12px;
  min-height: 61px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.player[data-active='true'] { background: #edf6ed; border-color: #a5c7b2; }
.player-info { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.color { color: var(--muted); font-size: 11px; }
.player strong { display: block; font-size: 14px; }
.stone { width: 24px; height: 24px; flex: none; border-radius: 50%; box-shadow: 0 2px 3px #3c2d253f; }
[data-color='0'] .stone { border: 1px dashed #b7a488; box-shadow: none; }
[data-color='1'] .stone { background: radial-gradient(circle at 35% 26%, #55534c, #1a1917 75%); }
[data-color='2'] .stone { background: radial-gradient(circle at 35% 26%, #fffdf8, #ddd1bc 90%); border: 1px solid #d2c5b2; }
.color-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
.color-choices button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 5px 8px;
  border: 1px solid #d4c5ae;
  border-radius: 9px;
  background: #fffdf8;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.color-choices button:enabled:hover { border-color: #83a38d; background: #edf6ed; }
.color-choices button:disabled { opacity: .55; cursor: default; }
.color-choices .stone { width: 16px; height: 16px; }
.turn-dot { display: none; width: 7px; height: 7px; flex: none; border-radius: 50%; background: #357657; }
.player[data-active='true'] .turn-dot { display: block; }
.status {
  margin: 0;
  padding: 10px 2px;
  min-height: 42px;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  overflow-wrap: anywhere;
}
.status[data-error='true'] { color: #943923; }
.board-frame {
  overflow: hidden;
  border-radius: 13px;
  box-shadow: 0 6px 18px #72431e24, 0 1px 3px #72431e38;
  background: #eab371;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  touch-action: manipulation;
}
canvas[data-playable='true'] { cursor: crosshair; }
canvas:focus { outline: none; }
canvas:focus-visible { outline: 3px solid var(--green); outline-offset: -4px; }
.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 10px 2px 0;
  font-size: 13px;
  line-height: 1.5;
}
.footer p { margin: 0; color: var(--muted); }
.footer button {
  border: 0;
  padding: 5px 0;
  background: none;
  color: var(--green);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.footer button[data-confirm='true'] { color: #943923; }
.footer button:disabled { opacity: .55; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (min-width: 520px) {
  .app { padding: 27px 22px 24px; }
  .masthead { margin-bottom: 22px; }
}
@media (max-width: 360px) {
  .app { padding-inline: 12px; }
  .player { padding-inline: 8px; }
}
