:root {
  --cream: #fff6e6;
  --sand: #fbe9cf;
  --ink: #3b2a1e;
  --brand: #1b6e7a;
  --accent: #c0581a;
  --good: #3bab6b;
  --noor: #ef7f68;
  --zaid: #2a9db0;
  --reem: #9a7bd6;
  --rafrouf: #4d9fe0;
  --font: "Baloo Bhaijaan 2", "Noto Naskh Arabic", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font-family: var(--font); cursor: pointer; border: 0; color: inherit; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#stickers {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 5px; padding: 6px 8px; border-radius: 999px;
  background: rgba(255, 246, 230, .82); box-shadow: 0 3px 12px rgba(80, 50, 20, .18);
}
.slot {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 19px; background: #efe0c8; filter: grayscale(1); opacity: .45; transition: all .4s;
}
.slot.on { background: #fff; filter: none; opacity: 1; box-shadow: 0 0 0 3px var(--good) inset; }
.slot.next { opacity: .9; filter: grayscale(.2); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.14); } }

.round {
  pointer-events: auto; position: absolute; width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255, 246, 230, .9); font-size: 24px; box-shadow: 0 3px 10px rgba(80, 50, 20, .22);
}
/* under the sticker bar, so the answer cards at the bottom never cover them */
#btn-menu { left: max(12px, env(safe-area-inset-left)); top: calc(max(10px, env(safe-area-inset-top)) + 58px); }
#btn-replay { right: max(12px, env(safe-area-inset-right)); top: calc(max(10px, env(safe-area-inset-top)) + 58px); }

@media (max-width: 480px) {
  .slot { width: 28px; height: 28px; font-size: 15px; }
  #stickers { gap: 3px; padding: 5px 6px; }
}

/* ---------- speech bubbles & emotes ---------- */
#bubbles, #emotes { position: fixed; inset: 0; pointer-events: none; }
.bubble {
  position: absolute; left: 0; top: 0; max-width: min(78vw, 360px); padding: 8px 18px 10px;
  background: #fff; border-radius: 22px; border: 4px solid var(--who, var(--brand));
  box-shadow: 0 6px 18px rgba(60, 40, 20, .2); text-align: center;
  transform: translate(-50%, -100%) scale(.6); opacity: 0; transition: opacity .18s, transform .22s cubic-bezier(.3, 1.6, .5, 1);
}
.bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -14px; margin-left: -10px;
  border: 10px solid transparent; border-top: 12px solid var(--who, var(--brand)); border-bottom: 0;
}
.bubble .ar { font-size: clamp(24px, 6.4vw, 34px); font-weight: 700; line-height: 1.55; color: var(--ink); white-space: nowrap; }
.bubble .en { font-size: 14px; color: #8a7462; line-height: 1.2; margin-top: -2px; }
.no-en .bubble .en, .no-en .choice .en, .no-en .end-row .en { display: none; }

.emote {
  position: absolute; left: 0; top: 0; font-size: 34px; transform: translate(-50%, -50%);
  animation: emote 1.6s ease-out forwards;
}
@keyframes emote {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.4); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  75% { opacity: 1; transform: translate(-50%, -90%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(.9); }
}

#hand {
  position: fixed; left: 0; top: 0; font-size: 46px; pointer-events: none; z-index: 5;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .25)); animation: point 1s ease-in-out infinite;
}
@keyframes point { 0%, 100% { margin-top: 0; } 50% { margin-top: 14px; } }

/* ---------- choices ---------- */
#choices {
  position: fixed; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 14px; padding: 0 14px; flex-wrap: wrap; z-index: 4;
}
.choice {
  min-width: 128px; max-width: 44vw; padding: 10px 14px 12px; border-radius: 26px; background: #fff;
  box-shadow: 0 6px 0 #e4cfae, 0 10px 22px rgba(80, 50, 20, .2); text-align: center;
  animation: popin .35s cubic-bezier(.3, 1.6, .5, 1) both;
}
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 #e4cfae; }
.choice .icon { font-size: 44px; line-height: 1.1; }
.choice img.face { width: 82px; height: 82px; object-fit: contain; display: block; margin: 0 auto -4px; }
.choice .ar { font-size: clamp(24px, 6vw, 32px); font-weight: 800; line-height: 1.5; }
.choice .num { font-size: 52px; font-weight: 800; line-height: 1.05; color: var(--brand); }
.choice .dots { font-size: 14px; letter-spacing: 2px; color: var(--accent); }
.choice .en { font-size: 13px; color: #8a7462; }
.choice.wrong { animation: shake .45s; opacity: .45; }
.choice.right { box-shadow: 0 0 0 5px var(--good), 0 10px 22px rgba(40, 120, 70, .3); transform: scale(1.06); }
@keyframes popin { from { opacity: 0; transform: translateY(30px) scale(.7); } }
@keyframes shake { 20% { transform: translateX(-10px) rotate(-3deg); } 45% { transform: translateX(9px) rotate(3deg); } 70% { transform: translateX(-6px); } }

/* ---------- activities ---------- */
#activity { position: fixed; inset: 0; z-index: 3; }
.scrub {
  position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(88vw, 420px); height: 220px; border-radius: 30px; background: rgba(214, 240, 250, .93);
  box-shadow: 0 8px 24px rgba(30, 90, 120, .25); overflow: hidden; touch-action: none;
}
.scrub .hands { position: absolute; left: 50%; top: 46%; font-size: 92px; transform: translate(-50%, -50%); transition: transform .08s; }
.scrub .tip { position: absolute; left: 0; right: 0; top: 10px; text-align: center; font-size: 30px; }
.scrub .meter { position: absolute; left: 22px; right: 22px; bottom: 16px; height: 16px; border-radius: 9px; background: #fff; }
.scrub .meter div { height: 100%; width: 0; border-radius: 9px; background: linear-gradient(90deg, #7ad0f0, #3bab6b); transition: width .1s; }
.foam { position: absolute; width: 26px; height: 26px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff, rgba(255, 255, 255, .6) 45%, rgba(170, 220, 255, .5));
  border: 1px solid rgba(255, 255, 255, .9); animation: foam 1.1s ease-out forwards; }
@keyframes foam { to { transform: translateY(-50px) scale(1.4); opacity: 0; } }

.patience {
  position: absolute; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--good) calc(var(--p, 0) * 1%), rgba(255, 246, 230, .92) 0);
  box-shadow: 0 8px 24px rgba(80, 50, 20, .2);
}
.patience .face { width: 124px; height: 124px; border-radius: 50%; background: var(--cream); display: grid; place-items: center; font-size: 66px; }
.patience.shh .face { animation: shh .5s; }
@keyframes shh { 40% { transform: scale(1.18); } }

/* ---------- reward fx ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.big-sticker {
  position: absolute; left: 50%; top: 42%; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%;
  display: grid; place-items: center; font-size: 84px; background: #fff;
  box-shadow: 0 0 0 8px var(--good), 0 14px 40px rgba(40, 100, 60, .35);
  transition: transform .8s cubic-bezier(.6, -0.2, .3, 1), opacity .8s;
  animation: stickerin .55s cubic-bezier(.3, 1.7, .5, 1);
}
@keyframes stickerin { from { transform: scale(0) rotate(-40deg); } }
.confetti { position: absolute; width: 12px; height: 16px; border-radius: 3px; top: -20px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- screens ---------- */
#loading, #title, #end, #menu {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; padding: 16px;
}
#loading { background: var(--sand); display: flex; flex-direction: column; align-items: center; justify-content: center; }
#loading .bar { width: min(70vw, 320px); height: 18px; border-radius: 10px; background: #f1d9b5; overflow: hidden; margin-top: 20px; }
#load-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--rafrouf), var(--brand)); transition: width .2s; }

#title { background: linear-gradient(rgba(251, 233, 207, .25), rgba(251, 233, 207, .55)); }
.title-card, .end-card {
  width: min(94vw, 560px); padding: 22px 18px 24px; border-radius: 34px; text-align: center;
  background: rgba(255, 246, 230, .94); box-shadow: 0 16px 50px rgba(80, 50, 20, .25);
}
.logo-ar { font-size: clamp(34px, 9vw, 52px); font-weight: 800; color: var(--brand); line-height: 1.4; }
.logo-en { font-size: 16px; color: var(--accent); font-weight: 700; margin-top: -4px; }
.cast { display: flex; justify-content: center; align-items: flex-end; margin: 10px 0 6px; height: clamp(96px, min(30vh, 26vw), 210px); overflow: hidden; }
.cast img { height: 100%; margin: 0 -14px; animation: bob 2.4s ease-in-out infinite; }
.cast img:nth-child(2) { animation-delay: .3s; } .cast img:nth-child(3) { animation-delay: .6s; }
.cast img.bird { height: 46%; margin-left: -2px; animation-duration: 1.2s; }
@keyframes bob { 50% { transform: translateY(-8px); } }

.big-play {
  display: inline-flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 34px 14px; border-radius: 999px;
  font-size: clamp(28px, 7vw, 38px); font-weight: 800; color: #fff; background: var(--good);
  box-shadow: 0 7px 0 #2b8352, 0 12px 26px rgba(40, 120, 70, .35); animation: breathe 1.8s ease-in-out infinite;
}
.big-play:active { transform: translateY(5px); box-shadow: 0 2px 0 #2b8352; }
.pill {
  display: block; margin: 12px auto 0; padding: 8px 20px; border-radius: 999px; font-size: 18px; font-weight: 700;
  background: #f1dfc2; color: var(--ink);
}
.pill.primary { background: var(--good); color: #fff; }

#menu { background: rgba(60, 40, 20, .35); }
#menu .card { width: min(90vw, 360px); padding: 18px; border-radius: 26px; background: var(--cream); text-align: center; }
#menu .pill { width: 100%; }
.parents { font-size: 14px; color: #7d6754; margin: 16px 0 0; line-height: 1.4; }

#end { background: rgba(251, 233, 207, .45); }
.praise { font-size: clamp(48px, 13vw, 72px); font-weight: 800; color: var(--good); line-height: 1.3; }
.end-sub { font-size: 16px; font-weight: 700; color: var(--accent); margin-top: -6px; }
#end-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 14px 0 4px; text-align: start; max-height: 46vh; overflow: auto; }
.end-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 14px; background: #fff; }
.end-row .ico { font-size: 24px; }
.end-row .ar { font-size: 18px; font-weight: 700; line-height: 1.5; }
.end-row .en { font-size: 12px; color: #8a7462; line-height: 1.15; }
@media (max-width: 420px) { #end-list { grid-template-columns: 1fr; } }
