/* Yalla Speak games: shared design system.
   The palette comes from the Yallacademy logo: magenta "y", yellow "a", blue "ll", deep navy "academy".
   body.adult = calm, confident language-app look. body.kid = bright, chunky, playful. */
:root {
  --mag: #E6005C; --mag-d: #B3004A; --mag-tint: #FFE4EE;
  --sun: #F5B800; --sun-d: #C89400; --sun-tint: #FFF4CF;
  --blue: #14408C; --blue-d: #0D2F6B; --blue-tint: #E4ECFB; --sky: #3D7DF2;
  --navy: #1C0C45; --navy-2: #2C1869; --navy-3: #3D2590;
  --ink: #1C0C45; --muted: #6B6688; --line: #E7E3F1; --bg: #F5F4FB; --card: #ffffff; --soft: #F3F1FA;
  --good: #0E9F64; --good-d: #0B7D4E; --good-bg: #DFF6EC;
  --bad: #E5484D; --bad-d: #B4282D; --bad-bg: #FDE7E8;
  --ok: #A86F00; --ok-bg: #FFF2CC;
  --shadow-0: 0 1px 2px rgba(28, 12, 69, .06);
  --shadow-1: 0 1px 2px rgba(28, 12, 69, .05), 0 10px 28px -6px rgba(28, 12, 69, .10);
  --shadow-2: 0 2px 6px rgba(28, 12, 69, .06), 0 24px 48px -12px rgba(28, 12, 69, .22);
  --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; color: var(--ink); background: var(--bg); overflow-x: hidden; overscroll-behavior: none;
  font-family: "Fredoka", "Cairo", system-ui, sans-serif; font-size: 18px; -webkit-font-smoothing: antialiased; }
body.adult { font-family: "Plus Jakarta Sans", "Cairo", system-ui, sans-serif; font-size: 16px; }
/* soft brand glow behind the page, most visible on a laptop */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(620px 420px at 100% 0%, rgba(230, 0, 92, .08), transparent 62%),
    radial-gradient(560px 460px at 0% 100%, rgba(20, 64, 140, .10), transparent 62%),
    radial-gradient(420px 320px at 4% 6%, rgba(245, 184, 0, .13), transparent 62%); }
.ar { font-family: "Cairo", system-ui, sans-serif; direction: rtl; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

.app { max-width: 560px; margin: 0 auto; padding: 14px 16px 44px; padding-bottom: max(44px, env(safe-area-inset-bottom)); }
body.wide .app { max-width: 1000px; }

/* icons (inline SVG from common.js) */
svg.i { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.24em; }
svg.i.fill { fill: currentColor; stroke: none; }

/* brand */
.logo { display: block; height: 28px; aspect-ratio: 4.3 / 1; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.logo-chip { display: inline-flex; background: #fff; border-radius: 99px; padding: 5px 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.logo-chip .logo { height: 22px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.topbar .back, .icon-btn { width: 44px; height: 44px; flex: none; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: grid; place-items: center; cursor: pointer; text-decoration: none; box-shadow: var(--shadow-0); font-size: 17px; transition: transform .15s var(--ease), background .2s, color .2s, border-color .2s; }
.topbar .back:active, .icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.topbar .title { flex: 1; min-width: 0; font-weight: 800; font-size: 17px; line-height: 1.15; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title small { display: block; font-weight: 700; font-size: 10.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 0 12px; height: 36px; font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow-0); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip svg.i { color: var(--sun); }
.chip.bump { animation: bump .45s var(--spring); }
@keyframes bump { 40% { transform: scale(1.22); } }

/* progress */
.progress { display: flex; align-items: center; gap: 10px; margin: 0 2px 16px; }
.steps { flex: 1; display: flex; gap: 5px; }
.steps span { flex: 1; height: 6px; border-radius: 99px; background: var(--line); transition: background .4s; }
.steps span.done { background: var(--blue); }
.steps span.now { background: var(--mag); }
.progress .count { font-size: 12px; font-weight: 800; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
body[data-phase="start"] .progress, body[data-phase="start"] .topbar .chip { display: none; }
.kid .steps span { height: 10px; }
.kid .steps span.done { background: var(--sun); }
.kid .progress .count { font-size: 14px; font-weight: 600; }

/* screens slide in softly each time a step changes */
#screen > * { animation: rise .5s var(--ease) both; }
#screen > *:nth-child(2) { animation-delay: .07s; }
#screen > *:nth-child(3) { animation-delay: .14s; }
#screen > *:nth-child(4) { animation-delay: .21s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes popin { from { opacity: 0; transform: scale(.6); } }
@keyframes floaty { 50% { transform: translateY(-8px); } }

/* cards and type */
.card { background: var(--card); border-radius: 22px; padding: 20px; box-shadow: var(--shadow-1); border: 1px solid rgba(28, 12, 69, .05); margin-bottom: 14px; }
.kid .card { border-radius: 28px; border: 0; box-shadow: 0 6px 0 rgba(28, 12, 69, .08), 0 18px 34px -14px rgba(28, 12, 69, .25); }
h1 { font-size: 27px; line-height: 1.15; margin: 6px 0 10px; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 21px; line-height: 1.2; margin: 4px 0 10px; letter-spacing: -.015em; font-weight: 800; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 800; }
.kid h1 { font-size: 32px; font-weight: 700; letter-spacing: 0; } .kid h2, .kid h3 { font-weight: 600; letter-spacing: 0; }
p { line-height: 1.55; margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.kicker { color: var(--mag); font-weight: 800; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 99px; background: var(--soft); color: #4A4470; }
.tag svg.i { width: 14px; height: 14px; }

/* buttons */
.btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border: 0; border-radius: 14px; font-weight: 700; font-size: 16px;
  cursor: pointer; padding: 10px 18px; background: var(--soft); color: var(--ink); text-decoration: none; text-align: center; line-height: 1.2;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, filter .2s, border-color .2s; }
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn.primary { background: var(--mag); color: #fff; box-shadow: 0 8px 18px -6px rgba(230, 0, 92, .55); }
.btn.navy { background: var(--navy); color: #fff; box-shadow: 0 8px 18px -8px rgba(28, 12, 69, .6); }
.btn.blue { background: var(--blue); color: #fff; box-shadow: 0 8px 18px -8px rgba(20, 64, 140, .6); }
.btn.sun { background: var(--sun); color: var(--navy); box-shadow: 0 8px 18px -8px rgba(245, 184, 0, .7); }
.btn.green { background: var(--good); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.big { min-height: 58px; font-size: 17px; }
.btn[disabled] { opacity: .45; pointer-events: none; box-shadow: none; }
.btn.rec { background: var(--bad); color: #fff; box-shadow: 0 0 0 0 rgba(229, 72, 77, .5); animation: recpulse 1.2s infinite; opacity: 1; }
@keyframes recpulse { 70% { box-shadow: 0 0 0 14px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
.kid .btn { min-height: 60px; border-radius: 20px; font-size: 20px; font-weight: 600; }
.kid .btn.primary { box-shadow: 0 6px 0 var(--mag-d); }
.kid .btn.primary:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--mag-d); }
.kid .btn.ghost { background: #fff; border: 2px solid var(--line); }
.kid .row .btn:not(.big) { font-size: 17px; padding: 8px 10px; white-space: nowrap; gap: 6px; }
.kid .row .btn:not(.big) svg.i { width: 18px; height: 18px; }
.kid .btn.big { min-height: 68px; font-size: 24px; animation: nudge 2.4s 1s var(--ease) infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: scale(1); } 78% { transform: scale(1.04) rotate(-1deg); } 86% { transform: scale(1.04) rotate(1deg); } }

/* notes and typed (test mode) input */
.note { display: block; border-radius: 14px; padding: 12px 14px; font-size: 15px; line-height: 1.5; margin-top: 12px; background: var(--ok-bg); color: #5A4200; animation: rise .35s var(--ease) both; }
.note.good { background: var(--good-bg); color: #0A5B3A; } .note.bad { background: var(--bad-bg); color: #8A1F23; }
.typed { display: none; gap: 8px; margin-top: 10px; } .typed.show { display: flex; }
.typed input { flex: 1; min-width: 0; min-height: 48px; border-radius: 14px; border: 1.5px solid var(--line); padding: 0 14px; background: #fff; font-size: 16px; transition: border-color .2s, box-shadow .2s; }
.typed input:focus { outline: 0; border-color: var(--sky); box-shadow: 0 0 0 4px rgba(61, 125, 242, .18); }
.typed .btn { flex: 0 0 auto; min-height: 48px; font-size: 15px; }
.kid .typed .btn { min-height: 48px; font-size: 16px; border-radius: 14px; }
.wd { display: inline-block; padding: 2px 8px; border-radius: 8px; margin: 3px 1px 0; font-weight: 700; }
.wd.good { background: var(--good-bg); color: var(--good-d); } .wd.ok { background: var(--ok-bg); color: var(--ok); } .wd.bad { background: var(--bad-bg); color: var(--bad-d); }
.note .wd.good { background: rgba(255, 255, 255, .7); }

/* drag and drop */
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; margin: 0 !important; animation: none !important; transform: translate(-50%, -50%) scale(1.08) rotate(-3deg); opacity: 1 !important;
  filter: drop-shadow(0 16px 18px rgba(28, 12, 69, .28)); }
.drop-hot { outline: 3px dashed var(--mag) !important; outline-offset: 3px; }
[data-drag] { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }

/* start screen */
.start { padding: 0; overflow: hidden; }
.hero { position: relative; height: 172px; display: grid; place-items: center; overflow: hidden; color: #fff; isolation: isolate;
  background: radial-gradient(120% 90% at 80% 0%, var(--navy-3), transparent 60%), linear-gradient(140deg, var(--navy), var(--navy-2)); }
.hero .logo-chip { position: absolute; top: 14px; left: 14px; z-index: 2; }
.hero .art { font-size: 88px; line-height: 1; filter: drop-shadow(0 14px 16px rgba(0, 0, 0, .35)); animation: floaty 4.5s ease-in-out infinite; }
.hero .smile { position: absolute; bottom: 20px; left: 50%; width: 132px; margin-left: -66px; }
.hero .orb { position: absolute; border-radius: 50%; z-index: -1; }
.hero .orb.a { width: 150px; height: 150px; right: -40px; bottom: -60px; background: var(--mag); opacity: .9; }
.hero .orb.b { width: 64px; height: 64px; left: 26px; bottom: 26px; background: var(--sun); }
.hero .orb.c { width: 14px; height: 70px; right: 46px; top: 26px; background: var(--sky); border-radius: 4px; box-shadow: 22px 0 0 var(--sky); opacity: .9; }
.hero .float { position: absolute; font-size: 34px; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .3)); animation: floaty 5s ease-in-out infinite; }
.start-body { padding: 20px 20px 22px; }
.how { list-style: none; padding: 0; margin: 12px 0 6px; display: grid; gap: 9px; counter-reset: how; }
.how li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; }
.how li::before { counter-increment: how; content: counter(how); width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--blue-tint); color: var(--blue); font-weight: 800; font-size: 13px; display: grid; place-items: center; margin-top: -2px; }
.start-body .ar { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--soft); font-size: 14.5px; line-height: 1.8; color: #4A4470; }

/* result screen */
.result-top { text-align: center; padding: 22px 20px 24px; position: relative; overflow: hidden; }
.result-top .logo { margin: 0 auto 12px; height: 26px; }
.result-top h1 { margin: 10px 0 0; }
.ring { position: relative; width: 148px; height: 148px; margin: 4px auto 8px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--soft); }
.ring .bar { stroke: var(--mag); stroke-linecap: round; stroke-dasharray: 100; animation: ringfill 1.3s .25s var(--ease) both; }
.ring.high .bar { stroke: var(--good); } .ring.mid .bar { stroke: var(--sun); }
@keyframes ringfill { from { stroke-dashoffset: 100; } }
.ring .num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1; }
.ring .num b { font-size: 40px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring .num b small { font-size: 18px; font-weight: 700; margin-left: 1px; }
.ring .num span { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-top: 6px; }
.stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 6px 0; }
.stars svg.i { width: 44px; height: 44px; fill: var(--line); stroke: none; }
.stars svg.i:nth-child(2) { width: 56px; height: 56px; margin-bottom: 6px; }
.stars svg.i.on { fill: var(--sun); filter: drop-shadow(0 4px 0 var(--sun-d)); animation: starpop .6s var(--spring) both; }
.stars svg.on:nth-child(1) { animation-delay: .5s; } .stars svg.on:nth-child(2) { animation-delay: .75s; } .stars svg.on:nth-child(3) { animation-delay: 1s; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.kid .stars svg.i { width: 58px; height: 58px; } .kid .stars svg.i:nth-child(2) { width: 74px; height: 74px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--soft); border-radius: 16px; padding: 14px; min-width: 0; }
.tiles .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.tile .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: #fff; color: var(--blue); margin-bottom: 10px; box-shadow: var(--shadow-0); }
.tile b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 3px; line-height: 1.3; }
.stat { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.stat:last-of-type { border-bottom: 0; }
.stat b { font-variant-numeric: tabular-nums; }
.review { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 14.5px; }
.review li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--bad-bg); color: #6E1A1E; line-height: 1.45; }
.review li.ok { background: var(--good-bg); color: #0A5B3A; }
.review li svg.i { margin-top: 1px; }
.teacher { display: flex; gap: 12px; align-items: flex-start; background: var(--blue-tint); color: #17306A; border-radius: 16px; padding: 14px; font-size: 14px; line-height: 1.5; margin-top: 14px; text-align: left; }
.teacher .ic { width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--blue); color: #fff; display: grid; place-items: center; }
.teacher b { color: var(--blue-d); }
.kid .teacher { font-size: 15px; }

/* big round mic for the kids games */
.mic { width: 112px; height: 112px; border-radius: 50%; border: 0; background: var(--mag); color: #fff; display: grid; place-items: center; margin: 10px auto 8px; cursor: pointer; position: relative;
  box-shadow: 0 8px 0 var(--mag-d), 0 18px 26px -8px rgba(230, 0, 92, .55); transition: transform .12s, box-shadow .12s, background .2s; }
.mic svg.i { width: 50px; height: 50px; }
.mic:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--mag-d); }
.mic::before, .mic::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 4px solid var(--mag); opacity: 0; pointer-events: none; }
.mic::before { animation: ringout 2.4s infinite; }
.mic.rec { background: var(--bad); box-shadow: 0 8px 0 var(--bad-d); }
.mic.rec::before, .mic.rec::after { border-color: var(--bad); animation: ringout 1.2s infinite; }
.mic.rec::after { animation-delay: .6s; }
@keyframes ringout { from { transform: scale(1); opacity: .65; } to { transform: scale(1.55); opacity: 0; } }

/* feedback */
.confetti { position: fixed; top: -40px; z-index: 900; pointer-events: none; font-size: 26px; animation: fall linear forwards; will-change: transform; }
.confetti.paper { width: 10px; height: 16px; border-radius: 3px; }
.confetti.paper.round { width: 11px; height: 11px; border-radius: 50%; }
@keyframes fall { to { transform: translate3d(var(--dx, 0), 112vh, 0) rotate(var(--rot, 540deg)); } }
.spark { position: fixed; z-index: 950; pointer-events: none; font-size: 24px; line-height: 1; margin: -12px 0 0 -12px; animation: spark .8s var(--ease) forwards; }
@keyframes spark { from { transform: translate(0, 0) scale(.4); opacity: 1; } to { transform: translate(var(--sx), var(--sy)) scale(1.2) rotate(120deg); opacity: 0; } }
.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

@media (min-width: 720px) {
  .app { padding-top: 28px; }
  .hero { height: 230px; }
  h1 { font-size: 30px; }
}
/* Reduced motion: no looping, bouncing, sliding or confetti. Short fades stay so steps still feel smooth. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .15s !important; scroll-behavior: auto !important; }
  #screen > *, .note, .game, .head, .hero { animation: fadein .3s ease both !important; }
  .stars svg.i.on { animation: fadein .45s ease both !important; }
  .stars svg.i.on:nth-child(2) { animation-delay: .2s !important; } .stars svg.i.on:nth-child(3) { animation-delay: .4s !important; }
  .ring .bar { animation: ringfill .8s ease both !important; }
}
