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

/* Base */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  overflow-x: hidden;
  padding-bottom: 2.5rem;
}

/* Container */
.container {
  text-align: center;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
}

/* Title */
h1 {
  font-size: 1.85rem;
  margin-bottom: 0.35rem;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #f7797d, #fbd786, #c6ffdd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  user-select: none;
}

/* Brand subtitle */
.brand-subtitle {
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 1.2rem;
  user-select: none;
}

/* Logo */
.logo {
  display: block;
  max-width: 100px;
  height: auto;
  margin: 0 auto 0.3rem;
  user-select: none;
  pointer-events: none;
}

/* Copyright */
.copyright {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.3);
  padding: 0.6rem 0.5rem;
  user-select: none;
  pointer-events: none;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.score-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

.score-label.score-x {
  color: #f7797d;
}

.score-label.score-o {
  color: #c6ffdd;
}

.score-label.score-draw {
  color: #fbd786;
}

.score-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}

/* Status */
.status {
  font-size: 1.15rem;
  margin-bottom: 1rem;
  height: 1.5em;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ccc;
  transition: color 0.3s ease;
}

.status.win {
  color: #fbd786;
  font-weight: 700;
  animation: statusPulse 0.6s ease-in-out infinite alternate;
}

.status.draw {
  color: #f7797d;
  font-weight: 700;
}

@keyframes statusPulse {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  aspect-ratio: 1;
  max-width: 340px;
  margin: 0 auto 1.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Cell */
.cell {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 10px;
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s ease, transform 0.15s ease, color 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.cell:hover:not(.taken) {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.04);
}

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

.cell.taken {
  cursor: default;
}

/* X and O colors */
.cell.x {
  color: #f7797d;
  text-shadow: 0 0 12px rgba(247, 121, 125, 0.5);
}

.cell.o {
  color: #c6ffdd;
  text-shadow: 0 0 12px rgba(198, 255, 221, 0.5);
}

/* Pop-in animation for X and O */
.cell.pop-in {
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Win cell highlight */
.cell.win-cell {
  background: rgba(251, 215, 134, 0.2);
  animation: winPulse 0.6s ease-in-out infinite alternate;
}

@keyframes winPulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

/* Draw cell highlight */
.cell.draw-cell {
  background: rgba(247, 121, 125, 0.15);
}

/* ===== Screen Management ===== */
.screen {
  display: none;
}
.screen.active {
  display: block;
}

/* ===== Menu / Difficulty Tagline ===== */
.menu-tagline {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 1.5rem;
  letter-spacing: 1px;
}

/* ===== Menu Buttons ===== */
.menu-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.menu-btn {
  width: 260px;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  background: linear-gradient(135deg, rgba(247, 121, 125, 0.25), rgba(198, 255, 221, 0.25));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
}
.menu-btn:hover {
  background: linear-gradient(135deg, rgba(247, 121, 125, 0.45), rgba(198, 255, 221, 0.45));
  box-shadow: 0 4px 24px rgba(247, 121, 125, 0.25);
}

/* ===== Difficulty Buttons ===== */
.diff-btn {
  width: 260px;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #fff;
}
.diff-novice {
  background: linear-gradient(135deg, rgba(198, 255, 221, 0.3), rgba(100, 220, 170, 0.2));
}
.diff-novice:hover {
  background: linear-gradient(135deg, rgba(198, 255, 221, 0.55), rgba(100, 220, 170, 0.4));
  box-shadow: 0 4px 20px rgba(198, 255, 221, 0.25);
}
.diff-challenger {
  background: linear-gradient(135deg, rgba(251, 215, 134, 0.3), rgba(220, 180, 80, 0.2));
}
.diff-challenger:hover {
  background: linear-gradient(135deg, rgba(251, 215, 134, 0.55), rgba(220, 180, 80, 0.4));
  box-shadow: 0 4px 20px rgba(251, 215, 134, 0.25);
}
.diff-grandmaster {
  background: linear-gradient(135deg, rgba(247, 121, 125, 0.3), rgba(200, 100, 130, 0.2));
}
.diff-grandmaster:hover {
  background: linear-gradient(135deg, rgba(247, 121, 125, 0.55), rgba(200, 100, 130, 0.4));
  box-shadow: 0 4px 20px rgba(247, 121, 125, 0.25);
}

/* ===== Back Button ===== */
.back-btn {
  margin-top: 1.2rem;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  padding: 0.5rem 1.4rem;
  border-radius: 8px;
}
.back-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ===== Game Top Bar ===== */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.mode-label {
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  user-select: none;
}

/* Music Toggle */
.music-toggle {
  transition: background 0.2s ease, color 0.2s ease;
}
.music-toggle.on {
  color: #c6ffdd;
  background: rgba(198, 255, 221, 0.12);
  border-color: rgba(198, 255, 221, 0.25);
}
.music-toggle.off {
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

/* ===== Buttons ===== */
.buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.8rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: scale(1.05);
}

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

.restart-btn {
  background: linear-gradient(135deg, #f7797d, #fbd786);
  color: #1a1a2e;
}

.restart-btn:hover {
  box-shadow: 0 4px 20px rgba(247, 121, 125, 0.4);
}

.reset-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 400px) {
  .cell {
    font-size: 2.2rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  .scoreboard {
    gap: 0.8rem;
  }

  .score-value {
    font-size: 1.4rem;
  }

  .buttons {
    flex-direction: column;
    align-items: center;
  }

  .menu-btn,
  .diff-btn {
    width: 220px;
    padding: 0.85rem 1.2rem;
    font-size: 0.95rem;
  }

  .mode-label {
    font-size: 0.65rem;
  }

  .brand-subtitle {
    font-size: 0.65rem;
  }

  .logo {
    max-width: 90px;
  }

  .copyright {
    font-size: 0.6rem;
  }
}
