/* ==================== 基础样式 ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #87CEEB 0%, #98D8C8 50%, #7CB342 100%);
}

#app {
  width: 100%;
  height: 100%;
}

/* ==================== 页面容器 ==================== */
.page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== 登录页面 ==================== */
.page-login {
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #87CEEB 0%, #98D8C8 100%);
}

.login-container {
  text-align: center;
  width: 100%;
  max-width: 400px;
}

.game-title {
  font-size: 2.5rem;
  color: #5D4037;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  margin-bottom: 10px;
}

.game-subtitle {
  font-size: 1.2rem;
  color: #795548;
  margin-bottom: 40px;
}

.login-box {
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  margin-bottom: 20px;
}

.password-input {
  width: 100%;
  padding: 15px 20px;
  font-size: 1.2rem;
  border: 3px solid #8B4513;
  border-radius: 25px;
  outline: none;
  text-align: center;
  margin-bottom: 15px;
  background: #FFF8E1;
}

.password-input:focus {
  border-color: #FF6F00;
  box-shadow: 0 0 10px rgba(255,111,0,0.3);
}

.error-text {
  color: #D32F2F;
  font-size: 0.9rem;
  margin-top: 10px;
}

/* ==================== 等待页面 ==================== */
.page-waiting {
  justify-content: center;
  align-items: center;
}

.waiting-container {
  text-align: center;
}

.waiting-animation {
  position: relative;
  width: 150px;
  height: 80px;
  margin: 0 auto 30px;
}

.waiting-piece-1,
.waiting-piece-2 {
  position: absolute;
  width: 60px;
  height: 60px;
  background: linear-gradient(145deg, #FFCCBC, #FFAB91);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
  color: #D84315;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  border: 3px solid #FF5722;
}

.waiting-piece-1 {
  left: 0;
  animation: moveLeft 1.5s ease-in-out infinite;
}

.waiting-piece-2 {
  right: 0;
  animation: moveRight 1.5s ease-in-out infinite;
}

@keyframes moveLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(30px); }
}

@keyframes moveRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-30px); }
}

/* ==================== 游戏页面 ==================== */
.page-game {
  background: linear-gradient(180deg, #87CEEB 0%, #98D8C8 60%, #7CB342 100%);
}

/* 顶部信息栏 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 20px;
  background: rgba(0,0,0,0.05);
  transition: all 0.3s;
}

.player-info.my-turn {
  background: rgba(76,175,80,0.2);
  box-shadow: 0 0 10px rgba(76,175,80,0.3);
}

.player-color {
  font-size: 1.5rem;
}

.player-name {
  font-size: 1rem;
  font-weight: bold;
  color: #333;
}

.game-status {
  text-align: center;
}

.turn-indicator {
  font-size: 0.9rem;
  color: #666;
}

.my-turn-text {
  color: #4CAF50;
  font-weight: bold;
  font-size: 1.1rem;
}

/* 棋盘容器 */
.board-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  overflow: hidden;
}

.board {
  position: relative;
  /* 手机竖屏：棋盘窄而高 */
  width: 100%;
  max-width: 220px;
  /* 8 行 × 4 列 → 宽高比 1:2（竖长方形） */
  aspect-ratio: 4 / 8;
  background: #DEB887;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 0 20px rgba(139,69,19,0.3);
  overflow: hidden;
}

.board-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 棋盘格子行（8 行） */
.board-row {
  display: flex;
  width: 100%;
  height: 12.5%;
}

/* 棋盘格子（4 列） */
.board-cell {
  width: 25%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.board-cell:active {
  background: rgba(255,255,255,0.3);
}

/* 楚河汉界 */
.river-text {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  color: #5D4037;
  pointer-events: none;
}

/* 可移动/可翻棋标记 */
.move-indicator {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

/* 可走：空位 → 绿色实心小点 */
.move-indicator.move-empty {
  width: 32%;
  height: 32%;
  background: rgba(76,175,80,0.85);
  box-shadow: 0 0 8px rgba(76,175,80,0.6);
}

/* 可吃：对方子 → 红色边框 + 红色 ✕ */
.move-indicator.move-capture {
  width: 80%;
  height: 80%;
  background: rgba(255,255,255,0.25);
  border: 4px solid #F44336;
  box-shadow: 0 0 12px rgba(244,67,54,0.6);
  animation: capturePulse 0.8s ease-in-out infinite;
}

/* 探查+吃：炮打未翻开的对方棋（翻开+吃掉）→ 红色虚线+? */
.move-indicator.move-capture-unknown {
  width: 80%;
  height: 80%;
  background: rgba(255,255,255,0.2);
  border: 3px dashed #F44336;
  box-shadow: 0 0 10px rgba(244,67,54,0.5);
  animation: capturePulse 0.8s ease-in-out infinite;
}

.move-indicator.move-capture-unknown::before {
  content: '?';
  position: absolute;
  font-size: 1.2rem;
  color: #F44336;
  font-weight: bold;
  text-shadow: 0 0 4px #FFF, 0 0 2px #FFF;
  top: 8%;
  left: 8%;
  line-height: 1;
}

/* 探查：炮打未翻开的己方棋（翻开，炮不动）→ 黄色虚线+🔍 */
.move-indicator.move-probe {
  width: 80%;
  height: 80%;
  background: rgba(255,255,255,0.2);
  border: 3px dashed #FFA000;
  box-shadow: 0 0 10px rgba(255,160,0,0.5);
  animation: probePulse 1s ease-in-out infinite;
}

.move-indicator .probe-icon {
  font-size: 1.3rem;
  line-height: 1;
}

@keyframes probePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(255,160,0,0.5); }
  50%      { transform: scale(1.05); box-shadow: 0 0 16px rgba(255,160,0,0.8); }
}

.move-indicator .capture-icon {
  font-size: 1.4rem;
  color: #F44336;
  font-weight: bold;
  text-shadow: 0 0 4px #FFF, 0 0 2px #FFF;
  line-height: 1;
}

@keyframes capturePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px rgba(244,67,54,0.6); }
  50%      { transform: scale(1.08); box-shadow: 0 0 20px rgba(244,67,54,0.9); }
}

.flip-indicator {
  position: absolute;
  width: 80%;
  height: 80%;
  border: 3px dashed #FF9800;
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
}

/* 选中状态 */
.board-cell.selected {
  background: rgba(255,193,7,0.4);
}

/* ==================== 被吃棋子栏 ==================== */
.captured-bar {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(255,255,255,0.85);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.8rem;
  min-height: 28px;
}

.captured-side {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.captured-right {
  justify-content: flex-end;
  text-align: right;
}

.captured-label {
  font-weight: bold;
  color: #5D4037;
  white-space: nowrap;
}

.captured-piece {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.75rem;
  line-height: 1.3;
}

.captured-piece.red-cap {
  background: #FFCDD2;
  color: #B71C1C;
  border: 1px solid #EF9A9A;
}

.captured-piece.black-cap {
  background: #CFD8DC;
  color: #263238;
  border: 1px solid #90A4AE;
}

.captured-none {
  color: #aaa;
  font-style: italic;
}

.captured-divider {
  width: 1px;
  height: 20px;
  background: #ccc;
  margin: 0 8px;
}

/* ==================== 阶段提示条 ==================== */
.phase-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.9rem;
}

.phase-text {
  font-weight: bold;
}

.phase-text.phase-flip { color: #1976D2; }
.phase-text.phase-move { color: #2E7D32; }
.phase-text.phase-wait { color: #999; }

.revealed-count {
  color: #888;
  font-size: 0.85rem;
}

/* ==================== 选中提示条 ==================== */
.hint-bar {
  padding: 10px 14px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: bold;
  animation: hintSlide 0.25s ease-out;
}

.hint-bar.hint-warn {
  background: rgba(255,152,0,0.18);
  color: #E65100;
  border-bottom: 2px solid #FF9800;
}

.hint-bar.hint-info {
  background: rgba(33,150,243,0.12);
  color: #1565C0;
  border-bottom: 2px solid #2196F3;
}

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

/* ==================== 玩法说明卡（登录页） ==================== */
.rules-card {
  background: rgba(255,255,255,0.9);
  border-radius: 12px;
  padding: 0 14px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-align: left;
}

.rules-card summary {
  padding: 12px 0;
  font-weight: bold;
  color: #5D4037;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.rules-card[open] summary {
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.rules-list {
  padding: 0 0 12px 20px;
  font-size: 0.85rem;
  line-height: 1.7;
  color: #555;
}

.rules-list ul {
  padding-left: 18px;
  margin-top: 4px;
}

.rank-table {
  background: #FFF8E1;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 6px 0;
  font-size: 0.82rem;
  font-family: monospace;
}

.rank-table > div {
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
}

.rank-table .rank-note {
  color: #D84315;
  font-weight: bold;
  font-family: -apple-system, 'PingFang SC', sans-serif;
}

/* 棋子样式 */
.piece {
  width: 85%;
  height: 85%;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 1.4rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  transition: transform 0.3s, box-shadow 0.3s;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.piece.red {
  background: linear-gradient(145deg, #FFECB3, #FFCCBC);
  border: 3px solid #D84315;
  color: #BF360C;
}

.piece.black {
  background: linear-gradient(145deg, #CFD8DC, #90A4AE);
  border: 3px solid #37474F;
  color: #263238;
}

/* 棋子背面（仅显示 "?"，不显示中文） */
.piece.back {
  background:
    repeating-linear-gradient(45deg, #8D6E63 0 8px, #6D4C41 8px 16px);
  border: 3px solid #4E342E;
  color: #FFF8E1;
  font-size: 0;       /* 兜底隐藏内部可能的文字 */
}

.piece-back {
  display: block;
  font-size: 1.6rem;
  font-weight: bold;
  color: #FFE0B2;
  text-shadow: 0 0 6px rgba(0,0,0,0.5);
  line-height: 1;
}

/* 棋子选中 */
.piece.selected {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(255,193,7,0.8);
}

/* 棋子可移动（点击选择后） */
.piece.can-move {
  animation: canMoveAnim 0.5s ease-in-out infinite;
}

@keyframes canMoveAnim {
  0%, 100% { box-shadow: 0 3px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 3px 15px rgba(76,175,80,0.6); }
}

/* ==================== 底部操作栏 ==================== */
.bottom-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  flex-wrap: nowrap;
}

/* ==================== 按钮样式 ==================== */
.btn {
  padding: 10px 20px;
  font-size: 1rem;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}

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

.btn-primary {
  background: linear-gradient(145deg, #4CAF50, #388E3C);
  color: white;
  box-shadow: 0 4px 15px rgba(76,175,80,0.4);
}

.btn-primary:hover {
  background: linear-gradient(145deg, #66BB6A, #43A047);
}

.btn-primary:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: linear-gradient(145deg, #90A4AE, #78909C);
  color: white;
}

.btn-undo {
  background: linear-gradient(145deg, #FF9800, #F57C00);
  color: white;
  font-size: 0.85rem;
  padding: 8px 12px;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(255,152,0,0.4);
}

.btn-undo:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-restart {
  background: linear-gradient(145deg, #66BB6A, #43A047);
  color: white;
  font-size: 0.85rem;
  padding: 8px 12px;
  white-space: nowrap;
}

.btn-chat {
  background: linear-gradient(145deg, #2196F3, #1976D2);
  color: white;
  font-size: 0.85rem;
  padding: 8px 12px;
  white-space: nowrap;
}

.btn-mute {
  width: 50px;
  height: 50px;
  padding: 0;
  font-size: 1.5rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #9E9E9E, #757575);
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-mute.muted {
  background: linear-gradient(145deg, #EF5350, #E53935);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.8);
  color: #666;
  border: 2px solid #8B4513;
}

.btn-large {
  padding: 15px 40px;
  font-size: 1.2rem;
}

/* ==================== 聊天面板 ==================== */
.chat-panel {
  position: fixed;
  bottom: 70px;
  left: 10px;
  right: 10px;
  max-height: 50vh;
  background: rgba(255,255,255,0.98);
  border-radius: 20px;
  box-shadow: 0 -5px 30px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #2196F3;
  color: white;
  font-weight: bold;
}

.btn-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 5px 10px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  max-height: 200px;
}

.chat-message {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-message.my-message {
  align-items: flex-end;
}

.msg-player {
  font-size: 0.75rem;
  color: #666;
  margin-bottom: 3px;
}

.msg-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 15px;
  background: #E0E0E0;
  word-break: break-all;
}

.chat-message.my-message .msg-bubble {
  background: #2196F3;
  color: white;
}

.chat-input-area {
  display: flex;
  padding: 10px;
  gap: 10px;
  border-top: 1px solid #eee;
}

.chat-input {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 1rem;
}

.chat-input:focus {
  border-color: #2196F3;
}

.btn-send {
  padding: 10px 20px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 20px;
  font-weight: bold;
}

.voice-area {
  padding: 10px;
  border-top: 1px solid #eee;
}

.btn-voice {
  padding: 8px 12px;
  background: linear-gradient(145deg, #9C27B0, #7B1FA2);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
}

.btn-voice.recording {
  background: linear-gradient(145deg, #F44336, #D32F2F);
  animation: recordingPulse 0.5s ease-in-out infinite;
}

.btn-voice:disabled {
  background: #ccc;
}

@keyframes recordingPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* ==================== 模态弹窗 ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h3 {
  margin-bottom: 15px;
  color: #333;
}

.modal p {
  margin-bottom: 20px;
  color: #666;
}

.modal-large {
  max-width: 360px;
  padding: 40px 30px;
}

.modal-large h2 {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: #333;
}

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

.modal .btn-agree {
  background: linear-gradient(145deg, #4CAF50, #388E3C);
  color: white;
  padding: 12px 30px;
}

.modal .btn-reject {
  background: linear-gradient(145deg, #9E9E9E, #757575);
  color: white;
  padding: 12px 30px;
}

/* ==================== 动画 ==================== */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.chat-panel {
  animation: slideUp 0.3s ease-out;
}

/* ==================== 响应式适配 ==================== */
@media (max-height: 600px) {
  .game-title {
    font-size: 2rem;
  }

  .top-bar {
    padding: 8px 10px;
  }

  .bottom-bar {
    padding: 6px 6px;
    gap: 6px;
  }

  .btn-undo,
  .btn-chat,
  .btn-voice,
  .btn-restart {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

/* 横屏提示 */
@media (orientation: landscape) and (max-height: 500px) {
  .page-game::before {
    content: '请使用竖屏模式';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FFF8E1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    color: #5D4037;
    z-index: 9999;
  }
}

/* ==================== 滚动条样式 ==================== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}
