/* ============================================================
   Tic Tac Toe - Stylesheet
   Soft gradient, glassmorphism, responsive, smooth animations.
   ============================================================ */

/* ---------- Reset & base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', 'Poppins', system-ui, -apple-system, sans-serif;
  color: #2d2a4a;
}

body {
  min-height: 100vh;
  /* Soft pastel gradient background */
  background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 50%, #fad0c4 100%);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-x: hidden;
}

/* Decorative blurred blobs behind everything */
body::before,
body::after {
  content: "";
  position: fixed;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background: #c2a6ff;
  top: -120px;
  left: -120px;
}
body::after {
  background: #ffb6d9;
  bottom: -120px;
  right: -120px;
}

/* ---------- App wrapper & screens ---------- */
.app {
  width: 100%;
  max-width: 480px;
  position: relative;
}

.screen {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;

  /* Glassmorphism card */
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow:
    0 20px 50px rgba(110, 80, 180, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.screen.active {
  display: block;
  animation: fadeIn 0.5s ease forwards;
  opacity: 1;
  transform: translateY(0);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Menu screen ---------- */
.title {
  text-align: center;
  font-size: clamp(2rem, 6vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #7b5cff, #ff6fa3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
  text-shadow: 0 4px 20px rgba(123, 92, 255, 0.15);
}

.subtitle {
  text-align: center;
  color: #5b577d;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: linear-gradient(135deg, #7b5cff, #ff6fa3);
  box-shadow: 0 10px 25px rgba(123, 92, 255, 0.35);
  transition: transform 0.2s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

.mode-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(123, 92, 255, 0.45);
  filter: brightness(1.05);
}

.mode-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.mode-btn[data-mode="pvc"] {
  background: linear-gradient(135deg, #43c6ac, #4b8afe);
  box-shadow: 0 10px 25px rgba(75, 138, 254, 0.35);
}
.mode-btn[data-mode="pvc"]:hover {
  box-shadow: 0 14px 30px rgba(75, 138, 254, 0.45);
}

.mode-icon { font-size: 1.4rem; }

/* ---------- Game header ---------- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.game-title {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(90deg, #7b5cff, #ff6fa3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.8);
  color: #5b4bdc;
  box-shadow: 0 4px 12px rgba(123, 92, 255, 0.2);
  transition: transform 0.2s ease, background 0.2s ease;
}
.icon-btn:hover {
  transform: scale(1.08);
  background: #fff;
}
.icon-btn:active { transform: scale(0.95); }

/* ---------- Scoreboard ---------- */
.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.score-card {
  text-align: center;
  padding: 10px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 16px rgba(120, 100, 180, 0.15);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.score-card.active {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(120, 100, 180, 0.3);
}

.score-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6a6690;
  margin-bottom: 4px;
}
.score-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.x-card .score-value { color: #4b8afe; }
.o-card .score-value { color: #ff6fa3; }
.draw-card .score-value { color: #7b5cff; }

/* ---------- Turn indicator ---------- */
.turn-indicator {
  text-align: center;
  margin-bottom: 14px;
  font-weight: 600;
  color: #4a4672;
  min-height: 1.4em;
  transition: color 0.3s ease;
}

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 20px;
}

.cell {
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  font-size: clamp(2.2rem, 10vw, 3.2rem);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  box-shadow:
    0 6px 16px rgba(120, 100, 180, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease;
  user-select: none;
}

.cell:hover:not(.filled):not(.disabled) {
  transform: translateY(-3px);
  background: #fff;
  box-shadow: 0 12px 22px rgba(123, 92, 255, 0.28);
}

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

.cell.filled {
  cursor: not-allowed;
}

.cell.x {
  color: #4b8afe;
  text-shadow: 0 0 18px rgba(75, 138, 254, 0.55);
  animation: pop 0.3s ease;
}
.cell.o {
  color: #ff6fa3;
  text-shadow: 0 0 18px rgba(255, 111, 163, 0.55);
  animation: pop 0.3s ease;
}

@keyframes pop {
  0%   { transform: scale(0.3); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

/* Winning cells: glowing gold pulse */
.cell.win {
  background: linear-gradient(135deg, #fff4b0, #ffd86b);
  color: #6b4a00 !important;
  text-shadow: 0 0 20px rgba(255, 200, 50, 0.9);
  animation: winPulse 1s ease-in-out infinite;
}

@keyframes winPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 200, 50, 0.6), 0 6px 16px rgba(200, 150, 0, 0.3); }
  50%      { box-shadow: 0 0 30px rgba(255, 200, 50, 0.95), 0 10px 22px rgba(200, 150, 0, 0.5); }
}

.board.locked .cell:not(.filled) {
  cursor: default;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, #7b5cff, #ff6fa3);
  box-shadow: 0 8px 20px rgba(123, 92, 255, 0.3);
  transition: transform 0.2s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow: 0 12px 26px rgba(123, 92, 255, 0.4);
}
.action-btn:active { transform: scale(0.97); }

.action-btn.ghost {
  background: transparent;
  color: #7b5cff;
  border: 2px solid rgba(123, 92, 255, 0.5);
  box-shadow: none;
}
.action-btn.ghost:hover {
  background: rgba(123, 92, 255, 0.1);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 80, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 100;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #fff;
  padding: 28px 28px 22px;
  border-radius: 22px;
  text-align: center;
  max-width: 320px;
  width: 85%;
  box-shadow: 0 30px 60px rgba(60, 30, 120, 0.4);
  transform: scale(0.85) translateY(10px);
  transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2);
}
.modal-overlay.show .modal {
  transform: scale(1) translateY(0);
}

#modal-title {
  font-size: 1.6rem;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #7b5cff, #ff6fa3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#modal-message {
  color: #5b577d;
  margin-bottom: 18px;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 380px) {
  .score-label { font-size: 0.72rem; }
  .score-value { font-size: 1.25rem; }
  .action-btn  { padding: 10px 16px; font-size: 0.88rem; }
  .screen      { padding: 22px 16px; }
}

@media (min-width: 700px) {
  .app { max-width: 520px; }
}
