:root {
  --bg: #f6f3ec;
  --bg-deep: #efeadf;
  --surface: #ffffff;
  --surface-soft: #fbf9f4;
  --ink: #20231f;
  --ink-soft: #3c4039;
  --muted: #77786f;
  --muted-2: #9a9b91;
  --line: #e5dfd2;
  --line-strong: #d6cebd;
  --green: #2f6b5e;
  --green-deep: #245449;
  --green-soft: #eaf3ef;
  --green-pale: #f2f8f5;
  --vermilion: #b4442e;
  --vermilion-soft: #f8eae5;
  --gold: #c7a15b;
  --wood: #e7cda2;
  --shadow-sm: 0 1px 2px rgba(43, 36, 24, 0.05), 0 4px 14px rgba(43, 36, 24, 0.04);
  --shadow-md: 0 10px 34px rgba(50, 40, 24, 0.09);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(199, 161, 91, 0.10), transparent 26rem),
    radial-gradient(circle at 88% 18%, rgba(47, 107, 94, 0.07), transparent 30rem),
    var(--bg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.01em;
}

::selection {
  background: rgba(47, 107, 94, 0.18);
}

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

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 44px);
  background: rgba(246, 243, 236, 0.88);
  border-bottom: 1px solid rgba(214, 206, 189, 0.7);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
}

.brand-seal {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border-radius: 9px;
  color: #fff8ee;
  background: linear-gradient(145deg, #c35238, #9f3524);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 4px 10px rgba(159, 53, 36, 0.20);
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1;
  padding-bottom: 2px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.16em;
}

.brand-text small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.22em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  position: relative;
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease;
}

.nav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
}

.nav a.active {
  color: var(--green-deep);
  background: var(--green-soft);
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}

.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.progress-pill b {
  color: var(--green);
  font-weight: 600;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.icon-btn:hover {
  color: var(--green);
  border-color: rgba(47, 107, 94, 0.28);
  background: #fff;
}

.icon-btn.muted {
  color: var(--muted-2);
  text-decoration: line-through;
}

/* Layout */
.main {
  flex: 1;
}

.workspace {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 344px;
  gap: 24px;
  align-items: start;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 3.4vw, 44px) 58px;
}

.workspace.is-two-col {
  grid-template-columns: 252px minmax(0, 1fr);
}

.workspace.is-two-col .panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 28px;
  align-items: start;
  padding-top: 2px;
}

.workspace.is-two-col .panel .panel-main {
  min-width: 0;
}

.workspace.is-two-col .panel .panel-side {
  padding-top: 6px;
}

.stage {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 96px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-sm);
}

.sidebar-head {
  padding: 17px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(251, 249, 244, 0.55));
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  color: var(--vermilion);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.kicker::before {
  content: "";
  width: 16px;
  height: 1px;
  background: currentColor;
  opacity: 0.65;
}

.sidebar-head h2 {
  font-size: 20px;
  line-height: 1.3;
}

.sidebar-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.sidebar-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}

.sidebar-progress .bar {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--bg-deep);
}

.sidebar-progress .bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 250ms ease;
}

.sidebar-list {
  margin: 0;
  padding: 7px;
  list-style: none;
  max-height: calc(100vh - 250px);
  overflow: auto;
}

.sidebar-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-list::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: var(--line-strong);
}

.list-item {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) 16px;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.list-item:hover {
  background: var(--surface-soft);
}

.list-item.active {
  background: var(--green-soft);
}

.list-item .num {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  font-family: var(--serif);
  font-size: 12px;
}

.list-item.active .num {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.list-item.done .num {
  border-color: rgba(47, 107, 94, 0.25);
  color: var(--green);
  background: var(--green-soft);
}

.list-item .label {
  min-width: 0;
}

.list-item .label strong {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item.active .label strong {
  color: var(--green-deep);
  font-weight: 600;
}

.list-item .label small {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  justify-self: center;
}

.state-dot.done {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 107, 94, 0.10);
}

.sidebar-foot {
  padding: 11px 16px 13px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.6;
}

/* Board card */
.board-card {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.board-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(199, 161, 91, 0.16);
  border-radius: 13px;
  pointer-events: none;
}

.board-wrap {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  margin: 0 auto;
}

.board-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 0 5px;
  color: var(--muted);
  font-size: 11.5px;
}

.turn-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
}

.turn-stone {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #20211f;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.24);
}

.turn-stone.white {
  border: 1px solid #cec8ba;
  background: #fdfcf8;
}

.board-caption .coord-note {
  color: var(--muted-2);
}

.board-card.is-done {
  box-shadow: 0 0 0 1px rgba(47, 107, 94, 0.18), var(--shadow-md);
}

/* SVG board */
.goban {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
  user-select: none;
  cursor: default;
}

.goban.interactive {
  cursor: pointer;
}

.goban .grid-line {
  stroke: #68492f;
  stroke-width: 1.1;
  opacity: 0.52;
  vector-effect: non-scaling-stroke;
}

.goban .grid-edge {
  stroke-width: 1.7;
  opacity: 0.78;
}

.goban .coord {
  fill: #8b6a45;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0.9;
}

.goban .star {
  fill: #563a24;
  opacity: 0.82;
}

.goban .stone-shape {
  filter: url(#stone-shadow);
}

.goban .stone-highlight {
  fill: #ffffff;
  opacity: 0.16;
  pointer-events: none;
}

.goban .last-move {
  fill: var(--vermilion);
  stroke: #fffaf1;
  stroke-width: 1.5;
}

.goban .target-ring {
  fill: none;
  stroke: var(--vermilion);
  stroke-width: 2.1;
  opacity: 0.9;
  pointer-events: none;
}

.goban .hint-ring {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.8;
  opacity: 0.95;
  transform-box: fill-box;
  transform-origin: center;
  animation: hintPulse 1.25s ease-out infinite;
  pointer-events: none;
}

.goban .hint-dot {
  fill: var(--green);
  pointer-events: none;
}

.goban .wrong-mark {
  stroke: #c13b2a;
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.goban .correct-mark {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.6;
  pointer-events: none;
}

.goban .territory-mark {
  opacity: 0.22;
  pointer-events: none;
}

.goban .territory-stone {
  opacity: 0.88;
  pointer-events: none;
}

.goban .move-number {
  font-family: var(--sans);
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.goban .ghost-stone {
  opacity: 0;
  pointer-events: none;
}

.goban .ghost-stone.visible {
  opacity: 0.38;
}

.goban .board-note {
  fill: #7e5d3b;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

@keyframes hintPulse {
  0% {
    opacity: 0.85;
    transform: scale(0.72);
  }
  70% {
    opacity: 0;
    transform: scale(1.22);
  }
  100% {
    opacity: 0;
    transform: scale(1.22);
  }
}

/* Panel */
.panel {
  min-width: 0;
  padding-top: 2px;
}

.panel-main {
  min-width: 0;
}

.panel h1 {
  font-size: clamp(28px, 3.1vw, 38px);
  line-height: 1.18;
  letter-spacing: -0.01em;
}

.panel .subhead {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.03em;
}

.panel .intro {
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.85;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  font-size: 11.5px;
}

.chip.goal {
  border-color: rgba(180, 68, 46, 0.18);
  color: var(--vermilion);
  background: var(--vermilion-soft);
}

.chip.turn {
  border-color: rgba(47, 107, 94, 0.16);
  color: var(--green-deep);
  background: var(--green-pale);
}

.panel-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.panel-section h3 {
  margin-bottom: 9px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hint-box {
  padding: 12px 14px;
  border: 1px solid rgba(199, 161, 91, 0.36);
  border-radius: 10px;
  background: #fbf6e9;
  color: #6f5a33;
  font-size: 13px;
  line-height: 1.7;
}

.hint-box[hidden] {
  display: none;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  color: #fff;
  background: var(--green);
  box-shadow: 0 5px 14px rgba(47, 107, 94, 0.20);
}

.btn.primary:hover {
  background: var(--green-deep);
}

.btn.secondary {
  border-color: var(--line-strong);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.7);
}

.btn.secondary:hover {
  border-color: rgba(47, 107, 94, 0.35);
  color: var(--green-deep);
  background: #fff;
}

.btn.ghost {
  color: var(--muted);
  background: transparent;
}

.btn.ghost:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
}

.btn.small {
  min-height: 31px;
  padding: 5px 10px;
  font-size: 12px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  box-shadow: none;
}

.btn .key {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.10);
  font-size: 10px;
}

.result-card {
  position: relative;
  margin-top: 20px;
  padding: 16px 16px 15px;
  border: 1px solid rgba(47, 107, 94, 0.22);
  border-radius: 12px;
  background: linear-gradient(180deg, #f5faf7, #fbfdfb);
  animation: riseIn 340ms ease both;
}

.result-card h3 {
  margin: 0 0 6px;
  color: var(--green-deep);
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0;
  text-transform: none;
}

.result-card p {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
}

.result-card .stamp {
  position: absolute;
  top: 12px;
  right: 13px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--vermilion);
  border-radius: 5px;
  color: var(--vermilion);
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.15;
  letter-spacing: 0.08em;
  text-align: center;
  transform: rotate(6deg);
  opacity: 0.82;
  animation: stampIn 280ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.source-line {
  margin-top: 18px;
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.6;
}

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

@keyframes stampIn {
  from { opacity: 0; transform: rotate(6deg) scale(1.35); }
  to { opacity: 0.82; transform: rotate(6deg) scale(1); }
}

/* Segmented controls */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.segmented button {
  min-height: 31px;
  padding: 4px 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.segmented button.active {
  color: var(--green-deep);
  background: #fff;
  box-shadow: 0 1px 4px rgba(43, 36, 24, 0.10);
  font-weight: 600;
}

/* Setup / play */
.setup-card {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.setup-card h2 {
  font-size: 25px;
}

.setup-card > p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.field {
  min-width: 0;
}

.field > label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.field.full {
  grid-column: 1 / -1;
}

.setup-note {
  margin-top: 20px;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.engine-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.engine-note i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c39a3a;
  flex: none;
}

.engine-note.ready {
  color: var(--green-deep);
}

.engine-note.ready i {
  background: var(--green);
}

.engine-note.error {
  color: var(--vermilion, #b4462f);
}

.engine-note.error i {
  background: var(--vermilion, #b4462f);
}

.engine-eval {
  margin: 4px 0 0;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.6;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.game-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.stat {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.55);
}

.stat small {
  display: block;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.stat strong {
  display: block;
  margin-top: 2px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}

.stat strong.green {
  color: var(--green-deep);
}

.stat strong.vermilion {
  color: var(--vermilion);
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.status-line .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: breathe 1.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

.move-log {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 130px;
  overflow: auto;
  margin-top: 12px;
  padding-top: 4px;
}

.move-log:empty::before {
  content: "还没有落子";
  color: var(--muted-2);
  font-size: 11.5px;
}

.move-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: #fff;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.move-pill b {
  color: var(--ink-soft);
  font-weight: 600;
}

.move-pill.black b::before,
.move-pill.white b::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 3px;
  border-radius: 50%;
  vertical-align: 1px;
  background: #242522;
}

.move-pill.white b::before {
  border: 1px solid #cfc8ba;
  background: #fbfaf6;
}

.score-box {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.8;
}

.score-box b {
  color: var(--green-deep);
}

/* Joseki / kifu */
.step-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.step-badge strong {
  color: var(--green-deep);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
}

.comment-box {
  min-height: 86px;
  margin-top: 14px;
  padding: 14px 15px;
  border-left: 3px solid var(--green);
  border-radius: 0 9px 9px 0;
  background: var(--green-pale);
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.8;
}

.comment-box {
  max-height: 340px;
  overflow: auto;
}

.comment-box p + p {
  margin-top: 9px;
}

.comment-box .move-tag {
  display: block;
  margin-bottom: 5px;
  color: var(--green-deep);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.playback-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 17px;
}

.playback-row .spacer {
  flex: 1;
}

.move-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  max-height: 158px;
  overflow: auto;
  margin-top: 12px;
  padding: 2px;
}

.move-grid button {
  min-height: 27px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: #fff;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.move-grid button:hover {
  border-color: rgba(47, 107, 94, 0.35);
  color: var(--green-deep);
}

.move-grid button.active {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.move-grid button.pass {
  color: var(--vermilion);
}

.move-grid button.featured {
  border-color: rgba(180, 68, 46, 0.5);
  color: var(--vermilion);
  box-shadow: inset 0 0 0 1px rgba(180, 68, 46, 0.08);
}

.move-grid button.featured.active {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.kifu-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.kifu-desc {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.55);
}

.toggle-row span {
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 99px;
  background: var(--line-strong);
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.switch.on {
  background: var(--green);
}

.switch.on::after {
  transform: translateX(16px);
}

/* Empty / intro states */
.intro-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.intro-card h2 {
  font-size: 25px;
}

.intro-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.intro-card .action-row {
  margin-top: 18px;
}

/* Footer */
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 22px;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 18px clamp(18px, 3.4vw, 44px) 26px;
  border-top: 1px solid rgba(214, 206, 189, 0.62);
  color: var(--muted-2);
  font-size: 11px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.text-btn {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: none;
  font-size: 11px;
  text-decoration: underline;
  text-decoration-color: rgba(119, 120, 111, 0.35);
  text-underline-offset: 3px;
}

.text-btn:hover {
  color: var(--green-deep);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  max-width: min(88vw, 460px);
  padding: 10px 16px;
  border-radius: 9px;
  color: #f8f6f0;
  background: rgba(32, 35, 31, 0.94);
  box-shadow: 0 10px 30px rgba(20, 18, 14, 0.20);
  font-size: 12.5px;
  line-height: 1.5;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: rgba(153, 53, 36, 0.96);
}

.toast.success {
  background: rgba(36, 84, 73, 0.96);
}

/* Modal */
.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 28, 23, 0.34);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 26px 28px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(26, 22, 15, 0.24);
  animation: riseIn 220ms ease both;
}

.modal-card h2 {
  padding-right: 34px;
  font-size: 24px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  font-size: 19px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.modal-body {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
}

.modal-body h3 {
  margin: 18px 0 6px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  margin: 6px 0;
}

.modal-body ul {
  margin: 6px 0;
  padding-left: 18px;
}

.modal-body li {
  margin: 4px 0;
}

.modal-body a {
  color: var(--green-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}

.import-form {
  display: grid;
  gap: 12px;
}

.import-form textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.6;
}

.import-form input[type="file"] {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.import-hint {
  color: var(--muted);
  font-size: 11.5px;
}

.form-error {
  color: var(--vermilion);
  font-size: 12px;
}

.import-form .field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

/* Play setup */
.sidebar-body {
  display: grid;
  gap: 16px;
  padding: 16px 18px 18px;
}

.sidebar-body .segmented {
  display: flex;
  width: 100%;
}

.sidebar-body .segmented button {
  flex: 1 1 auto;
  padding-left: 6px;
  padding-right: 6px;
}

.sidebar-body .btn {
  width: 100%;
}

.sidebar-body .setup-note {
  margin-top: 0;
}

.source-line a {
  color: var(--green-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Small helpers */
.muted {
  color: var(--muted);
}

.serif {
  font-family: var(--serif);
}

.hidden {
  display: none !important;
}

.nowrap {
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 224px minmax(0, 1fr);
    gap: 22px;
  }

  .workspace .panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 26px;
    align-items: start;
    padding-top: 0;
  }

  .workspace .panel > .panel-main:only-child {
    grid-column: 1 / -1;
  }

  .workspace .panel .panel-side {
    padding-top: 4px;
  }

  .sidebar {
    top: 90px;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    gap: 7px 18px;
    padding-top: 10px;
    padding-bottom: 9px;
  }

  .brand {
    order: 1;
  }

  .top-actions {
    order: 2;
    margin-left: auto;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    padding-bottom: 1px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding-top: 18px;
  }

  .sidebar {
    position: static;
    order: 1;
  }

  .stage {
    order: 2;
  }

  .panel {
    order: 3;
    grid-column: auto !important;
    display: block !important;
    padding-top: 0;
  }

  .workspace .panel .panel-side {
    padding-top: 0;
  }

  .sidebar-list {
    display: flex;
    gap: 6px;
    max-height: none;
    overflow-x: auto;
    padding: 7px;
  }

  .sidebar-list li {
    flex: 0 0 auto;
  }

  .list-item {
    width: auto;
    min-width: 140px;
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .list-item .state-dot {
    display: none;
  }

  .sidebar-foot,
  .sidebar-progress {
    display: none;
  }

  .board-card {
    padding: 12px;
  }

  .board-card::before {
    inset: 6px;
  }
}

.nowrap {
  white-space: nowrap;
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .brand-text small {
    display: none;
  }

  .progress-pill {
    padding: 5px 8px;
    font-size: 10.5px;
  }

  .board-caption {
    margin-top: 8px;
    font-size: 10.5px;
  }

  .panel h1 {
    font-size: 28px;
  }

  .setup-card {
    padding: 18px;
  }

  .setup-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .field.full {
    grid-column: auto;
  }

  .game-stats {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .move-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .modal-card {
    padding: 21px 19px;
  }

  .toast {
    bottom: 16px;
  }
}
