/* 中国象棋国风对弈系统样式表 */
:root {
  --board-bg: #d7a15c;
  --board-wood-1: #e9be81;
  --board-wood-2: #c68945;
  --board-border: #5a3214;
  --line-color: #4a2608;
  --river-text: #6b3e15;
  
  --piece-wood-light: #fbe6c2;
  --piece-wood-dark: #d89f5d;
  --piece-shadow: rgba(0, 0, 0, 0.45);

  --red-color: #c91818;
  --black-color: #1a1a1a;
  
  --highlight-select: #ffd700;
  --highlight-move: #4ade80;
  --highlight-capture: #ef4444;
  --highlight-last: rgba(245, 158, 11, 0.7);

  --ui-bg: #1e1b18;
  --panel-bg: rgba(36, 31, 26, 0.92);
  --panel-border: #524336;
  --text-main: #f3ede2;
  --text-muted: #a39482;
  --accent-gold: #e5b567;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Kaiti', 'STKaiti', 'KaiTi', '楷体', 'PingFang SC', 'Microsoft YaHei', serif;
  background: radial-gradient(circle at 50% 30%, #2c251e 0%, #120f0c 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* 顶部导航标题与快捷栏 */
.top-nav {
  height: 56px;
  background: rgba(22, 19, 16, 0.95);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  font-size: 24px;
  color: var(--accent-gold);
  filter: drop-shadow(0 0 6px rgba(229, 181, 103, 0.4));
}
.brand-title {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.brand-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(229, 181, 103, 0.15);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-family: -apple-system, sans-serif;
}

/* 模式切换胶囊栏 */
.mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 3px;
  gap: 4px;
}
.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mode-btn:hover {
  color: #fff;
}
.mode-btn.active {
  background: var(--accent-gold);
  color: #1a1208;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(229, 181, 103, 0.4);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.icon-btn:hover {
  background: rgba(229, 181, 103, 0.2);
  border-color: var(--accent-gold);
  color: #fff;
}

/* 主对局视窗布局 */
.game-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  gap: 20px;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

/* 左侧：棋盘主体区域 */
.board-section {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  width: 580px;
  max-width: 100%;
  min-width: 0;
}

/* 玩家信息指示卡条 (上方对手，下方自己) */
.player-bar {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.player-bar.bottom {
  margin-top: 10px;
  margin-bottom: 0;
}
.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  border: 2px solid;
}
.player-avatar.red {
  background: #fff;
  color: var(--red-color);
  border-color: var(--red-color);
}
.player-avatar.black {
  background: #333;
  color: #fff;
  border-color: #fff;
}
.player-name {
  font-size: 15px;
  font-weight: bold;
}
.player-status {
  font-size: 11px;
  color: var(--text-muted);
}
.player-timer {
  font-family: 'Consolas', monospace;
  font-size: 20px;
  font-weight: bold;
  color: var(--accent-gold);
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 10px;
  border-radius: 4px;
  border: 1px solid rgba(229, 181, 103, 0.3);
}
.player-bar.turn-active {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(229, 181, 103, 0.3);
}

/* 网格与棋子共享 532 × 596 坐标层，比例不可分别缩放。 */
.board-wrapper {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, var(--board-wood-1) 0%, var(--board-wood-2) 100%);
  border: 8px solid var(--board-border);
  border-radius: 12px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7), inset 0 0 25px rgba(0, 0, 0, 0.4);
  padding: 3%;
  user-select: none;
  touch-action: manipulation;
}
.board-surface {
  position: relative;
  width: 100%;
  aspect-ratio: 532 / 596;
}
.board-svg, .pieces-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.board-svg {
  pointer-events: none;
}
.pieces-container {
  pointer-events: auto;
}

/* 独立棋子 (3D 雕刻微浮质感，全屏自适应 transform 中心点) */
.chess-piece {
  position: absolute;
  width: min(54px, 10.2%);
  aspect-ratio: 1;
  height: auto;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--piece-wood-light) 0%, var(--piece-wood-dark) 90%);
  border: 2px solid #7c4819;
  box-shadow: 0 4px 10px var(--piece-shadow), inset 0 2px 4px rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s;
  z-index: 10;
}
.chess-piece::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 1px dashed rgba(124, 72, 25, 0.45);
}
@media (hover: hover) and (pointer: fine) {
  .chess-piece:hover {
    transform: translate(-50%, -50%) translateY(-3px) scale(1.05);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
    z-index: 20;
  }
}
.chess-piece.selected {
  transform: translate(-50%, -50%) translateY(-5px) scale(1.12);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.6), 0 0 16px var(--highlight-select);
  border-color: var(--highlight-select);
  z-index: 30;
}
.chess-piece.in-check {
  animation: checkPulse 1s infinite;
}

.piece-char {
  font-size: min(28px, 5.5vw);
  font-weight: 900;
  line-height: 1;
}
.chess-piece.red .piece-char {
  color: var(--red-color);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6), 0 -1px 1px rgba(90, 0, 0, 0.5);
}
.chess-piece.black .piece-char {
  color: var(--black-color);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6), 0 -1px 1px rgba(0, 0, 0, 0.8);
}

/* 目标可走落子点提示光标 */
.move-marker {
  position: absolute;
  width: min(52px, 10%);
  aspect-ratio: 1;
  height: auto;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  cursor: pointer;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
}
.move-marker.empty::after {
  content: '';
  width: min(18px, 3.5vw);
  height: min(18px, 3.5vw);
  border-radius: 50%;
  background: var(--highlight-move);
  opacity: 0.8;
  box-shadow: 0 0 8px var(--highlight-move);
  animation: pulseDot 1.2s infinite ease-in-out;
}
.move-marker.capture {
  border: 3px dashed var(--highlight-capture);
  background: rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 12px var(--highlight-capture);
  animation: captureRing 1.2s infinite;
}

/* 上一步走棋轨迹高亮框 */
.last-move-box {
  position: absolute;
  width: min(56px, 10.5%);
  aspect-ratio: 1;
  height: auto;
  transform: translate(-50%, -50%);
  border: 2px solid var(--highlight-last);
  background: rgba(245, 158, 11, 0.15);
  border-radius: 6px;
  pointer-events: none;
  z-index: 5;
}

/* 隐藏 AI 锦囊·神之一手专属提示光圈 (仅自己可见) */
.god-hint-source {
  position: absolute;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.8), inset 0 0 10px rgba(255, 215, 0, 0.5);
  pointer-events: none;
  z-index: 25;
  animation: godPulse 1.2s infinite ease-in-out;
}
.god-hint-target {
  position: absolute;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  border-radius: 50%;
  border: 2px dashed #00f0ff;
  background: rgba(0, 240, 255, 0.2);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.9);
  pointer-events: none;
  z-index: 25;
  animation: godTargetSpin 3s linear infinite;
}
.god-hint-target::after {
  content: '★';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  color: #00f0ff;
  text-shadow: 0 0 8px #00f0ff;
}

@keyframes godPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 0.5; }
}
@keyframes godTargetSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 右侧战况监控与互动面板 */
.side-panel {
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: bold;
  color: var(--accent-gold);
}

/* 房间状态卡片 */
.room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px dashed var(--panel-border);
}
.room-id-tag {
  font-size: 13px;
  color: var(--text-muted);
}
.room-id-tag strong {
  color: #fff;
  font-size: 16px;
  letter-spacing: 1.5px;
  margin-left: 4px;
  font-family: -apple-system, sans-serif;
}

/* 对局控制按钮组 */
.game-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.action-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.action-btn:hover:not(:disabled) {
  background: var(--accent-gold);
  color: #16120e;
  font-weight: bold;
}
.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.action-btn.danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* 棋谱记录栏 */
.notation-box {
  height: 160px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.8;
}
.notation-box::-webkit-scrollbar { width: 4px; }
.notation-box::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

.move-entry {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.08);
}
.move-entry:hover {
  background: rgba(229, 181, 103, 0.08);
}
.move-idx {
  color: var(--text-muted);
  width: 32px;
}
.move-red {
  color: #f87171;
  flex: 1;
}
.move-black {
  color: #e2e8f0;
  flex: 1;
}

/* 实时聊天与快捷弹幕栏 */
.chat-box {
  display: flex;
  flex-direction: column;
  height: 200px;
}
.chat-logs {
  flex: 1;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-logs::-webkit-scrollbar { width: 4px; }
.chat-logs::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

.chat-msg {
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}
.chat-msg.system {
  color: var(--accent-gold);
  background: rgba(229, 181, 103, 0.1);
  font-size: 11px;
}
.chat-msg.red {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}
.chat-msg.black {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
}
.chat-msg.spectator {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.08);
}

.chat-quick-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0;
}
.quick-pill {
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.quick-pill:hover {
  background: var(--accent-gold);
  color: #1a1208;
}

.chat-input-bar {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.chat-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--panel-border);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
  outline: none;
}
.chat-input:focus {
  border-color: var(--accent-gold);
}
.chat-send-btn {
  background: var(--accent-gold);
  border: none;
  color: #1a1208;
  font-weight: bold;
  padding: 0 14px;
  border-radius: 4px;
  cursor: pointer;
}

/* 弹窗对话框与遮罩层 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  background: var(--panel-bg);
  border: 2px solid var(--accent-gold);
  border-radius: 12px;
  width: 380px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  text-align: center;
}
.modal-title {
  font-size: 20px;
  color: var(--accent-gold);
  margin-bottom: 12px;
  font-weight: bold;
}
.modal-body {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 20px;
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.modal-btn {
  padding: 8px 20px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-weight: bold;
}
.modal-btn.primary {
  background: var(--accent-gold);
  color: #1a1208;
}
.modal-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* 动效 */
@keyframes checkPulse {
  0%, 100% { box-shadow: 0 0 10px var(--red-color); }
  50% { box-shadow: 0 0 25px var(--red-color), inset 0 0 12px var(--red-color); }
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.3); opacity: 1; }
}
@keyframes captureRing {
  0% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  50% { transform: translate(-50%, -50%) rotate(180deg) scale(1.1); }
  100% { transform: translate(-50%, -50%) rotate(360deg) scale(1); }
}

/* 窄屏导航分行，避免模式和工具按钮挤成竖排。 */
.mode-btn, .icon-btn, .brand-title {
  white-space: nowrap;
}
@media (max-width: 1100px) {
  .top-nav {
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 8px;
    padding: 10px 8px;
  }
  .brand-badge {
    display: none;
  }
}

@media (max-width: 980px) {
  .game-container {
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    gap: 12px;
  }
  .side-panel {
    width: 580px;
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .top-nav {
    padding: 8px;
    gap: 6px;
  }
  .brand-icon {
    font-size: 20px;
  }
  .brand-title {
    font-size: 17px;
    letter-spacing: 2px;
  }
  .mode-tabs, .nav-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    max-width: 420px;
    gap: 4px;
  }
  .mode-btn {
    justify-content: center;
    min-width: 0;
    min-height: 40px;
    padding: 6px 2px;
    font-size: 13px;
  }
  .nav-actions .icon-btn {
    justify-content: center;
    min-width: 0;
    min-height: 40px;
    padding: 6px 2px;
    font-size: 12px;
  }
  #ai-difficulty {
    grid-column: 1 / -1;
    width: 100%;
    font-size: 16px;
  }
  .game-container {
    padding-top: 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .board-section, .side-panel {
    width: 100%;
    max-width: 420px;
  }
  .board-wrapper {
    border-width: 6px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  }
  .player-bar {
    padding: 6px 10px;
    margin-bottom: 6px;
    min-height: 52px;
  }
  .player-bar.bottom {
    margin-top: 6px;
  }
  .player-info {
    gap: 7px;
    min-width: 0;
  }
  .player-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    font-size: 15px;
  }
  .player-name {
    font-size: 13px;
  }
  .player-status {
    font-size: 11px;
  }
  .player-timer {
    flex-shrink: 0;
    font-size: 17px;
    padding: 2px 6px;
  }
  .panel-card {
    padding: 10px;
    min-width: 0;
  }
  .room-bar {
    gap: 6px;
    padding: 8px;
  }
  .room-id-tag strong {
    font-size: 15px;
  }
  .icon-btn, .action-btn, .quick-pill, .chat-send-btn, .modal-btn {
    min-height: 40px;
  }
  .action-btn {
    font-size: 13px;
    padding: 8px 0;
  }
  .notation-box {
    height: 120px;
  }
  .chat-box {
    height: 240px;
  }
  .chat-logs {
    min-height: 48px;
  }
  .chat-input {
    min-width: 0;
    font-size: 16px;
  }
  .modal-box {
    width: min(380px, calc(100vw - 24px));
    padding: 20px 16px;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
}
