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

body {
  font-family: 'Arial', sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: white;
  padding: 10px;
}

#game-container {
  position: relative;
  background: #0a1929;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  padding: 15px;
  max-width: 600px;
  width: 100%;
}

#game-ui {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: bold;
  color: #4fc3f7;
  text-align: center;
  gap: 8px;
  flex-wrap: wrap;
}

#game-ui > div {
  flex: 1;
}

#game-board {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  grid-template-columns: repeat(4, 1fr);
}

#game-board.level-2 {
  grid-template-columns: repeat(5, 1fr);
}

#game-board.level-3 {
  grid-template-columns: repeat(6, 1fr);
}

.card {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
  border: 2px solid #4fc3f7;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 4px 15px rgba(30, 136, 229, 0.3);
}

.card:hover:not(.matched):not(.flipped) {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(30, 136, 229, 0.6);
  background: linear-gradient(135deg, #2196f3 0%, #1e88e5 100%);
}

.card.flipped {
  background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
  box-shadow: 0 4px 15px rgba(79, 195, 247, 0.4);
}

.card.matched {
  background: linear-gradient(135deg, #66bb6a 0%, #558b2f 100%);
  box-shadow: 0 4px 15px rgba(102, 187, 106, 0.4);
  border-color: #81c784;
  cursor: default;
}

.card.matched:hover {
  transform: none;
}

#start-screen, #game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 25, 41, 0.98);
  padding: 25px 30px;
  border-radius: 12px;
  text-align: center;
  border: 2px solid #1e88e5;
  box-shadow: 0 0 30px rgba(30, 136, 229, 0.5);
  z-index: 100;
  width: 90%;
  max-width: 500px;
}

#start-screen h1, #game-over h2 {
  font-size: 28px;
  margin-bottom: 15px;
  color: #4fc3f7;
  text-shadow: 0 0 10px rgba(79, 195, 247, 0.5);
}

#start-screen p {
  font-size: 14px;
  margin: 8px 0;
  color: #90caf9;
}

#final-moves {
  font-size: 18px;
  margin-bottom: 15px;
  color: #4fc3f7;
}

button {
  background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
  color: white;
  border: none;
  padding: 12px 25px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(30, 136, 229, 0.4);
  margin: 8px;
  width: 100%;
  max-width: 200px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(30, 136, 229, 0.6);
  background: linear-gradient(135deg, #2196f3 0%, #1e88e5 100%);
}

button:active {
  transform: translateY(0);
}

.hidden {
  display: none;
}

.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  background: rgba(30, 136, 229, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 16px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(30, 136, 229, 0.4);
  backdrop-filter: blur(10px);
}

.back-button:hover {
  background: rgba(30, 136, 229, 1);
  transform: translateX(-5px);
  box-shadow: 0 6px 20px rgba(30, 136, 229, 0.6);
}

@media (min-width: 640px) {
  #game-container {
    padding: 25px;
  }
  
  #game-ui {
    font-size: 16px;
    margin-bottom: 25px;
  }
  
  .card {
    font-size: 28px;
  }
  
  #start-screen, #game-over {
    padding: 35px 50px;
  }
  
  #start-screen h1, #game-over h2 {
    font-size: 38px;
  }
  
  #start-screen p {
    font-size: 16px;
  }
  
  #final-moves {
    font-size: 22px;
  }
  
  button {
    padding: 15px 35px;
    font-size: 16px;
    width: auto;
  }
}

@media (min-width: 1024px) {
  #game-container {
    padding: 30px;
  }
  
  #game-ui {
    font-size: 18px;
    margin-bottom: 30px;
  }
  
  .card {
    font-size: 32px;
  }
  
  #start-screen, #game-over {
    padding: 40px 60px;
  }
  
  #start-screen h1, #game-over h2 {
    font-size: 48px;
  }
  
  #start-screen p {
    font-size: 16px;
  }
  
  #final-moves {
    font-size: 24px;
  }
  
  button {
    padding: 15px 40px;
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  #game-board {
    gap: 8px;
  }
  
  .back-button {
    top: 10px;
    left: 10px;
    padding: 8px 16px;
    font-size: 14px;
  }
}
