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

:root {
  --emerald: #10b981;
  --emerald-light: #d1fae5;
  --emerald-dark: #065f46;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --rose: #f43f5e;
  --rose-light: #ffe4e6;
  --rose-dark: #9f1239;
  --rose-glow: rgba(244, 63, 94, 0.25);
  --amber: #f59e0b;
  --bg: #f9fafb;
  --bg-gradient-start: #f3f4f6;
  --bg-gradient-mid: #ffffff;
  --bg-gradient-end: #f3f4f6;
  --card-bg: rgba(255, 255, 255, 0.6);
  --cell-bg: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: rgba(107, 114, 128, 0.4);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-mid), var(--bg-gradient-end));
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

/* ====== BACKGROUND BLOBS ====== */
body::before,
body::after {
  content: '';
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: -120px;
  right: -120px;
  background: rgba(16, 185, 129, 0.15);
}

body::after {
  bottom: -120px;
  left: -120px;
  background: rgba(244, 63, 94, 0.15);
}

/* ====== SCREENS ====== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.menu-content, .game-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 380px;
  padding: 20px;
}

/* ====== LOGO ====== */
.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo-x {
  font-size: 80px;
  font-weight: 900;
  color: var(--emerald);
  text-shadow: 0 0 40px var(--emerald-glow);
  animation: float 3s ease-in-out infinite;
  display: inline-block;
}

.logo-amp {
  font-size: 48px;
  font-weight: 900;
  color: var(--text-faint);
}

.logo-o {
  font-size: 80px;
  font-weight: 900;
  color: var(--rose);
  text-shadow: 0 0 40px var(--rose-glow);
  animation: float 3s ease-in-out infinite 0.5s;
  display: inline-block;
}

.logo-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 500;
  margin-top: -12px;
}

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

/* ====== SECTION TITLES ====== */
.section-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: -16px;
  text-align: center;
}

/* ====== MODE BUTTONS ====== */
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 0 4px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.mode-btn:active {
  transform: translateY(0);
}

.mode-pvp {
  border-color: var(--emerald-light);
  background: rgba(16, 185, 129, 0.04);
}

.mode-pvp:hover {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.1);
}

.mode-pvp .mode-icon {
  background: var(--emerald-light);
  color: var(--emerald-dark);
}

.mode-bot {
  border-color: var(--rose-light);
  background: rgba(244, 63, 94, 0.04);
}

.mode-bot:hover {
  border-color: var(--rose);
  background: rgba(244, 63, 94, 0.08);
  box-shadow: 0 10px 40px rgba(244, 63, 94, 0.1);
}

.mode-bot .mode-icon {
  background: var(--rose-light);
  color: var(--rose-dark);
}

.mode-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  transition: transform 0.2s ease;
}

.mode-icon svg {
  width: 24px;
  height: 24px;
}

.mode-btn:hover .mode-icon {
  transform: scale(1.1);
}

.mode-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.mode-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* ====== DIFFICULTY BUTTONS ====== */
.diff-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 0 4px;
}

.diff-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 20px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.diff-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.diff-btn:active {
  transform: translateY(0);
}

.diff-easy {
  border-color: #d1fae5;
  background: rgba(16, 185, 129, 0.04);
}

.diff-easy:hover {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.1);
}

.diff-medium {
  border-color: #fef3c7;
  background: rgba(245, 158, 11, 0.04);
}

.diff-medium:hover {
  border-color: var(--amber);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 10px 40px rgba(245, 158, 11, 0.1);
}

.diff-hard {
  border-color: var(--rose-light);
  background: rgba(244, 63, 94, 0.04);
}

.diff-hard:hover {
  border-color: var(--rose);
  background: rgba(244, 63, 94, 0.08);
  box-shadow: 0 10px 40px rgba(244, 63, 94, 0.1);
}

.diff-icon {
  font-size: 24px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.diff-btn:hover .diff-icon {
  transform: scale(1.25);
}

.diff-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diff-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.diff-desc {
  font-size: 14px;
  color: var(--text-muted);
}

/* ====== BACK BUTTON ====== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.back-btn svg {
  width: 16px;
  height: 16px;
}

.back-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

/* ====== GAME HEADER ====== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.game-header .back-btn {
  margin-left: -8px;
}

.spacer {
  width: 70px;
}

.mode-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 14px;
  border-radius: 20px;
}

/* ====== SCOREBOARD ====== */
.scoreboard {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.score-card {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: rgba(249, 250, 251, 0.5);
  text-align: center;
}

.score-x {
  border-color: var(--emerald-light);
  background: rgba(16, 185, 129, 0.04);
}

.score-draw {
  border-color: var(--border);
}

.score-o {
  border-color: var(--rose-light);
  background: rgba(244, 63, 94, 0.04);
}

.score-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-value {
  font-size: 28px;
  font-weight: 900;
  margin-top: 2px;
}

.score-x .score-value {
  color: var(--emerald);
}

.score-draw .score-value {
  color: var(--text-muted);
}

.score-o .score-value {
  color: var(--rose);
}

/* ====== STATUS ====== */
.status {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.3s ease;
  text-align: center;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.status.status-won {
  color: var(--text);
  transform: scale(1.08);
}

.status.status-draw {
  color: var(--amber);
  transform: scale(1.04);
}

.status-x {
  color: var(--emerald);
  font-weight: 900;
  font-size: 22px;
}

.status-o {
  color: var(--rose);
  font-weight: 900;
  font-size: 22px;
}

/* Bot thinking dots */
.thinking-dots {
  display: inline-flex;
  gap: 3px;
  margin-left: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--rose);
  border-radius: 50%;
  animation: dotBounce 1s ease-in-out infinite;
}

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

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

/* ====== BOARD ====== */
.board-wrapper {
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.cell {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: none;
  background: var(--cell-bg);
  font-size: 48px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  outline: none;
}

.cell:hover:not(.taken):not(.disabled) {
  background: rgba(0, 0, 0, 0.04);
}

.cell:active:not(.taken):not(.disabled) {
  transform: scale(0.95);
}

.cell.taken {
  cursor: default;
}

.cell.disabled {
  cursor: default;
  pointer-events: none;
}

.cell .mark {
  display: inline-block;
  line-height: 1;
}

.cell .mark-x {
  color: var(--emerald);
  text-shadow: 0 0 20px var(--emerald-glow);
  animation: pop 0.3s ease-out;
}

.cell .mark-o {
  color: var(--rose);
  text-shadow: 0 0 20px var(--rose-glow);
  animation: pop 0.3s ease-out;
}

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

.cell.win-cell {
  background: rgba(16, 185, 129, 0.08);
  box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.3);
  animation: winBounce 0.5s ease-out;
}

@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes winBounce {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.08); }
  60% { transform: scale(0.96); }
}

/* ====== WIN LINE SVG ====== */
.win-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#win-line {
  stroke: var(--emerald);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  opacity: 0.7;
}

#win-line.animate {
  animation: drawLine 0.5s ease-out forwards;
}

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* ====== ACTION BUTTONS ====== */
.action-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.btn-primary {
  background: var(--text);
  color: white;
  border-color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 140px;
}

.btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* ====== HINT ====== */
.hint {
  font-size: 12px;
  color: rgba(107, 114, 128, 0.5);
}

.hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
}

/* ====== RESPONSIVE ====== */
@media (min-width: 480px) {
  .cell {
    width: 108px;
    height: 108px;
    font-size: 56px;
  }

  .board {
    gap: 12px;
    padding: 18px;
  }

  .logo-x, .logo-o {
    font-size: 90px;
  }

  .logo-amp {
    font-size: 54px;
  }
}

@media (max-width: 340px) {
  .cell {
    width: 80px;
    height: 80px;
    font-size: 40px;
  }

  .board {
    gap: 8px;
    padding: 10px;
  }

  .logo-x, .logo-o {
    font-size: 64px;
  }

  .logo-amp {
    font-size: 40px;
  }

  .mode-btn, .diff-btn {
    padding: 16px;
  }
}
