:root {
  --a-color: #1565c0;
  --b-color: #e53935;
  --board-bg: #f9f3e3;
  --board-line: #2c2c2c;
  --node-empty: #ffffff;
  --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: 12px;
  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 {
  background: var(--board-bg);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: min(560px, 95vw);
}
.board-svg {
  display: block;
  width: 100%;
  height: auto;
}

.board-line {
  stroke: var(--board-line);
  stroke-width: 3;
  stroke-linecap: round;
}

.node {
  cursor: pointer;
}
.node-hit {
  fill: transparent;
}
.node-circle {
  fill: var(--node-empty);
  stroke: var(--board-line);
  stroke-width: 2;
  transition:
    fill 0.15s,
    stroke 0.15s,
    opacity 0.15s;
}
.node-empty .node-circle {
  /* Empty intersection: hide the placeholder circle so only the
     small intersection dot beneath it remains visible. */
  fill: transparent;
  stroke: transparent;
  opacity: 0;
  pointer-events: none;
}
.node-dot {
  fill: var(--board-line);
  pointer-events: none;
}
.node-a .node-dot,
.node-b .node-dot,
.node-empty.node-highlight .node-dot {
  display: none;
}
.node-text {
  font-size: 18px;
  font-weight: bold;
  fill: #fff;
  pointer-events: none;
  user-select: none;
}
.node-a .node-circle {
  fill: var(--a-color);
  stroke: #0d3c6e;
  opacity: 1;
}
.node-b .node-circle {
  fill: var(--b-color);
  stroke: #8b1a17;
  opacity: 1;
}

.node-selected .node-circle {
  stroke: #ff9800;
  stroke-width: 5;
  filter: drop-shadow(0 0 6px rgba(255, 152, 0, 0.85));
}
.node-empty.node-highlight .node-circle {
  /* Reachable empty intersection becomes a clearly visible target. */
  fill: #fff59d;
  stroke: #f9a825;
  stroke-width: 3;
  opacity: 1;
  pointer-events: auto;
}
.node-win .node-circle {
  stroke: #ffd600;
  stroke-width: 5;
  animation: winPulse 0.8s ease-in-out infinite alternate;
}
@keyframes winPulse {
  from {
    filter: drop-shadow(0 0 4px rgba(255, 214, 0, 0.6));
  }
  to {
    filter: drop-shadow(0 0 14px rgba(255, 214, 0, 1));
  }
}

#rules-panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  padding: 20px;
  max-width: 320px;
  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-result {
  margin-top: 16px;
  font-size: 18px;
  font-weight: bold;
}

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