:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #5d6876;
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --line: #d7cec0;
  --board-surface:
    linear-gradient(120deg, rgba(255, 255, 255, 0.16), rgba(129, 74, 26, 0.08)),
    url("../assets/boards/classic.jpg");
  --board-border: #8a5f2d;
  --board-line: rgba(42, 31, 19, 0.68);
  --board-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32), 0 12px 28px rgba(54, 37, 20, 0.18);
  --board-hover: rgba(15, 118, 110, 0.24);
  --board-richness-overlay: linear-gradient(transparent, transparent);
  --board-richness-opacity: 0;
  --board-richness-blend-mode: normal;
  --black-stone-fill: radial-gradient(circle at 35% 30%, #5b626b, #11161d 62%, #050609);
  --black-stone-shadow: 0 7px 12px rgba(0, 0, 0, 0.28);
  --white-stone-fill: radial-gradient(circle at 32% 26%, #ffffff, #ece8dc 58%, #c7bcaa);
  --white-stone-shadow: 0 7px 12px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(80, 72, 63, 0.22);
  --stone-backdrop-filter: none;
  --stone-glass-highlight: linear-gradient(transparent, transparent);
  --stone-glass-caustic: linear-gradient(transparent, transparent);
  --stone-glass-edge-light: linear-gradient(transparent, transparent);
  --stone-glass-bottom-shade: linear-gradient(transparent, transparent);
  --stone-glass-rim: linear-gradient(transparent, transparent);
  --stone-glass-blend-mode: normal, normal, normal, normal, normal, normal;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #9f2d20;
  --shadow: 0 18px 48px rgba(35, 31, 25, 0.12);
  --page-background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent 34%, rgba(159, 45, 32, 0.08)),
    var(--paper);
  --panel-background: rgba(255, 253, 248, 0.92);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-background);
  color: var(--ink);
}

body[data-theme="classic"] {
  --ink: #1c2430;
  --muted: #5d6876;
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --line: #d7cec0;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --shadow: 0 18px 48px rgba(35, 31, 25, 0.12);
  --page-background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08), transparent 34%, rgba(159, 45, 32, 0.08)),
    var(--paper);
  --panel-background: rgba(255, 253, 248, 0.92);
  --board-surface:
    linear-gradient(120deg, rgba(255, 255, 255, 0.16), rgba(129, 74, 26, 0.08)),
    url("../assets/boards/classic.jpg");
  --board-border: #8a5f2d;
  --board-line: rgba(42, 31, 19, 0.68);
  --board-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32), 0 12px 28px rgba(54, 37, 20, 0.18);
  --board-hover: rgba(15, 118, 110, 0.24);
}

body[data-theme="dragon"] {
  --ink: #17231f;
  --muted: #50665e;
  --paper: #e8efeb;
  --surface: #f8fbf8;
  --line: #a3b7ad;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --shadow: 0 18px 48px rgba(12, 47, 43, 0.16);
  --page-background:
    linear-gradient(135deg, rgba(9, 71, 65, 0.15), transparent 28%, rgba(131, 55, 24, 0.12)),
    repeating-linear-gradient(45deg, rgba(12, 94, 87, 0.08) 0 2px, transparent 2px 22px),
    repeating-linear-gradient(135deg, transparent 0 15px, rgba(34, 93, 84, 0.07) 15px 17px),
    var(--paper);
  --panel-background: rgba(248, 251, 248, 0.94);
  --board-surface:
    linear-gradient(rgba(250, 242, 214, 0.46), rgba(250, 242, 214, 0.54)),
    linear-gradient(135deg, rgba(10, 58, 49, 0.12), transparent 48%),
    url("../assets/boards/dragon.jpg");
  --board-border: #254b40;
  --board-line: rgba(22, 37, 29, 0.82);
  --board-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26), 0 12px 28px rgba(15, 63, 54, 0.22);
  --board-hover: rgba(255, 214, 111, 0.28);
}

body[data-theme="cherry"] {
  --ink: #2a2329;
  --muted: #75616b;
  --paper: #fbf0f3;
  --surface: #fffafa;
  --line: #e5c7cf;
  --accent: #b4536a;
  --accent-strong: #8f3f52;
  --shadow: 0 18px 48px rgba(98, 50, 64, 0.13);
  --page-background:
    linear-gradient(120deg, rgba(180, 83, 106, 0.14), transparent 34%, rgba(15, 118, 110, 0.08)),
    repeating-linear-gradient(30deg, rgba(180, 83, 106, 0.08) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(150deg, transparent 0 18px, rgba(221, 150, 166, 0.1) 18px 20px),
    var(--paper);
  --panel-background: rgba(255, 250, 250, 0.94);
  --board-surface:
    linear-gradient(rgba(255, 250, 246, 0.28), rgba(255, 250, 246, 0.36)),
    linear-gradient(120deg, rgba(180, 83, 106, 0.08), transparent 54%),
    url("../assets/boards/cherry.jpg");
  --board-border: #9c5266;
  --board-line: rgba(71, 46, 34, 0.72);
  --board-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 12px 28px rgba(118, 58, 75, 0.18);
  --board-hover: rgba(180, 83, 106, 0.24);
}

body[data-theme="lotus"] {
  --ink: #18271f;
  --muted: #52685e;
  --paper: #eef6ee;
  --surface: #fbfff9;
  --line: #c6d8c7;
  --accent: #27745c;
  --accent-strong: #1f5d49;
  --shadow: 0 18px 48px rgba(32, 78, 59, 0.13);
  --page-background:
    linear-gradient(115deg, rgba(39, 116, 92, 0.12), transparent 31%, rgba(96, 132, 171, 0.11)),
    repeating-linear-gradient(90deg, rgba(39, 116, 92, 0.07) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(0deg, transparent 0 18px, rgba(97, 151, 128, 0.08) 18px 20px),
    var(--paper);
  --panel-background: rgba(251, 255, 249, 0.94);
  --board-surface:
    linear-gradient(rgba(255, 250, 232, 0.58), rgba(255, 250, 232, 0.64)),
    linear-gradient(135deg, rgba(39, 116, 92, 0.08), transparent 48%),
    url("../assets/boards/lotus.jpg");
  --board-border: #4e8068;
  --board-line: rgba(25, 44, 31, 0.84);
  --board-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 12px 28px rgba(41, 82, 59, 0.18);
  --board-hover: rgba(39, 116, 92, 0.24);
}

body[data-theme="mountain"] {
  --ink: #1f2832;
  --muted: #5d6874;
  --paper: #eef1f3;
  --surface: #fbfcfb;
  --line: #c8d0d6;
  --accent: #476f86;
  --accent-strong: #35596c;
  --shadow: 0 18px 48px rgba(34, 52, 66, 0.14);
  --page-background:
    linear-gradient(135deg, rgba(71, 111, 134, 0.16), transparent 29%, rgba(141, 119, 85, 0.08)),
    repeating-linear-gradient(160deg, rgba(71, 111, 134, 0.08) 0 2px, transparent 2px 30px),
    repeating-linear-gradient(20deg, transparent 0 22px, rgba(70, 86, 99, 0.06) 22px 24px),
    var(--paper);
  --panel-background: rgba(251, 252, 251, 0.94);
  --board-surface:
    linear-gradient(rgba(251, 249, 239, 0.42), rgba(251, 249, 239, 0.48)),
    linear-gradient(145deg, rgba(71, 111, 134, 0.09), transparent 46%),
    url("../assets/boards/mountain.jpg");
  --board-border: #536575;
  --board-line: rgba(31, 39, 47, 0.82);
  --board-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34), 0 12px 28px rgba(45, 58, 71, 0.18);
  --board-hover: rgba(71, 111, 134, 0.22);
}

body[data-stone-theme="classic"] {
  --black-stone-fill: radial-gradient(circle at 35% 30%, #5b626b, #11161d 62%, #050609);
  --black-stone-shadow: 0 7px 12px rgba(0, 0, 0, 0.28);
  --white-stone-fill: radial-gradient(circle at 32% 26%, #ffffff, #ece8dc 58%, #c7bcaa);
  --white-stone-shadow: 0 7px 12px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(80, 72, 63, 0.22);
  --stone-backdrop-filter: none;
}

body[data-stone-theme="red-blue"] {
  --black-stone-fill: radial-gradient(circle at 35% 28%, #ffbbb1, #c42d22 48%, #63110d 82%);
  --black-stone-shadow: 0 7px 13px rgba(88, 17, 12, 0.32), inset 0 0 0 1px rgba(92, 18, 12, 0.22);
  --white-stone-fill: radial-gradient(circle at 34% 28%, #b9dcff, #2563eb 50%, #0f2f82 84%);
  --white-stone-shadow: 0 7px 13px rgba(15, 47, 130, 0.3), inset 0 0 0 1px rgba(14, 43, 112, 0.24);
  --stone-backdrop-filter: none;
}

body[data-stone-theme="green-yellow"] {
  --black-stone-fill: radial-gradient(circle at 35% 28%, #bff2cf, #20864a 50%, #0d4325 84%);
  --black-stone-shadow: 0 7px 13px rgba(12, 67, 37, 0.31), inset 0 0 0 1px rgba(10, 63, 34, 0.24);
  --white-stone-fill: radial-gradient(circle at 34% 28%, #fff7b3, #e4b72e 52%, #8a5a08 84%);
  --white-stone-shadow: 0 7px 13px rgba(97, 65, 8, 0.29), inset 0 0 0 1px rgba(103, 69, 8, 0.22);
  --stone-backdrop-filter: none;
}

body[data-stone-material="glass"] {
  --board-richness-overlay:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.04), transparent 58%),
    linear-gradient(rgba(54, 39, 31, 0.05), rgba(54, 39, 31, 0.08));
  --board-richness-opacity: 1;
  --board-richness-blend-mode: multiply;
}

body[data-stone-material="glass"][data-stone-theme="classic"] {
  --black-stone-fill: radial-gradient(circle at 43% 36%, rgba(255, 255, 255, 0.12) 0 8%, rgba(88, 95, 98, 0.26) 30%, rgba(28, 35, 39, 0.5) 70%, rgba(6, 8, 10, 0.62) 100%);
  --black-stone-shadow: 0 10px 18px rgba(0, 0, 0, 0.22), 0 2px 4px rgba(0, 0, 0, 0.1), inset 3px 4px 10px rgba(255, 255, 255, 0.34), inset -7px -9px 18px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.32);
  --white-stone-fill: radial-gradient(circle at 43% 36%, rgba(255, 255, 255, 0.64) 0 10%, rgba(248, 250, 252, 0.38) 42%, rgba(216, 223, 230, 0.26) 78%, rgba(255, 255, 255, 0.32) 100%);
  --white-stone-shadow: 0 10px 18px rgba(0, 0, 0, 0.16), 0 2px 4px rgba(0, 0, 0, 0.08), inset 3px 4px 10px rgba(255, 255, 255, 0.76), inset -7px -9px 18px rgba(118, 128, 138, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.68);
  --stone-glass-highlight:
    radial-gradient(ellipse at 26% 20%, rgba(255, 255, 255, 0.82) 0 6%, rgba(255, 255, 255, 0.35) 7% 14%, transparent 28%),
    radial-gradient(ellipse at 42% 32%, rgba(255, 255, 255, 0.22) 0 20%, transparent 46%);
  --stone-glass-edge-light: radial-gradient(circle at 50% 46%, transparent 0 58%, rgba(255, 255, 255, 0.2) 64%, transparent 73%);
  --stone-glass-caustic:
    linear-gradient(115deg, transparent 0 38%, rgba(255, 255, 255, 0.1) 47%, transparent 58%),
    linear-gradient(25deg, transparent 0 54%, rgba(255, 255, 255, 0.08) 62%, transparent 72%);
  --stone-glass-bottom-shade: radial-gradient(ellipse at 54% 86%, rgba(0, 0, 0, 0.16) 0 14%, transparent 46%);
  --stone-glass-rim: radial-gradient(circle at 50% 52%, transparent 0 61%, rgba(255, 255, 255, 0.18) 68%, rgba(0, 0, 0, 0.16) 86%, rgba(255, 255, 255, 0.28) 100%);
  --stone-glass-blend-mode: screen, soft-light, soft-light, multiply, soft-light, normal;
  --stone-backdrop-filter: blur(1.6px) saturate(1.35) contrast(1.08);
}

body[data-stone-material="glass"][data-stone-theme="red-blue"] {
  --black-stone-fill: radial-gradient(circle at 43% 36%, rgba(255, 235, 232, 0.14) 0 9%, rgba(220, 38, 38, 0.28) 32%, rgba(127, 29, 29, 0.5) 78%, rgba(82, 18, 18, 0.58) 100%);
  --black-stone-shadow: 0 10px 18px rgba(91, 18, 18, 0.22), 0 2px 4px rgba(91, 18, 18, 0.1), inset 3px 4px 10px rgba(255, 225, 225, 0.42), inset -7px -9px 18px rgba(127, 29, 29, 0.18), inset 0 0 0 1px rgba(255, 216, 216, 0.42);
  --white-stone-fill: radial-gradient(circle at 43% 36%, rgba(230, 242, 255, 0.18) 0 9%, rgba(37, 99, 235, 0.28) 34%, rgba(30, 64, 175, 0.5) 78%, rgba(20, 48, 140, 0.58) 100%);
  --white-stone-shadow: 0 10px 18px rgba(30, 64, 175, 0.22), 0 2px 4px rgba(30, 64, 175, 0.1), inset 3px 4px 10px rgba(224, 241, 255, 0.46), inset -7px -9px 18px rgba(30, 64, 175, 0.18), inset 0 0 0 1px rgba(219, 234, 254, 0.46);
  --stone-glass-highlight:
    radial-gradient(ellipse at 26% 20%, rgba(255, 255, 255, 0.78) 0 6%, rgba(255, 255, 255, 0.32) 7% 14%, transparent 28%),
    radial-gradient(ellipse at 42% 32%, rgba(255, 255, 255, 0.19) 0 20%, transparent 46%);
  --stone-glass-edge-light: radial-gradient(circle at 50% 46%, transparent 0 58%, rgba(255, 255, 255, 0.18) 64%, transparent 73%);
  --stone-glass-caustic:
    linear-gradient(115deg, transparent 0 38%, rgba(255, 255, 255, 0.1) 47%, transparent 58%),
    linear-gradient(25deg, transparent 0 54%, rgba(255, 255, 255, 0.08) 62%, transparent 72%);
  --stone-glass-bottom-shade: radial-gradient(ellipse at 54% 86%, rgba(0, 0, 0, 0.15) 0 14%, transparent 46%);
  --stone-glass-rim: radial-gradient(circle at 50% 52%, transparent 0 61%, rgba(255, 255, 255, 0.18) 68%, rgba(56, 26, 46, 0.15) 86%, rgba(255, 255, 255, 0.27) 100%);
  --stone-glass-blend-mode: screen, soft-light, soft-light, multiply, soft-light, normal;
  --stone-backdrop-filter: blur(1.6px) saturate(1.35) contrast(1.08);
}

body[data-stone-material="glass"][data-stone-theme="green-yellow"] {
  --black-stone-fill: radial-gradient(circle at 43% 36%, rgba(232, 255, 239, 0.16) 0 9%, rgba(22, 163, 74, 0.28) 34%, rgba(20, 83, 45, 0.5) 78%, rgba(12, 58, 30, 0.58) 100%);
  --black-stone-shadow: 0 10px 18px rgba(20, 83, 45, 0.22), 0 2px 4px rgba(20, 83, 45, 0.1), inset 3px 4px 10px rgba(222, 255, 232, 0.44), inset -7px -9px 18px rgba(20, 83, 45, 0.18), inset 0 0 0 1px rgba(220, 252, 231, 0.44);
  --white-stone-fill: radial-gradient(circle at 43% 36%, rgba(255, 252, 220, 0.22) 0 9%, rgba(234, 179, 8, 0.3) 36%, rgba(133, 77, 14, 0.46) 78%, rgba(109, 65, 12, 0.54) 100%);
  --white-stone-shadow: 0 10px 18px rgba(133, 77, 14, 0.2), 0 2px 4px rgba(133, 77, 14, 0.09), inset 3px 4px 10px rgba(254, 249, 195, 0.5), inset -7px -9px 18px rgba(133, 77, 14, 0.15), inset 0 0 0 1px rgba(254, 249, 195, 0.48);
  --stone-glass-highlight:
    radial-gradient(ellipse at 26% 20%, rgba(255, 255, 255, 0.78) 0 6%, rgba(255, 255, 255, 0.32) 7% 14%, transparent 28%),
    radial-gradient(ellipse at 42% 32%, rgba(255, 255, 255, 0.19) 0 20%, transparent 46%);
  --stone-glass-edge-light: radial-gradient(circle at 50% 46%, transparent 0 58%, rgba(255, 255, 255, 0.18) 64%, transparent 73%);
  --stone-glass-caustic:
    linear-gradient(115deg, transparent 0 38%, rgba(255, 255, 255, 0.1) 47%, transparent 58%),
    linear-gradient(25deg, transparent 0 54%, rgba(255, 255, 255, 0.08) 62%, transparent 72%);
  --stone-glass-bottom-shade: radial-gradient(ellipse at 54% 86%, rgba(0, 0, 0, 0.14) 0 14%, transparent 46%);
  --stone-glass-rim: radial-gradient(circle at 50% 52%, transparent 0 61%, rgba(255, 255, 255, 0.18) 68%, rgba(61, 61, 30, 0.14) 86%, rgba(255, 255, 255, 0.27) 100%);
  --stone-glass-blend-mode: screen, soft-light, soft-light, multiply, soft-light, normal;
  --stone-backdrop-filter: blur(1.6px) saturate(1.35) contrast(1.08);
}

button,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 8px 20px rgba(15, 118, 110, 0.18);
}

button.is-active:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #ffffff;
}

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

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 32px 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.toggle-control input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 18px;
}

.title-group h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.title-group p {
  margin: 7px 0 0;
  color: var(--muted);
  max-width: 520px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: end;
  gap: 9px;
}

.control {
  display: grid;
  gap: 4px;
  min-width: 132px;
}

.control.compact {
  min-width: 86px;
}

.control span {
  color: var(--muted);
  font-size: 0.78rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(290px, 360px);
  gap: 18px;
  align-items: start;
}

.play-area,
.side-area > section {
  background: var(--panel-background);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.play-area {
  padding: clamp(12px, 2vw, 18px);
}

.play-area.is-game-over {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
}

.status-row {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.status-title {
  margin: 0;
  font-weight: 750;
  font-size: 1.05rem;
}

.status-message,
.last-move {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.last-move {
  min-width: 130px;
  text-align: right;
}

.game-over-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  border-radius: 8px;
  color: #0f172a;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.game-over-banner[hidden] {
  display: none;
}

.board {
  --board-size: 9;
  --board-lines: 8;
  --board-padding: clamp(22px, 4vw, 44px);
  position: relative;
  display: block;
  aspect-ratio: 1;
  width: min(100%, 78vh);
  margin: 0 auto;
  padding: var(--board-padding);
  border-radius: 8px;
  border: 1px solid var(--board-border);
  border-color: var(--board-border);
  background: var(--board-surface);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: var(--board-shadow);
  overflow: hidden;
}

.play-area.is-game-over .board {
  filter: saturate(0.94) contrast(0.98);
}

.board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--board-richness-overlay);
  opacity: var(--board-richness-opacity);
  mix-blend-mode: var(--board-richness-blend-mode);
  pointer-events: none;
}

.board-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.board-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.board-grid line {
  stroke: var(--board-line);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.coordinate-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.coordinate-label {
  position: absolute;
  z-index: 0;
  min-width: 1.3em;
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 58%, transparent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  transform: translate(-50%, -50%);
  user-select: none;
}

.coordinate-label-top {
  top: calc(var(--board-padding) * -0.62);
}

.coordinate-label-bottom {
  top: calc(100% + var(--board-padding) * 0.62);
}

.coordinate-label-left {
  left: calc(var(--board-padding) * -0.62);
}

.coordinate-label-right {
  left: calc(100% + var(--board-padding) * 0.62);
}

.point {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  width: calc(84% / var(--board-lines));
  height: calc(84% / var(--board-lines));
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
}

.point:disabled {
  cursor: default;
  opacity: 1;
}

.point::before {
  content: "";
  width: 76%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: scale(0.72);
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.point:not(:disabled):hover::before {
  transform: scale(0.72);
  background: var(--board-hover);
  box-shadow: inset 0 0 0 1px rgba(11, 95, 89, 0.25);
}

.point.black-stone::before,
.point.white-stone::before {
  transform: scale(0.92);
  -webkit-backdrop-filter: var(--stone-backdrop-filter);
  backdrop-filter: var(--stone-backdrop-filter);
}

.point.black-stone::before {
  background:
    var(--stone-glass-highlight),
    var(--stone-glass-edge-light),
    var(--stone-glass-caustic),
    var(--stone-glass-bottom-shade),
    var(--stone-glass-rim),
    var(--black-stone-fill);
  background-blend-mode: var(--stone-glass-blend-mode);
  box-shadow: var(--black-stone-shadow);
}

.point.white-stone::before {
  background:
    var(--stone-glass-highlight),
    var(--stone-glass-edge-light),
    var(--stone-glass-caustic),
    var(--stone-glass-bottom-shade),
    var(--stone-glass-rim),
    var(--white-stone-fill);
  background-blend-mode: var(--stone-glass-blend-mode);
  box-shadow: var(--white-stone-shadow);
}

.point.last::after {
  content: "";
  position: absolute;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.62);
}

.coach-panel {
  display: block;
}

.coach-marker::after {
  --coach-marker-color: var(--accent);
  content: "";
  position: absolute;
  width: 32%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.18);
  background: color-mix(in srgb, var(--coach-marker-color) 18%, transparent);
  border: 2px solid var(--coach-marker-color);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.72), 0 4px 10px rgba(15, 23, 42, 0.16);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 72%, transparent), 0 4px 10px rgba(15, 23, 42, 0.16);
  pointer-events: none;
}

.coach-recommended::after {
  --coach-marker-color: #15803d;
}

.coach-good::after {
  --coach-marker-color: #0f766e;
}

.coach-risky::after {
  --coach-marker-color: #b45309;
}

.coach-avoid::after {
  --coach-marker-color: #b91c1c;
}

.point.coach-selected::after {
  content: "";
  position: absolute;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.18);
  background: color-mix(in srgb, var(--coach-marker-color, var(--accent)) 28%, transparent);
  border: 2px solid var(--coach-marker-color, var(--accent));
  box-shadow: 0 0 0 4px rgba(255, 253, 248, 0.76), 0 0 0 7px rgba(15, 118, 110, 0.2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--surface) 76%, transparent), 0 0 0 7px color-mix(in srgb, var(--coach-marker-color, var(--accent)) 24%, transparent);
  pointer-events: none;
}

.point.last.coach-marker::after {
  width: 20%;
  background: var(--danger);
  border: 2px solid var(--coach-marker-color);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.72), 0 0 0 6px var(--coach-marker-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 76%, transparent), 0 0 0 6px color-mix(in srgb, var(--coach-marker-color) 62%, transparent), 0 4px 10px rgba(15, 23, 42, 0.16);
}

.point.last.coach-marker.coach-selected::after {
  width: 24%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.78), 0 0 0 8px var(--coach-marker-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--surface) 78%, transparent), 0 0 0 8px color-mix(in srgb, var(--coach-marker-color) 72%, transparent), 0 4px 12px rgba(15, 23, 42, 0.18);
}

.side-area {
  display: grid;
  gap: 14px;
}

.metric-band {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
}

.metric {
  display: grid;
  gap: 4px;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
}

.metric strong {
  line-height: 1.35;
}

.stone-legend {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.stone-legend[hidden] {
  display: none;
}

.coach-panel,
.rules-panel,
.log-panel {
  padding: 14px;
}

.rules-panel[hidden] {
  display: none;
}

.coach-panel h2,
.rules-panel h2,
.log-panel h2 {
  margin: 0 0 9px;
  font-size: 1rem;
}

.rules-panel p {
  margin: 0;
  color: #334155;
  line-height: 1.55;
}

.coach-summary,
.coach-reply {
  margin: 0;
  color: #334155;
  line-height: 1.45;
}

.coach-reasons {
  margin: 8px 0;
  padding-left: 20px;
  color: #334155;
  line-height: 1.45;
}

.coach-reply {
  color: var(--muted);
}

.coach-sequence-title {
  margin: 0.75rem 0 0.25rem;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.coach-sequence-title:empty {
  display: none;
}

.coach-sequence {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding-left: 1.35rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.coach-sequence:empty {
  display: none;
}

.log-panel ol {
  margin: 0;
  padding-left: 22px;
  max-height: 280px;
  overflow: auto;
  color: #334155;
  line-height: 1.55;
}

.empty-log {
  color: var(--muted);
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: start;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .board {
    width: min(100%, 92vw);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 16px, 1180px);
    padding-top: 10px;
  }

  .title-group h1 {
    font-size: 1.55rem;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .toolbar button,
  .toolbar .control,
  .toolbar .toggle-control {
    width: 100%;
    min-width: 0;
  }

  .status-row {
    flex-direction: column;
    gap: 4px;
  }

  .last-move {
    min-width: 0;
    text-align: left;
  }
}
