.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.6rem;
  align-items: start;
}

@media (max-width: 980px) {
  .board-layout {
    grid-template-columns: 1fr;
  }
}

.board-col {
  display: flex;
  gap: 0.9rem;
  align-items: stretch;
  max-width: min(86vh, 700px);
  margin: 0 auto;
  width: 100%;
}

.board-col .cb {
  flex: 1;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.status-line {
  font-size: 1.02rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.8em;
}

.status-line.thinking::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.control-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.control-row + .control-row {
  margin-top: 0.7rem;
}

.control-row label {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.seg button {
  background: var(--bg-soft);
  border: none;
  color: var(--text-muted);
  padding: 0.42rem 0.85rem;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg button + button {
  border-left: 1px solid var(--line);
}

.seg button.active {
  background: var(--gold-dim);
  color: var(--gold-soft);
}

.move-list {
  display: grid;
  grid-template-columns: 2.4em 1fr 1fr;
  gap: 0.1rem 0.4rem;
  max-height: 260px;
  overflow-y: auto;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.move-list .num {
  color: var(--text-muted);
}

.move-list .ply {
  padding: 0.05rem 0.4rem;
  border-radius: 5px;
  cursor: default;
}

.move-list .ply.clickable {
  cursor: pointer;
}

.move-list .ply.clickable:hover {
  background: var(--panel-2);
}

.move-list .ply.current {
  background: var(--gold-dim);
  color: var(--gold-soft);
}

.coach-text {
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg-soft);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  padding: 0.7rem 0.85rem;
  min-height: 2.4em;
}

.coach-text .san {
  color: var(--gold-soft);
  font-weight: 700;
}

.captured-row {
  display: flex;
  align-items: center;
  gap: 0.12rem;
  min-height: 1.5em;
  font-size: 1.25rem;
  line-height: 1;
  flex-wrap: wrap;
}

.captured-row.white-pieces {
  color: #ece4cd;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.captured-row.black-pieces {
  color: #2c2722;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.25);
}

.captured-row .bal {
  font-size: 0.82rem;
  color: var(--green);
  font-family: var(--font-body);
  margin-left: 0.3rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

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

.engine-lines {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.engine-line {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.engine-line:hover {
  border-color: var(--gold);
}

.engine-line .score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold-soft);
  min-width: 3.4em;
}

.engine-line .pv {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.engine-line.best .score {
  color: var(--gold);
}

.depth-tag {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.verdict {
  font-size: 0.9rem;
  color: var(--gold-soft);
  margin-bottom: 0.7rem;
}

.verdict .vscore {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fen-row {
  display: flex;
  gap: 0.45rem;
}

.fen-row input {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.split-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.6rem;
  align-items: start;
}

@media (max-width: 980px) {
  .split-layout {
    grid-template-columns: 1fr;
  }
}

.list-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 76vh;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.list-item {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.list-item:hover {
  border-color: rgba(212, 168, 71, 0.45);
}

.list-item.active {
  border-color: var(--gold);
  background: var(--panel-2);
}

.list-item .li-title {
  font-weight: 600;
  font-size: 0.96rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.list-item .li-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.side-tag {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.side-tag.w {
  color: #ece4cd;
}

.side-tag.b {
  color: #8f86a8;
}

.detail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.detail-head h2 {
  font-size: 1.5rem;
}

.replay-controls {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.9rem;
}

.variation-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.variation-item {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.variation-item:hover {
  border-color: rgba(212, 168, 71, 0.45);
}

.variation-item.active {
  border-color: var(--gold);
}

.variation-item .v-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--gold-soft);
}

.variation-item .v-idea {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.tab-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}

.tab-row button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-row button.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold-soft);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.puzzle-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: transform 0.18s, border-color 0.18s;
}

.puzzle-card:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 168, 71, 0.5);
}

.puzzle-card.solved {
  border-color: rgba(111, 191, 115, 0.55);
}

.puzzle-card .p-title {
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
}

.puzzle-card .p-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.solved-check {
  color: var(--green);
  font-size: 1rem;
}

.feedback {
  font-weight: 600;
  min-height: 1.6em;
}

.feedback.good {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

.guide-section {
  margin-bottom: 2.4rem;
}

.guide-section > h2 {
  font-size: 1.45rem;
  color: var(--gold-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}

.lesson {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.8rem;
  overflow: hidden;
}

.lesson summary {
  cursor: pointer;
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  font-size: 1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.lesson summary::-webkit-details-marker {
  display: none;
}

.lesson summary::after {
  content: '+';
  color: var(--gold);
  font-size: 1.3rem;
  font-weight: 400;
}

.lesson[open] summary::after {
  content: '−';
}

.lesson-body {
  padding: 0 1.2rem 1.2rem;
  color: #cfccc4;
  font-size: 0.94rem;
}

.lesson-body p {
  margin-bottom: 0.8rem;
  max-width: 75ch;
}

.lesson-body strong {
  color: var(--gold-soft);
}

.diagram-row {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin: 1rem 0 0.4rem;
}

.diagram {
  width: min(280px, 100%);
}

.diagram .caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.55rem;
  text-align: center;
}

.shake {
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.win-glow {
  animation: win-glow 1.2s ease;
}

@keyframes win-glow {
  0% { box-shadow: 0 0 0 0 rgba(111, 191, 115, 0.8), 0 18px 50px rgba(0, 0, 0, 0.55); }
  100% { box-shadow: 0 0 0 26px rgba(111, 191, 115, 0), 0 18px 50px rgba(0, 0, 0, 0.55); }
}
