@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

:root{
  --bg-1:#fff8fc;
  --bg-2:#f6f4ff;
  --card-bg:rgba(255,255,255,.92);
  --text:#2f2440;
  --muted:#786d8a;
  --pink:#ff78b2;
  --pink-dark:#e05597;
  --purple:#9f7dff;
  --blue:#79d0ff;
  --shadow:0 18px 46px rgba(86,53,116,.14);
  --shadow-soft:0 10px 24px rgba(86,53,116,.10);
}

*{
  margin:0;
  padding:0;
  box-sizing:border-box;
  font-family:"Poppins", sans-serif;
}

html{
  direction:rtl;
}

body{
  min-height:100vh;
  background:
    radial-gradient(circle at top right, rgba(255,203,227,.55), transparent 28%),
    radial-gradient(circle at bottom left, rgba(215,223,255,.72), transparent 34%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color:var(--text);
}

a{
  color:inherit;
  text-decoration:none;
}

button{
  font-family:inherit;
}

.game-page{
  min-height:100vh;
  padding:20px 14px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.game-shell{
  width:min(100%, 920px);
}

.game-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:14px;
}

.back-link,
.brand-badge{
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 16px;
  border-radius:999px;
  background:rgba(255,255,255,.85);
  box-shadow:var(--shadow-soft);
  font-weight:700;
}

.back-link{
  color:var(--muted);
}

.brand-badge{
  background:linear-gradient(135deg,var(--pink),var(--purple));
  color:#fff;
}

.game-card{
  background:var(--card-bg);
  box-shadow:var(--shadow);
  border-radius:32px;
  padding:24px;
}

.game-header{
  display:grid;
  grid-template-columns:minmax(0,1fr) 220px;
  gap:18px;
  align-items:start;
  margin-bottom:18px;
}

.game-kicker{
  margin:0 0 8px;
  color:var(--pink-dark);
  font-size:14px;
  font-weight:800;
}

h1{
  margin:0 0 10px;
  font-size:clamp(30px, 5vw, 52px);
  line-height:1.1;
}

.game-desc{
  margin:0;
  color:var(--muted);
  line-height:1.9;
  font-size:15px;
  max-width:640px;
}

.status-panel{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.status-box{
  background:linear-gradient(180deg,#eef3ff,#dde7ff);
  padding:16px;
  border-radius:20px;
  box-shadow:var(--shadow-soft);
  text-align:center;
}

.status-label{
  display:block;
  color:var(--muted);
  font-size:13px;
  margin-bottom:6px;
}

.status-box strong{
  font-size:24px;
  color:var(--text);
}

.restart-btn{
  border:0;
  min-height:46px;
  border-radius:16px;
  background:linear-gradient(135deg,var(--pink),var(--purple));
  color:#fff;
  font-size:15px;
  font-weight:700;
  cursor:pointer;
  box-shadow:var(--shadow-soft);
}

.wrapper{
  padding:20px;
  border-radius:24px;
  background:#f8f8f8;
  box-shadow:var(--shadow-soft);
  width:fit-content;
  margin-inline:auto;
}

.cards, .card, .view{
  display:flex;
  align-items:center;
  justify-content:center;
}

.cards{
  height:400px;
  width:400px;
  flex-wrap:wrap;
  justify-content:space-between;
}

.cards .card{
  cursor:pointer;
  list-style:none;
  user-select:none;
  position:relative;
  perspective:1000px;
  transform-style:preserve-3d;
  height:calc(100% / 4 - 10px);
  width:calc(100% / 4 - 10px);
}

.card.shake{
  animation:shake 0.35s ease-in-out;
}

@keyframes shake{
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-13px)}
  40%{transform:translateX(13px)}
  60%{transform:translateX(-8px)}
  80%{transform:translateX(8px)}
}

.card .view{
  width:100%;
  height:100%;
  position:absolute;
  border-radius:16px;
  background:#fff;
  pointer-events:none;
  backface-visibility:hidden;
  box-shadow:0 3px 10px rgba(0,0,0,0.08);
  transition:transform 0.25s linear;
}

.card .front-view img{
  width:22px;
}

.card .back-view img{
  max-width:48px;
}

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

.card.flip .back-view{
  transform:rotateY(0);
}

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

@media screen and (max-width: 820px){
  .game-header{
    grid-template-columns:1fr;
  }

  .status-panel{
    width:100%;
  }
}

@media screen and (max-width: 700px){
  .cards{
    height:350px;
    width:350px;
  }

  .card .front-view img{
    width:18px;
  }

  .card .back-view img{
    max-width:40px;
  }
}

@media screen and (max-width: 530px){
  .game-page{
    padding:14px 10px;
    align-items:flex-start;
  }

  .game-card{
    padding:16px;
    border-radius:24px;
  }

  .wrapper{
    padding:12px;
    border-radius:18px;
  }

  .cards{
    height:300px;
    width:300px;
  }

  .card .front-view img{
    width:15px;
  }

  .card .back-view img{
    max-width:35px;
  }

  .game-desc{
    font-size:14px;
  }
}