/* =========================================================
   games.css — Games zone (hub + 4 games)
   ========================================================= */

/* ---------- Hub ---------- */
.ghub { display: grid; gap: clamp(18px, 3vw, 28px); grid-template-columns: repeat(2, 1fr); }
@media (max-width: 700px) { .ghub { grid-template-columns: 1fr; } }
.gcard { position: relative; display: grid; grid-template-columns: 42% 1fr; align-items: center; gap: 8px; min-height: 230px;
  border: 0; padding: 0; text-align: start; cursor: pointer; color: inherit; border-radius: var(--r-xl); overflow: hidden;
  background: #fff; box-shadow: 0 8px 0 var(--c), var(--shadow-md); transition: transform .3s var(--ease-bounce), box-shadow .3s; }
.gcard:hover { transform: translateY(-6px) rotate(-.6deg); box-shadow: 0 12px 0 var(--c), var(--shadow-lg); }
.gcard:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--c), var(--shadow-sm); }
.gcard__art { align-self: stretch; display: grid; place-items: center; background: linear-gradient(140deg, var(--c), var(--c2)); position: relative; overflow: hidden; }
.gcard__art::after { content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.15); top: -40px; inset-inline-end: -40px; }
.gcard__art .big { font-family: var(--font-ar-head); font-weight: 800; font-size: clamp(3.6rem, 9vw, 5.4rem); color: #fff; line-height: 1; text-shadow: 0 6px 0 rgba(0,0,0,.15); }
.gcard__art img { height: 78%; width: auto; filter: drop-shadow(0 8px 10px rgba(0,0,0,.2)); }
.gcard__art svg { width: 70%; height: auto; }
.gcard__body { padding: 20px 22px 22px; display: grid; gap: 6px; }
.gcard__body h2 { font-size: clamp(1.3rem, 2.6vw, 1.7rem); margin: 0; color: var(--c-d); }
.gcard__body p { margin: 0; color: var(--muted); line-height: 1.6; }
.gcard__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.stars { display: inline-flex; gap: 3px; }
.stars svg { width: 26px; height: 26px; color: #E4DACA; }
.stars svg.on { color: var(--sun); filter: drop-shadow(0 2px 0 var(--sun-600)); }
.gcard .btn { --btn-bg: var(--c-d); --btn-fg: #fff; --btn-edge: rgba(0,0,0,.3); min-height: 50px; }
@media (max-width: 420px) { .gcard { grid-template-columns: 38% 1fr; min-height: 200px; } .gcard__body { padding: 14px; } .gcard__body p { font-size: .92rem; } }

/* ---------- Stage ---------- */
.stage-wrap[hidden], .ghub[hidden], .modes[hidden] { display: none; }
.gbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.gbar h1 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 0; color: var(--c-d); flex: 1; min-width: 160px; }
.modes { display: inline-flex; background: #fff; border-radius: var(--r-pill); padding: 5px; box-shadow: var(--shadow-sm); gap: 4px; }
.modes button { min-height: 48px; padding: 6px 20px; border: 0; border-radius: var(--r-pill); background: transparent; cursor: pointer;
  font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; color: var(--muted); transition: background .2s, color .2s; }
.modes button[aria-pressed="true"] { background: var(--c-d); color: #fff; }
.gboard { position: relative; min-height: min(68vh, 640px); border-radius: var(--r-xl); padding: clamp(16px, 3vw, 32px);
  background: radial-gradient(circle at 50% 0%, #fff 0, var(--c-l) 75%); box-shadow: inset 0 -8px 0 rgba(0,0,0,.04), var(--shadow-md);
  overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.gtop { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.gprog { display: flex; gap: 6px; flex: none; }
.gprog i { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: inset 0 0 0 3px rgba(0,0,0,.06); transition: transform .3s var(--ease-bounce), background .3s; }
.gprog i.ok { background: var(--sun); box-shadow: 0 2px 0 var(--sun-600); }
.gprog i.meh { background: var(--sky); box-shadow: 0 2px 0 var(--sky-600); }
.gprog i.cur { transform: scale(1.35); box-shadow: inset 0 0 0 3px var(--c-d); }
.ghint { text-align: center; font-family: var(--font-head); font-weight: 700; font-size: clamp(1.05rem, 2.4vw, 1.35rem); margin: 0 0 18px; color: var(--navy); }

/* prompt (question) */
.prompt { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 4px auto 22px; flex-wrap: wrap; text-align: center; }
.prompt__text { font-family: var(--font-head); font-weight: 800; font-size: clamp(1.4rem, 4vw, 2.2rem); color: var(--navy); }
.prompt .icon-btn { width: 64px; height: 64px; background: var(--c-d); color: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.25); animation: pulseBtn 2s ease-in-out infinite; }
@keyframes pulseBtn { 50% { transform: scale(1.08); } }
.prompt__guide { height: clamp(70px, 14vw, 110px); width: auto; }

/* choice buttons */
.choices { display: grid; gap: clamp(12px, 2.5vw, 22px); grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); max-width: 760px; margin-inline: auto; }
@media (max-width: 520px) { .choices[data-n="4"] { grid-template-columns: repeat(2, 1fr); } }
.choice { position: relative; aspect-ratio: 1; border: 0; border-radius: 32px; background: #fff; cursor: pointer; color: var(--navy);
  display: grid; place-items: center; padding: 8px; box-shadow: 0 8px 0 rgba(27,42,94,.12), var(--shadow-sm);
  transition: transform .2s var(--ease-bounce), opacity .35s, box-shadow .2s; font-family: var(--font-ar-head); font-weight: 800; }
.choice:hover { transform: translateY(-4px) rotate(-1.5deg); }
.choice:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(27,42,94,.12); }
.choice.right { background: #E9F9DD; box-shadow: 0 8px 0 var(--green-600); animation: yay .6s var(--ease-bounce); }
.choice.wrong { animation: wobble .5s; }
.choice.gone { opacity: .28; pointer-events: none; transform: scale(.9); filter: grayscale(.6); }
@keyframes yay { 40% { transform: scale(1.12) rotate(4deg); } }
@keyframes wobble { 20% { transform: rotate(-8deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(3deg); } }
.choice .letter { font-size: clamp(3.8rem, 13vw, 7rem); line-height: 1; color: var(--col, var(--navy)); }
.choice .num { font-size: clamp(3.4rem, 11vw, 6rem); line-height: 1; color: var(--col, var(--navy)); }
.choice .num small { display: block; font-family: var(--font-en-head); font-size: .32em; color: var(--muted); margin-top: 6px; }
.choice svg.animal { width: 88%; height: auto; }
.choice .lbl { position: absolute; bottom: 8px; inset-inline: 0; text-align: center; font-family: var(--font-head); font-size: clamp(.85rem, 2vw, 1.1rem); color: var(--muted); }

/* reveal card after correct answer */
.reveal-word { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 64px; margin-top: 20px; font-family: var(--font-ar-head); font-weight: 800; font-size: clamp(1.4rem, 4vw, 2rem); color: var(--c-d); }
.reveal-word .emo { font-size: 1.6em; animation: hop .7s var(--ease-out); }
.reveal-word:empty { visibility: hidden; }

/* ---------- Letters: learn grid ---------- */
.lgrid { display: grid; gap: clamp(8px, 1.6vw, 14px); grid-template-columns: repeat(7, 1fr); direction: rtl; }
@media (max-width: 700px) { .lgrid { grid-template-columns: repeat(4, 1fr); } }
.ltile { aspect-ratio: 1; border: 0; border-radius: 22px; background: #fff; cursor: pointer; display: grid; place-items: center; position: relative;
  font-family: var(--font-ar-head); font-weight: 800; font-size: clamp(2rem, 6vw, 3.2rem); color: var(--col); line-height: 1;
  box-shadow: 0 6px 0 rgba(27,42,94,.1), var(--shadow-sm); transition: transform .2s var(--ease-bounce); }
.ltile:hover { transform: translateY(-3px) rotate(-3deg); }
.ltile.talk { animation: yay .6s var(--ease-bounce); background: var(--sun-100); }
.ltile small { position: absolute; bottom: 4px; font-size: .32em; opacity: .9; }
.lpop { position: fixed; z-index: 120; inset: 0; display: grid; place-items: center; pointer-events: none; }
.lpop__card { background: #fff; border-radius: 40px; padding: 26px 40px; text-align: center; box-shadow: var(--shadow-lg); animation: pop .45s var(--ease-bounce); }
.lpop__card .big { font-family: var(--font-ar-head); font-weight: 800; font-size: clamp(5rem, 22vw, 9rem); line-height: 1.1; }
.lpop__card .word { font-family: var(--font-ar-head); font-weight: 800; font-size: clamp(1.5rem, 5vw, 2.2rem); color: var(--navy); }
.lpop__card .emo { font-size: clamp(3rem, 12vw, 4.5rem); }
.lpop__card .en { font-family: var(--font-en-head); color: var(--muted); font-weight: 600; }

/* ---------- Numbers ---------- */
.things { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: clamp(8px, 2vw, 16px);
  max-width: 640px; margin: 0 auto 22px; min-height: clamp(130px, 28vw, 220px); padding: 14px; background: rgba(255,255,255,.65); border-radius: 30px; }
.thing { width: clamp(52px, 13vw, 84px); height: clamp(52px, 13vw, 84px); border: 0; background: none; padding: 0; cursor: pointer; font-size: clamp(2.5rem, 10vw, 4rem); line-height: 1;
  display: grid; place-items: center; position: relative; transition: transform .25s var(--ease-bounce); animation: dropIn .5s var(--ease-bounce) both; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-30px) scale(.4); } }
.thing.counted { transform: scale(1.1); }
.thing.counted::after { content: attr(data-n); position: absolute; top: -6px; inset-inline-end: -6px; min-width: 30px; height: 30px; border-radius: 15px; padding: 0 6px;
  background: var(--orange-600); color: #fff; font-family: var(--font-head); font-size: 1rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 3px 0 #A93D05; }
.bignum { text-align: center; font-family: var(--font-ar-head); font-weight: 800; font-size: clamp(4.5rem, 18vw, 8rem); line-height: 1; color: var(--c-d); min-height: 1.1em; }
.bignum small { display: block; font-family: var(--font-head); font-size: .26em; color: var(--navy); margin-top: 8px; }
.numline { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.numline button { width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer; background: #fff; font-family: var(--font-ar-head); font-weight: 800; font-size: 1.5rem; color: var(--c-d); box-shadow: 0 4px 0 rgba(0,0,0,.1); }
.numline button[aria-pressed="true"] { background: var(--c-d); color: #fff; }

/* ---------- Farm ---------- */
.farm { display: grid; gap: clamp(10px, 2vw, 18px); grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .farm { grid-template-columns: repeat(2, 1fr); } }
.animal-btn { border: 0; cursor: pointer; border-radius: 30px; background: #fff; padding: 10px 10px 14px; display: grid; justify-items: center; gap: 4px;
  box-shadow: 0 7px 0 rgba(27,42,94,.1), var(--shadow-sm); transition: transform .2s var(--ease-bounce); }
.animal-btn:hover { transform: translateY(-4px) rotate(-2deg); }
.animal-btn svg { width: 100%; max-width: 160px; height: auto; }
.animal-btn b { font-family: var(--font-head); font-size: clamp(1.05rem, 2.6vw, 1.35rem); }
.animal-btn.talk svg { animation: hop .7s var(--ease-out); }
.sound-bubble { font-family: var(--font-head); font-weight: 800; color: var(--orange-600); min-height: 1.6em; font-size: 1.05rem; }
.farm-scene { position: relative; }
.farm-scene::before { content: ""; position: absolute; inset: auto -40px -40px; height: 46%; border-radius: 50% 50% 0 0; background: linear-gradient(#A6E07A, #7BC950); z-index: 0; }
.farm-scene > * { position: relative; z-index: 1; }

/* ---------- Memory ---------- */
.levels { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.levels .chip small { font-weight: 700; opacity: .85; }
@media (max-width: 520px) { .levels { gap: 6px; flex-wrap: nowrap; } .levels .chip { padding: 6px 12px; font-size: .95rem; flex-direction: column; gap: 0; line-height: 1.2; } .levels .chip small { font-size: .78rem; } }
.mgrid { display: grid; gap: clamp(8px, 1.8vw, 16px); grid-template-columns: repeat(var(--cols), 1fr); max-width: var(--maxw-grid, 760px); margin-inline: auto; perspective: 1200px; }
.mcard { aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; cursor: pointer; }
.mcard__in { display: block; position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .55s var(--ease-bounce); }
.mcard.open .mcard__in, .mcard.done .mcard__in { transform: rotateY(180deg); }
.mcard__face { position: absolute; inset: 0; border-radius: clamp(14px, 2.5vw, 24px); backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; box-shadow: 0 6px 0 rgba(27,42,94,.15), var(--shadow-sm); }
.mcard__back { background: linear-gradient(140deg, var(--purple-600), var(--sky)); display: grid; place-items: center; }
.mcard__back::before { content: ""; position: absolute; inset: 8%; border: 3px dashed rgba(255,255,255,.45); border-radius: inherit; }
.mcard__back img { width: 62%; height: auto; border-radius: 50%; box-shadow: 0 0 0 5px rgba(255,255,255,.35); }
.mcard__front { transform: rotateY(180deg); background: radial-gradient(circle at 50% 30%, #fff, var(--bg-c)); display: grid; place-items: end center; }
.mcard__front img { position: absolute; inset: 8% 6% 0; width: 88%; height: 92%; object-fit: contain; object-position: bottom; }
.mcard.done .mcard__front { box-shadow: 0 6px 0 var(--green-600), 0 0 0 4px var(--green) inset; }
.mcard.done .mcard__in { animation: matched .6s var(--ease-bounce); }
@keyframes matched { 50% { transform: rotateY(180deg) scale(1.08); } }
.mstats { display: flex; gap: 10px; flex-wrap: wrap; }
.mstat { padding: 6px 16px; border-radius: var(--r-pill); background: #fff; font-family: var(--font-head); font-weight: 800; box-shadow: var(--shadow-sm); }
.mstat b { color: var(--c-d); }

/* ---------- Win screen ---------- */
.win { text-align: center; }
.win__hero { height: 170px; width: auto; margin: -6px auto 4px; animation: hop 1s var(--ease-out) .2s both; }
.win h2 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0; color: var(--orange-600); }
.win__stars { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
.win__stars svg { width: clamp(54px, 14vw, 72px); height: auto; color: #E4DACA; }
.win__stars svg.on { color: var(--sun); filter: drop-shadow(0 4px 0 var(--sun-600)); animation: starIn .6s var(--ease-bounce) both; }
.win__stars svg.on:nth-child(2) { animation-delay: .25s; } .win__stars svg.on:nth-child(3) { animation-delay: .5s; }
@keyframes starIn { from { transform: scale(0) rotate(-120deg); opacity: 0; } }
.win p { font-size: 1.15rem; font-weight: 700; color: var(--muted); }
.win__btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }


/* back arrow points "backwards" in each reading direction */
html[dir="rtl"] #backBtn svg { transform: scaleX(-1); }

@media (max-width: 520px) {
  .gboard { padding: 14px; border-radius: 30px; }
  .choices[data-n="4"] .choice { aspect-ratio: 5 / 4; }
  .gprog i { width: 14px; height: 14px; }
  .prompt { margin-bottom: 14px; }
}
