/* ==========================================================================
   Premium Futuristic Landing — Global & Layout
   ========================================================================== */

:root {
  --bg: #111315;
  --bg-deep: #0a0b0c;
  --cyan: #4de8ff;
  --cyan-soft: rgba(77, 232, 255, 0.55);
  --cyan-dim: rgba(77, 232, 255, 0.12);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(77, 232, 255, 0.22);
  --text: #e8eef2;
  --text-muted: rgba(232, 238, 242, 0.55);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: "Orbitron", sans-serif;
  --font-body: "Exo 2", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

/* ==========================================================================
   Canvas background
   ========================================================================== */

#network-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Soft glow bloom over canvas */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 80% 60% at 50% 45%,
    rgba(77, 232, 255, 0.04) 0%,
    transparent 70%
  );
}

/* ==========================================================================
   Ambient floating particles (CSS)
   ========================================================================== */

.ambient-layer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.ambient-dot {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0;
  box-shadow: 0 0 6px var(--cyan-soft);
  animation: ambient-float linear infinite;
}

/* Stagger positions, durations, and delays for organic motion */
.ambient-dot:nth-child(1)  { left: 8%;  top: 12%; animation-duration: 28s; animation-delay: 0s;   }
.ambient-dot:nth-child(2)  { left: 22%; top: 78%; animation-duration: 34s; animation-delay: -4s;  }
.ambient-dot:nth-child(3)  { left: 45%; top: 25%; animation-duration: 26s; animation-delay: -8s;  }
.ambient-dot:nth-child(4)  { left: 67%; top: 55%; animation-duration: 32s; animation-delay: -2s;  }
.ambient-dot:nth-child(5)  { left: 88%; top: 18%; animation-duration: 30s; animation-delay: -12s; }
.ambient-dot:nth-child(6)  { left: 15%; top: 48%; animation-duration: 36s; animation-delay: -6s;  }
.ambient-dot:nth-child(7)  { left: 72%; top: 82%; animation-duration: 27s; animation-delay: -10s; }
.ambient-dot:nth-child(8)  { left: 55%; top: 68%; animation-duration: 33s; animation-delay: -14s; }
.ambient-dot:nth-child(9)  { left: 35%; top: 8%;  animation-duration: 29s; animation-delay: -3s;  }
.ambient-dot:nth-child(10) { left: 92%; top: 62%; animation-duration: 31s; animation-delay: -7s;  }
.ambient-dot:nth-child(11) { left: 5%;  top: 88%; animation-duration: 35s; animation-delay: -11s; }
.ambient-dot:nth-child(12) { left: 78%; top: 35%; animation-duration: 25s; animation-delay: -5s;  }

@keyframes ambient-float {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6);
  }
  10% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.2;
    transform: translate(30px, -40px) scale(1);
  }
  90% {
    opacity: 0.1;
  }
  100% {
    opacity: 0;
    transform: translate(-20px, 30px) scale(0.5);
  }
}

/* ==========================================================================
   Cinematic vignette
   ========================================================================== */

.vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(
    ellipse 75% 70% at 50% 50%,
    transparent 35%,
    rgba(0, 0, 0, 0.45) 75%,
    rgba(0, 0, 0, 0.85) 100%
  );
}

/* ==========================================================================
   Hero content
   ========================================================================== */

.hero {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem clamp(1.25rem, 4vw, 3rem);
  text-align: center;
  gap: clamp(2rem, 5vh, 3.5rem);
}

/* Page-load fade-in */
.hero-title,
.hero-actions {
  opacity: 0;
  animation: hero-fade-in 1.4s var(--ease-out) forwards;
}

.hero-actions {
  animation-delay: 0.55s;
}

@keyframes hero-fade-in {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* ==========================================================================
   Typography
   ========================================================================== */

.hero-title {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  line-height: 0.92;
  letter-spacing: 0.04em;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
}

.hero-title__line {
  display: block;
  width: 100%;
  font-size: clamp(2.2rem, 11.5vw, 8.5rem);
  background: linear-gradient(
    135deg,
    #ffffff 0%,
    #c8e8f0 35%,
    var(--cyan) 70%,
    rgba(77, 232, 255, 0.65) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 40px rgba(77, 232, 255, 0.25))
    drop-shadow(0 0 80px rgba(77, 232, 255, 0.08));
}

.hero-title__line--accent {
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(
    90deg,
    rgba(77, 232, 255, 0.85) 0%,
    #ffffff 40%,
    var(--cyan) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 50px rgba(77, 232, 255, 0.35));
}

/* Subtle shimmer on title after load */
.hero-title::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(77, 232, 255, 0.06) 50%,
    transparent 60%
  );
  animation: title-shimmer 8s var(--ease-smooth) 2s infinite;
}

@keyframes title-shimmer {
  0%,
  100% {
    opacity: 0;
    transform: translateX(-100%);
  }
  50% {
    opacity: 1;
    transform: translateX(100%);
  }
}

/* ==========================================================================
   CTA button — glassmorphism + neon
   ========================================================================== */

.cta-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2.75rem;
  font-family: var(--font-display);
  font-size: clamp(0.75rem, 2vw, 0.9rem);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cyan);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 2px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    0 0 20px rgba(77, 232, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    transform 0.5s var(--ease-out),
    box-shadow 0.5s var(--ease-out),
    border-color 0.5s var(--ease-out),
    color 0.5s var(--ease-out),
    background 0.5s var(--ease-out);
  overflow: hidden;
}

/* Animated border shimmer */
.cta-button::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--cyan-soft),
    transparent,
    var(--cyan-dim),
    transparent
  );
  background-size: 300% 100%;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.5;
  animation: border-shimmer 4s linear infinite;
  pointer-events: none;
}

@keyframes border-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.cta-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(77, 232, 255, 0.15),
    transparent 65%
  );
  opacity: 0;
  transition: opacity 0.5s var(--ease-out);
  pointer-events: none;
}

.cta-button:hover,
.cta-button:focus-visible {
  transform: scale(1.04);
  color: #fff;
  border-color: rgba(77, 232, 255, 0.55);
  background: rgba(77, 232, 255, 0.08);
  box-shadow:
    0 0 35px rgba(77, 232, 255, 0.35),
    0 0 60px rgba(77, 232, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  outline: none;
}

.cta-button:hover::after,
.cta-button:focus-visible::after {
  opacity: 1;
}

.cta-button:active {
  transform: scale(1.02);
}

/* Hero CTA row — side by side on desktop, stacked on mobile */
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 1.25rem;
}

#play-ttt-btn {
  cursor: pointer;
  border: none;
  font: inherit;
}

/* ==========================================================================
   Tic Tac Toe modal & game UI
   ========================================================================== */

.game-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.45s var(--ease-out),
    visibility 0.45s var(--ease-out);
}

.game-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.game-modal:not(.is-open) {
  display: none;
}

.game-modal.is-open {
  display: flex;
}

.game-panel {
  position: relative;
  width: min(100%, 380px);
  padding: 2rem 1.75rem 1.75rem;
  background: rgba(17, 19, 21, 0.92);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 40px rgba(77, 232, 255, 0.12),
    0 24px 48px rgba(0, 0, 0, 0.5);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.45s var(--ease-out);
}

.game-modal.is-open .game-panel {
  transform: translateY(0) scale(1);
}

.game-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.3s var(--ease-out);
}

.game-close:hover,
.game-close:focus-visible {
  color: var(--cyan);
  outline: none;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.game-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.mark {
  font-family: var(--font-display);
  font-weight: 700;
}

.mark--you {
  color: #fff;
}

.mark--almas {
  color: var(--cyan);
}

/* Scoreboard */
.scoreboard {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--glass);
  border: 1px solid rgba(77, 232, 255, 0.12);
  border-radius: 2px;
  text-align: center;
}

.scoreboard__heading {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.5rem;
}

.scoreboard__row {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.6;
}

.scoreboard__row span {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--cyan);
}

/* Game status message */
.game-status {
  min-height: 1.4em;
  margin-bottom: 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.game-status.is-win {
  color: #fff;
}

.game-status.is-lose {
  color: rgba(255, 120, 120, 0.9);
}

.game-status.is-draw {
  color: var(--cyan-soft);
}

/* 3×3 board */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 1.25rem;
}

.ttt-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: transparent;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(77, 232, 255, 0.15);
  border-radius: 2px;
  cursor: pointer;
  transition:
    background 0.35s var(--ease-out),
    border-color 0.35s var(--ease-out),
    box-shadow 0.35s var(--ease-out),
    transform 0.35s var(--ease-out);
}

.ttt-cell:not(:disabled):hover {
  background: rgba(77, 232, 255, 0.06);
  border-color: rgba(77, 232, 255, 0.35);
}

.ttt-cell:disabled {
  cursor: default;
}

.ttt-cell--x {
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.35);
}

.ttt-cell--o {
  color: var(--cyan);
  text-shadow: 0 0 20px rgba(77, 232, 255, 0.45);
}

.ttt-cell--win {
  background: rgba(77, 232, 255, 0.12);
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(77, 232, 255, 0.25);
}

.game-reset-btn {
  width: 100%;
  opacity: 1;
  animation: none;
  padding: 0.85rem 1.5rem;
}

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */

@media (max-width: 640px) {
  .hero-actions {
    flex-direction: column;
    width: 100%;
    max-width: 320px;
  }

  .hero-actions .cta-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .hero-title__line--accent {
    letter-spacing: 0.06em;
  }

  .cta-button {
    padding: 0.9rem 1.5rem;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
  }

  .game-panel {
    padding: 1.5rem 1.25rem 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-title,
  .hero-actions {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }

  .game-modal,
  .game-panel {
    transition: none;
  }

  .ambient-dot,
  .cta-button::before,
  .hero-title::after {
    animation: none;
  }
}
