@font-face { font-family: 'Plex'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/plex-400-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex'; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/plex-400-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/plex-600-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex'; font-style: normal; font-weight: 600; font-display: swap; src: url(../fonts/plex-600-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/plex-700-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex'; font-style: normal; font-weight: 700; font-display: swap; src: url(../fonts/plex-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #1b1240; --ink-2: #3a2a7a; --gold: #ffcf5a; --gold-2: #f59e2c; --gold-3: #c96a12; --rose: #ff5f7e; --mint: #4fe3c1; --sky: #8fd3ff;
  --glass: rgba(255, 255, 255, 0.14); --glass-2: rgba(20, 12, 52, 0.42); --stroke: rgba(255, 255, 255, 0.28); --cream: #fff7e8;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .9, .25, 1.2);
  font-family: Plex, system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1240; color: var(--cream); overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; }
[hidden] { display: none !important; }

.glass { background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,.08)); border: 1px solid var(--stroke); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); box-shadow: 0 10px 30px rgba(10, 4, 40, .28), inset 0 1px 0 rgba(255,255,255,.35); }
.icon-btn { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; transition: transform .18s var(--ease); }
.icon-btn:active { transform: scale(.88); }
.icon-btn.lang { font-family: Plex, sans-serif; font-weight: 700; font-size:18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border-radius: 999px; font-weight: 700; font-size:18px; }
.chip img { width: 26px; height: 26px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.chip.flame svg { fill: #ff9a3c; width: 22px; height: 22px; filter: drop-shadow(0 0 6px rgba(255,154,60,.7)); }
.hud-spacer { flex: 1; }

/* Loader */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 18px; background: radial-gradient(120% 90% at 50% 30%, #4b2d86 0%, #1b1240 70%); transition: opacity .5s; }
.loader-icon { width: 120px; height: 120px; border-radius: 30px; box-shadow: 0 20px 60px rgba(255, 160, 60, .35); animation: bob 2s ease-in-out infinite; }
.loader-bar { width: 200px; height: 8px; border-radius: 9px; background: rgba(255,255,255,.15); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 9px; transition: width .2s; }
.loader p { margin: 0; opacity: .8; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-2deg); } }

/* HUD */
.hud .glass, .powers .glass { backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(180deg, rgba(40,24,96,.72), rgba(24,14,64,.66)); }
.hud { position: fixed; inset: 0 0 auto 0; z-index: 10; padding: calc(10px + var(--safe-t)) 12px 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { display: flex; align-items: center; gap: 8px; }
.score { min-width: 86px; height: 46px; border-radius: 16px; display: grid; place-items: center; padding: 0 14px; font-family: Plex, sans-serif; font-weight: 700; font-size:28px;  }
.feathers { display: flex; gap: 2px; }
.feathers img { width: 34px; height: 40px; object-fit: contain; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); transition: transform .3s var(--ease), filter .3s, opacity .3s; }
.feathers img.lost { filter: grayscale(1) brightness(.6); opacity: .45; transform: scale(.8) rotate(-12deg); }
.word-card { margin: 10px auto 0; max-width: 560px; display: flex; align-items: center; gap: 12px; padding: 8px 12px 10px 8px; border-radius: 24px; }
.word-card .pic { flex: none; width: 70px; height: 70px; border-radius: 18px; background: radial-gradient(circle at 50% 35%, #fff 0%, #ffe9c2 70%, #ffd49a 100%); box-shadow: inset 0 -4px 0 rgba(200, 120, 40, .25), 0 6px 14px rgba(0,0,0,.25); display: grid; place-items: center; }
.word-card .pic img { width: 52px; height: 52px; }
.word-main { flex: 1; min-width: 0; }
.slots { display: flex; gap: 6px; justify-content: center; direction: rtl; }
[dir=ltr] .slots { direction: ltr; } /* English words are spelled left to right */
.slot { width: 46px; height: 50px; border-radius: 14px; display: grid; place-items: center; font-family: Plex; font-weight: 700; font-size:28px; line-height: 1; color: rgba(255,255,255,.55); background: rgba(10, 4, 40, .3); border: 1.5px dashed rgba(255,255,255,.35); }
.slot.next { border: 2px solid var(--gold); color: #fff; box-shadow: 0 0 0 4px rgba(255, 207, 90, .25), 0 0 18px rgba(255, 207, 90, .5); animation: pulse 1.1s ease-in-out infinite; }
.slot.done { background: linear-gradient(180deg, #fff6dc, #ffd98a); color: var(--ink); border: 0; box-shadow: inset 0 -4px 0 rgba(201, 106, 18, .35), 0 4px 10px rgba(0,0,0,.2); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 207, 90, .12), 0 0 26px rgba(255, 207, 90, .7); } }
.meter { position: relative; height: 12px; margin-top: 8px; border-radius: 9px; background: rgba(10, 4, 40, .35); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,.4); }
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 9px; background: linear-gradient(90deg, #ffb238, #ffe17a, #fff3c4); box-shadow: 0 0 12px rgba(255, 210, 90, .8); transition: width .25s var(--ease); }
[dir=rtl] .meter i { inset: 0 0 0 auto; }
.meter.fever i { background: linear-gradient(90deg, #ff8a00, #ffd400, #fff); animation: shimmer .5s linear infinite; }
.meter span { position: absolute; inset-inline-end: 6px; top: -8px; font-family: Plex, sans-serif; font-weight: 700; font-size:18px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
@keyframes shimmer { 50% { filter: brightness(1.4); } }
.sprint { margin: 10px auto 0; max-width: 420px; padding: 8px 14px; border-radius: 18px; background: linear-gradient(180deg, rgba(255, 196, 70, .95), rgba(240, 140, 30, .95)); color: #3a1b00; font-weight: 700; text-align: center; box-shadow: 0 8px 26px rgba(255, 150, 30, .45); }
.sprint .sbar { height: 8px; margin-top: 5px; border-radius: 8px; background: rgba(60, 20, 0, .25); overflow: hidden; }
.sprint .sbar i { display: block; height: 100%; background: #fff; border-radius: 8px; }
.powers { position: fixed; bottom: calc(14px + var(--safe-b)); inset-inline-start: 14px; display: flex; gap: 8px; }
.powers .pw { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; position: relative; }
.powers .pw img { width: 34px; height: 34px; object-fit: contain; }
.powers .pw i { position: absolute; inset: auto 6px 4px; height: 4px; border-radius: 3px; background: var(--mint); transform-origin: left; }
.gust-warn { position: fixed; inset-inline-end: 18px; top: 50%; z-index: 11; width: 64px; height: 64px; margin-top: -32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.7); animation: blink .35s steps(2) infinite; }
.gust-warn svg { width: 38px; height: 38px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
@keyframes blink { 50% { opacity: .35; } }
.banner { position: fixed; left: 0; right: 0; top: 42%; z-index: 12; text-align: center; pointer-events: none; opacity: 0; }
.banner b { display: block; font-family: Plex, sans-serif; font-weight: 700; font-weight: 400; font-size: clamp(44px, 9vw, 92px); line-height: 1.1; background: linear-gradient(180deg, #fff9e6 10%, #ffd45c 55%, #f08a1c 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #6a2b00) drop-shadow(0 12px 22px rgba(0,0,0,.45)); }
.banner small { display: inline-block; margin-top: 6px; padding: 6px 16px; border-radius: 999px; background: rgba(20, 10, 50, .55); font-size: clamp(15px, 2.4vw, 20px); font-weight: 700; }
.howto { position: fixed; inset: auto 0 calc(70px + var(--safe-b)) 0; z-index: 12; text-align: center; pointer-events: none; }
.howto p { display: inline-block; margin: 0 16px; padding: 10px 18px; border-radius: 18px; background: rgba(20, 10, 50, .6); font-weight: 700; font-size:18px; }
.howto small { display: block; margin-top: 6px; opacity: .8; }
.howto .hand { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; background: radial-gradient(circle, #fff 0 30%, rgba(255,255,255,.35) 32% 60%, transparent 62%); animation: swipe 1.6s ease-in-out infinite; }
@keyframes swipe { 0%, 100% { transform: translateY(-34px); } 50% { transform: translateY(34px); } }
@media (min-width: 720px) {
  .hud { padding: calc(16px + var(--safe-t)) 22px 0; }
  .word-card { margin-top: -46px; max-width: 520px; }
  .slot { width: 54px; height: 58px; font-size:38px; }
  .word-card .pic { width: 80px; height: 80px; }
  .word-card .pic img { width: 60px; height: 60px; }
}
@media (max-width: 380px) { .slot { width: 40px; height: 46px; font-size:28px; } .feathers img { width: 28px; } .score { min-width: 70px; font-size:22px; } }

/* v3: joined-script word line, boot error, parental gate */
.joined { margin-top: 8px; text-align: center; font-family: Plex, sans-serif; font-weight: 700; font-size:22px; line-height: 1.15; color: #fff3c2; text-shadow: 0 2px 0 rgba(42, 27, 92, .7); }
.joined .rest { color: rgba(255,255,255,.28); text-shadow: none; }
@media (max-width: 719px) { .joined { font-size:22px; margin-top: 6px; } .meter { margin-top: 5px; } }
.boot-err { display: grid; gap: 10px; justify-items: center; max-width: 320px; padding: 0 16px; text-align: center; }
.boot-err b { font-family: Plex, sans-serif; font-weight: 700; font-weight: 400; font-size:22px; color: #ffe39a; }

/* R6: the menu paints over a still of the desert while the WebGL engine waits for the first touch */
.loader[hidden] { display: none; }
body.menu-still #stage { background: url(../assets/bg_desert.webp) center bottom / cover no-repeat, #1b1240; animation: stillPan 26s ease-in-out infinite alternate; }
#stage canvas.in { animation: canvasIn .6s ease both; }
@keyframes stillPan { from { background-position: 40% bottom; } to { background-position: 60% bottom; } }
@keyframes stillFly { 0%, 100% { transform: translate(-50%, 0) rotate(-2deg); } 50% { transform: translate(-50%, -14px) rotate(2deg); } }
@keyframes canvasIn { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { body.menu-still #stage, 