/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: #1a1a2e;
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ========== Topbar ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, #ff6b35, #e85d2a);
  color: #fff;
  font-family: 'Nunito', sans-serif;
}

.btn-back {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-back:hover { background: rgba(255,255,255,0.15); }

.game-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.stats {
  display: flex;
  gap: 0.8rem;
  font-weight: 700;
  font-size: 1rem;
}

.stat-player { color: #333; }
.stat-cpu { color: #eee; }

/* ========== Game Wrapper ========== */
.game-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.5rem;
  gap: 0.8rem;
}

/* ========== Turn Indicator ========== */
.turn-indicator {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  text-align: center;
  transition: background 0.3s;
}
.turn-indicator.player-turn { background: rgba(50,50,50,0.5); }
.turn-indicator.cpu-turn { background: rgba(255,255,255,0.2); }

/* ========== Board ========== */
.board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 500px;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  background: #1b5e20;
  border: 4px solid #1b5e20;
  border-radius: 8px;
  width: 100%;
  aspect-ratio: 1;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ========== Cell ========== */
.cell {
  background: #2e7d32;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  border-radius: 2px;
  transition: background 0.15s;
}

.cell.valid-move {
  cursor: pointer;
}
.cell.valid-move:hover {
  background: #388e3c;
}

/* Valid move dot */
.cell.valid-move::after {
  content: '';
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  position: absolute;
  pointer-events: none;
}

/* ========== Pieces ========== */
.piece {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  position: absolute;
  transition: transform 0.1s;
}

.piece.black {
  background: radial-gradient(circle at 35% 35%, #555, #111 60%, #000);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.15);
}

.piece.white {
  background: radial-gradient(circle at 35% 35%, #fff, #ddd 60%, #bbb);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 2px rgba(255,255,255,0.6);
}

/* ========== Flip Animation ========== */
.piece.flipping {
  animation: flipPiece 0.5s ease-in-out;
}

@keyframes flipPiece {
  0%   { transform: rotateY(0deg)   scaleX(1); }
  50%  { transform: rotateY(90deg)  scaleX(0); }
  100% { transform: rotateY(180deg) scaleX(1); }
}

/* ========== Last Move Highlight ========== */
.cell.last-move {
  box-shadow: inset 0 0 0 2px rgba(255, 200, 0, 0.6);
}

/* ========== Buttons ========== */
.btn {
  padding: 0.6rem 1.8rem;
  border: none;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.96); }

.btn-orange {
  background: linear-gradient(135deg, #ff6b35, #e85d2a);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,107,53,0.35);
}
.btn-orange:hover {
  box-shadow: 0 6px 18px rgba(255,107,53,0.5);
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal-content {
  background: #16213e;
  border-radius: 16px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-content h2 {
  font-size: 1.4rem;
  margin-bottom: 0.3rem;
}

.modal-content p {
  margin-bottom: 1.2rem;
  opacity: 0.85;
  font-size: 1rem;
}

.modal-content .btn { width: 100%; }

/* ========== Responsive ========== */
@media (max-width: 480px) {
  .topbar { padding: 0.5rem 0.6rem; }
  .game-title { font-size: 1rem; }
  .stats { gap: 0.5rem; font-size: 0.9rem; }
  .board-container { max-width: 95vw; }
  .turn-indicator { font-size: 0.95rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .game-wrapper { padding: 0.3rem 0.5rem; gap: 0.4rem; }
  .board-container { max-width: min(60vh, 400px); }
  .turn-indicator { font-size: 0.85rem; padding: 0.2rem 0.8rem; }
}

/* ===== SEO GAME INFO SECTION ===== */
.game-info {
  max-width: 780px;
  margin: 1rem auto;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  line-height: 1.6;
}
.game-info h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-info h3 { font-size: 0.95rem; font-weight: 700; margin: 0.8rem 0 0.3rem; }
.game-info ul { padding-left: 1.2rem; }
.game-info li { margin-bottom: 0.2rem; }
