.ctm-page {
  min-height: 70vh;
  padding: 34px 0 72px;
  background:
    radial-gradient(circle at 12% 8%, rgba(39, 173, 205, 0.13), transparent 28%),
    linear-gradient(180deg, #f6fbfd 0%, #ffffff 100%);
}

.ctm-page__container {
  width: min(1120px, calc(100% - 32px));
  max-width: min(1120px, calc(100% - 32px)) !important;
  padding-right: 0;
  padding-left: 0;
}

.ctm-page__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: #126aa1;
  font-weight: 700;
  text-decoration: none;
}

.ctm-page__back:hover {
  color: #0b4e7c;
}

.ctm-game {
  overflow: hidden;
  border: 1px solid #cde5ee;
  border-radius: 28px;
  background: #eaf7fb;
  box-shadow: 0 22px 56px rgba(24, 83, 112, 0.16);
}

.ctm-game__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  background: linear-gradient(130deg, #167fc1, #12a7b8);
  color: #ffffff;
}

.ctm-game__heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ctm-game__heading-icon {
  display: inline-flex;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  align-items: center;
  justify-content: center;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 24px;
}

.ctm-game__eyebrow,
.ctm-game__title,
.ctm-game__message,
.ctm-game__complete p {
  margin: 0;
}

.ctm-game__eyebrow {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 700;
}

.ctm-game__title {
  color: #ffffff;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.25;
}

.ctm-game__level {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.ctm-game__stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 28px;
  padding: 17px 20px 12px;
  color: #557484;
  font-size: 15px;
}

.ctm-game__stats strong {
  color: #113d55;
  font-weight: 800;
}

.ctm-game__meter {
  height: 8px;
  margin: 0 20px 18px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(79, 119, 138, 0.15);
}

.ctm-game__meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #167fc1, #12a7b8);
  transition: width 240ms ease;
}

.ctm-game__board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0 20px;
}

.ctm-card {
  position: relative;
  min-height: 136px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  perspective: 700px;
}

.ctm-card:focus-visible {
  outline: 4px solid rgba(13, 93, 145, 0.38);
  outline-offset: 3px;
}

.ctm-card__inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 320ms ease;
}

.ctm-card.is-open .ctm-card__inner,
.ctm-card.is-matched .ctm-card__inner {
  transform: rotateY(180deg);
}

.ctm-card__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  padding: 13px;
  border-radius: inherit;
  backface-visibility: hidden;
}

.ctm-card__front {
  background: linear-gradient(145deg, #167fc1, #12a7b8);
  box-shadow: 0 9px 20px rgba(24, 83, 112, 0.18);
  color: #ffffff;
  font-size: 26px;
}

.ctm-card:hover .ctm-card__front {
  background: linear-gradient(145deg, #116fa9, #0f94a3);
}

.ctm-card__back {
  border: 1px solid #cde5ee;
  background: #ffffff;
  box-shadow: 0 9px 20px rgba(24, 83, 112, 0.15);
  color: #12364b;
  text-align: center;
  transform: rotateY(180deg);
}

.ctm-card__art {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 13px;
  background-image: url("/assets/games/computing-matching/concept-illustrations.png");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  filter: drop-shadow(0 4px 5px rgba(18, 54, 75, 0.15));
}

.ctm-card__art--algorithm {
  background-position: 0 0;
}

.ctm-card__art--debug {
  background-position: 50% 0;
}

.ctm-card__art--condition {
  background-position: 100% 0;
}

.ctm-card__art--loop {
  background-position: 0 100%;
}

.ctm-card__art--decomposition {
  background-position: 50% 100%;
}

.ctm-card__art--pattern {
  background-position: 100% 100%;
}

.ctm-card__kind {
  color: #64808f;
  font-size: 12px;
  font-weight: 700;
}

.ctm-card__text {
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 800;
  line-height: 1.35;
}

.ctm-card.is-matched .ctm-card__back {
  border-color: #47ae8f;
  background: #e3f7ef;
  color: #16745d;
}

.ctm-card.is-matched .ctm-card__back::after {
  position: absolute;
  top: 9px;
  right: 10px;
  content: "\f058";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
}

.ctm-game__complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 20px 0;
  padding: 13px 16px;
  border-radius: 16px;
  background: #ddf5eb;
  color: #146a57;
  font-weight: 800;
  text-align: center;
}

.ctm-game__complete[hidden] {
  display: none;
}

.ctm-game__complete i {
  color: #e6a817;
  font-size: 24px;
}

.ctm-game__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 20px 22px;
}

.ctm-game__message {
  color: #557484;
  font-size: 15px;
}

.ctm-game__reset {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid #c7dde6;
  border-radius: 14px;
  background: #ffffff;
  color: #12364b;
  font-weight: 700;
  cursor: pointer;
}

.ctm-game__reset:hover {
  border-color: #82bdd5;
  background: #f4fbfd;
}

@media (max-width: 767.98px) {
  .ctm-page {
    padding: 22px 0 52px;
  }

  .ctm-page__container {
    width: calc(100% - 22px);
    max-width: calc(100% - 22px) !important;
  }

  .ctm-game {
    border-radius: 22px;
  }

  .ctm-game__header {
    align-items: flex-start;
    padding: 18px;
  }

  .ctm-game__heading-icon {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
  }

  .ctm-game__level {
    display: none;
  }

  .ctm-game__stats {
    gap: 8px 18px;
    padding-right: 12px;
    padding-left: 12px;
    font-size: 14px;
  }

  .ctm-game__meter {
    margin-right: 12px;
    margin-left: 12px;
  }

  .ctm-game__board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    padding: 0 12px;
  }

  .ctm-card {
    min-height: 112px;
    border-radius: 15px;
  }

  .ctm-card__face {
    gap: 4px;
    padding: 7px;
  }

  .ctm-card__art {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 10px;
  }

  .ctm-card__kind {
    font-size: 10px;
  }

  .ctm-card__text {
    font-size: clamp(12px, 3.5vw, 15px);
  }

  .ctm-game__complete {
    margin-right: 12px;
    margin-left: 12px;
  }

  .ctm-game__footer {
    align-items: stretch;
    flex-direction: column;
    padding: 17px 12px 19px;
  }

  .ctm-game__reset {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ctm-card__inner,
  .ctm-game__meter-fill {
    transition: none;
  }
}
