/* ==========================================================
   Игровая зона: карточки игр, полноэкранный режим, память
   ========================================================== */

.games-hero {
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  background:
    radial-gradient(110% 100% at 100% 0%, rgba(255, 196, 107, 0.45), rgba(255, 196, 107, 0) 55%),
    linear-gradient(135deg, #0a4453, #0f7a8f 60%, #17a2b8);
  box-shadow: 0 16px 38px rgba(8, 62, 74, 0.24);
  position: relative;
  overflow: hidden;
}

.games-hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -70px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 20px solid rgba(255, 255, 255, 0.1);
}

.games-hero__top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.games-hero__ic {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
  flex: 0 0 46px;
}

.games-hero__ic svg {
  width: 24px;
  height: 24px;
}

.games-hero h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.games-hero p {
  margin: 3px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
}

.games-hero__stats {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

.games-hero__stat {
  flex: 1;
  padding: 10px 12px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.games-hero__stat b {
  display: block;
  font-size: 19px;
  font-weight: 800;
  color: #ffe1b5;
}

.games-hero__stat span {
  display: block;
  margin-top: 1px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
}

.game-card {
  position: relative;
  min-height: 154px;
  border-radius: 22px;
  padding: 17px;
  color: #fff;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: left;
  width: 100%;
  border: 0;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(4, 27, 34, 0.88) 0%, rgba(4, 27, 34, 0.5) 55%, rgba(4, 27, 34, 0.18) 100%);
}

.game-card > * {
  position: relative;
  z-index: 1;
}

.game-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: auto;
}

.game-card__ic {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.game-card__ic svg {
  width: 21px;
  height: 21px;
}

.game-card__title {
  margin: 10px 0 2px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.game-card__short {
  margin: 0;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.8);
  max-width: 30ch;
}

.game-card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.game-card__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
}

.game-card__meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.14);
}

.game-card__meta svg {
  width: 12px;
  height: 12px;
}

.game-card__play {
  height: 36px;
  padding: 0 14px;
  border-radius: 11px;
  background: #fff;
  color: #0a4453;
  font-weight: 800;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.game-card__play svg {
  width: 14px;
  height: 14px;
}

.game-card__done {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(46, 158, 107, 0.9);
  font-size: 10px;
  font-weight: 800;
  color: #fff;
}

.game-card__done svg {
  width: 12px;
  height: 12px;
}

.games-note {
  display: flex;
  gap: 9px;
  margin-top: 16px;
  padding: 11px 12px;
  border-radius: 14px;
  background: #fff8ec;
  border: 1px solid rgba(232, 163, 61, 0.22);
  font-size: 11.5px;
  color: #7c5a20;
  line-height: 1.45;
}

.games-note svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--gold);
  margin-top: 1px;
}

/* ---------- Полноэкранная игра ---------- */
.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: #041a21;
  color: #fff;
  overflow: hidden;
  animation: gameIn 0.25s ease both;
}

@keyframes gameIn {
  from { opacity: 0; transform: scale(1.02); }
  to { opacity: 1; transform: none; }
}

.game-stage {
  position: absolute;
  inset: 0;
}

.game-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.game-overlay.is-memory .game-stage {
  display: none;
}

.game-top {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background: linear-gradient(180deg, rgba(3, 20, 26, 0.72), rgba(3, 20, 26, 0));
  pointer-events: none;
}

.game-top > * {
  pointer-events: auto;
}

.game-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  backdrop-filter: blur(6px);
}

.game-close svg {
  width: 18px;
  height: 18px;
}

.game-hud {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.game-hud__item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 11px;
  background: rgba(5, 35, 43, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  font-weight: 800;
  font-size: 14px;
  color: #fff;
}

.game-hud__item span {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.66);
}

.game-hud__item--lives {
  color: #ffb3a0;
}

.game-screen {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px;
  background: rgba(3, 20, 26, 0.82);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.game-screen__tag {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(255, 196, 107, 0.18);
  border: 1px solid rgba(255, 196, 107, 0.3);
  color: #ffd08a;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-screen h2 {
  margin: 12px 0 6px;
  font-size: 27px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: 16ch;
}

.game-screen p {
  margin: 0;
  max-width: 32ch;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
}

.game-rules {
  display: flex;
  gap: 18px;
  margin: 18px 0 4px;
}

.game-rules div {
  text-align: center;
}

.game-rules b {
  display: block;
  font-size: 21px;
  font-weight: 800;
  color: #ffe1b5;
}

.game-rules span {
  display: block;
  margin-top: 2px;
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
}

.game-controls {
  margin-top: 14px !important;
  font-size: 11px !important;
  color: rgba(255, 255, 255, 0.62) !important;
  max-width: 30ch;
}

.game-start-btn {
  width: 100%;
  max-width: 300px;
  height: 54px;
  margin-top: 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f0782a, #ffa450);
  color: #2b1608;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 12px 28px rgba(240, 120, 42, 0.32);
}

.game-ghost-btn {
  margin-top: 10px;
  padding: 10px 16px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
}

.game-result-icon {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 32% 26%, #ffe3a8, #f0a23c);
  color: #4a2b08;
  box-shadow: 0 16px 34px rgba(240, 162, 60, 0.28);
  animation: pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.game-result-icon svg {
  width: 34px;
  height: 34px;
}

.game-result-score {
  margin: 16px 0 2px;
  font-size: 54px;
  font-weight: 800;
  line-height: 1;
  color: #ffd08a;
  letter-spacing: -0.03em;
}

.game-result-lead {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
}

.game-result-points {
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: 13px;
  background: rgba(46, 158, 107, 0.18);
  border: 1px solid rgba(127, 224, 195, 0.3);
  color: #9ff0cf;
  font-weight: 800;
  font-size: 15px;
}

.game-result-points.is-muted {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

/* ---------- Memory ---------- */
.game-overlay.is-memory {
  background:
    radial-gradient(120% 90% at 80% 0%, rgba(255, 196, 107, 0.18), transparent 55%),
    linear-gradient(160deg, #0a4453, #083e4a 60%, #061f26);
}

.memory-wrap {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 74px) 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
}

.memory-head {
  text-align: center;
  color: #fff;
}

.memory-head b {
  display: block;
  font-size: 17px;
  font-weight: 800;
}

.memory-head span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
}

.game-overlay.is-memory .memory-wrap {
  display: grid;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 410px;
}

.memory-card {
  aspect-ratio: 1;
  perspective: 600px;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 14px;
  cursor: pointer;
}

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

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

.memory-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.memory-front {
  background: linear-gradient(140deg, #0e6e82, #19a7be);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 14px rgba(3, 20, 26, 0.25);
}

.memory-front::after {
  content: "?";
  font-size: 24px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.55);
}

.memory-back {
  background: #fff;
  color: var(--sea);
  transform: rotateY(180deg);
  border: 1px solid rgba(8, 62, 74, 0.12);
}

.memory-back svg {
  width: 30px;
  height: 30px;
}

.memory-card.is-matched .memory-back {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: rgba(46, 158, 107, 0.3);
}

@media (max-width: 360px) {
  .quick {
    font-size: 9.5px;
  }
  .quick__ic {
    width: 32px;
    height: 32px;
  }
  .memory-grid {
    gap: 6px;
  }
}
