:root {
  color-scheme: dark;
  --ink: #f4f7ee;
  --muted: #9eafa5;
  --muted-strong: #c1cec5;
  --page: #06120d;
  --page-deep: #030b08;
  --surface: #0b1d15;
  --surface-raised: #10271c;
  --surface-soft: #122d20;
  --line: rgba(202, 225, 210, 0.13);
  --line-strong: rgba(202, 225, 210, 0.24);
  --green: #72dc8d;
  --green-bright: #9cf3ad;
  --green-dark: #135b36;
  --board: #12613a;
  --board-dark: #0d4d2d;
  --amber: #ffc96b;
  --danger: #ff8d86;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 18%, rgba(32, 121, 73, 0.17), transparent 28rem),
    radial-gradient(circle at 88% 85%, rgba(24, 92, 58, 0.12), transparent 34rem),
    linear-gradient(145deg, var(--page), var(--page-deep));
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 54px 54px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

button,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

label {
  cursor: pointer;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

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

:focus-visible {
  outline: 3px solid var(--green-bright);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  color: #031008;
  background: var(--green-bright);
  border-radius: 0.5rem;
  font-weight: 800;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 3rem));
  min-height: 84px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.site-header nav {
  display: flex;
  gap: 0.3rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.brand em {
  color: var(--green);
  font-style: normal;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: #173c29;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  transform: rotate(-5deg);
}

.brand-mark i {
  position: absolute;
  width: 13px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.brand-mark i:first-child {
  top: 6px;
  left: 6px;
  background: #07100b;
}

.brand-mark i:last-child {
  right: 6px;
  bottom: 6px;
  background: #f5f5eb;
}

.text-button,
.quiet-button,
.dialog-close {
  border: 0;
  background: transparent;
}

.text-button {
  padding: 0.7rem 0.85rem;
  color: var(--muted-strong);
  border-radius: 0.5rem;
  font-size: 0.86rem;
  font-weight: 700;
}

.text-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
}

main {
  width: min(1180px, calc(100% - 3rem));
  min-height: calc(100vh - 164px);
  margin: 0 auto;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.8rem;
}

.notice strong,
.notice p {
  margin: 0;
}

.notice p {
  margin-top: 0.2rem;
  color: var(--muted-strong);
  font-size: 0.88rem;
}

.notice-error {
  background: rgba(142, 41, 37, 0.18);
  border-color: rgba(255, 141, 134, 0.3);
}

.setup-view {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(520px, 1fr);
  gap: clamp(3rem, 7vw, 7rem);
  align-items: start;
  min-height: calc(100vh - 150px);
  padding: 4rem 0 5.5rem;
}

.intro {
  max-width: 520px;
}

.eyebrow,
.step-label {
  margin: 0;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.17em;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.eyebrow > span {
  width: 20px;
  height: 1px;
  background: var(--green);
}

.intro h1 {
  margin: 1.25rem 0 1.35rem;
  font-size: clamp(3.2rem, 6vw, 5.5rem);
  font-weight: 760;
  letter-spacing: -0.075em;
  line-height: 1.06;
}

.intro h1 strong {
  color: var(--green-bright);
  font-weight: inherit;
}

.lead {
  max-width: 31rem;
  margin: 0;
  color: var(--muted-strong);
  font-size: 1rem;
  line-height: 1.95;
}

.feature-list {
  display: grid;
  gap: 0.8rem;
  margin: 2.35rem 0 0;
  padding: 0;
  color: var(--muted-strong);
  font-size: 0.88rem;
  font-weight: 650;
  list-style: none;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.feature-list span {
  display: grid;
  width: 28px;
  height: 28px;
  color: var(--green-bright);
  background: rgba(87, 207, 119, 0.09);
  border: 1px solid rgba(87, 207, 119, 0.22);
  border-radius: 50%;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 850;
}

.setup-card {
  position: relative;
  padding: clamp(1.4rem, 3vw, 2rem);
  overflow: hidden;
  background: linear-gradient(145deg, rgba(18, 46, 32, 0.98), rgba(8, 26, 18, 0.98));
  border: 1px solid var(--line-strong);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.setup-card::after {
  position: absolute;
  top: -7rem;
  right: -7rem;
  width: 15rem;
  height: 15rem;
  background: radial-gradient(circle, rgba(103, 225, 133, 0.1), transparent 68%);
  content: "";
  pointer-events: none;
}

.card-heading,
.side-heading,
.game-topbar,
.block-toolbar,
.block-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-heading h2 {
  margin: 0.35rem 0 0;
  font-size: 1.55rem;
  letter-spacing: -0.035em;
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.65rem;
  color: var(--green-bright);
  background: rgba(102, 224, 132, 0.08);
  border: 1px solid rgba(102, 224, 132, 0.18);
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 750;
}

.offline-badge > span {
  width: 6px;
  height: 6px;
  background: var(--green-bright);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(102, 224, 132, 0.1);
}

fieldset {
  min-width: 0;
  margin: 1.6rem 0 0;
  padding: 1.3rem 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

legend {
  padding: 0;
  font-size: 0.86rem;
  font-weight: 780;
}

legend > span {
  margin-right: 0.55rem;
  color: var(--green);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.choice-card {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr 20px;
  gap: 0.72rem;
  align-items: center;
  min-height: 78px;
  padding: 0.65rem 0.75rem;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.choice-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.choice-card.checked {
  color: var(--ink);
  background: rgba(99, 220, 131, 0.075);
  border-color: rgba(116, 230, 145, 0.45);
}

.choice-card input,
.color-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.choice-card:focus-within,
.color-options label:focus-within {
  outline: 3px solid var(--green-bright);
  outline-offset: 3px;
}

.choice-card strong,
.choice-card small {
  display: block;
}

.choice-card strong {
  margin-bottom: 0.18rem;
  font-size: 0.86rem;
}

.choice-card small {
  color: var(--muted);
  font-size: 0.64rem;
}

.choice-card > b {
  display: grid;
  width: 19px;
  height: 19px;
  color: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  place-items: center;
  font-size: 0.66rem;
}

.choice-card.checked > b {
  color: #05200f;
  background: var(--green-bright);
  border-color: var(--green-bright);
}

.choice-visual {
  position: relative;
  display: block;
  width: 50px;
  height: 50px;
  background-color: #145f38;
  background-image:
    linear-gradient(rgba(205, 243, 216, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(205, 243, 216, 0.13) 1px, transparent 1px);
  background-size: calc(100% / 6) calc(100% / 6);
  border: 1px solid rgba(223, 245, 228, 0.15);
  border-radius: 0.3rem;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.15);
}

.choice-visual i {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.mini-standard i:nth-child(1),
.mini-standard i:nth-child(4) {
  background: #050b07;
}

.mini-standard i:nth-child(2),
.mini-standard i:nth-child(3) {
  background: #f1f2e9;
}

.mini-standard i:nth-child(1) { left: 18px; top: 18px; }
.mini-standard i:nth-child(2) { left: 26px; top: 18px; }
.mini-standard i:nth-child(3) { left: 18px; top: 26px; }
.mini-standard i:nth-child(4) { left: 26px; top: 26px; }

.mini-variant i {
  background: #09130d;
  border-radius: 1px;
}

.mini-variant i:nth-child(1) { left: 1px; top: 1px; }
.mini-variant i:nth-child(2) { left: 9px; top: 1px; }
.mini-variant i:nth-child(3) { left: 1px; top: 9px; }

.block-settings {
  animation: reveal 180ms ease-out;
}

.block-toolbar {
  margin: 0.85rem 0 0.65rem;
}

.block-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

#block-count {
  min-width: 3.5rem;
  color: var(--green-bright);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: right;
}

.block-picker-wrap {
  position: relative;
  width: min(100%, 260px);
  margin: 0 auto;
  padding: 18px 0 0 18px;
}

.block-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #105d36;
  border: 1px solid rgba(217, 243, 225, 0.22);
  border-radius: 0.35rem;
}

.block-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(217, 243, 225, 0.13);
  border-bottom: 1px solid rgba(217, 243, 225, 0.13);
  place-items: center;
}

.block-cell.candidate:hover {
  background: rgba(158, 244, 177, 0.11);
}

.block-cell.candidate::before {
  width: 38%;
  aspect-ratio: 1;
  border: 1px dashed rgba(209, 241, 218, 0.45);
  border-radius: 2px;
  content: "";
}

.block-cell[aria-pressed="true"] {
  background: rgba(5, 17, 10, 0.26);
}

.block-cell[aria-pressed="true"]::before {
  width: 48%;
  color: #d9eadc;
  background: #07110b;
  border: 1px solid rgba(236, 246, 238, 0.38);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}

.block-cell[aria-pressed="true"]::after {
  position: absolute;
  color: #dce8df;
  content: "×";
  font-size: clamp(0.6rem, 2vw, 0.85rem);
  font-weight: 900;
}

.block-cell.initial::before {
  width: 35%;
  aspect-ratio: 1;
  background: #eff2e9;
  border-radius: 50%;
  content: "";
}

.block-cell.initial.black::before {
  background: #050c08;
}

.mini-axis {
  position: absolute;
  display: grid;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.55rem;
  text-align: center;
}

.mini-axis-columns {
  top: 0;
  right: 0;
  left: 18px;
  grid-template-columns: repeat(6, 1fr);
}

.mini-axis-rows {
  top: 18px;
  bottom: 0;
  left: 0;
  grid-template-rows: repeat(6, 1fr);
  align-items: center;
}

.block-actions {
  width: min(100%, 260px);
  margin: 0.65rem auto 0;
}

.quiet-button {
  padding: 0.35rem 0.2rem;
  color: var(--muted-strong);
  border-radius: 0.3rem;
  font-size: 0.68rem;
  font-weight: 720;
}

.quiet-button:hover {
  color: var(--green-bright);
}

.quiet-button.danger:hover {
  color: var(--danger);
}

.field-error {
  margin: 0.55rem 0 0;
  color: var(--danger);
  font-size: 0.72rem;
  text-align: center;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.color-options label {
  position: relative;
}

.color-options label > span {
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.55rem;
  align-items: center;
  min-height: 59px;
  padding: 0.6rem 0.7rem;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  transition: border-color 140ms ease, background 140ms ease;
}

.color-options label.checked > span {
  color: var(--ink);
  background: rgba(102, 224, 132, 0.07);
  border-color: rgba(116, 230, 145, 0.43);
}

.color-options i {
  grid-row: 1 / 3;
}

.color-options strong {
  font-size: 0.78rem;
}

.color-options small {
  color: var(--muted);
  font-size: 0.61rem;
}

.disc,
.split-disc,
.turn-disc {
  display: inline-block;
  flex: 0 0 auto;
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
}

.disc-black {
  background: radial-gradient(circle at 35% 30%, #3d4a42, #030805 66%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset -3px -3px 5px rgba(0, 0, 0, 0.55), 0 3px 8px rgba(0, 0, 0, 0.35);
}

.disc-white {
  background: radial-gradient(circle at 35% 28%, #fff, #d9ded6 70%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: inset -3px -3px 5px rgba(80, 94, 83, 0.22), 0 3px 8px rgba(0, 0, 0, 0.3);
}

.split-disc {
  background: linear-gradient(90deg, #09110c 0 50%, #edf1e9 50%);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.local-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.2rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.65rem;
}

.primary-button,
.secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.62rem;
  font-weight: 800;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  padding: 0.8rem 1rem;
  color: #03160a;
  background: linear-gradient(135deg, var(--green-bright), #66d984);
  border: 0;
  box-shadow: 0 9px 24px rgba(63, 189, 96, 0.18);
}

.primary-button span:last-child {
  margin-left: auto;
  font-size: 1.2rem;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.secondary-button {
  min-height: 44px;
  padding: 0.7rem 1rem;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line-strong);
}

.secondary-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.secondary-button.compact {
  min-height: 36px;
  padding: 0.5rem 0.8rem;
  font-size: 0.72rem;
}

/* Game */
.game-view {
  padding: 2.2rem 0 5rem;
  animation: reveal 220ms ease-out;
}

.game-topbar {
  margin-bottom: 1.4rem;
}

.game-topbar h1 {
  margin: 0.35rem 0 0;
  font-size: 1.75rem;
  letter-spacing: -0.04em;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(470px, 1.35fr) minmax(310px, 0.65fr);
  gap: 1.15rem;
  align-items: start;
}

.board-panel,
.score-card,
.history-card,
.announcement,
.game-result {
  background: linear-gradient(145deg, rgba(15, 39, 27, 0.96), rgba(7, 23, 16, 0.96));
  border: 1px solid var(--line);
  border-radius: 1rem;
}

.board-panel {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.7rem);
  box-shadow: var(--shadow);
}

.turn-banner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 48px;
  margin-bottom: 1.1rem;
  padding: 0 0.2rem;
}

.turn-disc {
  width: 36px;
}

.turn-banner span,
.turn-banner strong {
  display: block;
}

#turn-label {
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 700;
}

#turn-detail {
  margin-top: 0.15rem;
  font-size: 0.94rem;
}

.board-kind-badge {
  margin-left: auto;
  padding: 0.32rem 0.58rem;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 0.62rem;
  font-weight: 750;
}

.board-area {
  position: relative;
  width: min(100%, 610px);
  margin: 0 auto;
  padding: 24px 0 0 24px;
}

.column-labels,
.row-labels {
  position: absolute;
  display: grid;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.62rem, 1.6vw, 0.75rem);
  font-weight: 700;
  text-align: center;
}

.column-labels {
  top: 0;
  right: 0;
  left: 24px;
  grid-template-columns: repeat(6, 1fr);
}

.row-labels {
  top: 24px;
  bottom: 0;
  left: 0;
  grid-template-rows: repeat(6, 1fr);
  align-items: center;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--board);
  border: 2px solid rgba(198, 235, 209, 0.25);
  border-radius: 0.45rem;
  box-shadow: inset 0 0 38px rgba(0, 0, 0, 0.23), 0 18px 40px rgba(0, 0, 0, 0.28);
}

.board-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(221, 244, 227, 0.13);
  border-bottom: 1px solid rgba(221, 244, 227, 0.13);
  perspective: 420px;
  place-items: center;
}

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

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

.board-cell.legal {
  cursor: pointer;
}

.board-cell.legal:hover,
.board-cell.legal:focus-visible {
  background: rgba(163, 241, 181, 0.09);
}

.stone {
  position: relative;
  z-index: 1;
  width: 69%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform-style: preserve-3d;
}

.stone.placed {
  animation: stone-in 220ms ease-out both;
}

.stone.flipped {
  animation: stone-flip 420ms cubic-bezier(0.45, 0, 0.2, 1) both;
}

.stone.flipped::before {
  position: absolute;
  z-index: 2;
  inset: -1px;
  border-radius: 50%;
  animation: stone-old-face 420ms steps(1, end) both;
  content: "";
}

.stone.flipped.flip-from-black::before {
  background: radial-gradient(circle at 35% 28%, #3d4a42 0%, #111915 25%, #020604 72%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset -7px -7px 12px rgba(0, 0, 0, 0.65), 0 7px 12px rgba(0, 0, 0, 0.36);
}

.stone.flipped.flip-from-white::before {
  background: radial-gradient(circle at 34% 27%, #fff 0%, #f0f2ed 44%, #bdc5bd 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: inset -6px -7px 11px rgba(82, 96, 85, 0.22), 0 7px 12px rgba(0, 0, 0, 0.28);
}

.stone.flipped::after {
  animation: stone-new-face 420ms steps(1, end) both;
}

.stone::after {
  position: absolute;
  top: 50%;
  left: 50%;
  box-sizing: border-box;
  content: "";
  transform: translate(-50%, -50%);
}

.stone.black {
  color: #9eaca2;
  background: radial-gradient(circle at 35% 28%, #3d4a42 0%, #111915 25%, #020604 72%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset -7px -7px 12px rgba(0, 0, 0, 0.65), 0 7px 12px rgba(0, 0, 0, 0.36);
}

.stone.black::after {
  width: 13%;
  aspect-ratio: 1;
  background: currentColor;
  border: 1px solid currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.stone.white {
  color: #536159;
  background: radial-gradient(circle at 34% 27%, #fff 0%, #f0f2ed 44%, #bdc5bd 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: inset -6px -7px 11px rgba(82, 96, 85, 0.22), 0 7px 12px rgba(0, 0, 0, 0.28);
}

.stone.white::after {
  width: 19%;
  aspect-ratio: 1;
  background: transparent;
  border: max(1px, 0.09em) solid currentColor;
  border-radius: 50%;
}

.legal-marker {
  width: 18%;
  aspect-ratio: 1;
  background: var(--green-bright);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(158, 243, 175, 0.08);
  opacity: 0.76;
  transition: transform 130ms ease, opacity 130ms ease;
}

.board-cell.legal:hover .legal-marker {
  opacity: 1;
  transform: scale(1.28);
}

.block-mark {
  display: grid;
  width: 62%;
  aspect-ratio: 1;
  color: #c4d2c8;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 3px, transparent 3px 7px),
    #07130c;
  border: 1px solid rgba(220, 237, 224, 0.27);
  border-radius: 7%;
  place-items: center;
  box-shadow: inset 0 0 13px rgba(0, 0, 0, 0.75), 0 4px 9px rgba(0, 0, 0, 0.25);
  font-size: clamp(0.85rem, 2.5vw, 1.5rem);
  font-weight: 500;
}

.board-cell.last::after {
  position: absolute;
  z-index: 2;
  top: 8%;
  right: 8%;
  width: 10%;
  aspect-ratio: 1;
  background: var(--amber);
  border: 1px solid rgba(18, 18, 8, 0.34);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 201, 107, 0.16);
  content: "";
}

.thinking-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0 24px;
  padding: 0.7rem 0.8rem;
  color: var(--muted-strong);
  background: rgba(97, 216, 127, 0.06);
  border: 1px solid rgba(97, 216, 127, 0.16);
  border-radius: 0.65rem;
}

.thinking-panel > div {
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
}

.thinking-panel > div > span {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.thinking-panel .danger {
  margin-left: auto;
}

.thinking-orbit {
  position: relative;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(135, 235, 159, 0.25);
  border-radius: 50%;
  animation: orbit 1.2s linear infinite;
}

.thinking-orbit i {
  position: absolute;
  top: -3px;
  left: 8px;
  width: 7px;
  height: 7px;
  background: var(--green-bright);
  border-radius: 50%;
}

.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0 0 24px;
  color: var(--muted);
  font-size: 0.63rem;
}

.board-legend > span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.board-legend i {
  display: inline-grid;
  width: 12px;
  height: 12px;
  place-items: center;
}

.legend-legal {
  width: 7px !important;
  height: 7px !important;
  background: var(--green-bright);
  border-radius: 50%;
}

.legend-last {
  background: var(--amber);
  border-radius: 50%;
}

.legend-block {
  color: var(--muted-strong);
  background: #08120c;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-style: normal;
  font-size: 0.55rem;
}

.game-sidebar {
  display: grid;
  gap: 0.75rem;
}

.score-card,
.history-card,
.game-result {
  padding: 1rem;
}

.side-heading h2,
.side-heading span {
  margin: 0;
}

.side-heading h2 {
  font-size: 0.82rem;
}

.side-heading > span {
  color: var(--muted);
  font-size: 0.62rem;
}

.scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.score {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 0.55rem;
  align-items: center;
  min-width: 0;
  padding: 0.72rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid transparent;
  border-radius: 0.65rem;
}

.score.active {
  background: rgba(107, 227, 137, 0.06);
  border-color: rgba(107, 227, 137, 0.27);
}

.score .disc {
  width: 28px;
}

.score small,
.score strong {
  display: block;
}

.score small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.54rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score strong {
  font-size: 0.75rem;
}

.score output {
  font-size: 1.55rem;
  font-weight: 820;
  letter-spacing: -0.05em;
}

.game-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding: 0.65rem 0.2rem 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.58rem;
  font-weight: 650;
}

.game-meta strong {
  color: var(--muted-strong);
}

.book-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.book-status i {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
}

.book-status.loaded {
  color: var(--green);
}

.book-status.loaded i {
  background: var(--green);
}

.book-status.warning {
  color: var(--amber);
}

.book-status.warning i {
  background: var(--amber);
}

.announcement {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 0.55rem;
  align-items: start;
  padding: 0.75rem 0.9rem;
  color: var(--muted-strong);
}

.announcement > span {
  margin-top: 0.36rem;
  color: var(--green);
  font-size: 0.42rem;
}

.announcement.warning > span {
  color: var(--amber);
}

.announcement.error > span {
  color: var(--danger);
}

.announcement p {
  margin: 0;
  font-size: 0.69rem;
  line-height: 1.65;
}

.history-card {
  min-height: 160px;
}

.history-empty {
  display: grid;
  min-height: 100px;
  padding: 1rem;
  color: var(--muted);
  place-items: center;
  font-size: 0.66rem;
  text-align: center;
}

.move-history {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
  max-height: 194px;
  margin: 0.7rem 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  scrollbar-color: var(--line-strong) transparent;
}

.move-history li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  padding: 0.42rem 0.5rem;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.022);
  border-radius: 0.38rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
}

.move-history li > small {
  color: var(--muted);
}

.history-stone {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.history-stone.black {
  background: #030805;
  border: 1px solid #607067;
}

.history-stone.white {
  background: #e8eee7;
}

.game-result {
  text-align: center;
  border-color: rgba(113, 225, 141, 0.25);
}

.game-result > p {
  margin: 0;
  color: var(--green);
  font-size: 0.56rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.game-result h2 {
  margin: 0.35rem 0 0.2rem;
  font-size: 1.35rem;
}

.game-result span {
  color: var(--muted-strong);
  font-size: 0.68rem;
}

.game-actions {
  display: grid;
  gap: 0.5rem;
}

.game-actions .secondary-button {
  width: 100%;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 3rem));
  min-height: 80px;
  margin: 0 auto;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
}

footer > span {
  color: var(--muted-strong);
  font-weight: 800;
  letter-spacing: 0.12em;
}

/* Dialogs and fatal state */
dialog {
  width: min(600px, calc(100% - 2rem));
  max-height: min(700px, calc(100vh - 2rem));
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: linear-gradient(145deg, #10291d, #071a11);
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(1, 7, 4, 0.78);
  backdrop-filter: blur(6px);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.4rem;
  background: rgba(11, 31, 21, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.dialog-header h2 {
  margin: 0.28rem 0 0;
  font-size: 1.4rem;
}

.dialog-close {
  display: grid;
  width: 36px;
  height: 36px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 50%;
  place-items: center;
  font-size: 1.2rem;
}

.dialog-content {
  display: grid;
  gap: 0.4rem;
  padding: 1.2rem 1.4rem 1.5rem;
}

.dialog-content section {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.85rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.dialog-content section:last-child {
  border-bottom: 0;
}

.dialog-content section > span {
  display: grid;
  width: 32px;
  height: 32px;
  color: var(--green-bright);
  background: rgba(103, 225, 133, 0.08);
  border: 1px solid rgba(103, 225, 133, 0.18);
  border-radius: 50%;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 850;
}

.dialog-content h3,
.dialog-content p {
  margin: 0;
}

.dialog-content h3 {
  font-size: 0.85rem;
}

.dialog-content p {
  margin-top: 0.35rem;
  color: var(--muted-strong);
  font-size: 0.74rem;
  line-height: 1.85;
}

.dialog-content.prose {
  gap: 0.8rem;
}

.about-note {
  margin-top: 0.5rem;
  padding: 0.9rem;
  background: rgba(255, 201, 107, 0.05);
  border: 1px solid rgba(255, 201, 107, 0.16);
  border-radius: 0.65rem;
  font-size: 0.76rem;
}

.fatal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: grid;
  padding: 1rem;
  background: rgba(1, 7, 4, 0.86);
  place-items: center;
  backdrop-filter: blur(8px);
}

.fatal-card {
  width: min(450px, 100%);
  padding: 1.6rem;
  background: linear-gradient(145deg, #152b20, #091a12);
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.fatal-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0 auto;
  color: var(--danger);
  background: rgba(255, 141, 134, 0.08);
  border: 1px solid rgba(255, 141, 134, 0.25);
  border-radius: 50%;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 850;
}

.fatal-card h2 {
  margin: 1rem 0 0.5rem;
  font-size: 1.2rem;
}

.fatal-card p {
  margin: 0 0 1.2rem;
  color: var(--muted-strong);
  font-size: 0.76rem;
  line-height: 1.75;
}

.fatal-card > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes stone-in {
  from { opacity: 0.35; transform: scale(0.78) rotateY(60deg); }
  to { opacity: 1; transform: scale(1) rotateY(0); }
}

@keyframes stone-flip {
  0% { transform: rotateY(0) scale(1); }
  49% { transform: rotateY(88deg) scale(0.94); }
  50% { transform: rotateY(-88deg) scale(0.94); }
  100% { transform: rotateY(0) scale(1); }
}

@keyframes stone-old-face {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes stone-new-face {
  0%, 49% { opacity: 0; }
  50%, 100% { opacity: 1; }
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .setup-view {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    align-items: center;
    max-width: 680px;
    margin: 0 auto;
    padding-top: 3rem;
  }

  .intro {
    max-width: 630px;
  }

  .intro h1 {
    font-size: clamp(3.5rem, 11vw, 5.5rem);
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 720px;
    margin: 0 auto;
  }

  .game-sidebar {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .announcement,
  .game-actions,
  .game-result {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .site-header,
  main,
  footer {
    width: min(100% - 1.5rem, 1180px);
  }

  .site-header {
    min-height: 68px;
  }

  .brand {
    font-size: 0.7rem;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .site-header .text-button {
    padding: 0.55rem 0.45rem;
    font-size: 0.7rem;
  }

  .setup-view {
    padding: 2.4rem 0 3.5rem;
  }

  .intro h1 {
    margin-top: 1rem;
    font-size: clamp(3rem, 15vw, 4.4rem);
  }

  .lead {
    font-size: 0.9rem;
  }

  .feature-list {
    margin-top: 1.6rem;
  }

  .setup-card {
    margin: 0 -0.1rem;
    padding: 1.15rem;
    border-radius: 0.9rem;
  }

  .offline-badge {
    display: none;
  }

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

  .choice-card {
    min-height: 70px;
  }

  .color-options label > span {
    grid-template-columns: 1fr;
    grid-template-rows: 25px auto auto;
    gap: 0.12rem;
    justify-items: center;
    min-height: 85px;
    padding: 0.5rem 0.25rem;
    text-align: center;
  }

  .color-options i {
    grid-row: auto;
  }

  .game-view {
    padding-top: 1.25rem;
  }

  .game-topbar h1 {
    font-size: 1.35rem;
  }

  .board-panel {
    padding: 0.9rem 0.65rem 1rem;
    border-radius: 0.8rem;
  }

  .turn-banner {
    margin-bottom: 0.6rem;
    padding: 0 0.3rem;
  }

  .turn-disc {
    width: 30px;
  }

  .board-area {
    padding: 20px 0 0 20px;
  }

  .column-labels {
    left: 20px;
  }

  .row-labels {
    top: 20px;
  }

  .thinking-panel,
  .board-legend {
    margin-left: 20px;
  }

  .thinking-panel .danger {
    max-width: 5.2rem;
  }

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

  .announcement,
  .game-actions,
  .game-result {
    grid-column: auto;
  }

  footer {
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    text-align: center;
  }

  footer p {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (forced-colors: active) {
  .legal-marker,
  .board-cell.last::after {
    forced-color-adjust: none;
  }

  .legal-marker {
    background: Highlight;
  }

  .board-cell.last::after {
    background: LinkText;
  }

  .stone::after {
    color: CanvasText;
    forced-color-adjust: auto;
  }

  .stone.flipped::before {
    display: none;
  }

  .stone.flipped::after {
    animation: none;
    opacity: 1;
  }
}
