:root {
  --cell-size: 36px;
  --font-size: 18px;
  --primary-bg: #1e293b;
  --cell-bg: #334155;
  --cell-hover: #475569;
  --text-color: #f8fafc;
  --accent: #3b82f6;
}
* { box-sizing: border-box; }
body {
  background-color: var(--primary-bg);
  color: var(--text-color);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100vh;
}
h1 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: var(--accent);
}
#score {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--text-color);
}
#best {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--text-color);
}
#grid {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: 4px;
}
.tile {
  width: var(--cell-size);
  height: var(--cell-size);
  font-size: var(--font-size);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--cell-bg);
  border: 1px solid #475569;
  color: var(--text-color);
  cursor: pointer;
  transition: transform 1.6s cubic-bezier(.4,2,.6,1);
  border-radius: 4px;
}
.tile.match {
  animation: disappear 0.3s forwards;
}
@keyframes disappear {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
@media (min-width: 768px) {
  :root {
    --cell-size: 48px;
    --font-size: 22px;
  }
}

#popup-container {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 100;
}

.popup {
  font-size: 2rem;
  font-weight: bold;
  color: gold;
  animation: popup 1s ease-out forwards;
  opacity: 0;
}

@keyframes popup {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-40px); opacity: 0; }
}

.floating-score {
  font-size: 1.2rem;
  font-weight: bold;
  color: lightgreen;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  z-index: 200;
}

@keyframes floatUp {
  0% { transform: translate(-50%, 0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -40px); opacity: 0; }
}
