/* ============================================================
   Reversi - Game Styles
   ============================================================ */

:root {
  --black-color: #000000;
  --black-light: #333333;
  --white-color: #ffffff;
  --white-light: #f0f0f0;
  --board-bg: #8b5a2b;
  --cell-bg: #d2691e;
  --cell-border: #654321;
  --selected-color: #ffd600;
  --valid-move-color: #4caf50;
  --invalid-move-color: #e53935;
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --cell-size: 70px;
  --cell-gap: 2px;
}

* {
  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: var(--black-light);
}

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

.mode-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-pvp {
  background: var(--black-color);
  color: #fff;
}

.btn-pve {
  background: var(--white-color);
  color: #000;
  border: 2px solid #000;
}

/* ---- 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;
}

.btn-rps:hover {
  border-color: var(--black-color);
  background: var(--white-light);
}

.btn-rps.selected {
  border-color: var(--selected-color);
  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: 1100px;
}

/* ---- Main Game Area: Board + Rules Panel ---- */
#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;
}

.black-text {
  color: #000;
  font-weight: bold;
}

.white-text {
  color: #666;
  font-weight: bold;
}

/* ---- Board 8x8 ---- */
#board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--cell-gap);
  padding: var(--cell-gap);
  background: var(--board-bg);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  border: 4px solid var(--cell-border);
}

/* ---- Cell ---- */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--cell-bg);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border: 2px solid var(--cell-border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.cell:hover {
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

/* Piece styles */
.piece {
  width: 85%;
  height: 85%;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

.piece-black {
  background: radial-gradient(circle at 30% 30%, #666, #000);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.piece-white {
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Valid move indicator */
.valid-move-indicator {
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--valid-move-color);
  opacity: 0.7;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 0.8; }
  100% { transform: scale(0.8); opacity: 0.5; }
}

/* Selected highlight */
.cell-selected {
  border-color: var(--selected-color) !important;
  box-shadow: 0 0 12px var(--selected-color);
  transform: scale(1.1);
}

/* Last move highlight */
.cell-last-move {
  border-color: #ff9800 !important;
  box-shadow: 0 0 10px #ff9800;
}

/* ---- Game Rules Panel ---- */
#rules-panel {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  width: 250px;
  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;
}

.rule-section p {
  color: #666;
  font-size: 12px;
}

/* ---- Action Hint ---- */
#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(--invalid-move-color);
  background: rgba(229, 57, 53, 0.1);
}

#message.info {
  color: var(--valid-move-color);
  background: rgba(76, 175, 80, 0.2);
}

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

.btn-restart {
  background: var(--black-color);
  color: #fff;
  font-size: 18px;
}

/* ---- Responsive Layout ---- */
@media (max-width: 900px) {
  #game-main {
    flex-direction: column;
    align-items: center;
  }
  #rules-panel {
    width: 100%;
    max-width: 600px;
  }
}

@media (max-width: 700px) {
  :root {
    --cell-size: calc((100vw - 80px) / 8);
    --cell-gap: 1px;
  }

  .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;
  }

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

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

@media (max-width: 400px) {
  :root {
    --cell-size: calc((100vw - 60px) / 8);
    --cell-gap: 0.5px;
  }
}