/* ==================== */
/* CSS Variables */
/* ==================== */
:root {
  --bg-gradient: linear-gradient(
    135deg,
    #0a1628 0%,
    #1a0a3e 25%,
    #4a1a5e 50%,
    #1a0a3e 75%,
    #0a1628 100%
  );
  --panel-bg: rgba(10, 20, 50, 0.9);
  --panel-border: rgba(255, 215, 0, 0.5);
  --accent: #4ba3ff;
  --accent-hover: #6bb5ff;
  --accent-dark: #3576d3;
  --grid-bg: radial-gradient(circle at 30% 20%, #2a4fa8, #1a2d6b 70%);
  --grid-border: rgba(20, 50, 120, 0.9);
  --cell-size: 65px;
  --cell-gap: 12px;
  --winner-color: #ffd700;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.85);
  --text-hint: rgba(255, 255, 255, 0.6);
  font-family: "Poppins", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* ==================== */
/* Reset & Base Styles */
/* ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vh, 40px) clamp(16px, 4vw, 48px);
  overflow-x: hidden;
}

/* Animated background effect - DISABLED for performance */
body::before {
  display: none;
}

/* ==================== */
/* Game Container */
/* ==================== */
.game-container {
  position: relative;
  z-index: 1;
  max-width: 600px;
  background: var(--panel-bg);
  border-radius: 32px;
  border: 3px solid var(--panel-border);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7);
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==================== */
/* Typography */
/* ==================== */
h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  text-align: center;
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffffff;
  font-weight: 900;
  padding-bottom: 8px;
}

/* ==================== */
/* Header Status */
/* ==================== */
#header {
  font-size: clamp(1.3rem, 3vw, 1.6rem);
  text-align: center;
  font-weight: 600;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(
    135deg,
    rgba(75, 163, 255, 0.2),
    rgba(138, 196, 255, 0.15)
  );
  border: 2px solid rgba(75, 163, 255, 0.4);
  padding: 16px 24px;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

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

/* ==================== */
/* Buttons */
/* ==================== */
button {
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: 16px;
  border: none;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(75, 163, 255, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  position: relative;
  overflow: hidden;
  min-width: 160px;
}

button:hover:not(:disabled) {
  opacity: 0.9;
}

button:active:not(:disabled) {
  opacity: 0.8;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Subtle glow effect on board - DISABLED for performance */

.row {
  display: flex;
  gap: var(--cell-gap);
  justify-content: center;
}

/* ==================== */
/* Game Cells */
/* ==================== */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  min-width: var(--cell-size);
  min-height: var(--cell-size);
  max-width: var(--cell-size);
  max-height: var(--cell-size);
  border-radius: 50%;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.5),
    0 3px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  flex-shrink: 0;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(20, 40, 100, 0.95);
  z-index: 1;
}

.cell:hover::before {
  background: rgba(50, 90, 180, 0.85);
}

.cell:active {
  opacity: 0.9;
}

/* Red checker */
.cell.red::before {
  background: radial-gradient(circle at 35% 30%, #ff8585, #e41e1e 65%);
  box-shadow: inset 0 -5px 12px rgba(0, 0, 0, 0.35),
    inset 0 3px 8px rgba(255, 255, 255, 0.35);
}

/* Yellow checker */
.cell.yellow::before {
  background: radial-gradient(circle at 35% 30%, #fff9a0, #f0b800 65%);
  box-shadow: inset 0 -5px 12px rgba(0, 0, 0, 0.35),
    inset 0 3px 8px rgba(255, 255, 255, 0.45);
}

/* Winning cell animation */
.cell.winner::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 6px solid var(--winner-color);
  z-index: 2;
  box-shadow: 0 0 30px var(--winner-color);
}

.cell:focus-visible {
  outline: 4px solid rgba(75, 163, 255, 0.9);
  outline-offset: 6px;
}

/* ==================== */
/* Touch Hint */
/* ==================== */
.touch-hint {
  font-size: 1rem;
  text-align: center;
  color: var(--text-hint);
  line-height: 1.6;
  padding: 0 16px;
  margin: 0;
}

/* ==================== */
/* Responsive Design */
/* ==================== */

/* Tablet */
@media (max-width: 768px) {
  :root {
    --cell-size: 55px;
    --cell-gap: 10px;
  }

  .game-container {
    max-width: 90vw;
    padding: 28px;
  }

  h1 {
    font-size: 2.5rem;
    letter-spacing: 0.1em;
  }

  #header {
    min-height: 55px;
    padding: 14px 20px;
    font-size: 1.4rem;
  }

  #playground {
    padding: 16px;
  }
}

/* Mobile */
@media (max-width: 540px) {
  :root {
    --cell-size: 45px;
    --cell-gap: 9px;
  }

  body {
    padding: 16px;
  }

  .game-container {
    border-radius: 28px;
    padding: 24px;
    max-width: 100%;
  }

  h1 {
    font-size: 2rem;
  }

  #header {
    font-size: 1.2rem;
    min-height: 50px;
  }

  #playground {
    border-width: 4px;
    padding: 14px;
  }

  button {
    width: 100%;
    padding: 14px 28px;
    min-width: auto;
  }

  .touch-hint {
    font-size: 0.9rem;
  }
}

/* Small mobile */
@media (max-width: 400px) {
  :root {
    --cell-size: 38px;
    --cell-gap: 8px;
  }

  body {
    padding: 12px;
  }

  .game-container {
    padding: 20px;
    gap: 18px;
    border-radius: 24px;
  }

  h1 {
    font-size: 1.7rem;
  }

  #header {
    min-height: 48px;
    font-size: 1.1rem;
  }

  #playground {
    padding: 12px;
  }
}

/* Landscape mode optimization for mobile */
@media (max-height: 700px) and (orientation: landscape) {
  :root {
    --cell-size: 40px;
    --cell-gap: 8px;
  }

  body {
    padding: 12px 16px;
  }

  .game-container {
    gap: 16px;
    padding: 20px;
    max-width: 90vw;
  }

  h1 {
    font-size: 1.8rem;
  }

  #header {
    min-height: 45px;
    font-size: 1.1rem;
    padding: 10px 18px;
  }

  .touch-hint {
    display: none;
  }

  #playground {
    padding: 12px;
  }
}

/* Desktop large screens */
@media (min-width: 1200px) {
  :root {
    --cell-size: 70px;
    --cell-gap: 14px;
  }

  .game-container {
    max-width: 650px;
    padding: 40px;
  }

  #playground {
    padding: 24px;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .cell::before {
    box-shadow: inset 0 -4px 12px rgba(0, 0, 0, 0.4),
      0 2px 8px rgba(0, 0, 0, 0.25);
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  /* All animations already disabled for performance */
}

/* Dark mode support (if user prefers dark) */
@media (prefers-color-scheme: dark) {
  /* Already dark by default */
}

/* Print styles */
@media print {
  body {
    background: white;
  }

  body::before {
    display: none;
  }

  .game-container {
    box-shadow: none;
    border: 2px solid #000;
  }

  button,
  .input-area {
    display: none;
  }
}
