/* ============================================================
   MEMORY GAME — STYLES
   ------------------------------------------------------------
   Card proportions match real playing cards: 2.5" x 3.5",
   which is a 5:7 ratio. That ratio is set once below and the
   whole grid scales off it, so cards stay "card shaped" at
   any screen size.
   ============================================================ */

:root {
  /* ---- Card-table palette ---- */
  --felt: #0f3d2e;
  --felt-dark: #0a2b20;
  --gold: #c9a24b;
  --gold-bright: #e8c877;
  --ivory: #faf6ec;
  --ink: #1c1c1c;
  --match-glow: #8fbf7a;

  /* ---- Sizing ---- */
  --card-width: 130px;
  --card-ratio: 5 / 7; /* 2.5in x 3.5in */
  --gap: 16px;
}

.memory-game-wrap {
  background:
    radial-gradient(circle at 50% 0%, var(--felt) 0%, var(--felt-dark) 100%);
  padding: 40px 20px 56px;
  border-radius: 18px;
  font-family: "Georgia", "Iowan Old Style", serif;
  color: var(--ivory);
  max-width: 720px;
  margin: 0 auto;
}

.memory-game-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
  border-bottom: 1px solid rgba(201, 162, 75, 0.35);
  padding-bottom: 16px;
}

.memory-game-title {
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--gold-bright);
}

.memory-game-stats {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 0.85rem;
  color: var(--ivory);
  opacity: 0.85;
  display: flex;
  gap: 18px;
}

.memory-game-stats span strong {
  color: var(--gold-bright);
  font-weight: 600;
}

/* ---- Grid ---- */
.memory-game-grid {
  display: grid;
  grid-template-columns: repeat(4, var(--card-width));
  gap: var(--gap);
  justify-content: center;
}

@media (max-width: 520px) {
  :root { --card-width: 78px; --gap: 10px; }
  .memory-game-grid { grid-template-columns: repeat(3, var(--card-width)); }
}

/* ---- Card ---- */
.card {
  aspect-ratio: var(--card-ratio);
  width: var(--card-width);
  perspective: 800px;
  cursor: pointer;
}

.card[data-locked="true"] {
  cursor: default;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-style: preserve-3d;
}

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

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(0, 0, 0, 0.25);
}

/* Back face (shown by default, face-down) */
.card-back {
  background:
    repeating-linear-gradient(
      45deg,
      var(--felt) 0px,
      var(--felt) 6px,
      var(--felt-dark) 6px,
      var(--felt-dark) 12px
    );
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back::after {
  content: "";
  width: 55%;
  height: 40%;
  border: 2px solid var(--gold);
  border-radius: 50% / 60%;
  box-shadow: inset 0 0 0 4px var(--felt-dark), inset 0 0 0 5px var(--gold-bright);
  opacity: 0.9;
}

/* Used instead of the felt pattern when CARD_BACK_IMAGE is set in the JS config */
.card-back.has-image {
  background: var(--ivory);
  padding: 6px;
}

.card-back.has-image::after {
  content: none;
}

.card-back.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}

/* Front face (the player's uploaded image), flipped into view */
.card-front {
  background: var(--ivory);
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}

/* Matched state — quiet glow instead of removing the card */
.card.is-matched .card-face {
  box-shadow: 0 0 0 3px var(--match-glow), 0 3px 10px rgba(0, 0, 0, 0.45);
}

.card.is-matched {
  cursor: default;
}

/* ---- Win banner ---- */
.memory-game-win {
  display: none;
  margin-top: 26px;
  text-align: center;
  font-family: "Georgia", serif;
}

.memory-game-win.is-visible {
  display: block;
}

.memory-game-win p {
  font-size: 1.15rem;
  color: var(--gold-bright);
  margin: 0 0 14px;
}

.memory-game-restart {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: var(--gold);
  color: var(--felt-dark);
  border: none;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.memory-game-restart:hover {
  background: var(--gold-bright);
  transform: translateY(-1px);
}

.memory-game-restart:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: 2px;
}

/* ---- Accessibility ---- */
@media (prefers-reduced-motion: reduce) {
  .card-inner {
    transition: none;
  }
}

.card:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}
