*, *::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 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, #ff6b35, #e85d2a);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.btn-back {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.btn-back:hover { background: rgba(255,255,255,0.2); }

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

.stats { font-size: 0.9rem; font-weight: 600; }

.game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  gap: 0.8rem;
}

.turn-indicator {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.4rem 1.2rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
}

.turn-indicator.player-turn { background: rgba(77,171,247,0.2); color: #4dabf7; }
.turn-indicator.cpu-turn { background: rgba(255,107,107,0.2); color: #ff6b6b; }
.turn-indicator.check { background: rgba(255,59,59,0.3); color: #ff4444; }

.board-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(88vw, 480px);
  height: min(88vw, 480px);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 3px solid #444;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(9vw, 3.2rem);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  transition: background 0.15s;
}

.cell.light { background: #f0d9b5; }
.cell.dark { background: #b58863; }

.cell.selected { background: #7fc97f !important; }
.cell.valid-move::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
}

.cell.valid-capture { background: rgba(255,80,80,0.4) !important; }
.cell.last-move { background: rgba(255,255,100,0.35) !important; }
.cell.in-check { background: rgba(255,0,0,0.5) !important; }

.controls { display: flex; gap: 0.5rem; }

.btn {
  border: none;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7rem 2rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn:active { transform: scale(0.96); }

.btn-orange {
  background: linear-gradient(135deg, #ff6b35, #e85d2a);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255,107,53,0.4);
}

.btn-orange:hover {
  box-shadow: 0 6px 20px rgba(255,107,53,0.6);
  transform: translateY(-1px);
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.visible { display: flex; }

.modal {
  background: #16213e;
  border-radius: 20px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes modalIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-icon { font-size: 3.5rem; margin-bottom: 0.5rem; }
.modal-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.3rem; }
.modal-msg { font-size: 1rem; opacity: 0.8; margin-bottom: 1.2rem; }

.promo-choices {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1rem;
}

.promo-btn {
  font-size: 2.5rem;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
  color: #fff;
}

.promo-btn:hover { background: rgba(255,255,255,0.25); }

@media (max-width: 400px) {
  .topbar { padding: 0.5rem 0.7rem; }
  .game-title { font-size: 1rem; }
  .cell { font-size: min(11vw, 2.5rem); }
}

@media (orientation: landscape) and (max-height: 500px) {
  .board {
    width: min(70vh, 400px);
    height: min(70vh, 400px);
  }
  .game-container { padding: 0.4rem; gap: 0.3rem; }
}

/* ===== SEO GAME INFO SECTION ===== */
body:has(.game-info) { overflow-y: auto; height: auto; min-height: 100dvh; }
.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; }
