/* ---------- Space Memory ---------- */
.space-memory-level {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 82px clamp(14px, 3vw, 34px) 26px;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 214, 107, 0.18), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(103, 214, 255, 0.16), transparent 28%),
    radial-gradient(circle at 72% 78%, rgba(255, 141, 98, 0.12), transparent 32%),
    linear-gradient(135deg, #080711 0%, #14102a 48%, #071a20 100%);
  color: #eef7ff;
}

.space-memory-shell {
  position: relative;
  z-index: 34;
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(250px, 0.44fr) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 28px);
  align-items: center;
}

.space-memory-copy {
  display: grid;
  gap: 16px;
  align-content: center;
}

.space-memory-copy > span {
  color: #8feaff;
  font-size: 13px;
  font-weight: 1000;
  text-transform: uppercase;
}

.space-memory-copy h1 {
  max-width: 420px;
  color: #fff7d8;
  font-family: "Fraunces", serif;
  font-size: clamp(42px, 6vw, 74px);
  font-weight: 500;
  line-height: 0.94;
}

.space-memory-copy p {
  max-width: 390px;
  color: rgba(238, 247, 255, 0.76);
  font-size: 17px;
  line-height: 1.36;
}

.space-memory-status {
  min-height: 104px;
  width: min(390px, 100%);
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid rgba(143, 234, 255, 0.24);
  border-radius: 8px;
  background: rgba(9, 18, 38, 0.76);
  color: #fff7d8;
  padding: 16px 18px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.space-memory-status strong {
  font-size: 17px;
  line-height: 1.3;
}

.space-memory-status small {
  color: rgba(238, 247, 255, 0.68);
  font-weight: 900;
}

.space-memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.space-memory-actions button {
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #ffd66b;
  color: #171005;
  font: inherit;
  font-weight: 1000;
  padding: 12px 18px;
  cursor: pointer;
}

.space-memory-actions button + button {
  background: rgba(238, 247, 255, 0.12);
  color: #eef7ff;
}

.space-memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.35vw, 14px);
  width: min(760px, 100%);
  justify-self: end;
}

.space-memory-card {
  min-width: 0;
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  perspective: 900px;
}

.space-memory-card:disabled {
  cursor: default;
}

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

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

.space-memory-card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  backface-visibility: hidden;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.34);
}

.space-memory-card-back {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 214, 107, 0.22), transparent 28%),
    linear-gradient(150deg, rgba(143, 234, 255, 0.14), rgba(255, 141, 98, 0.1)),
    rgba(13, 14, 34, 0.9);
}

.space-memory-card-back strong {
  width: clamp(44px, 42%, 76px);
  height: clamp(44px, 42%, 76px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 247, 216, 0.96);
  color: #181106;
  font-family: "Fraunces", serif;
  font-size: clamp(2.1rem, 5vw, 4rem);
  font-weight: 500;
  line-height: 1;
}

.space-memory-card-orbit {
  position: absolute;
  inset: 14%;
  border: 2px solid rgba(143, 234, 255, 0.28);
  border-radius: 50%;
  transform: rotate(-24deg) scaleY(0.62);
}

.space-memory-card-front {
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 4px;
  padding: clamp(8px, 1.5vw, 14px);
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 28%, color-mix(in srgb, var(--memory-card-tint) 34%, transparent), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 46%),
    rgba(9, 18, 38, 0.92);
}

.space-memory-card-front strong {
  max-width: 100%;
  color: #fff7d8;
  font-family: "Fraunces", serif;
  font-size: clamp(1rem, 1.9vw, 1.5rem);
  font-weight: 500;
  line-height: 1;
  text-align: center;
}

.space-memory-card-front small {
  min-height: 1.1em;
  color: rgba(238, 247, 255, 0.7);
  font-size: clamp(0.68rem, 1.1vw, 0.82rem);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.space-memory-world {
  position: relative;
  width: min(78%, 112px);
  aspect-ratio: 1;
  align-self: center;
  border-radius: 50%;
  background: var(--memory-card-tint);
  box-shadow:
    inset -18px -18px 26px rgba(0, 0, 0, 0.24),
    inset 14px 14px 24px rgba(255, 255, 255, 0.16),
    0 0 28px color-mix(in srgb, var(--memory-card-tint) 52%, transparent);
}

.space-memory-world::before,
.space-memory-world::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.space-memory-world-sun {
  background:
    radial-gradient(circle at 36% 32%, #fff9bf 0 16%, transparent 17%),
    radial-gradient(circle at 50% 50%, #ffd66b 0 54%, #ff8d62 72%);
  box-shadow:
    0 0 28px rgba(255, 214, 107, 0.52),
    0 0 56px rgba(255, 141, 98, 0.24);
}

.space-memory-world-sun::before {
  inset: -10%;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 8deg,
    rgba(255, 214, 107, 0.42) 0 5deg,
    transparent 5deg 13deg
  );
  filter: blur(2px);
  z-index: -1;
}

.space-memory-world-mercury {
  background:
    radial-gradient(circle at 30% 38%, rgba(255, 255, 255, 0.22) 0 6%, transparent 7%),
    radial-gradient(circle at 58% 28%, rgba(54, 45, 39, 0.28) 0 7%, transparent 8%),
    linear-gradient(135deg, #d6c8b5, #7e7368);
}

.space-memory-world-venus {
  background:
    repeating-linear-gradient(-16deg, rgba(255, 247, 216, 0.36) 0 9px, transparent 9px 18px),
    linear-gradient(135deg, #f5d184, #d9824f);
}

.space-memory-world-earth {
  background:
    radial-gradient(circle at 37% 38%, #61d394 0 15%, transparent 16%),
    radial-gradient(circle at 64% 58%, #7cffce 0 12%, transparent 13%),
    radial-gradient(circle at 48% 24%, #eef7ff 0 7%, transparent 8%),
    linear-gradient(135deg, #67d6ff, #236fc4);
}

.space-memory-world-mars {
  background:
    radial-gradient(circle at 60% 34%, rgba(90, 38, 22, 0.32) 0 13%, transparent 14%),
    radial-gradient(circle at 32% 65%, rgba(255, 215, 158, 0.24) 0 9%, transparent 10%),
    linear-gradient(135deg, #ffb06f, #b84d35);
}

.space-memory-world-jupiter {
  background:
    radial-gradient(circle at 72% 54%, rgba(170, 70, 48, 0.58) 0 13%, transparent 14%),
    repeating-linear-gradient(0deg, #f8d29d 0 10px, #d99261 10px 18px, #fff0c9 18px 27px);
}

.space-memory-world-saturn {
  background:
    repeating-linear-gradient(0deg, #f8e4a2 0 11px, #c8a96b 11px 20px),
    #f3dd92;
}

.space-memory-world-saturn::before {
  left: -34%;
  right: -34%;
  top: 39%;
  height: 24%;
  border: 8px solid rgba(255, 243, 199, 0.84);
  border-top-color: rgba(255, 243, 199, 0.32);
  border-radius: 50%;
  transform: rotate(-16deg);
}

.space-memory-world-neptune {
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.22) 0 11%, transparent 12%),
    linear-gradient(135deg, #7ca7ff, #254fb0);
}

.space-memory-card:hover .space-memory-card-face,
.space-memory-card:focus-visible .space-memory-card-face {
  border-color: rgba(255, 214, 107, 0.58);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.4),
    0 0 0 5px rgba(255, 214, 107, 0.08);
}

.space-memory-card:focus-visible {
  outline: none;
}

.space-memory-card.matched .space-memory-card-front {
  border-color: rgba(124, 255, 206, 0.7);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.4),
    0 0 0 5px rgba(124, 255, 206, 0.1),
    0 0 30px rgba(124, 255, 206, 0.2);
}

.space-memory-card.pulse .space-memory-card-front {
  animation: space-memory-pop 0.54s ease-out both;
}

@keyframes space-memory-pop {
  0% {
    transform: rotateY(180deg) scale(1);
  }
  48% {
    transform: rotateY(180deg) scale(1.05);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

@media (max-width: 880px) {
  .space-memory-level {
    align-items: start;
    padding: 76px 12px 18px;
  }

  .space-memory-shell {
    grid-template-columns: 1fr;
  }

  .space-memory-copy {
    justify-items: center;
    text-align: center;
  }

  .space-memory-copy h1 {
    font-size: clamp(34px, 10vw, 54px);
  }

  .space-memory-board {
    justify-self: center;
    width: min(100%, 620px);
    gap: 8px;
  }

  .space-memory-card-front {
    padding: 7px;
  }
}

@media (max-width: 480px) {
  .space-memory-board {
    gap: 6px;
  }

  .space-memory-card-front strong {
    font-size: clamp(0.72rem, 3.1vw, 1rem);
  }

  .space-memory-card-front small {
    display: none;
  }
}
