/* ==============================
   :root Design Tokens
   ============================== */
:root {
  --bg-main: #030305;
  --bg-surface: #0a0a12;
  --bg-surface-elevated: #14141f;
  --text-primary: #e2e2e5;
  --text-muted: #7a7a8c;
  --accent: #00f0ff;
  --accent-hover: #5ffaff;
  --border: #1e1e2a;
}

/* ==============================
   Global Reset & Base
   ============================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Chakra Petch', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ==============================
   Font Imports
   ============================== */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;600&display=swap');

/* ==============================
   Main UI Wrapper
   ============================== */
#app-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  transition: transform 0.2s ease;
}

/* Larger screens – two‑column layout */
@media (min-width: 769px) {
  #app-container {
    grid-template-columns: 1fr 1fr;
  }
}

/* Small screens – tighter padding */
@media (max-width: 480px) {
  #app-container {
    padding: 0.5rem;
  }
}

/* ==============================
   Primary CTA Button
   ============================== */
#primary-action {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-family: 'Orbitron', sans-serif;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#primary-action:hover {
  background: var(--accent-hover);
}

#primary-action:active {
  transform: scale(0.98);
}

/* ==============================
   Game Board
   ============================== */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  position: relative; /* for absolute win lines */
}

/* Individual cell – acts like a card */
.cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--accent);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease, filter 0.2s ease;
}

/* Hover elevation */
.cell:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  filter: drop-shadow(0 0 8px var(--accent));
}

/* Token colors */
.cell.x {
  color: #ff5e5e;
}
.cell.o {
  color: var(--accent);
}

/* Pseudo‑elements for X and O */
.cell.x::after {
  content: "X";
}
.cell.o::after {
  content: "O";
}

/* Disabled state after a move */
.cell.disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* ==============================
   Winning Line Animation
   ============================== */
.win-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
  opacity: 0;
  animation: winLineAnim 0.6s forwards;
  z-index: 10;
}

/* Glowing strike‑through effect */
@keyframes winLineAnim {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  100% {
    opacity: 1;
    transform: scaleX(1);
  }
}

/* ==============================
   Scoreboard & Status
   ============================== */
.scoreboard {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
  color: var(--text-primary);
  font-family: 'Orbitron', sans-serif;
}

.score-item {
  font-size: 1.2rem;
}

/* Centered status text */
.status {
  text-align: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ==============================
   Micro‑Interactions & Elevations
   ============================== */
.card,
.cell {
  transition: box-shadow 0.2s ease, transform 0.1s ease, filter 0.2s ease;
}

.card:hover {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* Ensure no horizontal overflow */
body {
  overflow-x: hidden;
}

/* ==============================
   Responsive Adjustments
   ============================== */
@media (max-width: 768px) {
  .cell {
    font-size: 2.5rem;
  }
  .status {
    font-size: 1.3rem;
  }
}

@media (max-width: 480px) {
  .cell {
    font-size: 2rem;
  }
  #primary-action {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
  .scoreboard {
    font-size: 1rem;
  }
}

/* ==============================
   Winning Cell Animation
   ============================== */
.cell.winner {
  animation: winCellAnim 0.6s ease-out;
}

@keyframes winCellAnim {
  0% {
    transform: scale(0.8);
    opacity: 0;
    filter: drop-shadow(0 0 6px var(--accent));
  }
  100% {
    transform: scale(1);
    opacity: 1;
    filter: drop-shadow(0 0 12px var(--accent));
  }
}