.tile-match {
  --tm-panel: rgba(255, 255, 255, 0.055);
  --tm-line: rgba(176, 109, 255, 0.26);
  --tm-gold: #ffd700;
  --tm-gold-soft: #ffb347;
  --tm-pink: #e040fb;
  --tm-teal: #00e5cc;
  width: min(980px, 100%);
  margin: 0 auto;
  color: #fff;
}

.tm-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.tm-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  color: var(--tm-gold-soft);
  margin: 0 0 0.45rem;
}

.tm-copy {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.7;
  margin: 0;
}

.tm-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tm-button {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  font: inherit;
  font-weight: 900;
  color: #1a0040;
  background: linear-gradient(135deg, var(--tm-gold), #ff8c00);
  cursor: pointer;
  box-shadow: 0 0 26px rgba(255, 215, 0, 0.28);
}

.tm-button.secondary {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--tm-line);
  box-shadow: none;
}

.tm-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.2rem;
}

.tm-stat {
  border: 1px solid var(--tm-line);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  background: var(--tm-panel);
  backdrop-filter: blur(8px);
}

.tm-stat-label {
  display: block;
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.tm-stat-value {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--tm-teal);
}

.tm-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.tm-card {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 1.1rem;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

.tm-card[disabled] {
  cursor: default;
}

.tm-card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.42s ease;
}

.tm-card.is-flipped .tm-card-inner,
.tm-card.is-matched .tm-card-inner {
  transform: rotateY(180deg);
}

.tm-card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  backface-visibility: hidden;
  border: 1px solid var(--tm-line);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.26);
}

.tm-card-back {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 215, 0, 0.22), transparent 28%),
    linear-gradient(145deg, rgba(123, 47, 255, 0.82), rgba(13, 0, 32, 0.9));
}

.tm-card-back::after {
  content: "✦";
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(1.7rem, 5vw, 3rem);
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.45);
}

.tm-card-front {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(45, 0, 96, 0.86));
  font-size: clamp(2rem, 7vw, 4rem);
}

.tm-card.is-matched .tm-card-face {
  border-color: rgba(0, 229, 204, 0.72);
  box-shadow: 0 0 28px rgba(0, 229, 204, 0.26);
}

.tm-message {
  margin-top: 1.2rem;
  min-height: 1.7rem;
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.7;
}

.tm-message strong {
  color: var(--tm-gold-soft);
}

@media (max-width: 760px) {
  .tm-header {
    grid-template-columns: 1fr;
  }

  .tm-actions {
    justify-content: flex-start;
  }

  .tm-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .tm-board {
    gap: 0.55rem;
  }
}
