/* Category Match — memory flip */

.match-page {
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.match-app {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 16px 12px 28px;
}

.match-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.match-title {
  margin: 0 0 4px;
  font-size: clamp(1.45rem, 5.5vw, 1.9rem);
  letter-spacing: -0.02em;
}

.match-hint {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 28ch;
}

.match-scores {
  display: flex;
  gap: 8px;
}

.match-stat {
  min-width: 58px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.22);
  text-align: center;
}

.match-stat-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

.match-stat-value {
  display: block;
  margin-top: 2px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.match-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.match-diff {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 600;
}

.match-diff select {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #1e293b;
  color: #f1f5f9;
  font-weight: 700;
}

.match-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}

.match-btn.primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #fff;
}

.match-btn:active {
  transform: scale(0.98);
}

.match-board {
  --match-cols: 4;
  display: grid;
  grid-template-columns: repeat(var(--match-cols), minmax(0, 1fr));
  gap: 8px;
  perspective: 900px;
}

.match-board[data-pairs="6"] {
  --match-cols: 4;
}

.match-board[data-pairs="8"] {
  --match-cols: 4;
}

.match-board[data-pairs="10"] {
  --match-cols: 5;
}

@media (max-width: 420px) {
  .match-board[data-pairs="10"] {
    --match-cols: 4;
  }
}

.match-card {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transform-style: preserve-3d;
  transition: transform 0.38s ease;
}

.match-card:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

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

.match-card.is-matched {
  cursor: default;
  pointer-events: none;
}

.match-card.is-matched .match-face-front {
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.85);
}

.match-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.match-face-back {
  background:
    radial-gradient(circle at 30% 20%, rgba(96, 165, 250, 0.35), transparent 55%),
    linear-gradient(160deg, #1e3a5f 0%, #0f172a 70%);
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.match-face-back img {
  width: 62%;
  height: 62%;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.match-face-front {
  transform: rotateY(180deg);
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.match-face-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111827;
}

.match-face-front.is-logo img {
  object-fit: contain;
  width: 72%;
  height: 72%;
  padding: 8%;
  box-sizing: content-box;
}

.match-status {
  margin: 14px 0 0;
  min-height: 1.3em;
  text-align: center;
  color: #94a3b8;
  font-size: 0.9rem;
}

.match-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}

.match-overlay[hidden] {
  display: none !important;
}

.match-overlay-card {
  width: min(360px, 100%);
  padding: 22px 18px;
  border-radius: 16px;
  background: #111827;
  border: 1px solid rgba(148, 163, 184, 0.28);
  text-align: center;
}

.match-overlay-card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.match-overlay-card p {
  margin: 0 0 16px;
  color: #94a3b8;
  line-height: 1.45;
}

.match-face-front.is-broken {
  background: linear-gradient(145deg, #334155, #1e293b);
}

.match-face-front.is-broken img {
  display: none;
}

.match-leaderboard {
  margin-top: 18px;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.72);
}

.match-leaderboard-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.match-leaderboard-lead {
  margin: 0 0 12px;
  color: #94a3b8;
  font-size: 0.78rem;
  line-height: 1.4;
}

.match-leaderboard-lead a {
  color: #93c5fd;
  font-weight: 700;
}

.match-leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.match-leaderboard-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.45);
}

.match-leaderboard-row.is-you {
  border: 1px solid rgba(96, 165, 250, 0.55);
  background: rgba(37, 99, 235, 0.18);
}

.match-leaderboard-rank {
  font-weight: 800;
  color: #93c5fd;
  font-variant-numeric: tabular-nums;
}

.match-leaderboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.9rem;
}

.match-leaderboard-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
  white-space: nowrap;
}

.match-leaderboard-empty {
  margin: 0;
  color: #64748b;
  font-size: 0.85rem;
}
