/* Mobile-First & Professional UI Variables */
:root {
  --primary-bg: linear-gradient(135deg, #2b1055 0%, #7597de 100%);
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  --text-main: #ffffff;
  --text-secondary: #e0e0e0;
  --accent-color: #ff00cc;
  --accent-hover: #d900ad;
  --button-bg: linear-gradient(45deg, #ff00cc, #333399);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--primary-bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Montserrat', sans-serif;
  color: var(--text-main);
  overflow: hidden; /* Prevent scrolling while playing */
}

/* Main Container to hold everything centered */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  padding: 10px;
}

/* Glassmorphism Panels */
.scoreBoard, #modeSelection {
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  color: var(--text-main);
}

/* Mode Selection Screen */
#modeSelection {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex; /* Flex is set inline by JS, but good default */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(43, 16, 85, 0.95); /* Solid backing for readability */
}

#modeSelection h2 {
  font-size: 2rem;
  margin-bottom: 30px;
  background: -webkit-linear-gradient(#eee, #333); 
  text-shadow: 0 0 10px rgba(255,255,255,0.5);
  color: white;
}

button {
  margin: 10px;
  padding: 15px 40px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--button-bg);
  border: none;
  border-radius: 50px;
  color: white;
  transition: transform 0.2s, box-shadow 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

button:active {
  transform: translateY(1px);
}

/* Scoreboard */
.scoreBoard {
  width: 90%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 15px;
  margin-bottom: 20px;
  /* Use JS to toggle display, but default can be hidden or block */
  display: none; 
}

.scoreBoard div {
  text-align: center;
}

h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  margin: 0;
  opacity: 0.8;
}

h1#score {
  font-size: 2.5rem;
  margin: 5px 0 0 0;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

#timer {
  font-size: 1.2rem;
  font-weight: bold;
  color: #ffeb3b;
}

#changeMode {
  padding: 8px 16px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.2);
}

/* Game Grid */
.grid {
  display: none; /* Initially hidden */
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: 90vw;
  height: 90vw;
  max-width: 500px;
  max-height: 500px;
  background: rgba(255, 255, 255, 0.15);
  padding: 5px;
  border-radius: 15px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
  margin-bottom: 20px;
}

.grid div {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
  /* Prevent default touch actions like scrolling within a tile */
  touch-action: none;
}

.grid div:hover {
  transform: scale(1.1);
  z-index: 10;
}

/* Animations */
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.grid div {
  animation: pop 0.3s ease-out;
}

/* Responsive adjustments */
@media (min-width: 600px) {
  .scoreBoard {
    width: 500px;
  }
}
