body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease;
}

body.dark-mode {
  background: #111;
}

body:not(.dark-mode) {
  background: #ffffff4a;
}

body:not(.dark-mode) .enter-button {
  color: #ffffff;
  background: #a400fcbc;
}

body.dark-mode .enter-button {
  color: #ffffff;
  background: #29013e91;
}

main.container {
  flex: 1;
  display: flex;
  justify-content: center;
  position: relative;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, 80px);
  grid-template-rows: repeat(8, 80px);
  gap: 10px;
  width: max-content;
  left: 50%;
  transform: translateX(-50%);
  position: absolute;
  opacity: 0.5;
  margin: 0 auto;
}

.block {
  width: 80px;
  height: 80px;
  opacity: 0;
  background: transparent;
  position: absolute;
  transition: opacity 1s ease, background 2s ease, transform 1s ease;
  border: 1px solid #a400fc2d;
  z-index: 1;
  border-radius: 16px;
}

.dark-mode .block {
  border: 1px solid #444;
}

.block.show {
  opacity: 0.5;
  background: linear-gradient(-45deg, #a400fc1e, #a81fb456, #8b30bc15);
  background-size: 200% 200%;
  animation: gradientFlow 1s ease infinite;
}

body:not(.dark-mode) .block,
body:not(.dark-mode) .special-block.visible,
body:not(.dark-mode) .special-block {
  opacity: 0.5;
}

body:not(.dark-mode) .special-block.fade-out {
  opacity: 0;
}

.block.dragging {
  opacity: 0.36;
  z-index: 10;
  transform: scale(1.1);
}

.block:hover {
  transform: scale(1.1);
  cursor: grab;
}

.block.merged {
  background: #00babd !important;
  animation: none;
  opacity: 0;
  transition: background 1s ease, opacity 2s ease;
}

@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes shine {
  0% {
    box-shadow: 0 0 0px #fff5;
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 8px #a400fc;
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0px #65288662;
    transform: scale(1);
  }
}

.block.shine {
  animation: shine 2s ease-in-out;
}

.block.pulse {
  box-shadow: 0 0 10px 5px #ca67ff85;
  animation: pulse 2s ease;
}

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

.cell {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 16px;
  box-sizing: border-box;
  transition: background 0.3s ease;
}

.cell:hover {
  background: #c250ff53;
  cursor: pointer;
  border-radius: 16px;
}

.cell.highlight {
  box-shadow: 0 0 12px 4px #a400fc21;
  background: #c861ff28;
  transition: background 1s ease, box-shadow 2s ease;
}

.cell,
.block {
  width: 50px;
  height: 50px;
  margin: 5px;
}

.enter-button-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  text-align: center;
}

.enter-button {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif,
    "Arial Black", sans-serif;
  display: inline-block;
  padding: 16px 16px;
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: none;
  border-radius: 14px;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
  transition: all 0.4s ease, background-position 1.5s ease;
}

.enter-button:hover {
  background-size: 200% 200%;
  background: linear-gradient(-45deg, #d07aff, #ea02ff, #c862ff) !important;
  animation: gradientFlow 1s ease infinite;
  transform: translateY(-8px) scale(1.05);
  text-decoration: none;
  box-shadow: 0 15px 30px rgba(164, 0, 252, 0.5);
}

.enter-button:active {
  transform: translateY(0) scale(0.96);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.block.glow {
  box-shadow: 0 0 10px 5px yellow;
}

.special-block {
  background: linear-gradient(135deg, #a400fc21, #ffc80011);
  background-size: 200% 200%;
  opacity: 0;
  transition: opacity 1s, left 0.5s, top 0.5s, transform 2s;
  z-index: 2;
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 16px;
}

.special-block.visible {
  opacity: 0.5;
}

.special-block.fade-out {
  opacity: 0;
}

.shrink {
  transform: scale(0);
  transition: transform 0.5s ease, opacity 0.5s ease;
}

.flash {
  animation: flashEffect 0.3s ease-in-out;
}

@keyframes flashEffect {
  0% {
    background-color: #ffc600;
  }
  50% {
    background-color: white;
  }
  100% {
    background-color: transparent;
  }
}
