/* ============================================================
   Tic-Tac-Toe - Game Styles
   ============================================================ */

:root {
  --x-color: #1565c0;
  --x-light: #42a5f5;
  --o-color: #e53935;
  --o-light: #ef5350;
  --board-bg: #f9f3e3;
  --board-line: #2c2c2c;
  --node-empty: #ffffff;
  --overlay-bg: rgba(0, 0, 0, 0.7);
}

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

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

/* ---- Common Buttons ---- */
.btn {
  padding: 12px 32px;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

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

.btn:active {
  transform: translateY(0);
}

/* ---- Overlay ---- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.overlay-content {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ---- Mode Selection ---- */
.game-title {
  font-size: 42px;
  margin-bottom: 4px;
  color: #333;
}

.subtitle {
  font-size: 16px;
  color: #888;
  margin-bottom: 32px;
}

.mode-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  justify-content: center;
}

.mode-buttons .btn {
  padding: 10px 20px;
  font-size: 16px;
}

.btn-pvp {
  background: #333;
  color: #fff;
}

.btn-pve {
  background: #fff;
  color: #333;
  border: 2px solid #333;
}

.btn-online {
  background: #1565c0;
  color: #fff;
}

/* ---- Rock Paper Scissors ---- */
#rps-section h2 {
  margin-bottom: 24px;
  color: #333;
}

.rps-player {
  margin-bottom: 20px;
}

.rps-player h3 {
  margin-bottom: 10px;
  font-size: 16px;
  color: #555;
}

.rps-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-rps {
  background: #fff;
  border: 2px solid #ccc;
  padding: 10px 18px;
  font-size: 16px;
  border-radius: 8px;
}

@media (hover: hover) {
  .btn-rps:hover {
    border-color: #333;
    background: #f5f5f5;
  }
}

.btn-rps.selected {
  border-color: #ffd600;
  background: #fff9c4;
}

.rps-status {
  margin-top: 8px;
  font-size: 14px;
  color: #888;
}

.rps-result {
  margin-top: 16px;
  font-size: 18px;
  font-weight: bold;
  min-height: 28px;
}

/* ---- Game Area ---- */
#game-area {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 700px;
}

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

/* ---- Status Bar ---- */
#status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 12px 20px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 100%;
}

.status-item {
  font-size: 15px;
}

.label {
  color: #777;
}

.team-indicator {
  font-weight: bold;
}

.text-x {
  color: var(--x-color);
}

.text-o {
  color: var(--o-color);
}

/* ---- Board SVG ---- */
#board {
  background: var(--board-bg);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: min(420px, 90vw);
}

.board-svg {
  display: block;
  width: 100%;
  height: auto;
}

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

/* ---- Node (intersection) ---- */
.node {
  cursor: pointer;
}

.node-hit {
  fill: transparent;
}

.node-dot {
  fill: var(--board-line);
  pointer-events: none;
}

.node-circle {
  fill: var(--node-empty);
  stroke: var(--board-line);
  stroke-width: 2;
  transition:
    fill 0.15s,
    stroke 0.15s,
    opacity 0.15s;
}

.node-text {
  font-size: 22px;
  font-weight: bold;
  fill: #fff;
  pointer-events: none;
  user-select: none;
}

/* Empty node: hide circle and dot */
.node:not(.node-x):not(.node-o) .node-circle {
  fill: transparent;
  stroke: transparent;
  opacity: 0;
}

.node:not(.node-x):not(.node-o) .node-dot {
  display: block;
}

/* X piece */
.node-x .node-circle {
  fill: var(--x-color);
  stroke: #0d3c6e;
  opacity: 1;
}

.node-x .node-dot {
  display: none;
}

.node-x .node-text {
  fill: #fff;
}

/* O piece */
.node-o .node-circle {
  fill: var(--o-color);
  stroke: #8b1a17;
  opacity: 1;
}

.node-o .node-dot {
  display: none;
}

.node-o .node-text {
  fill: #fff;
}

/* Win highlight */
.node-win .node-circle {
  stroke: #ffd600;
  stroke-width: 4;
  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 ---- */
#rules-panel {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 220px;
  font-size: 13px;
  line-height: 1.6;
}

#rules-panel h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #333;
  border-bottom: 2px solid var(--board-bg);
  padding-bottom: 8px;
}

.rule-section {
  margin-bottom: 12px;
}

.rule-section h4 {
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.rule-section ul {
  list-style: none;
  padding-left: 4px;
}

.rule-section li {
  color: #666;
  padding: 1px 0;
}

/* ---- Message Area ---- */
#message {
  margin-top: 12px;
  padding: 10px 20px;
  font-size: 15px;
  color: #555;
  text-align: center;
  min-height: 40px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  width: 100%;
  max-width: 360px;
}

#message.error {
  color: var(--o-color);
  background: rgba(229, 57, 53, 0.1);
}

#message.info {
  color: #1b5e20;
  background: rgba(76, 175, 80, 0.2);
}

/* ---- Game Over ---- */
#game-over .overlay-content h2 {
  font-size: 28px;
  margin-bottom: 24px;
}

.btn-restart {
  background: #333;
  color: #fff;
  font-size: 18px;
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .overlay-content {
    padding: 24px 16px;
  }

  .game-title {
    font-size: 32px;
  }

  .btn {
    padding: 10px 22px;
    font-size: 16px;
  }

  .mode-buttons {
    flex-direction: column;
    gap: 12px;
  }

  .rps-buttons {
    flex-direction: column;
    align-items: center;
  }

  #game-main {
    flex-direction: column;
    align-items: center;
  }

  #rules-panel {
    width: 100%;
    max-width: 360px;
  }

  #status-bar {
    gap: 8px 16px;
    padding: 10px 12px;
  }

  .status-item {
    font-size: 13px;
  }
}
