/* Tile Match (memory) Game Styles */
.main-text {
  margin-top: 100px;
}

.tile-match-game-section {
  max-width: 780px;
  margin: 60px auto 0 auto;
  padding: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0));
  border-radius: 18px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.74);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.tile-match-game-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0.65), rgba(255,255,255,0) 40%);
  pointer-events: none;
  opacity: 0.55;
}

.tm-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 14, 22, 0.68);
  backdrop-filter: blur(8px);
  z-index: 30;
}

.tm-overlay-card {
  width: min(440px, calc(100% - 48px));
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 22px;
  padding: 22px 22px 20px;
  text-align: center;
  box-shadow: 0 28px 70px rgba(0,0,0,0.35);
  position: relative;
  z-index: 1;
}

.tm-overlay-title {
  font-size: 2.1rem;
  font-weight: 900;
  color: #0d1020;
  letter-spacing: 0.01em;
}

.tm-overlay-subtitle {
  margin-top: 6px;
  font-size: 1.02rem;
  font-weight: 600;
  color: rgba(13, 16, 32, 0.75);
}

.tm-score-label {
  margin-top: 16px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(13, 16, 32, 0.55);
}

.tm-score-label-tight {
  margin-top: 12px;
}

.tm-score {
  margin-top: 6px;
  font-size: 4.1rem;
  font-weight: 900;
  line-height: 1;
  color: #0d1020;
}

.tm-score-small {
  font-size: 2.4rem;
  opacity: 0.9;
}

.tm-overlay-btn {
  margin-top: 18px;
  padding: 12px 42px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
  background: linear-gradient(90deg, #111 0%, #2a2f4a 100%);
  box-shadow: 0 18px 44px rgba(0,0,0,0.22);
  transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
  font-family: 'Poppins', sans-serif;
}

.tm-overlay-btn:hover {
  transform: translateY(-2px);
  filter: saturate(1.1);
  box-shadow: 0 22px 52px rgba(0,0,0,0.28);
}

.tm-overlay-btn:active {
  transform: translateY(0px) scale(0.99);
}

.level-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 14, 22, 0.65);
  backdrop-filter: blur(6px);
  color: #fff;
  font-weight: 900;
  font-size: 3.2rem;
  border-radius: 18px;
  z-index: 10;
  letter-spacing: 0.02em;
  text-shadow: 0 14px 40px rgba(0,0,0,0.35);
}

.tm-timer {
  margin-bottom: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #0d1020;
  position: relative;
  z-index: 1;
}

.tile-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: 12px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  position: relative;
  z-index: 1;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(.2,.9,.25,1);
  --match-color: #ffffff;
  --match-text: #000000;
}

.tile.flipped {
  transform: rotateY(180deg);
}

.tile-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
}

.tile-back {
  background:
    /* Curved highlight (top) */
    radial-gradient(140% 120% at 35% 10%, rgba(70, 70, 70, 0.55), rgba(255, 255, 255, 0) 58%),
    /* Curved darken (bottom) */
    radial-gradient(140% 115% at 50% 120%, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0) 62%),
    #000;
  /* box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.20),
    inset 0 -14px 24px rgba(0, 0, 0, 0.18); */
}

/* .tile-back::after {
  content: '';
  width: 52%;
  height: 52%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: block;
} */

.tile-front {
  transform: rotateY(180deg);
  color: var(--match-text, #000);
  background:
    /* Curved highlight (top) */
    /* radial-gradient(140% 120% at 35% 10%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 58%), */
    /* Curved darken (bottom) */
    radial-gradient(140% 115% at 50% 120%, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0) 62%),
    var(--match-color);
  /* box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.20),
    inset 0 -14px 24px rgba(0, 0, 0, 0.18); */
  font-weight: 800;
  font-size: 6.2rem;
}

.tile.matched {
  cursor: default;
}

@media (max-width: 600px) {
  .main-text {
      margin-top: 60px;
  }
  .tile-match-game-section{
    max-width: 90%;
    margin: 20px auto 0 auto;
    padding: 12px 14px;
  }
  .tile-grid {
    gap: 10px;
    padding: 12px;
  }
  .tile-front {
    font-size: var(--tile-font-size, 1.8rem);
  }
}
