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

body {
  font-family: "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #8b4513 0%, #d2691e 50%, #cd853f 100%);
  min-height: 100vh;
  padding: 20px;
}

.game-container {
  max-width: 1400px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #8b0000 0%, #dc143c 100%);
  color: white;
  padding: 20px;
  text-align: center;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
  display: flex;
  justify-content: center;
  gap: 30px;
  font-size: 1.1rem;
}

.current-player {
  font-weight: bold;
}

.main-content {
  display: flex;
  gap: 20px;
  padding: 20px;
}

.game-board-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.board {
  width: 540px;
  height: 600px;
  background: #f5deb3;
  border: 3px solid #8b4513;
  border-radius: 10px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* 棋盘线条样式已移至JavaScript中直接设置 */

/* 移动端触摸优化 */
.position,
.piece {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.piece {
  touch-action: manipulation;
}

/* 移动端按钮优化 */
@media (hover: none) and (pointer: coarse) {
  .control-btn:hover,
  .mode-btn:hover,
  .modal-btn:hover {
    transform: none;
    box-shadow: none;
  }

  .control-btn:active,
  .mode-btn:active,
  .modal-btn:active {
    transform: scale(0.95);
  }

  .piece:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  }

  .piece:active {
    transform: scale(1.05);
  }

  .position:hover {
    background: transparent;
  }

  .position:active {
    background: rgba(255, 215, 0, 0.3);
  }
}

.river {
  position: absolute;
  left: 30px;
  top: 270px;
  width: 480px;
  height: 60px;
  background: rgba(135, 206, 235, 0.1);
  border: 1px solid #4682b4;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 18px;
  font-weight: bold;
  color: #4682b4;
  z-index: 1;
}

.river-text {
  font-size: 16px;
  font-weight: bold;
}

.river-divider {
  flex: 1;
  text-align: center;
  font-size: 14px;
  color: #666;
}

/* 兵卒位置标记 - 十字形 */
.pawn-marker::before,
.pawn-marker::after {
  content: "";
  position: absolute;
  background: #8b4513;
}

.pawn-marker::before {
  width: 10px;
  height: 1px;
  top: 4px;
  left: 0;
}

.pawn-marker::after {
  width: 1px;
  height: 10px;
  top: 0;
  left: 4px;
}

/* 炮位置标记 - 圆形 */
.cannon-marker::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid #8b4513;
  border-radius: 50%;
  top: 2px;
  left: 2px;
}

.position {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.position:hover {
  background: rgba(255, 215, 0, 0.3);
}

.position.selected {
  background: rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.position.possible-move {
  background: rgba(0, 255, 0, 0.3);
  border: 2px solid #00ff00;
}

.piece {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  z-index: 10;
  position: relative;
}

.piece.red {
  background: radial-gradient(circle, #ff6b6b 0%, #dc143c 100%);
  color: white;
  border: 2px solid #8b0000;
}

.piece.black {
  background: radial-gradient(circle, #4a4a4a 0%, #2c2c2c 100%);
  color: white;
  border: 2px solid #000000;
}

.piece:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.game-controls {
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-panel,
.move-history,
.game-rules {
  background: white;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.control-panel h3,
.move-history h3,
.game-rules h3 {
  color: #8b4513;
  margin-bottom: 10px;
  font-size: 1.2rem;
}

.control-btn {
  width: 100%;
  padding: 10px;
  margin: 5px 0;
  background: linear-gradient(135deg, #8b4513 0%, #d2691e 100%);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.mode-selection {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.mode-btn {
  flex: 1;
  padding: 8px 12px;
  background: #f0f0f0;
  color: #666;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mode-btn:hover {
  background: #e0e0e0;
  border-color: #ccc;
}

.mode-btn.active {
  background: linear-gradient(135deg, #8b4513 0%, #d2691e 100%);
  color: white;
  border-color: #8b4513;
}

.ai-settings {
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 5px;
}

.ai-settings h4 {
  margin: 0 0 8px 0;
  color: #8b4513;
  font-size: 1rem;
}

.difficulty-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: white;
  font-size: 0.9rem;
  color: #666;
}

.history-list {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.history-item {
  padding: 5px;
  border-bottom: 1px solid #eee;
  color: #666;
}

.game-rules ul {
  list-style: none;
  font-size: 0.9rem;
  color: #666;
}

.game-rules li {
  padding: 3px 0;
  position: relative;
  padding-left: 15px;
}

.game-rules li:before {
  content: "•";
  color: #8b4513;
  position: absolute;
  left: 0;
}

.back-button {
  padding: 20px;
  text-align: center;
  background: #f8f9fa;
}

.back-link {
  color: #8b4513;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: bold;
  transition: color 0.3s ease;
}

.back-link:hover {
  color: #d2691e;
}

/* 模态框样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: white;
  border-radius: 15px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  animation: slideIn 0.3s ease;
}

.modal-header {
  background: linear-gradient(135deg, #8b4513 0%, #d2691e 100%);
  color: white;
  padding: 20px;
  border-radius: 15px 15px 0 0;
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-body {
  padding: 30px 20px;
  text-align: center;
}

.game-over-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.modal-body p {
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: #333;
}

.game-over-stats {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 15px;
  margin: 20px 0;
}

.game-over-stats p {
  margin: 5px 0;
  font-size: 1rem;
  color: #666;
}

.modal-footer {
  padding: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.modal-btn.primary {
  background: linear-gradient(135deg, #8b4513 0%, #d2691e 100%);
  color: white;
}

.modal-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.modal-btn:not(.primary) {
  background: #f0f0f0;
  color: #666;
}

.modal-btn:not(.primary):hover {
  background: #e0e0e0;
}

/* 将军提示样式 */
.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
  color: white;
  padding: 15px 30px;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: bold;
  box-shadow: 0 4px 15px rgba(255, 68, 68, 0.4);
  z-index: 999;
  animation: checkNotification 0.5s ease;
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes checkNotification {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 1200px) {
  .main-content {
    flex-direction: column;
    align-items: center;
  }

  .game-controls {
    width: 100%;
    max-width: 600px;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .control-panel,
  .move-history,
  .game-rules {
    flex: 1;
    min-width: 250px;
  }
}

/* 平板适配 */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .game-controls {
    width: 100%;
    max-width: 600px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
  }

  .control-panel,
  .move-history,
  .game-rules {
    flex: 1;
    min-width: 280px;
  }
}

/* 手机适配 */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .game-container {
    margin: 0;
    border-radius: 10px;
  }

  .header {
    padding: 15px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .game-info {
    flex-direction: column;
    gap: 10px;
    font-size: 1rem;
  }

  .main-content {
    padding: 15px;
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  .board {
    width: 320px;
    height: 356px;
    border: 2px solid #8b4513;
  }

  .river {
    left: 18px;
    top: 160px;
    width: 284px;
    height: 36px;
    font-size: 14px;
    padding: 0 10px;
  }

  .river-text {
    font-size: 12px;
  }

  .river-divider {
    font-size: 10px;
  }

  .position {
    width: 32px;
    height: 32px;
  }

  .piece {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .game-controls {
    width: 100%;
    flex-direction: column;
    gap: 15px;
  }

  .control-panel,
  .move-history,
  .game-rules {
    width: 100%;
  }

  .mode-selection {
    flex-direction: column;
    gap: 8px;
  }

  .mode-btn {
    padding: 10px;
    font-size: 0.9rem;
  }

  .control-btn {
    padding: 12px;
    font-size: 0.9rem;
  }

  .history-list {
    max-height: 120px;
  }

  .game-rules ul {
    font-size: 0.8rem;
  }

  /* 模态框移动端适配 */
  .modal-content {
    width: 95%;
    max-width: 350px;
  }

  .modal-header h2 {
    font-size: 1.3rem;
  }

  .game-over-icon {
    font-size: 3rem;
  }

  .modal-body p {
    font-size: 1.1rem;
  }

  .modal-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  /* 将军提示移动端适配 */
  .notification {
    top: 10px;
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 20px;
  }
}

/* 小屏手机适配 */
@media (max-width: 480px) {
  .header h1 {
    font-size: 1.8rem;
  }

  .board {
    width: 280px;
    height: 312px;
  }

  .river {
    left: 16px;
    top: 140px;
    width: 248px;
    height: 32px;
    font-size: 12px;
    padding: 0 8px;
  }

  .position {
    width: 28px;
    height: 28px;
  }

  .piece {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .control-panel h3,
  .move-history h3,
  .game-rules h3 {
    font-size: 1.1rem;
  }

  .game-over-icon {
    font-size: 2.5rem;
  }

  .modal-body p {
    font-size: 1rem;
  }
}
