* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #e0f7fa, #f1f8e9);
  margin: 0;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  color: white;
  background: linear-gradient(45deg, #007bff, #00c6ff);
  padding: 18px 35px;
  border-radius: 18px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  font-size: 2.5em;
  letter-spacing: 1px;
}

#main-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  flex-wrap: wrap;
}

#status {
  font-size: 1.3em;
  text-align: center;
  margin: 20px 0;
  color: #222;
  font-weight: bold;
}

.card {
  padding: 25px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  backdrop-filter: blur(10px);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 70px rgba(0,0,0,0.3);
}

/* board & cells */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: #ddd;
  padding: 15px;
  border-radius: 15px;
  min-width: 330px;
  min-height: 330px;
  justify-items: center;
  align-items: center;
  position: relative; /* needed for pseudo element */
}

.cell {
  width: 100px;
  height: 100px;
  background: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.8em;
  font-weight: 800;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.25s ease;
  box-shadow: 0 5px 15px rgba(0,0,0,0.15);
  user-select: none;
}

.cell:hover:not(.disabled) {
  background: #f9f9f9;
  transform: scale(1.06);
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.cell.disabled {
  pointer-events: none;
  background: #f0f0f0;
  color: #bbb;
}

/* X and O styles */
.cell.x {
  color: #007bff;
  text-shadow: 0 2px 6px rgba(0,123,255,0.28);
}

.cell.o {
  color: #e63946;
  text-shadow: 0 2px 6px rgba(230,57,70,0.28);
}

/* ---------- Winning strike pseudo element (centered & animated) ---------- */
/* default pseudo - hidden (scaleX(0)) */
.board::after {
  content: "";
  position: absolute;
  background: var(--line-color, #222);
  border-radius: 10px;
  width: var(--line-width, 100%);
  height: var(--line-thickness, 10px);
  top: var(--line-top, 50%);
  left: var(--line-left, 50%);
  transform-origin: center;
  transform: translate(-50%, -50%) rotate(var(--line-rotation, 0deg)) scaleX(0);
  transition: transform 420ms cubic-bezier(.2,.9,.2,1), background 180ms;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  pointer-events: none;
}

/* When a win class is added we set the custom properties to position/rotate the bar,
   and also force scaleX(1) so the bar animates in */
.board.win-row-0::after,
.board.win-row-1::after,
.board.win-row-2::after,
.board.win-col-0::after,
.board.win-col-1::after,
.board.win-col-2::after,
.board.win-diag-0::after,
.board.win-diag-1::after {
  transform: translate(-50%, -50%) rotate(var(--line-rotation, 0deg)) scaleX(1);
  display: block;
}

/* Horizontal rows (top / middle / bottom) */
.board.win-row-0 { --line-top: calc(100% * (1/6)); --line-left: 50%; --line-rotation: 0deg; --line-width: 100%; }
.board.win-row-1 { --line-top: 50%;                         --line-left: 50%; --line-rotation: 0deg; --line-width: 100%; }
.board.win-row-2 { --line-top: calc(100% * (5/6)); --line-left: 50%; --line-rotation: 0deg; --line-width: 100%; }

/* Vertical columns (left / middle / right) - rotate 90deg */
.board.win-col-0 { --line-top: 50%; --line-left: calc(100% * (1/6)); --line-rotation: 90deg; --line-width: 100%; }
.board.win-col-1 { --line-top: 50%; --line-left: 50%;                  --line-rotation: 90deg; --line-width: 100%; }
.board.win-col-2 { --line-top: 50%; --line-left: calc(100% * (5/6)); --line-rotation: 90deg; --line-width: 100%; }

/* Diagonals (centered bar rotated ±45deg; width = sqrt(2)*100% ≈ 142%) */
.board.win-diag-0 { --line-top: 50%; --line-left: 50%; --line-rotation: 45deg;  --line-width: 142%; }
.board.win-diag-1 { --line-top: 50%; --line-left: 50%; --line-rotation: -45deg; --line-width: 142%; }

/* Color the strike to match winner (added by JS as .winner-x or .winner-o) */
.board.winner-x { --line-color: rgba(0,123,255,0.95); }
.board.winner-o { --line-color: rgba(230,57,70,0.95); }

/* Modal, buttons and rules (same polished look) */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.55);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 35px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  max-width: 350px;
}

.modal-content h2 {
  margin-bottom: 25px;
  font-size: 1.8em;
}

button {
  margin: 10px 8px;
  padding: 12px 25px;
  font-size: 1em;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
}

button:hover {
  background: #0056b3;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

.rules {
  max-width: 320px;
  background: #fff;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  font-size: 1em;
  line-height: 1.7;
}

.rules h3 {
  margin-top: 0;
  color: #007bff;
  font-size: 1.3em;
}

/* Responsiveness */
@media (max-width: 900px) {
  .board { min-width: 260px; min-height: 260px; gap: 8px; }
  .cell { width: 80px; height: 80px; font-size: 2.2em; }
}

@media (max-width: 600px) {
  h1 { font-size: 2em; }
  .board { min-width: 220px; min-height: 220px; gap: 6px; }
  .cell { width: 70px; height: 70px; font-size: 1.9em; }
}
