﻿.memory-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  padding: clamp(1.6rem, 4vw, 2.4rem);
}

.memory-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.2rem;
}

.memory-hero p {
  max-width: 720px;
}

.memory-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.memory-panel {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  min-width: clamp(280px, 32vw, 380px);
  padding: clamp(1.2rem, 3vw, 1.5rem);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

.memory-stats {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.memory-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.25));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.memory-stat strong {
  font-size: 1.4rem;
  letter-spacing: 0.04em;
}

.memory-controls {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: 1fr;
}

.memory-segment {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.memory-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.memory-pill {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.5rem 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.memory-pill.active {
  border-color: color-mix(in srgb, var(--accent-primary) 55%, transparent);
  background: color-mix(in srgb, var(--accent-primary) 18%, transparent);
  color: var(--accent-primary);
}

.memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.2rem;
}

.memory-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.2rem;
  margin-top: 0.5rem;
}

.memory-board {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1.4rem, 3vw, 1.8rem);
  border-radius: 18px;
}

.memory-board .glass-card {
  padding: 0;
}

.memory-board__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.memory-board__title {
  display: block;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.memory-hint {
  max-width: 320px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.memory-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--memory-cols, 4), minmax(86px, 1fr));
  gap: 0.75rem;
  padding: 0.2rem 0.1rem 0.4rem;
}

.memory-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.memory-card__inner {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.36s ease, opacity 0.22s ease;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.015);
}

.memory-card__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.6rem;
  transition: transform 0.3s ease, opacity 0.22s ease;
}

.memory-card__front {
  transform: rotateY(0deg);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: linear-gradient(145deg, rgba(50, 75, 110, 0.35), rgba(12, 18, 35, 0.55));
  color: #d2e8ff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.78rem;
  gap: 0.35rem;
  opacity: 1;
}

.memory-card__back {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, color-mix(in srgb, var(--card-color, #5fd5ff) 35%, #0b1222 65%), rgba(255, 255, 255, 0.1));
  border: 1px solid color-mix(in srgb, var(--card-color, #5fd5ff) 65%, transparent);
  color: #ffffff;
  gap: 0.2rem;
  text-align: center;
  opacity: 0;
}

.memory-card__symbol {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.memory-card__name {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.memory-card__tag {
  margin-top: 0.2rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.8rem;
}

.memory-card__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
}

.memory-card.is-flipped .memory-card__inner {
  transform: rotateY(0deg);
}

.memory-card.is-flipped .memory-card__front {
  opacity: 0;
  transform: rotateY(180deg);
}

.memory-card.is-flipped .memory-card__back {
  opacity: 1;
  transform: rotateY(0deg);
}

.memory-card.is-matched {
  pointer-events: none;
}

.memory-card.is-matched .memory-card__inner {
  transform: rotateY(180deg) !important;
}

.memory-card.is-matched .memory-card__back {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--card-color, #5fd5ff) 60%, transparent),
    0 16px 40px rgba(0, 0, 0, 0.35);
  background: linear-gradient(150deg, color-mix(in srgb, var(--card-color, #5fd5ff) 45%, transparent), rgba(255, 255, 255, 0.08));
}

.memory-card__hint {
  font-size: 0.8rem;
  color: #c2d5ff;
}

.memory-card__face {
  gap: 0.3rem;
}

.memory-status {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.memory-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.35rem);
}

.memory-panel {
  padding: clamp(1rem, 3vw, 1.3rem);
  gap: 1.2rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.memory-side h4 {
  margin: 0;
}

.memory-side ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
  display: grid;
  gap: 0.4rem;
}

.memory-log {
  display: grid;
  gap: 0.5rem;
  max-height: 240px;
  overflow: auto;
  padding-right: 0.2rem;
}

.memory-log__item {
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.memory-log__item:first-child {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.memory-tips {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

[data-memory-root].memory-theme-neon .memory-card__front {
  background: linear-gradient(145deg, rgba(60, 80, 255, 0.12), rgba(0, 0, 0, 0.25));
  color: #9bc9ff;
}

[data-memory-root].memory-theme-neon .memory-board {
  background: radial-gradient(circle at 10% 10%, rgba(79, 223, 255, 0.12), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(255, 95, 138, 0.14), transparent 38%),
    rgba(255, 255, 255, 0.02);
  border-radius: 18px;
}

[data-memory-root].memory-theme-earth .memory-card__front {
  background: linear-gradient(145deg, rgba(95, 168, 112, 0.18), rgba(10, 14, 22, 0.4));
  color: #b6efc8;
}

[data-memory-root].memory-theme-earth .memory-board {
  background: radial-gradient(circle at 20% 15%, rgba(182, 239, 200, 0.14), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(255, 205, 140, 0.16), transparent 38%),
    rgba(255, 255, 255, 0.02);
  border-radius: 18px;
}

[data-memory-root].memory-theme-mono .memory-card__front {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.35));
  color: #d9dde8;
}

[data-memory-root].memory-theme-mono .memory-card__back {
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.12), rgba(10, 10, 10, 0.4));
}

[data-memory-root].memory-theme-mono .memory-board {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.28));
  border-radius: 18px;
}

@media (max-width: 1080px) {
  .memory-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .memory-hero {
    flex-direction: column;
  }

  .memory-board__head {
    flex-direction: column;
  }

  .memory-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
