/**
 * style.css — 中国象棋联机对战平台样式
 *
 * 传统古风风格：木质棋盘、立体棋子、红黑经典配色
 */

/* ==================== 全局样式 ==================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --board-bg: #DEB887;
  --board-border: #8B4513;
  --grid-line: #5C3317;
  --red-color: #C0392B;
  --red-dark: #922B21;
  --black-color: #1A1A2E;
  --piece-bg: #F5DEB3;
  --piece-shadow: rgba(0,0,0,0.3);
  --panel-bg: #2C1810;
  --panel-text: #F5DEB3;
  --gold: #DAA520;
  --button-bg: #8B4513;
  --button-hover: #A0522D;
  --highlight: #FFD700;
  --danger: #E74C3C;
  --success: #27AE60;
}

body {
  font-family: 'STKaiti', 'KaiTi', '楷体', 'SimSun', '宋体', serif;
  background: linear-gradient(135deg, #1a0a00 0%, #3d1c00 50%, #1a0a00 100%);
  background-attachment: fixed;
  min-height: 100vh;
  height: auto;
  color: #F5DEB3;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 背景纹理 */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5 L55 30 L30 55 L5 30Z' stroke='%23ffffff08' fill='none' stroke-width='0.5'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ==================== 顶部标题 ==================== */

.header {
  text-align: center;
  padding: 20px 0;
  margin-bottom: 20px;
}

.header h1 {
  font-size: 2.8em;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(218, 165, 32, 0.5), 0 0 30px rgba(218, 165, 32, 0.2);
  letter-spacing: 8px;
  font-weight: normal;
}

.header .subtitle {
  font-size: 1em;
  color: #B8860B;
  letter-spacing: 4px;
  margin-top: 5px;
}

/* ==================== 大厅（创建/加入房间） ==================== */

.lobby {
  max-width: 500px;
  margin: 50px auto;
  padding: 40px;
  background: var(--panel-bg);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  border: 2px solid #5C3317;
}

.lobby h2 {
  text-align: center;
  color: var(--gold);
  font-size: 1.6em;
  margin-bottom: 30px;
  letter-spacing: 4px;
}

.lobby .section {
  margin-bottom: 25px;
  padding: 20px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
}

.lobby .section h3 {
  color: var(--panel-text);
  font-size: 1.1em;
  margin-bottom: 15px;
  letter-spacing: 2px;
}

.lobby label {
  display: block;
  color: #B8860B;
  font-size: 0.9em;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.lobby input[type="text"],
.lobby input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border: 1px solid #5C3317;
  border-radius: 6px;
  color: var(--panel-text);
  font-size: 1em;
  font-family: inherit;
  letter-spacing: 2px;
  transition: border-color 0.3s;
}

.lobby input:focus {
  outline: none;
  border-color: var(--gold);
}

.lobby .checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.lobby .checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.lobby .checkbox-row label {
  margin-bottom: 0;
  cursor: pointer;
}

/* ==================== 按钮样式 ==================== */

.btn {
  display: inline-block;
  padding: 10px 24px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: linear-gradient(180deg, #5C3317, #3d1c00);
  color: var(--gold);
  font-size: 1em;
  font-family: inherit;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
}

.btn:hover {
  background: linear-gradient(180deg, #8B4513, #5C3317);
  box-shadow: 0 0 15px rgba(218,165,32,0.3);
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(180deg, #B8860B, #8B6914);
  color: #1a0a00;
  border-color: #DAA520;
  font-weight: bold;
}

.btn.primary:hover {
  background: linear-gradient(180deg, #DAA520, #B8860B);
  box-shadow: 0 0 20px rgba(218,165,32,0.5);
}

.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn.danger:hover {
  background: var(--danger);
  color: white;
}

.btn.full { width: 100%; }
.btn.small { padding: 6px 14px; font-size: 0.85em; }

/* ==================== 游戏主界面 ==================== */

.game-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: nowrap; /* PC端不换行 */
  padding: 0 15px;
}

/* ==================== 棋盘区域 ==================== */

.board-wrapper {
  position: relative;
  flex-shrink: 0;
}

.board-frame {
  padding: 20px;
  background: linear-gradient(135deg, #8B4513, #5C3317);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6), inset 0 2px 4px rgba(255,255,255,0.1);
  border: 3px solid #3d1c00;
  display: inline-block;
}

.board {
  position: relative;
  background: #DEB887;
  border: 3px solid #5C3317;
  border-radius: 4px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.15);
}

.board canvas {
  display: block;
}

/* ==================== 侧边栏 ==================== */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 300px;
  flex-shrink: 0;
}

/* 玩家信息面板 */
.player-panel {
  padding: 15px;
  border-radius: 10px;
  text-align: center;
  border: 2px solid;
  position: relative;
}

.player-panel.red-player {
  background: linear-gradient(180deg, rgba(192,57,43,0.15), rgba(192,57,43,0.05));
  border-color: var(--red-color);
}

.player-panel.black-player {
  background: linear-gradient(180deg, rgba(26,26,46,0.3), rgba(26,26,46,0.1));
  border-color: #555;
}

.player-panel .player-name {
  font-size: 1.1em;
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.player-panel.red-player .player-name { color: var(--red-color); }
.player-panel.black-player .player-name { color: #AAA; }

.player-panel .timer {
  font-size: 1.8em;
  font-family: 'Courier New', monospace;
  letter-spacing: 3px;
  padding: 5px 15px;
  border-radius: 6px;
  display: inline-block;
  background: rgba(0,0,0,0.3);
}

.player-panel .timer.active {
  animation: timer-pulse 2s infinite;
  box-shadow: 0 0 15px rgba(218,165,32,0.4);
}

.player-panel .timer.urgent {
  color: var(--danger);
  animation: timer-urgent 0.5s infinite;
}

.player-panel .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 5px var(--success); }
.status-dot.offline { background: #666; }

@keyframes timer-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(218,165,32,0.3); }
  50% { box-shadow: 0 0 20px rgba(218,165,32,0.6); }
}

@keyframes timer-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 操作按钮区 */
.action-panel {
  padding: 15px;
  background: var(--panel-bg);
  border-radius: 10px;
  border: 2px solid #5C3317;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.action-panel .btn {
  flex: 1;
  min-width: 70px;
  text-align: center;
}

/* 走棋记录 */
.move-log {
  flex: 1;
  max-height: 250px;
  overflow-y: auto;
  padding: 12px;
  background: var(--panel-bg);
  border-radius: 10px;
  border: 2px solid #5C3317;
}

.move-log h4 {
  color: var(--gold);
  text-align: center;
  margin-bottom: 10px;
  letter-spacing: 3px;
  font-size: 0.95em;
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.move-log .move-item {
  padding: 4px 8px;
  margin: 3px 0;
  border-radius: 4px;
  font-size: 0.9em;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.move-log .move-item.red-move {
  color: var(--red-color);
  background: rgba(192,57,43,0.05);
}

.move-log .move-item.black-move {
  color: #AAA;
  background: rgba(255,255,255,0.02);
}

.move-log .move-num {
  color: #666;
  margin-right: 8px;
  font-size: 0.8em;
  min-width: 25px;
}

/* 滚动条 */
.move-log::-webkit-scrollbar { width: 4px; }
.move-log::-webkit-scrollbar-track { background: transparent; }
.move-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ==================== 房间信息栏 ==================== */

.room-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 15px;
  padding: 10px 20px;
  background: var(--panel-bg);
  border-radius: 8px;
  border: 1px solid #5C3317;
}

.room-info .room-code {
  color: var(--gold);
  font-size: 1.2em;
  letter-spacing: 3px;
}

.room-info .turn-indicator {
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.9em;
  letter-spacing: 2px;
}

.room-info .turn-indicator.red-turn {
  background: rgba(192,57,43,0.2);
  color: var(--red-color);
}

.room-info .turn-indicator.black-turn {
  background: rgba(150,150,150,0.2);
  color: #AAA;
}

/* ==================== 对局结束横幅 ==================== */

.game-over-banner {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px 24px;
  margin-bottom: 15px;
  background: linear-gradient(135deg, rgba(44,24,16,0.95), rgba(60,30,10,0.95));
  border: 2px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(218,165,32,0.25);
  animation: slideDown 0.4s ease-out;
  flex-wrap: wrap;
}

.game-over-banner .game-over-icon {
  font-size: 2em;
  flex-shrink: 0;
  width: 50px;
  text-align: center;
}

.game-over-banner .game-over-text {
  flex: 1;
  min-width: 150px;
}

.game-over-banner .game-over-title {
  color: var(--gold);
  font-size: 1.2em;
  font-weight: bold;
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.game-over-banner .game-over-reason {
  color: #B8860B;
  font-size: 0.9em;
  letter-spacing: 1px;
  line-height: 1.5;
}

.game-over-banner .game-over-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 手机端适配 */
@media (max-width: 600px) {
  .game-over-banner {
    padding: 12px 16px;
    gap: 10px;
  }
  .game-over-banner .game-over-icon {
    font-size: 1.5em;
    width: 35px;
  }
  .game-over-banner .game-over-title {
    font-size: 1em;
    letter-spacing: 2px;
  }
  .game-over-banner .game-over-reason {
    font-size: 0.8em;
  }
  .game-over-banner .game-over-actions {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }
}

/* ==================== 弹窗/模态框 ==================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s;
}

.modal {
  padding: 30px 40px;
  background: var(--panel-bg);
  border-radius: 12px;
  border: 2px solid var(--gold);
  text-align: center;
  max-width: 420px;
  animation: slideUp 0.3s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

.modal h3 {
  color: var(--gold);
  font-size: 1.4em;
  margin-bottom: 15px;
  letter-spacing: 3px;
}

.modal p {
  color: var(--panel-text);
  margin-bottom: 20px;
  line-height: 1.8;
  letter-spacing: 1px;
}

.modal .modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ==================== 提示通知 ==================== */

.toast {
  position: fixed;
  top: 60px; /* 在导航栏下方（导航栏 48px） */
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 1em;
  letter-spacing: 2px;
  z-index: 10002; /* 高于导航栏 z-index: 9999 */
  animation: toastIn 0.3s, toastOut 0.3s 2.5s forwards;
  white-space: nowrap;
}

.toast.info { background: #2980B9; color: white; }
.toast.warning { background: #E67E22; color: white; }
.toast.error { background: var(--danger); color: white; }
.toast.success { background: var(--success); color: white; }
.toast.check { background: #8B0000; color: #FFD700; border: 2px solid #FFD700; font-size: 1.2em; }

@keyframes toastIn { from { top: 0px; opacity: 0; } to { top: 60px; opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ==================== 响应式布局 ==================== */

/* 平板竖屏及以下 */
@media (max-width: 900px) {
  .game-container {
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 0 5px;
  }

  .sidebar {
    width: 100%;
    max-width: 500px;
  }

  .header h1 {
    font-size: 2em;
    letter-spacing: 4px;
  }

  .board-frame {
    padding: 12px;
  }

  .header {
    padding: 10px 0;
    margin-bottom: 10px;
  }
}

/* 手机端 */
@media (max-width: 600px) {
  .header h1 {
    font-size: 1.6em;
    letter-spacing: 3px;
  }

  .header .subtitle {
    font-size: 0.8em;
    letter-spacing: 2px;
  }

  .board-frame {
    padding: 8px;
    border-radius: 8px;
    border-width: 2px;
  }

  .sidebar {
    max-width: 100%;
    gap: 8px;
  }

  .action-panel {
    padding: 8px;
    gap: 4px;
  }

  .action-panel .btn {
    padding: 8px 6px;
    font-size: 0.75em;
    letter-spacing: 1px;
  }

  .player-panel {
    padding: 10px;
  }

  .player-panel .timer {
    font-size: 1.4em;
    padding: 4px 10px;
  }

  .player-panel .player-name {
    font-size: 0.95em;
    letter-spacing: 2px;
    margin-bottom: 4px;
  }

  .move-log {
    max-height: 150px;
    padding: 8px;
  }

  .move-log .move-item {
    font-size: 0.8em;
    padding: 2px 4px;
  }

  .room-info {
    padding: 8px 12px;
    gap: 8px;
    margin-bottom: 10px;
  }

  .room-info .room-code {
    font-size: 1em;
    letter-spacing: 2px;
  }

  .room-info .turn-indicator {
    font-size: 0.8em;
    padding: 3px 8px;
  }

  .lobby {
    margin: 20px auto;
    padding: 20px;
  }

  .lobby h2 {
    font-size: 1.3em;
  }

  .modal {
    padding: 20px 25px;
    margin: 0 15px;
  }

  .modal h3 {
    font-size: 1.2em;
  }

  .modal p {
    font-size: 0.9em;
  }

  .toast {
    font-size: 0.85em;
    padding: 10px 20px;
    white-space: normal;
    max-width: 90vw;
    text-align: center;
  }
}

/* ==================== 聊天框 ==================== */

.chat-box {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-radius: 10px;
  border: 2px solid #5C3317;
  overflow: hidden;
  min-height: 160px;
  max-height: 220px;
}

.chat-box h4 {
  color: var(--gold);
  text-align: center;
  padding: 8px 12px 6px;
  letter-spacing: 3px;
  font-size: 0.95em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin: 0;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 60px;
}

.chat-message {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.82em;
  letter-spacing: 1px;
  line-height: 1.4;
  word-break: break-all;
}

.chat-message .chat-sender {
  font-weight: bold;
  margin-right: 4px;
}

.chat-message.red-msg { color: var(--red-color); background: rgba(192,57,43,0.06); }
.chat-message.black-msg { color: #AAA; background: rgba(255,255,255,0.02); }

.chat-message .chat-time {
  font-size: 0.7em;
  color: #666;
  margin-left: 6px;
}

.chat-empty {
  text-align: center;
  color: #555;
  font-size: 0.8em;
  padding: 15px;
  letter-spacing: 1px;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 6px 10px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.chat-input-row input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid #5C3317;
  border-radius: 4px;
  color: var(--panel-text);
  font-size: 0.85em;
  font-family: inherit;
  letter-spacing: 1px;
  min-width: 0;
}

.chat-input-row input:focus {
  outline: none;
  border-color: var(--gold);
}

.chat-input-row input::placeholder {
  color: #555;
  letter-spacing: 1px;
}

.chat-input-row .btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 0.8em;
}

/* 聊天滚动条 */
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* ==================== 棋子选中与高亮 ==================== */

.piece-selected {
  animation: piece-glow 1s infinite alternate;
}

@keyframes piece-glow {
  from { filter: drop-shadow(0 0 4px #FFD700); }
  to { filter: drop-shadow(0 0 12px #FFD700); }
}

/* ==================== 将军闪烁 ==================== */

.check-flash {
  animation: check-blink 0.5s 3;
}

@keyframes check-blink {
  0%, 100% { background: transparent; }
  50% { background: rgba(255, 0, 0, 0.3); }
}
