* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: #0C0D14;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding-top: 16px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e0e0e0;
}

#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  padding: 0 8px;
}

/* ── HUD ─────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: #13141D;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 16px;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #888;
  text-transform: uppercase;
}

.hud-value {
  font-size: 28px;
  font-weight: 700;
  color: #00ff88;
}

.hud-value--ai {
  color: #ff4466;
}

#turn-indicator {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffcc00;
  text-align: center;
  text-transform: uppercase;
  min-width: 120px;
  transition: color 0.3s;
}

/* ── Board ───────────────────────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: min(90vw, calc(90vh - 100px));
  height: min(90vw, calc(90vh - 100px));
  max-width: 500px;
  max-height: 500px;
  background: #0e3a18;
  border: 3px solid #0e3a18;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.08), 0 4px 20px rgba(0, 0, 0, 0.5);
}

.cell {
  background: #1a5c2a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.cell:hover {
  background: #1f6b32;
}

.cell.valid-move::after {
  content: '';
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(0, 255, 136, 0.25);
  position: absolute;
  pointer-events: none;
  transition: background 0.2s;
}

.cell.valid-move:hover::after {
  background: rgba(0, 255, 136, 0.5);
}

.cell.last-move {
  box-shadow: inset 0 0 0 2px rgba(0, 255, 136, 0.35);
}

/* ── Discs ───────────────────────────────────────────────── */
.disc {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  position: absolute;
  transition: transform 0.1s;
  perspective: 200px;
}

.disc-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease-in-out;
}

.disc-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.disc-face--black {
  background: radial-gradient(ellipse at 35% 30%, #3a3a5e, #1a1a2e 70%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.1);
}

.disc-face--white {
  background: radial-gradient(ellipse at 35% 30%, #ffffff, #d0d0d0 70%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.6);
  transform: rotateY(180deg);
}

/* When disc is white, rotate inner to show white face */
.disc-inner.white {
  transform: rotateY(180deg);
}

/* Flip animation */
.disc-inner.flipping {
  transition: transform 0.5s ease-in-out;
}

/* Placed animation */
.disc.placed {
  animation: discPlace 0.3s ease-out;
}

@keyframes discPlace {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Overlay ─────────────────────────────────────────────── */
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 13, 20, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.3s;
}

#overlay.hidden {
  display: none;
}

#overlay-box {
  text-align: center;
  padding: 40px 32px;
}

#overlay-box h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #00ff88;
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
  letter-spacing: 3px;
}

.subtitle {
  font-size: 15px;
  color: #888;
  margin-bottom: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.controls-hint {
  font-size: 13px;
  color: #666;
  margin-bottom: 24px;
  line-height: 1.6;
}

.game-btn {
  background: linear-gradient(135deg, #00ff88, #00cc6a);
  color: #0C0D14;
  border: none;
  padding: 14px 40px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 3px;
  border-radius: 6px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.game-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
}

.game-btn:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

#result-title {
  font-size: 32px;
  margin-bottom: 8px;
}

#result-detail {
  font-size: 15px;
  color: #aaa;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 400px) {
  #hud {
    padding: 8px 10px;
  }
  .hud-label {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .hud-value {
    font-size: 22px;
  }
  #turn-indicator {
    font-size: 11px;
    min-width: 80px;
  }
  #overlay-box h1 {
    font-size: 28px;
  }
}
