/* ═══════════════════════════════════════════
   Chess Styles — 联合文社 · 棋
   ═══════════════════════════════════════════ */

/* ── Page Hero ── */
.chess-hero {
  text-align: center;
  padding: clamp(2rem, 5vw, 3rem) 0 clamp(1rem, 3vw, 2rem);
}

.chess-page-title {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: var(--gap-sm) 0;
}

.chess-subtitle {
  font-size: 0.9rem;
  color: var(--ui-fg-muted);
  max-width: 400px;
  margin: 0 auto;
}

/* ── Mode Cards ── */
.chess-modes-grid {
  display: flex;
  justify-content: center;
  gap: var(--gap-lg);
  flex-wrap: wrap;
  margin-bottom: var(--gap-xl);
}

.chess-mode-card {
  width: 240px;
  background: var(--ui-surface);
  border: var(--ui-border) solid var(--ui-line);
  padding: var(--gap-xl) var(--gap-lg);
  text-align: center;
  cursor: var(--cursor-pointer);
  transition: border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  color: var(--ui-fg);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
}
.chess-mode-card:hover {
  border-color: var(--ui-line-hover);
  transform: translateY(-2px);
}
.chess-mode-card.selected {
  border-color: var(--ui-fg);
  background: var(--ui-surface-2);
}

.chess-mode-icon {
  font-size: 2rem;
  margin-bottom: var(--gap-xs);
}

.chess-mode-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chess-mode-desc {
  font-size: 0.78rem;
  color: var(--ui-fg-muted);
}

/* ── Difficulty Section ── */
.chess-difficulty-section,
.chess-game-select-section {
  text-align: center;
  margin-bottom: var(--gap-xl);
}
.chess-difficulty-section h3,
.chess-game-select-section h3 {
  margin-bottom: var(--gap-md);
  font-family: var(--font-serif);
  font-size: 1.25rem;
}

.chess-difficulty-grid {
  display: flex;
  justify-content: center;
  gap: var(--gap-md);
  flex-wrap: wrap;
}

.chess-diff-card {
  width: 200px;
  background: var(--ui-surface);
  border: var(--ui-border) solid var(--ui-line);
  padding: var(--gap-lg);
  text-align: center;
  cursor: var(--cursor-pointer);
  transition: border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  color: var(--ui-fg);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-xs);
}
.chess-diff-card:hover {
  border-color: var(--ui-line-hover);
  transform: translateY(-2px);
}
.chess-diff-card.selected {
  border-color: var(--ui-fg);
  background: var(--ui-surface-2);
}

.chess-diff-icon {
  font-size: 2rem;
  margin-bottom: var(--gap-xs);
}

.chess-diff-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.chess-diff-desc {
  font-size: 0.75rem;
  color: var(--ui-fg-muted);
}

/* ── Game Type Cards ── */
.chess-game-grid {
  display: flex;
  justify-content: center;
  gap: var(--gap-md);
  flex-wrap: wrap;
}

.chess-game-card {
  width: 200px;
  background: var(--ui-surface);
  border: var(--ui-border) solid var(--ui-line);
  padding: var(--gap-lg);
  text-align: center;
  cursor: var(--cursor-pointer);
  transition: border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
  color: var(--ui-fg);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-xs);
}
.chess-game-card:hover {
  border-color: var(--ui-line-hover);
  transform: translateY(-2px);
}
.chess-game-card.selected {
  border-color: var(--ui-fg);
  background: var(--ui-surface-2);
}

.chess-game-icon {
  font-size: 2rem;
  margin-bottom: var(--gap-xs);
  color: var(--ui-fg);
}

.chess-game-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.chess-game-desc {
  font-size: 0.75rem;
  color: var(--ui-fg-muted);
}

/* ── Confirm Button ── */
.chess-confirm-section {
  text-align: center;
  margin: var(--gap-xl) 0;
}
.chess-start-btn {
  padding: 14px 40px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
}

/* ── Game Screen ── */
.chess-game-screen {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--gap-md);
}

.chess-game-topbar {
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-sm) 0;
  margin-bottom: var(--gap-md);
  border-bottom: var(--ui-border) solid var(--ui-line);
}

.chess-game-info {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
}

.chess-game-type-label {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
}

.chess-mode-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ui-fg-muted);
  padding: 2px 8px;
  border: var(--ui-border) solid var(--ui-line);
  background: var(--ui-surface);
}

/* ── Board Container ── */
.chess-board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-xl);
  flex-wrap: wrap;
  margin-bottom: var(--gap-md);
}

.chess-player-panel {
  width: 160px;
  text-align: center;
  padding: var(--gap-md);
  border: var(--ui-border) solid var(--ui-line);
  background: var(--ui-surface);
  transition: border-color var(--dur-fast);
}
.chess-player-panel.active-player {
  border-color: var(--ui-fg);
}

.chess-player-avatar {
  font-size: 1.8rem;
  margin-bottom: var(--gap-xs);
  color: #ef4444;
}
.player-blue { color: #3b82f6 !important; }

.chess-player-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.chess-player-status {
  font-size: 0.72rem;
  color: var(--ui-fg-muted);
  font-family: var(--font-mono);
}

.chess-player-captured {
  margin-top: var(--gap-sm);
  font-size: 0.78rem;
  color: var(--ui-fg-muted);
  min-height: 20px;
}

/* ── Canvas Board ── */
.chess-board-wrap {
  position: relative;
  border: var(--ui-border) solid var(--ui-line);
  background: var(--ui-surface);
  padding: 4px;
}

.chess-board-wrap canvas {
  display: block;
  cursor: var(--cursor-pointer);
}

/* ── Controls ── */
.chess-controls {
  display: flex;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-sm);
  flex-wrap: wrap;
  justify-content: center;
}

.chess-status-bar {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ui-fg-muted);
  padding: var(--gap-xs) var(--gap-md);
  border: var(--ui-border) solid var(--ui-line);
  background: var(--ui-surface);
  display: inline-block;
  margin: 0 auto;
}

/* ── Victory Dialog ── */
.chess-victory-icon {
  font-size: 3rem;
  margin-bottom: var(--gap-sm);
}

/* ── Highlight ── */
.chess-highlight-cell {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  background: rgba(139,124,247,0.35);
}

/* ── Invite Section ── */
.chess-invite-section {
  text-align: center;
  margin-bottom: var(--gap-xl);
}
.chess-invite-section h3 {
  margin-bottom: var(--gap-md);
  font-family: var(--font-serif);
  font-size: 1.25rem;
}

.chess-invite-form {
  margin-top: var(--gap-lg);
}

.chess-invite-input-group {
  display: flex;
  gap: var(--gap-sm);
  justify-content: center;
  align-items: center;
  max-width: 500px;
  margin: 0 auto var(--gap-sm);
}
.chess-invite-input-group .input {
  flex: 1;
  min-width: 0;
}

.chess-invite-hint {
  font-size: 0.75rem;
  color: var(--ui-fg-muted);
  margin-top: var(--gap-xs);
}

.chess-invite-result {
  margin-top: var(--gap-md);
  padding: var(--gap-md);
  background: var(--ui-surface);
  border: var(--ui-border) solid var(--ui-line);
}

.chess-invite-success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-xs);
  color: #22c55e;
  font-weight: 600;
}
.chess-invite-success code {
  font-family: var(--font-mono);
  background: var(--ui-surface-2);
  padding: 2px 8px;
  color: var(--ui-fg);
}

.chess-invite-waiting {
  font-size: 0.85rem;
  color: var(--ui-fg-muted);
  margin: var(--gap-sm) 0;
}

.chess-join-section {
  margin-top: var(--gap-xl);
}
.chess-join-or {
  font-size: 0.78rem;
  color: var(--ui-fg-muted);
  margin-bottom: var(--gap-sm);
}

/* ── Topbar Actions ── */
.chess-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

.chess-room-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ui-fg-muted);
  padding: 2px 10px;
  border: var(--ui-border) solid var(--ui-line);
  background: var(--ui-surface);
}
.chess-room-badge code {
  color: var(--ui-fg);
  font-weight: 500;
}

/* ── Chat Area ── */
.chess-chat-area {
  width: 100%;
  max-width: 400px;
  margin: var(--gap-md) auto 0;
  border: var(--ui-border) solid var(--ui-line);
  background: var(--ui-surface);
  display: flex;
  flex-direction: column;
}
.chess-chat-messages {
  height: 120px;
  overflow-y: auto;
  padding: var(--gap-xs) var(--gap-sm);
  font-size: 0.75rem;
  line-height: 1.5;
}
.chess-chat-msg {
  margin-bottom: 2px;
  word-break: break-all;
}
.chess-chat-author {
  font-weight: 600;
  color: var(--ui-fg);
}
.chess-chat-input-row {
  display: flex;
  border-top: var(--ui-border) solid var(--ui-line);
}
.chess-chat-input-row .input {
  flex: 1;
  border: none;
  padding: 6px 10px;
  font-size: 0.78rem;
}
.chess-chat-input-row .btn {
  border-left: var(--ui-border) solid var(--ui-line);
  border-radius: 0;
}

/* ── Stagger animation ── */
.stagger > * { opacity: 0; animation: fadeIn 0.4s var(--ease-out) forwards; }
.stagger.visible > *:nth-child(1) { animation-delay: 0.05s; }
.stagger.visible > *:nth-child(2) { animation-delay: 0.1s; }
.stagger.visible > *:nth-child(3) { animation-delay: 0.15s; }
.stagger.visible > *:nth-child(4) { animation-delay: 0.2s; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .chess-board-container {
    flex-direction: column;
    gap: var(--gap-sm);
  }
  .chess-player-panel {
    width: 100%;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    padding: var(--gap-sm) var(--gap-md);
  }
  .chess-player-avatar { font-size: 1.3rem; margin-bottom: 0; }
  .chess-player-captured { margin-top: 0; }
}

@media (max-width: 480px) {
  .chess-mode-card, .chess-diff-card, .chess-game-card {
    width: 100%;
    max-width: 300px;
  }
  .chess-modes-grid, .chess-difficulty-grid, .chess-game-grid {
    flex-direction: column;
    align-items: center;
  }
  .chess-game-topbar {
    flex-wrap: wrap;
    gap: var(--gap-xs);
    justify-content: center;
  }
  .chess-game-info {
    flex-direction: column;
    gap: 2px;
  }
}
