:root {
  --a-color: #1565c0;
  --b-color: #e53935;
  --board-bg: #5d4037;
  --cell-bg: rgba(255, 255, 255, 0.95);
  --cell-border: #bdbdbd;
  --cell-size: 100px;
  --cell-gap: 2px;
  --overlay-bg: rgba(0, 0, 0, 0.5);
}

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

body {
  background: linear-gradient(135deg, #667eea, #764ba2);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #333;
}

.btn {
  padding: 12px 32px;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.btn:active {
  transform: translateY(0);
}
.btn-pvp {
  background: #333;
  color: #fff;
  margin: 8px;
}
.btn-pve {
  background: transparent;
  color: #333;
  border: 2px solid #333;
  margin: 8px;
}
.btn-rps {
  background: #f5f5f5;
  color: #333;
  font-size: 20px;
  padding: 16px 24px;
  margin: 4px;
}
.btn-rps:hover {
  background: #e0e0e0;
}
.btn-restart {
  background: #4caf50;
  color: #fff;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay-content {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 500px;
}
.game-title {
  font-size: 2.5em;
  margin-bottom: 8px;
}
.subtitle {
  color: #757575;
  margin-bottom: 24px;
}
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#game-area {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  width: 100%;
}

#status-bar {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.label {
  font-weight: bold;
}
.team-a {
  color: var(--a-color);
  font-weight: bold;
}
.team-b {
  color: var(--b-color);
  font-weight: bold;
}

#game-main {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

#board {
  display: grid;
  grid-template-columns: repeat(4, var(--cell-size));
  grid-template-rows: repeat(5, var(--cell-size));
  gap: var(--cell-gap);
  background: var(--board-bg);
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.cell {
  background: var(--cell-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
  user-select: none;
}
.cell:hover {
  transform: scale(1.05);
  z-index: 1;
}
.cell-a {
  color: var(--a-color);
  text-shadow: 0 2px 4px rgba(21, 101, 192, 0.3);
}
.cell-b {
  color: var(--b-color);
  text-shadow: 0 2px 4px rgba(229, 57, 53, 0.3);
}
.cell-selected {
  outline: 3px solid #ff9800;
  background: #fff3e0;
}
.cell-highlight {
  background: #e8f5e9;
}
.cell-jump {
  background: #fce4ec;
}
.cell-captured {
  background: #ffcdd2;
  opacity: 0.5;
}
.cell-win {
  background: #fff9c4;
  animation: winPulse 0.8s ease-in-out infinite alternate;
}
@keyframes winPulse {
  from {
    box-shadow: 0 0 8px #ffd600;
  }
  to {
    box-shadow: 0 0 20px #ffd600;
  }
}

#rules-panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 20px;
  max-width: 300px;
  font-size: 14px;
}
#rules-panel h3 {
  margin-bottom: 12px;
}
.rule-section {
  margin-bottom: 12px;
}
.rule-section h4 {
  margin-bottom: 4px;
  color: #555;
}
.rule-section ul {
  padding-left: 20px;
}
.rule-section li {
  margin-bottom: 4px;
}

#message {
  margin-top: 12px;
  font-size: 16px;
  min-height: 24px;
}
.error {
  color: #e53935;
  background: rgba(229, 57, 53, 0.1);
  padding: 8px 16px;
  border-radius: 8px;
}
.info {
  color: #2e7d32;
  background: rgba(46, 125, 50, 0.1);
  padding: 8px 16px;
  border-radius: 8px;
}

.rps-player {
  margin: 16px 0;
}
.rps-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.rps-status {
  margin-top: 8px;
  font-size: 16px;
}
.rps-result {
  margin-top: 16px;
  font-size: 18px;
  font-weight: bold;
}

@media (max-width: 700px) {
  :root {
    --cell-size: calc((100vw - 80px) / 4);
  }
  .overlay-content {
    padding: 24px;
    margin: 16px;
  }
  .game-title {
    font-size: 1.8em;
  }
  #rules-panel {
    max-width: 100%;
  }
}
