:root {
  --pink: #ff4d6d;
  --blue: #4dabf7;
  --purple: #cc5de8;
  --teal: #20c997;
  --yellow: #ffd43b;
  --orange: #ff922b;
  --ink: #2b2140;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Vazirmatn', sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #ffdeec 0%, #e6ddff 40%, #d3f0ff 100%);
  background-attachment: fixed;
  color: var(--ink);
  overflow-x: hidden;
}

/* floating blobs bg */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  z-index: 0;
  animation: float 12s ease-in-out infinite;
}
body::before {
  width: 320px; height: 320px;
  background: var(--pink);
  top: -80px; left: -60px;
}
body::after {
  width: 380px; height: 380px;
  background: var(--blue);
  bottom: -120px; right: -80px;
  animation-delay: -6s;
}
@keyframes float {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(30px) scale(1.1); }
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 18px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Title */
.title-block { text-align: center; }
.game-title {
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  font-weight: 900;
  background: linear-gradient(90deg, var(--pink), var(--purple), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
  animation: pulseGlow 3s ease-in-out infinite;
}
.game-title span { -webkit-text-fill-color: initial; }
@keyframes pulseGlow {
  0%,100% { filter: drop-shadow(0 4px 12px rgba(204,93,232,0.3)); }
  50% { filter: drop-shadow(0 6px 20px rgba(77,171,247,0.5)); }
}
.subtitle {
  margin-top: 6px;
  font-weight: 500;
  font-size: 1.05rem;
  color: #6b5c8a;
}

/* Menu */
.menu-card {
  width: 100%;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(12px);
  border-radius: 28px;
  padding: 26px 22px;
  box-shadow: 0 20px 50px rgba(120,80,180,0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.menu-heading {
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  color: #5a4a7a;
}

.mode-btn {
  border: none;
  cursor: pointer;
  border-radius: 22px;
  padding: 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,0.15);
}
.mode-btn:hover { transform: translateY(-4px) scale(1.02); }
.mode-btn:active { transform: scale(0.97); }
.mode-cpu { background: linear-gradient(135deg, var(--blue), var(--purple)); }
.mode-pvp { background: linear-gradient(135deg, var(--pink), var(--orange)); }
.mode-emoji { font-size: 2.4rem; }
.mode-title { font-size: 1.3rem; font-weight: 800; }
.mode-sub { font-size: .85rem; font-weight: 300; opacity: 0.95; }

.diff-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.diff-label { font-weight: 500; color: #6b5c8a; font-size: .95rem; }
.diff-btn {
  border: 2px solid #d9c9f2;
  background: #fff;
  color: #6b5c8a;
  padding: 8px 16px;
  border-radius: 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
}
.diff-btn:hover { border-color: var(--purple); }
.diff-active {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 14px rgba(204,93,232,0.4);
}

/* Scoreboard */
.scoreboard {
  width: 100%;
  display: flex;
  gap: 10px;
}
.score-box {
  flex: 1;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(120,80,180,0.12);
  border-top: 4px solid #ddd;
}
.score-x { border-top-color: var(--pink); }
.score-o { border-top-color: var(--blue); }
.score-d { border-top-color: var(--yellow); }
.score-emoji { font-size: 1.4rem; }
.score-value { font-size: 1.8rem; font-weight: 900; color: var(--ink); line-height: 1.1; }
.score-label { font-size: .78rem; font-weight: 500; color: #7a6b95; }

/* Turn banner */
.turn-banner {
  width: 100%;
  text-align: center;
  padding: 12px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .3s ease;
}
.turn-x { background: linear-gradient(90deg, var(--pink), var(--orange)); box-shadow: 0 8px 20px rgba(255,77,109,0.35); }
.turn-o { background: linear-gradient(90deg, var(--blue), var(--purple)); box-shadow: 0 8px 20px rgba(77,171,247,0.35); }

.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff; display: inline-block;
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2){ animation-delay: .2s; }
.dots i:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.3;} 40%{opacity:1;} }

.result-banner {
  width: 100%;
  text-align: center;
  padding: 16px;
  border-radius: 18px;
  font-weight: 900;
  font-size: 1.4rem;
  color: #fff;
  background: linear-gradient(90deg, var(--purple), var(--pink), var(--orange));
  box-shadow: 0 12px 30px rgba(204,93,232,0.4);
}

.bubble {
  background: #fff;
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 18px 18px 18px 4px;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

/* Board */
.board {
  width: 100%;
  aspect-ratio: 1;
  max-width: 360px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: rgba(255,255,255,0.55);
  padding: 10px;
  border-radius: 26px;
  box-shadow: 0 18px 44px rgba(120,80,180,0.22);
}
.cell {
  border: none;
  border-radius: 18px;
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  font-size: clamp(2.4rem, 12vw, 3.6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.05);
}
.cell:not(:disabled):hover {
  transform: scale(1.05);
  background: #fff;
  box-shadow: 0 6px 16px rgba(120,80,180,0.2);
}
.cell:disabled { cursor: default; }
.cell-x { background: #ffe3ea; }
.cell-o { background: #e0f0ff; }
.cell-win {
  animation: winPulse 0.9s ease-in-out infinite;
  background: linear-gradient(135deg, var(--yellow), var(--orange)) !important;
}
@keyframes winPulse {
  0%,100% { transform: scale(1); box-shadow: 0 0 0 rgba(255,212,59,0); }
  50% { transform: scale(1.08); box-shadow: 0 0 24px rgba(255,146,43,0.7); }
}
.mark { display: inline-block; }

/* Controls */
.controls {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.ctrl-btn {
  border: none;
  cursor: pointer;
  border-radius: 16px;
  padding: 12px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: .95rem;
  color: #fff;
  transition: transform .12s ease, box-shadow .12s ease;
  flex: 1;
  min-width: 120px;
}
.ctrl-btn:hover { transform: translateY(-2px); }
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-play { background: linear-gradient(135deg, var(--teal), var(--blue)); box-shadow: 0 8px 18px rgba(32,201,151,0.35); }
.ctrl-mode { background: linear-gradient(135deg, var(--purple), var(--pink)); box-shadow: 0 8px 18px rgba(204,93,232,0.35); }
.ctrl-reset { background: linear-gradient(135deg, #868e96, #495057); box-shadow: 0 8px 18px rgba(73,80,87,0.3); }

/* Footer */
.footer {
  margin-top: 10px;
  font-size: .85rem;
}
.footer a {
  color: #8a76b0;
  text-decoration: none;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.6);
  transition: all .15s ease;
}
.footer a:hover { background: #fff; color: var(--purple); }

/* Animations */
.pop-in { animation: popIn .3s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.fade-up { animation: fadeUp .5s ease both; }
@keyframes fadeUp {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Confetti */
.confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
</parameter>