.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding-top: 0;
  color: var(--text);
}

.match-status-row {
  display: grid;
  gap: 10px;
}

.status-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 9px 12px;
  border: 1px solid var(--accent-dark);
  border-radius: 9px;
  background: var(--panel-light);
  text-align: center;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.status-kicker {
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.12em;
}

.status-text {
  margin-top: 3px;
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.46);
}

.status-box.thinking {
  border-color: var(--accent);
  box-shadow: inset 0 0 26px rgba(202, 165, 106, 0.07);
}

.status-box.thinking .status-text {
  animation: status-pulse 1.1s ease-in-out infinite;
}

.status-box.check {
  border-color: var(--red);
  box-shadow: inset 0 0 28px rgba(198, 75, 64, 0.08);
}

.status-box.check .status-text {
  color: var(--red-light);
}

.status-box.over .status-text {
  color: var(--text);
}

.timer-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 50px;
  padding: 8px 10px;
  border: 2px solid #65716d;
  border-radius: 8px;
  background: var(--panel);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.timer-row.red {
  border-color: var(--red);
}

.timer-row.active {
  background: var(--panel-light);
  box-shadow: 0 0 0 2px rgba(202, 165, 106, 0.26), inset 0 0 20px rgba(202, 165, 106, 0.06);
}

.timer-row.player {
  box-shadow: inset 0 0 18px rgba(202, 165, 106, 0.08);
}

.timer-label {
  color: var(--text-dim);
  font-size: 14px;
}

.timer-value {
  color: var(--text);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.timer-row.low .timer-value {
  color: var(--red-light);
  animation: status-pulse 700ms ease-in-out infinite;
}

.notation-box {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 100px;
  overflow: hidden;
  border: 1px solid var(--accent-dark);
  border-radius: 9px;
  background: rgba(27, 36, 35, 0.86);
}

.notation-header {
  padding: 12px 12px 9px;
  color: var(--accent);
  font-family: "FangSong", "STFangsong", serif;
  font-size: 15px;
  letter-spacing: 0.3em;
  text-align: center;
}

.notation-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  list-style: none;
}

.notation-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px;
  padding: 5px 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  color: #d8dfdc;
  font-size: 14px;
  line-height: 1.4;
}

.notation-list li:hover {
  background: rgba(255, 255, 255, 0.025);
}

.notation-list .step-num {
  color: var(--text-faint);
  text-align: right;
}

.notation-list .move-red {
  color: var(--red-light);
}

.notation-list .move-blue {
  color: #8ec4e8;
}

.notation-list .move-black {
  color: #d8dfdc;
}

.notation-list .empty {
  display: block;
  padding: 10px 0;
  color: var(--text-faint);
  text-align: center;
}

/* 更多游戏：每步一行（序号 + 全文），避免挤进 24px 列换行 */
.notation-list li.extra-notation-row {
  grid-template-columns: 28px minmax(0, 1fr);
}

.notation-list .move-full {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.captured-box {
  color: var(--text-dim);
  font-size: 14px;
}

.captured-row {
  display: flex;
  align-items: center;
  min-height: 24px;
}

.captured-label {
  flex: 0 0 auto;
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
  color: var(--text-dim);
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 15px;
}

.captured-pieces .cap-red {
  color: var(--red-light);
}

.captured-pieces .cap-black {
  color: #d8dfdc;
}

.step-summary {
  color: var(--text-dim);
  font-size: 14px;
}

.match-meta {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid rgba(128, 102, 63, 0.46);
  border-radius: 8px;
  background: rgba(27, 36, 35, 0.52);
}

.action-panel {
  padding: 9px;
  border: 1px solid rgba(128, 102, 63, 0.56);
  border-radius: 9px;
  background: rgba(27, 36, 35, 0.72);
}

.side-switch {
  padding: 9px;
  border: 1px solid rgba(128, 102, 63, 0.56);
  border-radius: 9px;
  background: rgba(27, 36, 35, 0.72);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.segmented-btn {
  min-height: var(--control-h);
  padding: 0 8px;
  border: 1px solid rgba(202, 165, 106, 0.55);
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented-btn:hover {
  color: var(--accent);
}

.segmented-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #151a19;
  font-weight: 600;
}

.panel-label {
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.18em;
  text-align: center;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.action-grid .outline-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: var(--control-h);
  padding: 0 5px;
  font-size: 14px;
}

.action-glyph {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(202, 165, 106, 0.55);
  border-radius: 50%;
  color: var(--accent);
  font-family: "KaiTi", "STKaiti", serif;
  line-height: 1;
}

.action-grid .outline-btn:hover .action-glyph,
.action-grid .outline-btn:focus-visible .action-glyph {
  color: #151a19;
  background: var(--accent);
}

.piece-tray {
  padding: 8px;
  border: 1px solid var(--accent-dark);
  border-radius: 8px;
  background: var(--panel-light);
}

.tray-title {
  margin-bottom: 7px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
}

.tray-items {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.tray-piece {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid #9b7446;
  border-radius: 50%;
  color: var(--ink);
  background: #ead6a9;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.tray-piece.red {
  color: var(--red);
}

.tray-piece:hover,
.tray-piece.selected {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(202, 165, 106, 0.2);
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.58; }
}

@media (max-width: 720px) {
  .sidebar {
    gap: 9px;
  }

  .match-status-row {
    grid-template-columns: minmax(120px, 0.95fr) minmax(210px, 1.55fr);
    gap: 8px;
  }

  .status-box {
    min-height: 58px;
    padding-inline: 8px;
  }

  .status-kicker {
    font-size: 14px;
  }

  .status-text {
    font-size: 16px;
  }

  .timer-row {
    min-height: 58px;
  }

  .action-panel {
    order: 1;
  }

  .match-status-row {
    order: 0;
  }

  .notation-box {
    order: 3;
    min-height: 150px;
  }

  .match-meta {
    order: 2;
  }

  .piece-tray {
    order: 4;
  }
}

@media (max-width: 370px) {
  .match-status-row {
    grid-template-columns: 1fr;
  }
}

/* —— 对局 UI 增强 —— */
.timer-row.active {
  animation: timer-breathe 2.6s ease-in-out infinite;
}

.notation-list li {
  transition: background-color 140ms ease;
}

@keyframes timer-breathe {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(202, 165, 106, 0.22), inset 0 0 18px rgba(202, 165, 106, 0.05);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(202, 165, 106, 0.4), 0 0 22px rgba(202, 165, 106, 0.16), inset 0 0 24px rgba(202, 165, 106, 0.1);
  }
}
