/* ============================================================
   Cat and Mouse - Game Styles
   ============================================================ */

:root {
  --red-color: #e74c3c;
  --red-light: #fde8e6;
  --blue-color: #3498db;
  --blue-light: #d6eaf8;
  --bg-color: #1a1a2e;
  --card-bg: #16213e;
  --board-bg: #0f3460;
  --cell-bg: #2a2a4a;
  --card-back-bg: #1e1e3a;
  --selected-color: #f1c40f;
  --target-color: #2ecc71;
  --ai-highlight: #3498db;
  --overlay-bg: rgba(0, 0, 0, 0.85);
  --cell-size: 160px;
  --board-gap: 6px;
}

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

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #e0e0e0;
}

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

.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: var(--card-bg);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  border: 1px solid #2a2a4a;
}

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

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

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

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

.btn-pve {
  background: var(--blue-color);
  color: #fff;
}

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

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

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

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

.btn-rps {
  background: #2a2a4a;
  border: 2px solid #444;
  color: #e0e0e0;
  padding: 10px 18px;
  font-size: 16px;
  border-radius: 8px;
}

.btn-rps:hover {
  border-color: var(--blue-color);
  background: #1e3a5a;
}

.btn-rps.selected {
  border-color: var(--selected-color);
  background: #3a3010;
}

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

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

/* ---- 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: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid #2a2a4a;
  width: 100%;
}

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

.label {
  color: #888;
}

.team-indicator {
  font-weight: bold;
  font-size: 1.1em;
}

.red-text {
  color: var(--red-color);
  font-weight: bold;
}

.blue-text {
  color: var(--blue-color);
  font-weight: bold;
}

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

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

.cell:hover {
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

/* ---- Card back ---- */
.cell-back {
  background: var(--card-back-bg);
  border-radius: 4px;
  width: 90%;
  height: 90%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #333;
}

.cell-back::after {
  content: "?";
  font-size: 48px;
  font-weight: bold;
  color: #555;
  text-shadow: 0 0 8px rgba(100, 100, 200, 0.4);
}

/* ---- Card front ---- */
.cell-face {
  width: 90%;
  height: 90%;
  border-radius: 4px;
  overflow: hidden;
}

.cell-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Red team card border */
.cell-red {
  box-shadow: inset 0 0 0 2px rgba(231, 76, 60, 0.4);
}

/* Blue team card border */
.cell-blue {
  box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.4);
}

/* ---- Highlight States ---- */

/* Selected highlight (yellow) */
.cell-selected {
  border: 3px solid #f1c40f !important;
  box-shadow: 0 0 12px #f1c40f;
}

/* Move target highlight (green) */
.cell-target {
  border: 3px solid #2ecc71 !important;
  box-shadow: 0 0 12px #2ecc71;
}

/* Capture target highlight (red) */
.cell-capture-target {
  border: 3px solid #e74c3c !important;
  box-shadow: 0 0 12px #e74c3c;
}

/* AI action highlight (blue) */
.cell-ai-highlight {
  border: 3px solid #3498db !important;
  box-shadow: 0 0 12px #3498db, 0 0 28px rgba(52, 152, 219, 0.3);
}

/* Empty space */
.cell-empty {
  background: var(--cell-bg);
}

/* ---- Game Rules Panel ---- */
#rules-panel {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid #2a2a4a;
  width: 220px;
  font-size: 13px;
  line-height: 1.6;
  color: #ccc;
}

#rules-panel h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #e0e0e0;
  border-bottom: 2px solid #2a2a4a;
  padding-bottom: 8px;
}

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

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

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

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

/* ---- Captured Cards Display ---- */
#captured-area {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 16px;
  width: 100%;
}

.captured-section {
  flex: 1;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid #2a2a4a;
}

.captured-section h3 {
  font-size: 14px;
  margin-bottom: 8px;
  text-align: center;
}

.captured-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  min-height: 40px;
}

.captured-card {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  background: #2a2a4a;
}

.captured-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- Action Hint ---- */
#message {
  margin-top: 12px;
  padding: 10px 20px;
  font-size: 15px;
  color: #aaa;
  text-align: center;
  min-height: 40px;
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 1px solid #2a2a4a;
  width: 100%;
  max-width: 360px;
}

#message.error {
  color: var(--red-color);
  background: rgba(231, 76, 60, 0.15);
  border-color: rgba(231, 76, 60, 0.3);
}

#message.info {
  color: var(--blue-color);
  background: rgba(52, 152, 219, 0.15);
  border-color: rgba(52, 152, 219, 0.3);
}

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

#winner-text {
  font-size: 24px;
  margin-bottom: 24px;
  color: #e0e0e0;
}

.btn-restart {
  background: #2a2a4a;
  color: #e0e0e0;
  font-size: 18px;
  border: 1px solid #444;
}

.btn-restart:hover {
  background: #3a3a5a;
}

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

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

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

  .cell-back::after {
    font-size: 28px;
  }

  .overlay-content {
    padding: 28px 20px;
  }

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

  #captured-area {
    flex-direction: column;
    gap: 10px;
  }
}

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

  .cell-back::after {
    font-size: 20px;
  }
}
