/* ══════════════════════════════════════════
   GOBLET GOBBLERS — style.css
   ══════════════════════════════════════════ */

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

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ──────────────────────────────────────
   OVERLAY SCREENS
────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.hidden {
  display: none !important;
}

#game-screen {
  background: var(--bg-primary);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow-y: auto;
  flex-direction: column;
}

#start-screen {
  background: var(--bg-primary);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.screen-content {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
}

/* ──────────────────────────────────────
   START SCREEN
────────────────────────────────────── */
.game-logo-css {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 32px;
  max-width: 360px;
  width: 90%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.game-title {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6, #EC4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.game-desc { font-size: 16px; color: var(--text-secondary); text-align: center; line-height: 1.6; }
.game-hint { font-size: 13px; color: var(--text-muted); letter-spacing: 0.5px; }
.over-title { font-size: 32px; font-weight: 800; color: var(--text-primary); }

.stats-box {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 28px;
  display: flex;
  justify-content: center;
  gap: 32px;
  align-items: center;
}

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

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* ──────────────────────────────────────
   BUTTONS
────────────────────────────────────── */
.cta-btn {
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 20px var(--accent-glow);
  letter-spacing: 0.5px;
  width: 100%;
  max-width: 280px;
}
.cta-btn:hover { filter: brightness(1.1); }
.cta-btn:active { transform: scale(0.97); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  background: var(--btn-bg);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
  width: 100%;
}

.btn:hover {
  border-color: var(--accent);
  background: var(--btn-active);
}

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

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  width: auto;
  border-radius: 8px;
}

/* ──────────────────────────────────────
   RESULT SCREEN
────────────────────────────────────── */
.result-emoji {
  font-size: 72px;
  line-height: 1;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
}

.result-title.win {
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-title.lose {
  background: linear-gradient(135deg, #EC4899, #EF4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ──────────────────────────────────────
   GAME SCREEN
────────────────────────────────────── */
#game-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  padding: 12px 12px 16px;
  gap: 10px;
  position: relative;
}

/* ── Header ── */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 6px;
}

/* ── Status bar ── */
.status-bar {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.turn-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: background 0.2s;
}

.turn-dot.player1 {
  background: radial-gradient(circle at 35% 35%, #60A5FA, #3B82F6);
  border: 1px solid #2563EB;
}

.turn-dot.player2 {
  background: radial-gradient(circle at 35% 35%, #F472B6, #EC4899);
  border: 1px solid #DB2777;
}

.status-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.thinking-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinkDot 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ──────────────────────────────────────
   RESERVES
────────────────────────────────────── */
.reserve {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.reserve-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}

.reserve-pieces {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.reserve-piece {
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 2px solid transparent;
}

.reserve-piece:hover {
  transform: scale(1.1);
}

.reserve-piece.selected {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6), 0 0 16px rgba(59, 130, 246, 0.6);
  transform: scale(1.15);
}

.reserve-piece.disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Piece sizes */
.piece-small {
  width: 24px;
  height: 24px;
}

.piece-medium {
  width: 36px;
  height: 36px;
}

.piece-large {
  width: 48px;
  height: 48px;
}

/* Player colors */
.piece-player1 {
  background: radial-gradient(circle at 35% 35%, #93C5FD, #3B82F6);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.piece-player2 {
  background: radial-gradient(circle at 35% 35%, #F9A8D4, #EC4899);
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.4);
}

/* Disabled reserve piece (already used) */
.reserve-piece.disabled {
  opacity: 0.15;
  pointer-events: none;
}

/* ──────────────────────────────────────
   BOARD
────────────────────────────────────── */
.board-container {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  width: min(80vw, 300px);
  height: min(80vw, 300px);
  max-width: 300px;
  max-height: 300px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 8px;
}

.cell {
  background: var(--bg-tertiary, #21262D);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  aspect-ratio: 1;
}

.cell:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.cell.valid-target {
  border-color: #10B981;
  background: rgba(16, 185, 129, 0.1);
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.15);
}

.cell.selected {
  border-color: #FBBF24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4), inset 0 0 12px rgba(251, 191, 36, 0.15);
}

.cell.win-cell {
  animation: winPulse 0.8s ease-in-out infinite alternate;
}

@keyframes winPulse {
  from {
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
    border-color: #3B82F6;
  }
  to {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
    border-color: #60A5FA;
  }
}

/* Board pieces */
.board-piece {
  border-radius: 50%;
  transition: transform 0.2s;
  position: absolute;
}

.board-piece.piece-small {
  width: 28px;
  height: 28px;
}

.board-piece.piece-medium {
  width: 44px;
  height: 44px;
}

.board-piece.piece-large {
  width: 60px;
  height: 60px;
}

.board-piece.piece-player1 {
  background: radial-gradient(circle at 35% 35%, #93C5FD, #3B82F6);
  box-shadow: 0 3px 10px rgba(59, 130, 246, 0.5);
}

.board-piece.piece-player2 {
  background: radial-gradient(circle at 35% 35%, #F9A8D4, #EC4899);
  box-shadow: 0 3px 10px rgba(236, 72, 153, 0.5);
}

.board-piece.selected {
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.7), 0 0 16px rgba(251, 191, 36, 0.4);
  transform: scale(1.08);
}

/* ── Mini stats ── */
.mini-stats {
  display: flex;
  gap: 8px;
  width: 100%;
}

.mini-stat {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.mini-stat .val {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}

.mini-stat .lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mini-stat.wins .val { color: #10B981; }
.mini-stat.losses .val { color: var(--text-secondary); }
.mini-stat.games .val { color: var(--accent); }

/* ──────────────────────────────────────
   DISABLED STATE
────────────────────────────────────── */
.board.disabled {
  pointer-events: none;
}

.reserve.disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* ──────────────────────────────────────
   RESPONSIVE
────────────────────────────────────── */
@media (max-width: 380px) {
  .game-title { font-size: 28px; }
  .stat-value { font-size: 1.6rem; }
  .board {
    width: min(85vw, 260px);
    height: min(85vw, 260px);
  }
  .board-piece.piece-small { width: 22px; height: 22px; }
  .board-piece.piece-medium { width: 36px; height: 36px; }
  .board-piece.piece-large { width: 50px; height: 50px; }
}

@media (max-height: 700px) {
  .screen-content { gap: 20px; }
  .stats-box { padding: 14px 20px; gap: 24px; }
  .reserve { padding: 6px 10px; }
  #game-screen { gap: 6px; padding: 8px 8px 10px; }
}
