/* Raaj Hifz arcade (the /play/ app and its games). Loaded after hifz.css. */
body.app { padding-bottom: 76px; }
html[dir=rtl] body { font-family: var(--ar), var(--font); }
.app-main { max-width: 1040px; margin: 0 auto; padding: .8rem .9rem 2rem; }
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 50; background: #fffdf7; border-top: 2px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: .2rem .3rem calc(.2rem + env(safe-area-inset-bottom)); }
.tabbar a { display: grid; justify-items: center; gap: 0; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .78rem; padding: .3rem 0; border-radius: 12px; }
.tabbar a span { font-size: 1.45rem; line-height: 1.2; }
.tabbar a[aria-current=page] { color: var(--emerald-800); background: var(--emerald-50); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: #fff; cursor: pointer; display: grid; place-items: center; font-size: 1.2rem; }
.icon-btn[aria-pressed=true] { background: var(--emerald-50); }
.lang-btn { font-weight: 800; padding: 0 .8rem; border-radius: 999px; width: auto; }

/* player header */
.hello { display: grid; gap: .8rem; grid-template-columns: auto 1fr; align-items: center; background: linear-gradient(135deg, var(--emerald-800), var(--teal)); color: #fff; border-radius: 24px; padding: 1rem 1.1rem; position: relative; overflow: hidden; }
.hello::after { content: ''; position: absolute; inset: 0; background: var(--pattern); pointer-events: none; }
.hello > * { position: relative; z-index: 1; }
.hello h1 { color: #fff; font-size: 1.45rem; margin: 0; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--gold-100); display: grid; place-items: center; font-size: 2.3rem; border: 3px solid var(--gold-300); flex: none; }
.avatar.sm { width: 40px; height: 40px; font-size: 1.4rem; border-width: 2px; }
.avatar.lg { width: 92px; height: 92px; font-size: 3.2rem; }
.stats { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .3rem; }
.stat { background: rgba(255, 255, 255, .16); border-radius: 999px; padding: .1rem .7rem; font-weight: 800; font-size: .95rem; }
.levelbar { height: 12px; border-radius: 999px; background: rgba(255, 255, 255, .25); overflow: hidden; margin-top: .4rem; }
.levelbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-300), #fff3b0); border-radius: 999px; }
.card .levelbar { background: var(--cream-2); }
.daily { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; background: linear-gradient(135deg, #fff5d6, #fde68a); border: 2px solid var(--gold-300); }
.daily .big-ico { font-size: 2.6rem; }
@media (max-width: 560px) { .daily { grid-template-columns: auto 1fr; } .daily .btn { grid-column: 1 / -1; } }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 1.4rem 0 .6rem; }
.sec-h h2 { font-size: 1.3rem; margin: 0; }
.ach-strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .3rem; }
.ach { flex: none; display: grid; justify-items: center; width: 96px; text-align: center; font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.ach b { font-size: 2rem; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-100); border: 2px solid var(--gold-300); }
.ach.locked b { filter: grayscale(1); opacity: .35; background: #eee; border-color: #ddd; }
.empty { text-align: center; color: var(--muted); padding: 1.4rem; }
.list { display: grid; gap: .5rem; }
.item { display: flex; align-items: center; gap: .7rem; background: #fff; border: 2px solid var(--line); border-radius: var(--r-sm); padding: .6rem .8rem; }
.item .grow { min-width: 0; }
.item b { display: block; }
.lb .item.me { border-color: var(--gold); background: #fffbea; }
.rank { width: 2.2rem; text-align: center; font-weight: 800; color: var(--emerald-700); font-size: 1.1rem; }
.rank.r1 { color: #b8860b; } .rank.r2 { color: #64748b; } .rank.r3 { color: #9a5b13; }
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: .4rem; }
.heat div { border-radius: 10px; padding: .35rem; text-align: center; font-size: .75rem; font-weight: 700; border: 2px solid transparent; background: #f2efe4; color: var(--ink-2); }
.heat div .ar { display: block; font-size: 1.05rem; line-height: 1.4; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(5, 40, 33, .55); display: grid; place-items: center; padding: 1rem; animation: fade .15s; }
.modal { background: var(--cream); border-radius: 24px; padding: 1.3rem; width: min(560px, 100%); max-height: 90vh; overflow: auto; border: 3px solid var(--gold-300); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5); animation: pop .2s; }
.modal h2 { margin-top: 0; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; z-index: 120; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--emerald-900); color: #fff; padding: .6rem 1.1rem; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow); max-width: 92vw; text-align: center; }
.code-box { font-family: ui-monospace, Consolas, monospace; font-size: 1.35rem; letter-spacing: .08em; background: #fff; border: 2px dashed var(--gold); border-radius: 12px; padding: .7rem; text-align: center; user-select: all; direction: ltr; }
.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: .4rem; }
.avatars button { font-size: 1.9rem; height: 56px; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.avatars button[aria-pressed=true] { border-color: var(--emerald-700); background: var(--emerald-50); }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .8rem; }
.who button { display: grid; justify-items: center; gap: .3rem; padding: 1rem .5rem; border-radius: 20px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; font-size: 1.05rem; }
.who button:hover { border-color: var(--turq); }

/* ---------- game shell ---------- */
.game-top { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.game-top h1 { font-size: 1.3rem; margin: 0; }
.game-top .ar { color: var(--gold); font-size: 1.2rem; }
.hud { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: .3rem .5rem; margin-bottom: .8rem; position: sticky; top: .3rem; z-index: 20; }
.hud span { font-weight: 800; padding: 0 .55rem; border-radius: 999px; background: var(--cream-2); white-space: nowrap; }
.hud .hud-score { background: var(--gold-100); color: #7a5a00; }
.hud .hud-timer.low { background: var(--red-100); color: var(--red); }
.hud .grow { min-width: 4px; }
.progress { height: 8px; background: var(--cream-2); border-radius: 999px; overflow: hidden; flex-basis: 100%; }
.progress i { display: block; height: 100%; background: var(--turq); transition: width .3s; }
.pregame { display: grid; gap: 1rem; }
.pregame .gi { font-size: 3rem; }
.surah-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .35rem; max-height: 260px; overflow: auto; padding: .2rem; }
.surah-pick label { display: flex; align-items: center; gap: .35rem; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: .25rem .45rem; font-size: .82rem; cursor: pointer; }
.surah-pick label .ar { margin-inline-start: auto; font-size: 1rem; }
.surah-pick input { width: 18px; height: 18px; accent-color: var(--emerald-700); }
.stage { position: relative; }
.q-card { background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); }
.q-title { font-weight: 800; color: var(--ink-2); margin-bottom: .4rem; }
.options { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-top: .9rem; }
.opt { min-height: 58px; padding: .4rem .8rem; border-radius: 16px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; font-size: 1.05rem; box-shadow: 0 3px 0 var(--line); transition: transform .08s; }
.opt:hover { border-color: var(--turq); }
.opt:active { transform: translateY(2px); }
.opt.quran { font-size: 1.6rem; line-height: 1.6; }
.opt .ar { font-size: 1.35rem; display: block; line-height: 1.3; }
.opt.right { background: var(--green-100); border-color: var(--green); box-shadow: 0 3px 0 var(--green); }
.opt.wrong { background: var(--red-100); border-color: var(--red); box-shadow: 0 3px 0 var(--red); }
.opt[disabled] { cursor: default; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.pulse { animation: pulse .5s; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.feedback { margin-top: .8rem; border-radius: var(--r-sm); padding: .7rem .9rem; font-weight: 600; }
.feedback.good { background: var(--green-100); color: #14532d; }
.feedback.bad { background: var(--red-100); color: #7f1d1d; }
.feedback .quran { font-size: 1.35rem; }
.blank { display: inline-block; min-width: 3.2em; border-bottom: 3px dashed var(--gold); margin: 0 .15em; color: var(--gold); text-align: center; }
.next-row { display: flex; justify-content: center; margin-top: 1rem; }

/* results */
.results { text-align: center; }
.results .big { font-size: 3rem; font-weight: 800; color: var(--emerald-800); line-height: 1; }
.breakdown { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; text-align: start; max-width: 320px; margin: .8rem auto; font-size: .95rem; }
.breakdown span:nth-child(even) { font-weight: 800; text-align: end; }
.note { font-size: .82rem; color: var(--muted); }

/* spinner */
.wheel-wrap { position: relative; width: min(92vw, 440px); aspect-ratio: 1; margin: 0 auto; }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); }
.wheel-pin { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent; border-top: 34px solid var(--red); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); z-index: 2; }
.landed { text-align: center; margin-top: 1rem; }
.landed .ar { font-size: 2.4rem; color: var(--emerald-800); display: block; }

/* word search */
.ws { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 820px) { .ws { grid-template-columns: minmax(0, 1.5fr) 1fr; } }
.ws-grid { position: relative; display: grid; gap: 3px; background: var(--sand); padding: 6px; border-radius: 16px; touch-action: none; user-select: none; direction: ltr; width: min(100%, 520px); margin: 0 auto; }
.ws-grid button { aspect-ratio: 1; border: 0; border-radius: 8px; background: #fff; font-family: var(--ar); font-size: clamp(1.1rem, 5vw, 1.8rem); line-height: 1; cursor: pointer; color: var(--emerald-900); padding: 0; position: relative; z-index: 1; }
.ws-grid button.sel { background: var(--gold-300); }
.ws-grid button.found { color: #fff; }
.ws-grid svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.ws-words { display: flex; flex-wrap: wrap; gap: .4rem; align-content: start; }
.ws-words span { font-family: var(--ar); font-size: 1.35rem; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: .1rem .7rem; }
.ws-words span.done { text-decoration: line-through; opacity: .55; background: var(--green-100); }
.ws-words small { font-family: var(--font); font-size: .75rem; color: var(--muted); margin-inline-start: .3rem; }

/* matching */
.match { position: relative; display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.6rem; }
.match .col { display: grid; gap: .55rem; align-content: start; position: relative; z-index: 1; }
.match button { min-height: 58px; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; padding: .3rem .6rem; box-shadow: 0 3px 0 var(--line); }
.match button.quran { font-size: 1.3rem; line-height: 1.7; text-align: right; }
.match button .ar { font-size: 1.4rem; display: block; line-height: 1.25; }
.match button.sel { border-color: var(--gold); background: var(--gold-100); }
.match button.done { opacity: .9; cursor: default; }
.match svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
@media (max-width: 560px) { .match { gap: .8rem; grid-template-columns: 1.5fr 1fr; } .match button.quran { font-size: 1.12rem; } }

/* sortable lists (sequence + ladder) */
.sortable { display: grid; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.sortable li { display: flex; align-items: center; gap: .5rem; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: .4rem .5rem; box-shadow: 0 3px 0 var(--line); touch-action: none; user-select: none; }
.sortable li.dragging { opacity: .85; box-shadow: 0 12px 24px -8px rgba(0, 0, 0, .35); border-color: var(--turq); z-index: 5; position: relative; }
.sortable li.right { border-color: var(--green); background: var(--green-100); }
.sortable li.wrong { border-color: var(--red); background: var(--red-100); }
.sortable .handle { cursor: grab; font-size: 1.3rem; color: var(--muted); padding: .3rem; touch-action: none; }
.sortable .body { flex: 1; min-width: 0; }
.sortable .arrows { display: grid; gap: 2px; }
.sortable .arrows button { width: 40px; height: 30px; border-radius: 8px; border: 2px solid var(--line); background: var(--cream); cursor: pointer; font-size: .9rem; }
.sortable .quran { font-size: 1.3rem; line-height: 1.8; text-align: right; }
.sortable .ar { font-size: 1.45rem; }

/* flipcards */
.flip-grid { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(30%, 150px), 1fr)); perspective: 900px; }
.fcard { aspect-ratio: 3 / 3.4; border: 0; padding: 0; background: none; cursor: pointer; position: relative; transform-style: preserve-3d; transition: transform .35s; }
.fcard.up, .fcard.matched { transform: rotateY(180deg); }
.fcard .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 14px; display: grid; place-items: center; padding: .35rem; overflow: hidden; }
.fcard .back { background: var(--emerald-700) var(--pattern); border: 3px solid var(--gold-300); color: var(--gold-300); font-size: 1.8rem; }
.fcard .front { transform: rotateY(180deg); background: #fff; border: 2px solid var(--line); text-align: center; }
.fcard.matched .front { background: var(--green-100); border-color: var(--green); }
.fcard .front .quran { font-size: clamp(.9rem, 3.4vw, 1.2rem); line-height: 1.7; }
.fcard .front .ar { font-size: clamp(1.2rem, 4.5vw, 1.6rem); }
.fcard .front .en { font-size: clamp(.72rem, 2.8vw, .9rem); line-height: 1.25; }

/* true / false */
.tf-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1rem; }
.tf-buttons button { min-height: 84px; border-radius: 20px; border: 0; font-size: 1.5rem; font-weight: 800; color: #fff; cursor: pointer; box-shadow: 0 5px 0 rgba(0, 0, 0, .25); }
.tf-buttons .t { background: var(--green); } .tf-buttons .f { background: var(--red); }
.tf-buttons button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.qtimer { height: 10px; border-radius: 999px; background: var(--cream-2); overflow: hidden; margin-top: .6rem; }
.qtimer i { display: block; height: 100%; background: var(--gold); }

/* falling words */
.sky { position: relative; height: min(62vh, 520px); border-radius: 22px; overflow: hidden; background: linear-gradient(180deg, #0b3b4a, #0f766e 60%, #14b8a6); touch-action: manipulation; user-select: none; }
.sky::after { content: ''; position: absolute; inset: 0; background: var(--pattern); opacity: .6; pointer-events: none; }
.sky .ground { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: var(--gold-300); z-index: 2; }
.fw { position: absolute; z-index: 3; top: 0; padding: .2rem .8rem; border-radius: 999px; background: #fff; border: 3px solid var(--gold-300); font-family: var(--quran); font-size: clamp(1.2rem, 4.6vw, 1.7rem); line-height: 1.6; cursor: pointer; white-space: nowrap; color: var(--emerald-900); box-shadow: 0 6px 14px -6px rgba(0, 0, 0, .5); will-change: transform; }
.fw.hit { background: var(--green-100); border-color: var(--green); }
.fw.miss { background: var(--red-100); border-color: var(--red); }
.build { min-height: 3.4em; background: #fff; border-radius: 16px; border: 2px solid var(--line); padding: .3rem .8rem; margin-bottom: .6rem; text-align: center; }

/* maze */
.maze { display: grid; gap: 5px; background: var(--emerald-900); padding: 7px; border-radius: 18px; direction: rtl; width: min(100%, 620px); margin: 0 auto; }
.maze button { min-height: 64px; border-radius: 12px; border: 0; background: #f3ecd7; font-family: var(--quran); font-size: clamp(.85rem, 3.4vw, 1.3rem); line-height: 1.5; cursor: pointer; color: var(--emerald-900); padding: .2rem; word-break: break-word; }
.maze button.next-ok { box-shadow: inset 0 0 0 3px var(--turq-300); }
.maze button.on { background: var(--gold-300); }
.maze button.start { background: var(--turq-300); }
.maze button.exit::after { content: ' 🚪'; font-family: var(--font); }
.maze button.dead { background: var(--red-100); }

/* sorting */
.bins { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin-top: .8rem; }
.bin { min-height: 130px; background: var(--emerald-50); border: 3px dashed var(--teal); border-radius: 18px; padding: .5rem; display: grid; gap: .4rem; align-content: start; }
.bin.over, .bin.target { background: var(--turq-100); border-style: solid; }
.bin h3 { margin: 0; text-align: center; font-family: var(--ar); font-size: 1.4rem; color: var(--emerald-800); }
.tray { display: flex; flex-wrap: wrap; gap: .45rem; min-height: 70px; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: .5rem; }
.scard { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: .15rem .6rem; font-family: var(--quran); font-size: 1.2rem; line-height: 1.75; cursor: grab; touch-action: none; user-select: none; box-shadow: 0 3px 0 var(--line); direction: rtl; }
.scard.sel { border-color: var(--gold); background: var(--gold-100); }
.scard.right { border-color: var(--green); background: var(--green-100); cursor: default; }
.scard.wrong { border-color: var(--red); background: var(--red-100); }
.scard.ghost { position: fixed; z-index: 200; pointer-events: none; opacity: .9; }

/* zoom */
.zoom-box { position: relative; height: 210px; overflow: hidden; border-radius: 20px; background: #fffdf5; border: 3px double var(--gold); display: grid; place-items: center; }
.zoom-box .quran { font-size: 2rem; white-space: nowrap; transition: transform .25s linear; transform-origin: var(--fx, 50%) 55%; padding: 0 1rem; }
.zoom-meter { height: 10px; border-radius: 999px; background: var(--cream-2); overflow: hidden; margin: .6rem 0; }
.zoom-meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--turq)); }

/* spot the mistake */
.quiz-line { border: 3px dashed var(--red); background: repeating-linear-gradient(-45deg, #fff, #fff 12px, #fff7f7 12px, #fff7f7 24px); border-radius: 16px; padding: .8rem; }
.quiz-label { display: inline-block; background: var(--red); color: #fff; border-radius: 999px; padding: .05rem .7rem; font-weight: 800; font-size: .8rem; margin-bottom: .4rem; }
.word-btns { display: flex; flex-wrap: wrap; gap: .3rem; direction: rtl; justify-content: center; }
.word-btns button { font-family: var(--quran); font-size: 1.55rem; line-height: 1.8; padding: .05rem .5rem; border-radius: 10px; border: 2px solid transparent; background: transparent; cursor: pointer; color: var(--emerald-900); }
.word-btns button:hover { border-color: var(--gold); background: var(--gold-100); }
.word-btns button.right { background: var(--green-100); border-color: var(--green); }
.word-btns button.wrong { background: var(--red-100); border-color: var(--red); }

/* odd one out */
.odd-list { display: grid; gap: .6rem; }
.odd-list button { text-align: right; direction: rtl; }

/* audio */
.play-big { width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--emerald-700); color: #fff; font-size: 3rem; cursor: pointer; box-shadow: 0 6px 0 var(--emerald-900); display: grid; place-items: center; margin: .4rem auto; }
.play-big.playing { animation: pulse 1s infinite; background: var(--teal); }
canvas.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; width: 100%; height: 100%; }
