.memory-game {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card-back: #0f3460;
  --card-border: #d10019;
  --accent: #d10019;
  --text: #eaeaea;
  --text-muted: #8a8aaa;
  --radius: 0;
  --card-w: 110px;
  --card-h: 140px;
  --flip-dur: 400ms;
  --shake-dur: 300ms;
}

/* ── Header ── */
.memory-game header {
  /*
  width: 100%;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  */
  padding: 0 0 15px;
}

.memory-game .stats {
  display: flex;
  gap: 20px;
  justify-content: space-around;
}

.memory-game .stat {
  display: flex;
  /*flex-direction: column;*/
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-weight: 700;
}

.memory-game .stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  /*letter-spacing: 0.08em;*/
  color: var(--text-muted);
}

.memory-game .stat-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* ── Grid ── */
.memory-game main {
  position: relative;
}

/*
.memory-game #grid {
  display: grid;
  grid-template-columns: repeat(4, var(--card-w));
  grid-template-rows: repeat(3, var(--card-h));
  gap: 15px;
}
*/
.memory-game #grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(calc(33.33% - 10px), 1fr));
	grid-gap: 10px;
}

@media(min-width: 768px) {
	.memory-game #grid {
		grid-template-columns: repeat(auto-fit, minmax(calc(33.33% - 15px), 1fr));
		grid-gap: 15px;
	}
}
@media(min-width: 1140px) {
	.memory-game #grid {
		grid-template-columns: repeat(auto-fit, minmax(calc(25% - 30px), 1fr));
		grid-gap: 20px;
	}
}

/* ── Card ── */
.memory-game .card {
/*
  width: var(--card-w);
  height: var(--card-h);
*/
  perspective: 800px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border-radius: 0;
  border: 0;
  border-width: 8px;
  width: 100%;
  aspect-ratio: 1;
}

.memory-game .card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--flip-dur) ease;
  border-radius: var(--radius);
}

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

.memory-game .card.matched .card-inner {
  transform: rotateY(180deg);
  cursor: default;
}

.memory-game .card-back,
.memory-game .card-front {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 2px solid transparent;
}

/* Back face */
.memory-game .card-back {
  background: var(--accent);
  border-color: var(--card-border);
  overflow: hidden;
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: cover;
  background-image: url(https://www.germany.travel/media/redaktion/kampagne/media_folder_wagner_festspiele/memory/memorie_rueckseite_1.jpg);
}

.memory-game .card-back::before {
  content: '';
  position: absolute;
  inset: 0;
  /*
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 8px,
      rgba(255,255,255,0.03) 8px,
      rgba(255,255,255,0.03) 16px
    );*/
}

.memory-game .card-back-icon {
  font-size: 2rem;
  opacity: 0.4;
  position: relative;
  z-index: 1;
}

/* Front face */
.memory-game .card-front {
  /*background: var(--surface);*/
  
  transform: rotateY(180deg);
  /*padding: 10px 8px 6px;*/
}

.memory-game .card-front svg {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}

.memory-game .card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
  object-position: center;
}
.memory-game .card-front img.img-normal {
  border: 6px solid var(--accent);
}
.memory-game .card-front img.img-matched {
    display: block;
    opacity: 0;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.memory-game .card-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: center;
}

/* Matched state */
.memory-game .card.matched .card-front {
  
  background: rgba(30, 50, 35, 0.6);
  border-width: 0;
  border-color: var(--accent);
}

.memory-game .card.matched .card-front svg,
.memory-game .card.matched .card-front img {
  /*filter: saturate(0.25) brightness(1.1);*/
  /*filter: hue-rotate(0deg);*/
  /*filter: brightness(.75);*/
}

.memory-game .card.matched .card-label {
  color: rgba(100, 200, 120, 0.6);
}

.memory-game .card.matched img:not(.img-matched) {
	/*display: none;*/
}
.memory-game .card.matched img.img-matched {
    opacity: 1;
    transition-duration: 1s;
    transition-delay: 1s;
}
@media (min-width: 992px) {
	.memory-game .card-front img.img-normal {
		border-width: 8px;
	}
}

/* ── Animations ── */
@keyframes shake {
  0%   { transform: rotateY(180deg) translateX(0); }
  20%  { transform: rotateY(180deg) translateX(-8px); }
  40%  { transform: rotateY(180deg) translateX(8px); }
  60%  { transform: rotateY(180deg) translateX(-6px); }
  80%  { transform: rotateY(180deg) translateX(6px); }
  100% { transform: rotateY(180deg) translateX(0); }
}

.memory-game .card.shake .card-inner {
  animation: shake var(--shake-dur) ease;
  animation-delay: 500ms;
}

@keyframes match-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(100, 200, 120, 0.6); }
  50%  { box-shadow: 0 0 0 8px rgba(100, 200, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(100, 200, 120, 0); }
}

.card.matched .card-inner {
  animation: match-pulse 500ms ease forwards;
}

/* ── End Screen Overlay ── */
.memory-game #end-screen {
  display: none;
  position: absolute;
  background: white;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 24px;
  text-align: center;
  z-index: 2;
  width: 40%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 65px 10px #00000094;
  
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.5;
}

.memory-game #end-screen.visible {
  display: flex;
  justify-content: flex-start;
}

.memory-game .quotation,
.memory-game .end-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 2.2rem;
}

.memory-game .star {
  opacity: 0.2;
  transition: opacity 0.3s ease;
}

.memory-game .star.lit {
  opacity: 1;
}

.end-score {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.memory-game .end-details {
  display: flex;
  gap: 28px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.memory-game .end-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.memory-game .end-detail-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  /*letter-spacing: 0.08em;*/
}

.memory-game .end-detail-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.memory-game #restart-btn {
/*  margin-top: 8px;
  padding: 12px 32px;
*/
  padding: 0;
  color: var(--accent);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  /*letter-spacing: 0.04em;*/
  transition: background 0.2s, transform 0.1s;
  background: transparent;
}
.memory-game #restart-btn:after {
	content: "\e8da";
}

/*
.memory-game #restart-btn:hover {
  background: #ff6680;
}
*/
.memory-game #restart-btn:active {
  transform: scale(0.97);
}

/* Overlay */
.memory-game .overlay {
  /*position: fixed;*/
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}

/* Grandios label */
.memory-game .grandios-label {
  background: #fff;
  color: var(--accent);
  font-family: 'Open Sans', sans-serif;
  font-weight: 600;
  font-size: clamp(2rem, 8vw, 2.5rem);
  padding: 0.3em 0.8em;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  opacity: 0;
  transform: scale(0.1);
  transition: none;
  pointer-events: none;
}

.memory-game .grandios-label.pop {
  animation: grandiospop 2s cubic-bezier(0.34,1.56,0.64,1) forwards;
  animation-delay: .5s;
}

@keyframes grandiospop {
  0%   { opacity:0; transform: scale(0.1); }
  25%  { opacity:1; transform: scale(1.08); }
  45%  { transform: scale(0.94); }
  60%  { transform: scale(1.03); }
  72%  { transform: scale(1); }
  82%  { opacity:1; transform: scale(1); }
  100% { opacity:0; transform: scale(0.6); }
}

/* Confetti canvas */
.memory-game #confetti-canvas {
  position: absolute;
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99;
}

/* ── Responsive ── */
@media (max-width: 540px) {
	.memory-game #end-screen {
		width: 90%;
		padding: 20px 15px;
		height: 63%;
	}
}


/**-- Slider*/
section#memory-container {
	overflow: hidden;
}
.memory-slider {
	margin-top: 80px;
	padding: 60px 0;
	background: white;
	overflow: hidden;
	display: none;
}
.memory-slider.visible {
	display: block;
}
.memory-slider .container {
	padding: 0;
}

#memory-cards-slider .item {
	display: flex;
	flex-direction: column;
	align-content: center;
	gap: 20px;
}
#memory-cards-slider .item .cards-slider-img {
	display: flex;
	flex-direction: row;
	align-content: center;
	gap: 20px;
}
#memory-cards-slider .item img {
	width: 48%;
	width: calc(50% - 10px);
	border: 2px solid;
	filter: opacity(0.5);
}
#memory-cards-slider .owl-item.center .item img {
	filter: opacity(1);
}
#memory-cards-slider .owl-item:not(.center) .item .cards-slider-text {
	display: none;
}

.memory-slider .module-carousel .carousel-buttons .nav-btn {
	top: 25% !important;
}
@media (max-width: 767px) {
	.module-carousel .carousel-buttons {
		display: none;
	}
	#memory-cards-slider .item .cards-slider-img {
		gap: 10px;
	}
}
@media (min-width: 768px) {
	.memory-slider {
		margin-left: -100%;
		margin-right: -100%;
	}
}
