/* ===============================
   BAS
=============================== */

body {
  margin: 0;
  font-family: "Mitr", sans-serif;
  background: #91acc4;
  color: #2c3e50;
}

/* ===============================
   LAYOUT
=============================== */

.minnas-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;

  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  box-sizing: border-box;
}

.game-area {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  width: 100%; /* 🔥 viktigt */
}
.menu-button {
  margin-top: 40px;
  padding: 10px 20px;

  font-family: "Mitr", sans-serif;
  font-size: 1rem;

  background: rgb(63, 145, 148, 0.6);
  /* border: 1px solid rgba(0, 0, 0, 0.2); */
  /* color: #0c3a55; */
  transition: 0.2s;
  border: none;
  border-radius: 1vmin;
  padding: 1vmin 2vmin;

  cursor: pointer;
  transition: all 0.3s ease;
}

.menu-button:hover {
  background: rgb(208, 115, 27);
}
/* ===============================
   OVERLAY IMAGE
=============================== */

.overlay-image {
  margin-top: 20px;
  max-width: 300px;
  width: 100%;
  height: auto;
  opacity: 0.9;

  animation: float 6s ease-in-out infinite;
  transition:
    transform 0.6s ease,
    opacity 0.6s ease;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* ===============================
   INFO
=============================== */

.game-info-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

.game-info {
  font-size: 1.4rem;
  color: #c65e21;
}

/* ===============================
   SPELPLAN
=============================== */

.game-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;

  width: 100%;
  padding: 10px;

  flex: 1;
  min-width: 0;
}

/* ===============================
   MATCHED
=============================== */
.matched-container {
  flex: 0 1 clamp(80px, 12vw, 140px);

  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
  gap: 6px;

  overflow: visible;
  max-height: none;
}

.matched-card {
  width: 100%;
  aspect-ratio: 1 / 1;

  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #545050;

  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.matched-card img {
  width: 95%;
  height: 95%;
  object-fit: cover;
}

/* ===============================
   KORT
=============================== */
.card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  perspective: 800px;

  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;

  transition: opacity 0.4s ease;
}

.card:active {
  opacity: 0.9;
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;

  display: flex;
  justify-content: center;
  align-items: center;

  backface-visibility: hidden;
  overflow: hidden;

  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #727171;

  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);

  transition:
    transform 0.7s ease,
    box-shadow 0.3s ease;
}

/* ljusriktning */
.card-face::after {
  content: "";
  position: absolute;
  inset: 0;

  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.05) 40%,
    rgba(0, 0, 0, 0.03) 100%
  );

  pointer-events: none;
  opacity: 0.5;
}

.card-front {
  transform: rotateY(180deg);
}

.card.visible .card-front {
  transform: rotateY(0);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.card.visible .card-back {
  transform: rotateY(-180deg);
}

.card-back {
  border: 2px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* bilder */
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===============================
   OVERLAY
=============================== */

.overlay-text {
  position: fixed;
  inset: 0;

  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;

  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);

  font-size: 1.6rem;
  color: #0c3a55;
  text-align: center;
  padding: 20px;

  z-index: 100;
}

.overlay-text.visible {
  display: flex;
  animation: fadeIn 0.8s ease forwards;
}

.overlay-text-small {
  font-size: 1rem;
  margin-top: 10px;
  opacity: 0.7;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
/* ===============================
   RESPONSIVE
=============================== */

/* iPad → vänster kolumn */
@media (max-width: 1024px) and (min-width: 700px) {
  .game-area {
    flex-direction: row;
  }

  .matched-container {
    order: -1;
  }
}

/* mobil */
@media (max-width: 500px) {
  .game-container {
    grid-template-columns: repeat(3, 1fr);
  }
  .game-area {
    flex-direction: column;
    align-items: center;
  }

  .matched-container {
    width: 100%;
    flex: none;

    display: grid;
    grid-template-columns: repeat(auto-fit, 60px);
    justify-content: center;
    gap: 6px;
  }

  .matched-card {
    width: 60px;
    height: 60px;
  }
  .overlay-image {
    max-width: 140px;
  }
}

/* ===================================Buttonback===================================*/
button.buttonBack {
  position: relative;
  width: fit-content;
  cursor: pointer;
  padding: 3px 12px 3px 12px;
  background-color: rgb(86, 165, 164);
  background: linear-gradient(to bottom, #2e6b7f, #cbeefa);
  margin-left: 1%;
  margin-bottom: 3%;
  bottom: 35px;
  border-radius: 25px;
  border: 2px 4px 2px 2px solid rgb(69, 83, 97);
  border-left: solid rgba(249, 200, 191, 0.4);
  opacity: 0.9;
  color: #1f3847;
  font-size: clamp(14px, 2vw, 18px);
  font-family: var(--body-font);
  font-weight: 400;
  box-shadow: 5px 4px 8px rgba(0, 0, 0, 0.4);
  z-index: 1000 !important;
  transition:
    background-color 0.2s ease-in-out,
    box-shadow 0.2s ease-in-out,
    border 0.2s ease-in-out;
}

.buttonBack:active {
  background-color: rgba(255, 40, 3, 1);
  border: solid 1px #1f3847;
  background: linear-gradient(to bottom, #690202, #fc5252);
  box-shadow: none;
  transform: translateY(2px);
}

.buttonBack:active::before {
  content: "";
  position: absolute;
  height: 7px;
  width: 15px;
  height: 2px;
  margin-top: 0;
  margin-left: 10%;
  margin-right: 10%;
  border-radius: 30px;
  background-color: rgba(249, 200, 191, 0.4);
  transform-origin: 0 0;
  animation: scaleLine 0.3s forwards;
}

@keyframes scaleLine {
  0% {
    transform: scaleX(0);
  }
  100% {
    transform: scaleX(3);
  }
}

.minnas .back {
  position: fixed; /* viktig! */
  bottom: 35px;
  left: 20px;
  z-index: 9999 !important;
}
@media (max-width: 600px) {
  .buttonBack {
    font-size: 14px;
    padding: 3px 8px;
  }

  .minnas .back {
    bottom: 20px;
    left: 10px;
  }
}
