/* ============================================================
   Army Chess (Flip Chess) - Game Styles
   ============================================================ */

:root {
  --red-color: #c62828;
  --red-light: #ffcdd2;
  --blue-color: #1565c0;
  --blue-light: #bbdefb;
  --neutral-color: #f9a825;
  --bg-color: #f5f0e1;
  --board-bg: #c8b88a;
  --cell-bg: #e8dcc8;
  --card-back: #5d4037;
  --card-back-pattern: #795548;
  --selected-color: #ffd600;
  --target-color: #4caf50;
  --capture-target-color: #e53935;
  --flag-target-color: #f9a825;
  --ai-highlight: #42a5f5;
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --cell-size: 110px;
  --cell-gap: 8px;
}

* {
  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: #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(--card-back);
}

.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: #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(--blue-color);
  background: var(--blue-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;
}

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

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

/* ---- Board 5x5 ---- */
#board {
  display: grid;
  grid-template-columns: repeat(5, var(--cell-size));
  grid-template-rows: repeat(5, 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.15);
}

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

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

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

.cell-back::after {
  content: "?";
  font-size: 24px;
  font-weight: bold;
  color: var(--card-back-pattern);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

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

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

/* Red side piece border */
.cell-red {
  box-shadow: inset 0 0 0 2px var(--red-light);
}

/* Blue side piece border */
.cell-blue {
  box-shadow: inset 0 0 0 2px var(--blue-light);
}

/* Neutral flag piece */
.cell-neutral {
  box-shadow: inset 0 0 0 2px var(--neutral-color),
              0 0 8px rgba(249, 168, 37, 0.4);
  border-color: var(--neutral-color) !important;
}

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

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

/* Valid move target */
.cell-target {
  border-color: var(--target-color) !important;
  box-shadow: 0 0 10px var(--target-color);
}

/* Capture target */
.cell-capture-target {
  border-color: var(--capture-target-color) !important;
  box-shadow: 0 0 10px var(--capture-target-color);
}

/* Flag capture target (gold pulse animation) */
@keyframes flag-pulse {
  0%   { box-shadow: 0 0 8px var(--flag-target-color), 0 0 16px rgba(249, 168, 37, 0.4); }
  50%  { box-shadow: 0 0 16px var(--flag-target-color), 0 0 32px rgba(249, 168, 37, 0.7); }
  100% { box-shadow: 0 0 8px var(--flag-target-color), 0 0 16px rgba(249, 168, 37, 0.4); }
}

.cell-flag-target {
  border-color: var(--flag-target-color) !important;
  animation: flag-pulse 1s ease-in-out infinite;
}

/* AI action highlight */
.cell-ai-highlight {
  border-color: var(--ai-highlight) !important;
  box-shadow: 0 0 14px var(--ai-highlight), 0 0 28px rgba(66, 165, 245, 0.3);
}

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

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

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

.captured-section {
  flex: 1;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.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: 36px;
}

.captured-card {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  overflow: hidden;
}

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

/* ---- 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(--red-color);
  background: var(--red-light);
}

#message.info {
  color: var(--blue-color);
  background: var(--blue-light);
}

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

.btn-restart {
  background: var(--card-back);
  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) / 5);
    --cell-gap: 5px;
  }

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

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

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

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

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