:root {
  --ink: #18211e;
  --muted: #68716c;
  --jade: #116857;
  --jade-dark: #0a5043;
  --paper: #f6f2e8;
  --panel: rgba(255, 254, 250, 0.96);
  --line: rgba(24, 33, 30, 0.12);
  --board: #dfb86f;
  --board-line: rgba(54, 37, 16, 0.75);
  --danger: #a84235;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 107, 89, 0.08), transparent 28rem),
    radial-gradient(circle at 92% 82%, rgba(183, 132, 52, 0.1), transparent 30rem),
    var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(17, 104, 87, 0.24);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.topbar {
  min-height: 72px;
  padding:
    max(10px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    10px
    max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 242, 232, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  position: relative;
  background:
    linear-gradient(rgba(55, 39, 17, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55, 39, 17, 0.3) 1px, transparent 1px),
    #e0b76d;
  background-size: 10px 10px;
  box-shadow: 0 8px 20px rgba(58, 43, 23, 0.16);
}

.brand-mark i {
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
}

.brand-mark i:first-child {
  left: 8px;
  top: 8px;
  background: radial-gradient(circle at 35% 28%, #555b58, #151918 52%, #070908);
}

.brand-mark i:last-child {
  right: 7px;
  bottom: 7px;
  border: 1px solid #cbc6ba;
  background: radial-gradient(circle at 35% 25%, #fff, #f4f2ec 58%, #d2cec3);
}

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

.brand strong {
  font: 600 22px "STSong", "Songti SC", serif;
  letter-spacing: 0.05em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.local-badge {
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(17, 104, 87, 0.18);
  border-radius: 999px;
  color: var(--jade);
  background: rgba(255, 255, 255, 0.56);
  font-size: 10px;
  font-weight: 700;
}

.local-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2da982;
  box-shadow: 0 0 0 4px rgba(45, 169, 130, 0.12);
}

main {
  min-height: calc(100vh - 122px);
}

.setup-view {
  width: min(1080px, 92vw);
  min-height: calc(100vh - 122px);
  margin: 0 auto;
  padding: 64px 0 70px;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: clamp(42px, 8vw, 110px);
  align-items: center;
}

.hero-copy {
  position: relative;
}

.hero-copy::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -38px;
  width: 155px;
  height: 155px;
  border: 1px solid rgba(17, 104, 87, 0.14);
  border-radius: 50%;
  box-shadow:
    34px -20px 0 -25px rgba(17, 104, 87, 0.12),
    -42px 22px 0 -32px rgba(167, 116, 44, 0.16);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--jade);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero-copy h1,
.game-heading h1 {
  margin: 0;
  font: 600 clamp(42px, 6.2vw, 72px) / 1.14 "STSong", "Songti SC", serif;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 530px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.feature-row {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-row span {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  color: #4b5751;
  font-size: 10px;
}

.start-card,
.review-sheet {
  border: 1px solid rgba(24, 33, 30, 0.11);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(34, 42, 36, 0.1);
}

.start-card {
  padding: 25px;
  border-radius: 24px;
}

.card-heading {
  min-height: 47px;
  padding-bottom: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.card-heading span,
.card-heading small {
  display: block;
}

.card-heading span {
  font-size: 14px;
  font-weight: 800;
}

.card-heading small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.card-heading b {
  color: var(--jade);
  font: 600 24px "STSong", serif;
}

.field-label {
  margin: 18px 0 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.color-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-button {
  min-height: 78px;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #faf8f2;
  text-align: left;
  cursor: pointer;
}

.color-button.active {
  border-color: var(--jade);
  background: #edf5f1;
  box-shadow: inset 0 0 0 1px var(--jade);
}

.color-button strong,
.color-button small {
  display: block;
}

.color-button strong {
  font-size: 13px;
}

.color-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.mini-stone {
  flex: 0 0 auto;
  width: 27px;
  height: 27px;
  display: inline-block;
  border-radius: 50%;
}

.mini-stone.black,
.turn-orb.black {
  background: radial-gradient(circle at 34% 28%, #5a605d, #1b1f1d 45%, #070908 82%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.34);
}

.mini-stone.white,
.turn-orb.white {
  border: 1px solid #c9c5ba;
  background: radial-gradient(circle at 34% 26%, #fff, #f6f4ed 53%, #d1cdc2);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #faf8f2;
  font-size: 11px;
}

.primary-button,
.continue-button {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--jade);
  color: white;
  background: var(--jade);
  box-shadow: 0 12px 28px rgba(17, 104, 87, 0.22);
}

.primary-button:active {
  background: var(--jade-dark);
  transform: translateY(1px);
}

.start-button {
  margin-top: 23px;
}

.start-button span {
  float: right;
}

.continue-button {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: transparent;
}

.device-note {
  margin: 13px 0 0;
  color: #898f8a;
  font-size: 9px;
  text-align: center;
}

.knowledge-note {
  margin: 15px 0 0;
  padding: 11px 12px;
  border: 1px solid rgba(17, 104, 87, 0.13);
  border-radius: 12px;
  color: #5f6963;
  background: #edf5f1;
  font-size: 9px;
  line-height: 1.55;
}

.knowledge-note span {
  margin-right: 5px;
  color: var(--jade);
  font-weight: 800;
}

.game-view {
  width: min(1200px, calc(100% - 36px));
  margin: 0 auto;
  padding: 30px 0 55px;
}

.game-heading {
  padding: 0 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.game-heading .eyebrow {
  margin-bottom: 6px;
}

.game-heading h1 {
  font-size: clamp(31px, 7vw, 48px);
}

.game-heading > div > p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.desktop-game-layout {
  display: grid;
  grid-template-columns: minmax(560px, 790px) minmax(285px, 1fr);
  gap: clamp(18px, 2.6vw, 32px);
  align-items: start;
}

.board-column {
  min-width: 0;
}

.game-sidebar {
  min-width: 0;
  position: sticky;
  top: 96px;
}

.turn-orb {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

.turn-orb.thinking {
  animation: thinking 1.1s ease-in-out infinite alternate;
}

@keyframes thinking {
  to {
    transform: scale(0.88);
    opacity: 0.64;
  }
}

.board-card {
  padding: 7px;
  border: 1px solid rgba(24, 33, 30, 0.12);
  border-radius: 18px;
  background: rgba(255, 254, 250, 0.94);
  box-shadow: 0 18px 55px rgba(34, 42, 36, 0.1);
}

#goBoard {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border: 1px solid #a77f42;
  border-radius: 12px;
  background: var(--board);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.selection-dock {
  margin-top: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.9fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}

.selection-dock > div {
  padding-left: 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.selection-dock span {
  color: var(--muted);
  font-size: 9px;
}

.selection-dock strong {
  margin-top: 3px;
  font-size: 18px;
}

.selection-dock button {
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--jade);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.selection-dock button:disabled {
  color: #7b817d;
  background: #d8d9d4;
  cursor: default;
}

.score-strip {
  min-height: 52px;
  padding: 0 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
}

.score-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.score-strip .mini-stone {
  width: 16px;
  height: 16px;
}

.score-strip b {
  color: var(--ink);
  font-size: 11px;
}

.game-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.game-controls button {
  min-height: 48px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 254, 250, 0.88);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.game-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}

.game-controls .review-button {
  grid-column: 1 / -1;
  border-color: var(--jade);
  color: white;
  background: var(--jade);
}

.coach-card {
  margin-top: 13px;
  padding: 16px 17px;
  border-radius: 15px;
  background: #ede1c6;
}

@media (min-width: 901px) {
  .game-heading {
    max-width: 790px;
  }

  .board-card {
    border-radius: 22px;
  }

  #goBoard {
    cursor: crosshair;
  }

  .selection-dock {
    padding: 16px;
  }

  .selection-dock button {
    min-height: 52px;
  }

  .score-strip {
    padding: 8px 12px;
    justify-content: flex-start;
    column-gap: 16px;
  }

  .coach-card {
    padding: 20px;
  }
}

.coach-card span,
.coach-card strong {
  display: block;
}

.coach-card span {
  color: #82682f;
  font-size: 9px;
}

.coach-card strong {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.65;
}

footer {
  min-height: 50px;
  padding:
    0 max(18px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: #858c87;
  font-size: 9px;
}

.review-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding:
    max(16px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
}

.review-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(15, 23, 20, 0.62);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.review-sheet {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: 91vh;
  padding: 24px;
  overflow: auto;
  border-radius: 24px;
}

.review-head {
  padding-bottom: 17px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.review-head .eyebrow {
  margin-bottom: 5px;
}

.review-head h2 {
  margin: 0;
  font: 600 clamp(26px, 6vw, 38px) "STSong", "Songti SC", serif;
}

.close-review {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.review-summary {
  padding: 20px 0;
  display: grid;
  grid-template-columns: 135px 1fr;
  gap: 22px;
  align-items: center;
}

.review-score {
  min-height: 105px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 15px;
  color: white;
  background: var(--jade);
}

.review-score span {
  color: #b9dfd4;
  font-size: 9px;
}

.review-score strong {
  font: 600 40px "STSong", serif;
}

.review-score small {
  font-size: 9px;
  opacity: 0.7;
}

.review-summary h3 {
  margin: 0 0 8px;
  font: 600 21px / 1.35 "STSong", "Songti SC", serif;
}

.review-summary p {
  margin: 0 0 8px;
  color: #4e5852;
  font-size: 11px;
  line-height: 1.7;
}

.review-summary > div:last-child > span {
  color: var(--jade);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.6;
}

.finding-list {
  display: grid;
  gap: 8px;
}

.finding {
  padding: 13px;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf8f3;
}

.finding.good {
  border-color: #d2e4dc;
  background: #edf5f1;
}

.finding.watch {
  border-color: #ecd5ce;
  background: #fff3ef;
}

.finding-move {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
}

.finding-move span {
  font: 600 20px "STSong", serif;
}

.finding-move small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.finding strong {
  font-size: 11px;
}

.finding p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.empty-review {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.next-focus {
  margin-top: 14px;
  padding: 15px 17px;
  border-radius: 14px;
  background: #ede1c6;
}

.next-focus span,
.next-focus strong {
  display: block;
}

.next-focus span {
  color: #82682f;
  font-size: 9px;
}

.next-focus strong {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.65;
}

.close-review-wide {
  margin-top: 14px;
}

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 14px));
  min-width: 180px;
  max-width: 84vw;
  padding: 11px 16px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: white;
  background: rgba(24, 33, 30, 0.92);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
  text-align: center;
  font-size: 11px;
}

@media (max-width: 760px) {
  .setup-view {
    min-height: auto;
    padding: 40px 0 60px;
    grid-template-columns: 1fr;
    gap: 38px;
  }

  .hero-copy {
    text-align: center;
  }

  .hero-copy::after {
    display: none;
  }

  .lede {
    margin-left: auto;
    margin-right: auto;
  }

  .feature-row {
    justify-content: center;
  }

  .start-card {
    width: min(100%, 500px);
    margin: 0 auto;
  }
}

@media (max-width: 900px) {
  .game-view {
    width: min(760px, 100%);
    padding: 30px 14px 55px;
  }

  .desktop-game-layout {
    display: block;
  }

  .game-sidebar {
    position: static;
  }

  .selection-dock {
    margin-top: 12px;
  }

  .game-controls {
    grid-template-columns: repeat(5, 1fr);
  }

  .game-controls .review-button {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 67px;
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .brand strong {
    font-size: 19px;
  }

  .local-badge {
    padding: 6px 9px;
    font-size: 9px;
  }

  .setup-view {
    width: 93vw;
    padding-top: 34px;
  }

  .hero-copy h1 {
    font-size: 42px;
  }

  .lede {
    font-size: 12px;
  }

  .start-card {
    padding: 18px;
    border-radius: 19px;
  }

  .game-view {
    padding: 20px 4px 46px;
  }

  .game-heading {
    padding-left: 12px;
    padding-right: 12px;
  }

  .board-card {
    padding: 3px;
    border-radius: 12px;
  }

  #goBoard {
    border-radius: 9px;
  }

  .selection-dock,
  .score-strip,
  .game-controls,
  .coach-card {
    margin-left: 8px;
    margin-right: 8px;
  }

  .game-controls {
    grid-template-columns: repeat(3, 1fr);
  }

  .game-controls .review-button {
    grid-column: span 1;
  }

  .review-sheet {
    padding: 17px;
    border-radius: 19px;
  }

  .review-summary {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .review-score {
    min-height: 80px;
  }

  .finding {
    grid-template-columns: 45px 1fr;
    padding: 10px;
  }

  footer span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
