:root {
  color-scheme: light;
  --ink: #202220;
  --muted: #7b817e;
  --mist: #e8f0f1;
  --mist-deep: #d6e5e7;
  --paper: #f7f4ed;
  --paper-deep: #eee9df;
  --gold: #c6a84e;
  --gold-light: #e5cf82;
  --line: rgba(52, 58, 54, 0.13);
  --shadow: 0 24px 70px rgba(47, 60, 59, 0.12);
  --body-glow: rgba(255, 255, 255, 0.95);
  --body-accent: rgba(198, 168, 78, 0.08);
  --brand-stone: #222522;
  --eyebrow: #9b843f;
  --icon-border: rgba(255, 255, 255, 0.72);
  --icon-surface: rgba(255, 255, 255, 0.48);
  --icon-hover: rgba(255, 255, 255, 0.8);
  --frame-border: rgba(255, 255, 255, 0.75);
  --frame-surface: rgba(255, 255, 255, 0.29);
  --frame-halo: rgba(211, 230, 233, 0.72);
  --board-base: #e7e1d6;
  --board-grain-a: rgba(85, 66, 40, 0.018);
  --board-grain-b: rgba(92, 69, 38, 0.018);
  --board-sheen: rgba(255, 255, 255, 0.3);
  --board-vignette: rgba(87, 70, 48, 0.05);
  --panel-border: rgba(255, 255, 255, 0.72);
  --panel-surface: rgba(247, 249, 247, 0.55);
  --selector-surface: rgba(104, 119, 116, 0.09);
  --selector-active: rgba(255, 255, 255, 0.88);
  --selector-active-ink: #272a28;
  --note-border: rgba(198, 168, 78, 0.16);
  --note-surface: rgba(229, 207, 130, 0.12);
  --note-icon-surface: rgba(229, 207, 130, 0.26);
  --note-ink: #414542;
  --dialog-shade: rgba(35, 42, 39, 0.28);
  --dialog-surface: rgba(248, 247, 241, 0.95);
  --dialog-border: rgba(255, 255, 255, 0.8);
  --primary-surface: #dbc477;
  --primary-hover: #e3cb7d;
  --primary-ink: #373329;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

:root[data-theme="jade"] {
  --ink: #17372f;
  --muted: #648178;
  --mist: #e5f0ea;
  --mist-deep: #c9ded3;
  --gold: #5d9b7f;
  --gold-light: #9cc8b1;
  --line: rgba(36, 82, 68, 0.14);
  --shadow: 0 24px 70px rgba(34, 78, 65, 0.14);
  --body-glow: rgba(255, 255, 255, 0.92);
  --body-accent: rgba(55, 143, 109, 0.1);
  --brand-stone: #17372f;
  --eyebrow: #568d75;
  --icon-border: rgba(255, 255, 255, 0.68);
  --icon-surface: rgba(246, 252, 248, 0.54);
  --icon-hover: rgba(255, 255, 255, 0.88);
  --frame-border: rgba(255, 255, 255, 0.76);
  --frame-surface: rgba(238, 249, 243, 0.34);
  --frame-halo: rgba(187, 219, 204, 0.72);
  --board-base: #c5dbcd;
  --board-grain-a: rgba(30, 96, 70, 0.025);
  --board-grain-b: rgba(246, 255, 250, 0.08);
  --board-sheen: rgba(255, 255, 255, 0.26);
  --board-vignette: rgba(28, 91, 68, 0.08);
  --panel-border: rgba(255, 255, 255, 0.72);
  --panel-surface: rgba(240, 248, 244, 0.62);
  --selector-surface: rgba(49, 104, 85, 0.1);
  --selector-active: rgba(255, 255, 255, 0.86);
  --selector-active-ink: #17372f;
  --note-border: rgba(69, 139, 108, 0.18);
  --note-surface: rgba(131, 188, 160, 0.13);
  --note-icon-surface: rgba(103, 171, 139, 0.2);
  --note-ink: #2c584a;
  --dialog-shade: rgba(20, 54, 44, 0.3);
  --dialog-surface: rgba(241, 248, 244, 0.96);
  --dialog-border: rgba(255, 255, 255, 0.82);
  --primary-surface: #8dbca3;
  --primary-hover: #9bc9b0;
  --primary-ink: #17372f;
}

:root[data-theme="night"] {
  color-scheme: dark;
  --ink: #e7ece9;
  --muted: #9eaba7;
  --mist: #17201f;
  --mist-deep: #263330;
  --gold: #d1b96f;
  --gold-light: #e2ce8d;
  --line: rgba(218, 228, 223, 0.13);
  --shadow: 0 24px 75px rgba(0, 0, 0, 0.32);
  --body-glow: rgba(81, 104, 98, 0.22);
  --body-accent: rgba(211, 185, 102, 0.08);
  --brand-stone: #e3e8e5;
  --eyebrow: #cbb46e;
  --icon-border: rgba(225, 235, 231, 0.12);
  --icon-surface: rgba(225, 235, 231, 0.07);
  --icon-hover: rgba(225, 235, 231, 0.13);
  --frame-border: rgba(229, 238, 234, 0.13);
  --frame-surface: rgba(215, 229, 223, 0.06);
  --frame-halo: rgba(44, 65, 61, 0.88);
  --board-base: #526460;
  --board-grain-a: rgba(228, 239, 234, 0.025);
  --board-grain-b: rgba(10, 21, 19, 0.04);
  --board-sheen: rgba(224, 237, 231, 0.06);
  --board-vignette: rgba(4, 12, 10, 0.2);
  --panel-border: rgba(229, 238, 234, 0.11);
  --panel-surface: rgba(34, 46, 43, 0.72);
  --selector-surface: rgba(225, 235, 231, 0.07);
  --selector-active: rgba(229, 238, 234, 0.14);
  --selector-active-ink: #f1f4f2;
  --note-border: rgba(211, 185, 102, 0.18);
  --note-surface: rgba(211, 185, 102, 0.08);
  --note-icon-surface: rgba(211, 185, 102, 0.14);
  --note-ink: #d6ddd9;
  --dialog-shade: rgba(5, 10, 9, 0.58);
  --dialog-surface: rgba(33, 43, 41, 0.97);
  --dialog-border: rgba(230, 238, 234, 0.13);
  --primary-surface: #c6ae67;
  --primary-hover: #d1bb75;
  --primary-ink: #1b201e;
}

:root[data-theme="night"] .tool-button,
:root[data-theme="night"] .mode-button,
:root[data-theme="night"] .difficulty-button,
:root[data-theme="night"] .gentle-note p,
:root[data-theme="night"] .score-row,
:root[data-theme="night"] .board-size,
:root[data-theme="night"] .text-button {
  color: var(--muted);
}

:root[data-theme="night"] .dialog-close {
  background: rgba(230, 238, 234, 0.08);
  color: var(--ink);
}

:root[data-theme="night"] .turn-stone,
:root[data-theme="night"] .mini-stone--black,
:root[data-theme="night"] .stone--black {
  border: 1px solid rgba(255, 255, 255, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--mist);
  color: var(--ink);
  touch-action: pan-x pan-y;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 2%, var(--body-glow), transparent 29rem),
    radial-gradient(circle at 94% 96%, var(--body-accent), transparent 27rem),
    var(--mist);
  transition: background 320ms ease, color 250ms ease;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(198, 168, 78, 0.65);
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  margin-bottom: 14px;
}

.brand {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  gap: 3px;
  width: 30px;
  transform: rotate(-7deg);
}

.brand-mark i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-stone);
  box-shadow: inset -1px -1px 2px rgba(255, 255, 255, 0.24);
}

.brand-mark i:nth-child(2) {
  grid-column: 2;
  background: var(--gold);
}

.brand-mark i:nth-child(3) {
  grid-column: 3;
}

.brand-mark i:nth-child(4) {
  grid-column: 2;
}

.brand-mark i:nth-child(5) {
  grid-column: 1;
}

.brand strong {
  display: block;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.05;
}

.brand small,
.turn-card small,
.section-heading small,
.result-card > small,
.help-card > small {
  display: block;
  margin-top: 5px;
  color: var(--eyebrow);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--icon-border);
  border-radius: 50%;
  background: var(--icon-surface);
  box-shadow: 0 8px 20px rgba(51, 61, 60, 0.05);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.icon-button:hover {
  background: var(--icon-hover);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button svg,
.tool-button svg,
.mode-button svg,
.note-icon svg,
.primary-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.sound-off,
.is-muted .sound-on {
  display: none;
}

.is-muted .sound-off {
  display: block;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(480px, 1fr) 320px;
  gap: clamp(28px, 5vw, 70px);
  align-items: center;
}

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

.board-frame {
  position: relative;
  width: min(100%, calc(100svh - 164px));
  margin: 0 auto;
  padding: clamp(9px, 1.2vw, 15px);
  border: 1px solid var(--frame-border);
  border-radius: 10px;
  background: var(--frame-surface);
  box-shadow: var(--shadow), 0 0 0 1px rgba(110, 130, 128, 0.04);
}

.board-frame::after {
  position: absolute;
  inset: -13px;
  z-index: -1;
  border-radius: 18px;
  background: var(--frame-halo);
  content: "";
  filter: blur(1px);
}

.board-surface {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 4px;
  background:
    repeating-linear-gradient(88deg, transparent 0, transparent 27px, var(--board-grain-a) 28px, transparent 30px),
    repeating-linear-gradient(2deg, transparent 0, transparent 41px, var(--board-grain-b) 42px, transparent 45px),
    linear-gradient(135deg, var(--board-sheen), transparent 45%),
    var(--board-base);
  box-shadow: inset 0 0 40px rgba(91, 75, 53, 0.06);
}

.board-surface::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 45% 40%, transparent 50%, var(--board-vignette) 120%);
  content: "";
}

#board {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

#board.is-thinking {
  cursor: wait;
}

.mobile-status {
  display: none;
}

.board-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-top: 18px;
}

.tool-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 7px 13px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #555b58;
  font-size: 13px;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.tool-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink);
}

.tool-button:active:not(:disabled) {
  transform: scale(0.97);
}

.tool-button:disabled {
  opacity: 0.3;
  cursor: default;
}

.tool-button svg {
  width: 21px;
  height: 21px;
}

.tool-divider {
  width: 1px;
  height: 22px;
  background: rgba(65, 72, 68, 0.13);
}

.control-panel {
  padding: 31px 28px 24px;
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: var(--panel-surface);
  box-shadow: 0 18px 50px rgba(51, 65, 63, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.turn-card {
  display: flex;
  gap: 17px;
  align-items: center;
}

.turn-stone {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 27%, #515452 0, #252725 29%, #0e0f0e 76%);
  box-shadow: inset -5px -7px 12px rgba(0, 0, 0, 0.38), inset 3px 3px 7px rgba(255, 255, 255, 0.22), 0 7px 11px rgba(28, 31, 29, 0.24);
  transition: background 240ms ease, transform 240ms ease;
}

.turn-stone.is-white {
  background: radial-gradient(circle at 32% 26%, #fff 0, #f7f7f4 42%, #d9d9d3 100%);
  box-shadow: inset -4px -5px 9px rgba(118, 121, 115, 0.18), inset 3px 3px 7px #fff, 0 6px 11px rgba(40, 47, 43, 0.16);
}

.turn-stone.is-thinking {
  animation: gentle-pulse 1s ease-in-out infinite;
}

.turn-card h1 {
  margin: 4px 0 2px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(26px, 3vw, 32px);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.12;
}

.turn-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.rule {
  height: 1px;
  margin: 25px 0 23px;
  background: linear-gradient(90deg, var(--gold) 0 38px, var(--line) 38px 100%);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 3px 0 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 19px;
  font-weight: 600;
}

.section-heading small {
  margin: 0;
}

.board-size {
  color: #8e9490;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border-radius: 15px;
  background: var(--selector-surface);
}

.mode-button {
  display: flex;
  min-height: 74px;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #737a76;
  font-size: 12px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.mode-button svg {
  width: 24px;
  height: 24px;
}

.mode-button.is-active {
  background: var(--selector-active);
  color: var(--selector-active-ink);
  box-shadow: 0 5px 14px rgba(53, 64, 62, 0.08);
}

.mode-button:active {
  transform: scale(0.98);
}

.difficulty-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 17px;
}

.difficulty-section[hidden] {
  display: none;
}

.difficulty-heading {
  flex: 0 0 auto;
}

.difficulty-heading small {
  display: block;
  margin: 0 0 3px;
  color: var(--eyebrow);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.difficulty-heading h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 16px;
  font-weight: 600;
}

.difficulty-control {
  display: grid;
  flex: 1;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  max-width: 174px;
  padding: 4px;
  border-radius: 12px;
  background: var(--selector-surface);
}

.difficulty-button {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #777d79;
  font-size: 10px;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.difficulty-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.difficulty-button.is-active {
  background: var(--selector-active);
  color: var(--selector-active-ink);
  box-shadow: 0 4px 12px rgba(53, 64, 62, 0.07);
}

.difficulty-button:active {
  transform: scale(0.98);
}

.gentle-note {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 17px;
  padding: 13px 14px;
  border: 1px solid var(--note-border);
  border-radius: 14px;
  background: var(--note-surface);
}

.note-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--note-icon-surface);
  color: var(--eyebrow);
}

.note-icon svg {
  width: 19px;
  height: 19px;
}

.gentle-note p {
  margin: 0;
  color: #777d79;
  font-size: 11px;
  line-height: 1.55;
}

.gentle-note strong {
  color: var(--note-ink);
  font-size: 12px;
  font-weight: 600;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  color: #777d79;
}

.score-row > div {
  display: flex;
  gap: 7px;
  align-items: center;
}

.score-row small {
  min-width: 27px;
  font-size: 11px;
}

.score-row strong {
  color: var(--ink);
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  font-weight: 500;
}

.score-dash {
  margin: 0 13px;
  color: #b6bbb7;
}

.mini-stone,
.stone {
  display: inline-block;
  border-radius: 50%;
}

.mini-stone {
  width: 14px;
  height: 14px;
}

.mini-stone--black,
.stone--black {
  background: radial-gradient(circle at 32% 27%, #555 0, #161816 67%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.mini-stone--white,
.stone--white {
  border: 1px solid rgba(83, 87, 84, 0.15);
  background: radial-gradient(circle at 32% 27%, #fff 0, #e8e8e4 82%);
  box-shadow: 0 2px 4px rgba(54, 59, 56, 0.15);
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: var(--dialog-shade);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fade-in 200ms ease both;
}

.result-card,
.help-card,
.theme-card {
  position: relative;
  width: min(390px, 100%);
  padding: 45px 38px 34px;
  border: 1px solid var(--dialog-border);
  border-radius: 26px;
  background: var(--dialog-surface);
  box-shadow: 0 35px 90px rgba(29, 36, 33, 0.2);
  text-align: center;
  animation: card-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0 0 3px;
  border: 0;
  border-radius: 50%;
  background: rgba(79, 87, 82, 0.07);
  color: #606662;
  font-family: Arial, sans-serif;
  font-size: 25px;
  font-weight: 300;
  cursor: pointer;
}

.winning-stones,
.help-example {
  display: flex;
  justify-content: center;
  margin-bottom: 26px;
}

.winning-stones i,
.help-example i {
  display: block;
  width: 37px;
  height: 37px;
  margin-left: -4px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #565956 0, #161716 70%);
  box-shadow: inset -3px -4px 6px rgba(0, 0, 0, 0.28), inset 2px 2px 4px rgba(255, 255, 255, 0.2), 0 5px 10px rgba(29, 31, 29, 0.17);
  animation: stone-pop 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.winning-stones i:nth-child(2),
.help-example i:nth-child(2) { animation-delay: 60ms; }
.winning-stones i:nth-child(3),
.help-example i:nth-child(3) { animation-delay: 120ms; }
.winning-stones i:nth-child(4),
.help-example i:nth-child(4) { animation-delay: 180ms; }
.winning-stones i:nth-child(5),
.help-example i:nth-child(5) { animation-delay: 240ms; }

.winning-stones.is-white i {
  border: 1px solid rgba(91, 95, 91, 0.12);
  background: radial-gradient(circle at 32% 26%, #fff 0, #eeeeea 75%);
  box-shadow: inset -3px -4px 6px rgba(91, 95, 91, 0.14), 0 5px 10px rgba(29, 31, 29, 0.12);
}

.result-card h2,
.help-card h2,
.theme-card h2 {
  margin: 9px 0 9px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.result-card p,
.help-card p,
.theme-card > p {
  margin: 0 auto 27px;
  color: #777d79;
  font-size: 14px;
  line-height: 1.7;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 53px;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  background: var(--primary-surface);
  color: var(--primary-ink);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 9px 22px rgba(168, 139, 51, 0.18);
  transition: transform 150ms ease, background 150ms ease;
}

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

.primary-button:active {
  transform: scale(0.98);
}

.primary-button svg {
  width: 18px;
  height: 18px;
}

.text-button {
  margin-top: 13px;
  padding: 8px 15px;
  border: 0;
  background: transparent;
  color: #747a76;
  font-size: 13px;
  cursor: pointer;
}

.help-example {
  position: relative;
  margin-top: 28px;
  padding: 15px;
  border-radius: 16px;
  background:
    linear-gradient(rgba(81, 75, 64, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(81, 75, 64, 0.14) 1px, transparent 1px),
    var(--board-base);
  background-position: center;
  background-size: 37px 37px;
}

.help-example i {
  width: 32px;
  height: 32px;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 19;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -30px;
  width: 9px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold-light);
  opacity: 0;
  animation: confetti-fall var(--duration, 2.6s) ease-in var(--delay, 0s) forwards;
}

.theme-card {
  width: min(430px, 100%);
  padding: 40px 30px 30px;
  text-align: left;
}

.theme-card > small {
  display: block;
  color: var(--eyebrow);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
}

.theme-card h2 {
  margin: 8px 0 4px;
  text-align: center;
}

.theme-card > p {
  margin-bottom: 23px;
  text-align: center;
}

.theme-grid {
  display: grid;
  gap: 9px;
}

.theme-choice {
  display: grid;
  grid-template-columns: 76px 1fr 25px;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 82px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--icon-surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 150ms ease;
}

.theme-choice:active {
  transform: scale(0.985);
}

.theme-choice.is-active {
  border-color: var(--gold);
  background: var(--selector-active);
}

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

.theme-choice strong {
  margin-bottom: 4px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 17px;
  font-weight: 600;
}

.theme-choice small {
  color: var(--muted);
  font-size: 11px;
}

.theme-check {
  width: 22px;
  height: 22px;
  opacity: 0;
  fill: none;
  stroke: var(--gold);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.theme-choice.is-active .theme-check {
  opacity: 1;
}

.theme-swatch {
  position: relative;
  display: block;
  overflow: hidden;
  width: 76px;
  height: 60px;
  border-radius: 11px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24), 0 5px 12px rgba(26, 34, 31, 0.11);
}

.theme-swatch::before,
.theme-swatch::after {
  position: absolute;
  content: "";
}

.theme-swatch::before {
  inset: 11px;
  background:
    linear-gradient(90deg, transparent 48%, var(--swatch-grid) 49% 51%, transparent 52%),
    linear-gradient(transparent 48%, var(--swatch-grid) 49% 51%, transparent 52%);
  background-size: 15px 15px;
}

.theme-swatch i {
  position: absolute;
  z-index: 1;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.22);
}

.theme-swatch i:nth-child(1) { top: 17px; left: 23px; background: #181a18; }
.theme-swatch i:nth-child(2) { top: 28px; left: 34px; background: #f5f5f1; }
.theme-swatch i:nth-child(3) { top: 17px; left: 45px; background: #181a18; }

.theme-swatch--wood {
  --swatch-grid: rgba(75, 68, 56, 0.34);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), transparent), #e4ddd1;
}

.theme-swatch--jade {
  --swatch-grid: rgba(39, 92, 72, 0.32);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.38), transparent), #bdd7c7;
}

.theme-swatch--night {
  --swatch-grid: rgba(221, 232, 227, 0.26);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent), #4d605b;
}

.theme-swatch--night i:nth-child(1),
.theme-swatch--night i:nth-child(3) {
  border: 1px solid rgba(255, 255, 255, 0.28);
}

@keyframes gentle-pulse {
  0%, 100% { transform: scale(0.94); opacity: 0.7; }
  50% { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
}

@keyframes stone-pop {
  from { opacity: 0; transform: translateY(-18px) scale(0.65); }
}

@keyframes confetti-fall {
  0% { opacity: 0; transform: translate3d(0, -20px, 0) rotate(0); }
  12% { opacity: 0.9; }
  100% { opacity: 0; transform: translate3d(var(--drift, 20px), 110svh, 0) rotate(540deg); }
}

@media (max-width: 900px) {
  .app-shell {
    padding-right: max(22px, env(safe-area-inset-right));
    padding-left: max(22px, env(safe-area-inset-left));
  }

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

  .board-frame {
    width: min(100%, 680px);
  }

  .control-panel {
    width: min(680px, 100%);
    margin: 0 auto 20px;
  }

  .turn-card {
    display: none;
  }

  .control-panel > .rule {
    display: none;
  }

  .mobile-status {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    margin-bottom: 10px;
    font-family: "Songti SC", "STSong", serif;
    font-size: 18px;
    font-weight: 600;
  }

  .mobile-status .stone {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(13px, env(safe-area-inset-right));
    padding-left: max(13px, env(safe-area-inset-left));
  }

  .topbar {
    min-height: 58px;
    margin-bottom: 8px;
  }

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

  .brand small {
    font-size: 7px;
  }

  .brand-mark {
    transform: scale(0.86) rotate(-7deg);
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .top-actions {
    gap: 5px;
  }

  .board-frame {
    padding: 7px;
    border-radius: 7px;
  }

  .board-frame::after {
    inset: -7px;
    border-radius: 12px;
  }

  .board-tools {
    margin-top: 13px;
  }

  .tool-button {
    min-height: 43px;
  }

  .control-panel {
    padding: 23px 18px 20px;
    border-radius: 18px;
  }

  .mode-button {
    min-height: 69px;
  }

  .result-card,
  .help-card,
  .theme-card {
    padding: 42px 24px 27px;
  }
}

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