/* ── Match game styles ── */

.match-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  color: var(--ink);
}

.match-main .back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 1rem;
}

.match-main .back-link:hover {
  color: var(--ink);
}

/* ── Intro screen ── */

.match-intro {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.match-intro h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.match-intro .match-intro-sub {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.match-intro .match-intro-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

/* ── Playing phase ── */

.match-hud {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.match-timer {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.match-pairs {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ── Card grid ── */

.match-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.625rem;
}

.match-card {
  min-height: 7.5rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.4s, transform 0.4s;
}

.match-card:active {
  transform: scale(0.97);
}

.match-card-text {
  font-size: 0.9375rem;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

/* ── Card states ── */

.match-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.match-card.matched {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

.match-card.wrong {
  animation: match-shake 0.45s ease;
  border-color: var(--warn);
}

.match-card.locked {
  pointer-events: none;
}

@keyframes match-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(2px); }
}

/* Correct flash before fade */
.match-card.correct {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px color-mix(in srgb, #22c55e 25%, transparent);
}

/* ── Result screen ── */

.match-result {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.25rem;
}

.match-result h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.match-time-big {
  font-size: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin: 0.25rem 0;
}

.match-result-stats {
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.match-result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 280px;
}

/* Reuse quiz button styles */
.match-result-actions .quiz-action-btn {
  width: 100%;
}

/* ── Responsive ── */

@media (max-width: 540px) {
  .match-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .match-main {
    padding: 1rem 0.75rem 2rem;
  }

  .match-card {
    min-height: 6.5rem;
    padding: 0.6rem;
  }

  .match-card-text {
    font-size: 0.85rem;
    -webkit-line-clamp: 4;
  }
}

@media (max-width: 360px) {
  .match-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
}

/* ── Hover (desktop only) ── */

@media (hover: hover) {
  .match-card:not(.selected):not(.matched):not(.wrong):hover {
    border-color: var(--accent);
  }
}
