/* Basic setup */
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  font-family: Arial, sans-serif;
  color: #fff;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 50%, #000000 100%);
}

/* Canvas background */
canvas#bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Container for main content */
.container {
  position: relative;
  z-index: 2;
  max-width: 600px;
  margin: auto;
  padding: 20px;
  top: 30%;
}

/* Logo */
.logo {
  width: 90%;
  max-width: 500px;
  margin-bottom: 30px;
  filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
  animation: heartbeat 2s ease-in-out infinite;
}

/* Headings and text */
h1 {
  font-size: 3.5em;
  color: #FFD700;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

p {
  font-size: 1.3em;
  line-height: 1.6;
}

/* Countdown Timer */
#countdown {
  font-size: 1.5em;
  margin: 20px 0;
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  opacity: 0;
  animation: fadeInUp 1s forwards;
  animation-delay: 1s;
}

/* Email form */
.subscribe-form {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  opacity: 0;
  animation: fadeInUp 1s forwards;
  animation-delay: 2s;
}

.subscribe-form input {
  padding: 10px;
  font-size: 1em;
  border: none;
  border-radius: 5px 0 0 5px;
  outline: none;
}

.subscribe-form button {
  padding: 10px 20px;
  font-size: 1em;
  border: none;
  border-radius: 0 5px 5px 0;
  background-color: #FFD700;
  color: #000;
  cursor: pointer;
  transition: 0.3s;
}

.subscribe-form button:hover {
  background-color: #FFC300;
}

/* Fade-in animation */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Game Modal Styles */
.game-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.game-modal-content {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, #1a1a1a 100%);
  margin: 3% auto;
  padding: 25px;
  border-radius: 20px;
  width: 95%;
  max-width: 600px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 215, 0, 0.3);
  border: 3px solid #FFD700;
  animation: slideIn 0.4s ease-out;
  position: relative;
  overflow: hidden;
}

@keyframes slideIn {
  from { 
    transform: translateY(-50px) scale(0.9);
    opacity: 0;
  }
  to { 
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.game-modal-content::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #FFD700, #FFC300, #FFD700, #FFA500);
  border-radius: 20px;
  z-index: -1;
  animation: borderGlow 2s linear infinite;
}

@keyframes borderGlow {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.close-game {
  color: #FFD700;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
}

.close-game:hover {
  color: #FFC300;
  transform: scale(1.1);
}

.game-modal h2 {
  color: #FFD700;
  margin-bottom: 20px;
  font-size: 2em;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

/* Game Header */
.game-header {
  margin-bottom: 20px;
}

.game-header h2 {
  color: #FFD700;
  margin-bottom: 15px;
  font-size: 2.2em;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
  animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  from { text-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
  to { text-shadow: 0 0 25px rgba(255, 215, 0, 1), 0 0 35px rgba(255, 215, 0, 0.5); }
}

.game-stats {
  display: flex;
  justify-content: space-around;
  margin: 15px 0;
  background: rgba(255, 215, 0, 0.1);
  padding: 10px;
  border-radius: 15px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.stat-label {
  color: #FFD700;
  font-weight: bold;
  font-size: 0.9em;
}

.stat-value {
  color: #FFD700;
  font-size: 1.5em;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

/* Game Board Container */
.game-board-container {
  position: relative;
  display: inline-block;
  margin: 20px 0;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(3, 90px);
  gap: 8px;
  justify-content: center;
  background: rgba(255, 215, 0, 0.05);
  padding: 15px;
  border-radius: 15px;
  border: 2px solid rgba(255, 215, 0, 0.3);
  position: relative;
}

.cell {
  width: 90px;
  height: 90px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 215, 0, 0.1));
  border: 2px solid #FFD700;
  font-size: 2.5em;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: #FFD700;
  font-weight: bold;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

.cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.3), transparent);
  transition: left 0.5s;
}

.cell:hover::before {
  left: 100%;
}

.cell:hover {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 255, 255, 0.1));
  transform: scale(1.08) rotate(2deg);
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.6), inset 0 0 15px rgba(255, 215, 0, 0.2);
  border-color: #FFC300;
}

.cell.taken {
  cursor: not-allowed;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 255, 255, 0.1));
  animation: cellPop 0.4s ease-out;
}

@keyframes cellPop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.cell.taken:hover {
  transform: none;
  box-shadow: none;
}

.cell.winning {
  animation: winningPulse 0.6s ease-in-out infinite alternate;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.5), rgba(255, 255, 255, 0.2));
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
}

@keyframes winningPulse {
  from { 
    transform: scale(1);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
  }
  to { 
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(255, 215, 0, 1);
  }
}

/* Winning Line */
.winning-line {
  position: absolute;
  background: linear-gradient(90deg, #FFD700, #FFC300);
  height: 4px;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.winning-line.show {
  opacity: 1;
  animation: lineGlow 1s ease-in-out infinite alternate;
}

@keyframes lineGlow {
  from { box-shadow: 0 0 10px rgba(255, 215, 0, 0.8); }
  to { box-shadow: 0 0 20px rgba(255, 215, 0, 1); }
}

/* Game Controls */
.game-controls {
  margin-top: 20px;
}

.game-status {
  font-size: 1.3em;
  margin: 15px 0;
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  animation: statusPulse 2s ease-in-out infinite alternate;
}

@keyframes statusPulse {
  from { text-shadow: 0 0 10px rgba(255, 215, 0, 0.8); }
  to { text-shadow: 0 0 20px rgba(255, 215, 0, 1); }
}

.player-symbol {
  font-size: 1.2em;
  font-weight: bold;
  color: #FFC300;
  text-shadow: 0 0 15px rgba(255, 195, 0, 0.8);
}

.control-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.game-btn {
  padding: 12px 20px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 25px;
  font-weight: bold;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  min-width: 120px;
}

.game-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.game-btn:hover::before {
  left: 100%;
}

.reset-btn {
  background: linear-gradient(45deg, #FF6B6B, #FF8E8E);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.reset-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
  background: linear-gradient(45deg, #FF8E8E, #FF6B6B);
}

.new-btn {
  background: linear-gradient(45deg, #4ECDC4, #44A08D);
  color: white;
  box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.new-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(78, 205, 196, 0.6);
  background: linear-gradient(45deg, #44A08D, #4ECDC4);
}

.sound-btn {
  background: linear-gradient(45deg, #FFD700, #FFC300);
  color: #000;
  box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

.sound-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 215, 0, 0.6);
  background: linear-gradient(45deg, #FFC300, #FFD700);
}

.sound-btn.muted {
  background: linear-gradient(45deg, #666, #888);
  color: #ccc;
  box-shadow: 0 4px 15px rgba(102, 102, 102, 0.4);
}

/* Particle Effects */
.particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #FFD700;
  border-radius: 50%;
  pointer-events: none;
  animation: particleFloat 2s ease-out forwards;
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) scale(0);
  }
}

/* Responsive Design */
/* Mobile First - Small screens */
@media (max-width: 480px) {
  .container {
    padding: 15px;
    top: 20%;
  }
  
  .logo {
    width: 95%;
    max-width: 300px;
    margin-bottom: 20px;
  }
  
  h1 {
    font-size: 2.5em;
    margin: 15px 0;
  }
  
  p {
    font-size: 1.1em;
    line-height: 1.4;
    margin: 15px 0;
  }
  
  #countdown {
    font-size: 1.2em;
    margin: 15px 0;
  }
  
  .subscribe-form {
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
  }
  
  .subscribe-form input {
    width: 100%;
    border-radius: 5px;
    margin-bottom: 5px;
  }
  
  .subscribe-form button {
    width: 100%;
    border-radius: 5px;
  }
  
  /* Game Modal Mobile - Fixed sizing */
  .game-modal {
    padding: 10px;
  }
  
  .game-modal-content {
    margin: 0 auto;
    width: 100%;
    max-width: 95vw;
    height: 95vh;
    max-height: 95vh;
    padding: 10px;
    border-radius: 10px;
    overflow-y: auto;
    box-sizing: border-box;
  }
  
  .game-header h2 {
    font-size: 1.3em;
    margin-bottom: 8px;
  }
  
  .game-stats {
    flex-direction: row;
    gap: 5px;
    margin: 8px 0;
    padding: 5px;
  }
  
  .stat {
    flex-direction: column;
    align-items: center;
    padding: 3px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 3px;
    flex: 1;
  }
  
  .stat-label {
    font-size: 0.8em;
  }
  
  .stat-value {
    font-size: 1.2em;
  }
  
  .game-board {
    grid-template-columns: repeat(3, 50px);
    gap: 3px;
    margin: 10px auto;
    padding: 5px;
  }
  
  .cell {
    width: 50px;
    height: 50px;
    font-size: 1.5em;
  }
  
  .game-status {
    font-size: 1em;
    margin: 8px 0;
  }
  
  .control-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
  }
  
  .game-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 4px;
    font-size: 12px;
  }
  
  .close-game {
    font-size: 24px;
    padding: 5px;
  }
}

/* Tablet screens */
@media (min-width: 481px) and (max-width: 768px) {
  .container {
    padding: 20px;
    top: 25%;
  }
  
  .logo {
    width: 85%;
    max-width: 400px;
    margin-bottom: 25px;
  }
  
  h1 {
    font-size: 3em;
  }
  
  p {
    font-size: 1.2em;
  }
  
  #countdown {
    font-size: 1.3em;
  }
  
  .game-modal-content {
    margin: 3% auto;
    width: 95%;
    padding: 25px;
  }
  
  .game-board {
    grid-template-columns: repeat(3, 75px);
    gap: 6px;
  }
  
  .cell {
    width: 75px;
    height: 75px;
    font-size: 2.2em;
  }
  
  .control-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  
  .game-btn {
    width: 150px;
  }
}

/* Desktop screens */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    padding: 25px;
    top: 30%;
  }
  
  .logo {
    width: 80%;
    max-width: 450px;
  }
  
  h1 {
    font-size: 3.2em;
  }
  
  .game-modal-content {
    margin: 4% auto;
    width: 90%;
    max-width: 550px;
  }
  
  .game-board {
    grid-template-columns: repeat(3, 85px);
    gap: 7px;
  }
  
  .cell {
    width: 85px;
    height: 85px;
    font-size: 2.3em;
  }
}

/* Large desktop screens */
@media (min-width: 1025px) {
  .container {
    padding: 30px;
    top: 30%;
  }
  
  .logo {
    width: 90%;
    max-width: 500px;
  }
  
  h1 {
    font-size: 3.5em;
  }
  
  .game-modal-content {
    margin: 5% auto;
    width: 90%;
    max-width: 600px;
  }
  
  .game-board {
    grid-template-columns: repeat(3, 90px);
    gap: 8px;
  }
  
  .cell {
    width: 90px;
    height: 90px;
    font-size: 2.5em;
  }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    top: 10%;
    padding: 5px;
  }
  
  .logo {
    width: 50%;
    max-width: 200px;
    margin-bottom: 10px;
  }
  
  h1 {
    font-size: 1.8em;
    margin: 5px 0;
  }
  
  p {
    font-size: 0.9em;
    margin: 5px 0;
  }
  
  #countdown {
    font-size: 1em;
    margin: 5px 0;
  }
  
  /* Game Modal Landscape - Ultra compact */
  .game-modal-content {
    margin: 0 auto;
    width: 100%;
    max-width: 98vw;
    height: 98vh;
    max-height: 98vh;
    padding: 5px;
    overflow-y: auto;
  }
  
  .game-header h2 {
    font-size: 1.1em;
    margin-bottom: 5px;
  }
  
  .game-stats {
    flex-direction: row;
    gap: 3px;
    margin: 5px 0;
    padding: 3px;
  }
  
  .stat {
    flex-direction: column;
    align-items: center;
    padding: 2px;
    flex: 1;
  }
  
  .stat-label {
    font-size: 0.7em;
  }
  
  .stat-value {
    font-size: 1em;
  }
  
  .game-board {
    grid-template-columns: repeat(3, 40px);
    gap: 2px;
    margin: 5px auto;
    padding: 3px;
  }
  
  .cell {
    width: 40px;
    height: 40px;
    font-size: 1.2em;
  }
  
  .game-status {
    font-size: 0.9em;
    margin: 5px 0;
  }
  
  .control-buttons {
    flex-direction: row;
    gap: 3px;
    margin-top: 5px;
  }
  
  .game-btn {
    flex: 1;
    padding: 6px 3px;
    font-size: 10px;
  }
  
  .close-game {
    font-size: 20px;
    padding: 3px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .cell {
    min-height: 44px;
    min-width: 44px;
  }
  
  .game-btn {
    min-height: 44px;
    padding: 12px 20px;
  }
  
  .close-game {
    font-size: 32px;
    padding: 10px;
  }
}

/* Logo click effect and heartbeat animation */
.logo {
  cursor: pointer;
  transition: all 0.3s ease;
  animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
  }
  25% {
    transform: scale(1.15);
    filter: drop-shadow(0 0 35px rgba(255, 215, 0, 1));
  }
  50% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.9));
  }
  75% {
    transform: scale(1.2);
    filter: drop-shadow(0 0 40px rgba(255, 215, 0, 1));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.8));
  }
}

.logo:hover {
  animation-play-state: paused;
  transform: scale(1.25);
  filter: drop-shadow(0 0 50px rgba(255, 215, 0, 1));
}
/* Loader overlay styles */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s;
}
body.loaded .loader-overlay {
  opacity: 0;
  pointer-events: none;
}
.loader {
  width: 220px;
  height: 220px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.loader .box {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Animate the boxes */
  opacity: 0;
  transform: scale(0.5) rotate(-20deg);
  animation: loader-pop 1s forwards;
}
.loader .box0 { animation-delay: 0.1s; }
.loader .box1 { animation-delay: 0.2s; }
.loader .box2 { animation-delay: 0.3s; }
.loader .box3 { animation-delay: 0.4s; }
.loader .box4 { animation-delay: 0.5s; }
.loader .box5 { animation-delay: 0.6s; }
.loader .box6 { animation-delay: 0.7s; }
.loader .box7 { animation-delay: 0.8s; }
.loader .box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
@keyframes loader-pop {
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}
