:root {
  /* هوية لقمة الهنا: أحمر عنّابي + برتقالي + أبيض */
  --roast: #7A020B;
  --roast-2: #A00C15;
  --gold: #F7941D;
  --gold-deep: #C4640A;
  --honey: #FFB547;
  --cream: #FFFDF8;
  --cream-2: #FFE3D3;
  --ink: #5E0008;
  --muted: #9A5A50;
  --wa: #1FA855;
  --danger: #B3261E;
  --radius: 22px;
  /* الخطوط: Lemonada للنص العربي، Tajawal للأرقام والحقول والكود */
  --f-display: 'Lemonada', 'Tajawal', sans-serif;
  --f-body: 'Lemonada', 'Tajawal', system-ui, sans-serif;
  --f-clear: 'Tajawal', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
input, textarea, [dir="ltr"] { font-family: var(--f-clear); }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--f-body);
  color: var(--cream);
  background: var(--roast);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(70% 45% at 50% 30%, rgba(200,20,30,.75), transparent 75%),
    radial-gradient(90% 50% at 50% 110%, rgba(160,12,21,.6), transparent 70%);
}

.app {
  position: relative; z-index: 1;
  max-width: 460px; margin: 0 auto;
  min-height: 100svh;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px calc(env(safe-area-inset-bottom, 0px) + 28px);
  display: flex; flex-direction: column;
}

.brand { text-align: center; margin-bottom: 8px; }
.wordmark {
  font-family: 'Aref Ruqaa', 'Tajawal', serif;
  font-size: 2.1rem; line-height: 1.3;
  color: var(--honey);
  text-shadow: 0 2px 0 var(--gold-deep), 0 8px 24px rgba(0,0,0,.35);
}
.logo-img { height: 84px; width: auto; max-width: 60%; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.25)); }
.mascot { width: min(48vw, 200px); height: auto; margin: 0 auto; filter: drop-shadow(0 14px 18px rgba(40,0,0,.45)); animation: wave 3s ease-in-out infinite; transform-origin: 50% 90%; }
.mascot.small { width: 120px; animation-duration: 2.2s; }
@keyframes wave { 0%,100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-6px); } }

/* ---------- الشاشات ---------- */
.screen { display: none; flex: 1; flex-direction: column; justify-content: center; text-align: center; gap: 14px; }
.screen:not([data-screen="welcome"]) { justify-content: flex-start; padding-top: clamp(12px, 7vh, 80px); }
.screen.is-active { display: flex; animation: rise .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.kicker { margin: 0; color: var(--honey); font-weight: 700; letter-spacing: .02em; }
.hero {
  font-family: var(--f-display);
  margin: 0; font-size: clamp(3rem, 16vw, 4.4rem); line-height: 1.05; font-weight: 800;
}
.hero span { color: var(--gold); display: block; }
.hero.small { font-size: 2.4rem; }
.hero.move { font-size: clamp(2rem, 10.5vw, 3rem); line-height: 1.3; }
.hero.move span { color: var(--gold); }
.hero-loc { margin: -2px 0 2px; font-size: .78rem; font-weight: 500; line-height: 1.7; color: rgba(255,255,255,.88); }
.lead { margin: 0; font-size: 1.05rem; line-height: 1.7; color: var(--cream-2); }
.step { margin: 0; color: var(--gold); font-weight: 700; font-size: .95rem; }
.q { margin: 0 0 6px; font-family: var(--f-display); font-size: 1.6rem; font-weight: 700; }

.promise { list-style: none; padding: 0; margin: 4px 0 10px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.promise li {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px; padding: 6px 12px; font-size: .8rem;
}
.promise b { color: var(--honey); }

/* كرات عوامة مرسومة */
.balls { display: flex; justify-content: center; align-items: flex-end; height: 92px; margin: 6px 0; }
.balls i, .art i {
  display: block; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #FFF1C4 0 9%, transparent 22%),
    radial-gradient(circle at 60% 70%, #9C5308 0, transparent 60%),
    radial-gradient(circle at 45% 40%, #FFC35A, #E38A1B 62%, #A85A0A 100%);
  box-shadow: inset -4px -6px 10px rgba(90,40,0,.45), 0 8px 16px rgba(0,0,0,.35);
}
.balls i { width: 58px; height: 58px; margin: 0 -7px; animation: bob 2.6s ease-in-out infinite; }
.balls i:nth-child(2) { width: 70px; height: 70px; animation-delay: .3s; }
.balls i:nth-child(3) { width: 84px; height: 84px; z-index: 2; animation-delay: .6s; }
.balls i:nth-child(4) { width: 70px; height: 70px; animation-delay: .9s; }
.balls i:nth-child(5) { animation-delay: 1.2s; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- الأزرار ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  min-height: 58px; width: 100%; border-radius: 18px;
  font: 700 1.2rem/1.3 var(--f-body);
  transition: transform .12s ease, filter .2s;
}
.btn:active { transform: scale(.97); }
.btn-gold { color: var(--ink); background: linear-gradient(180deg, var(--honey), var(--gold)); box-shadow: 0 6px 0 var(--gold-deep), 0 14px 30px rgba(40,0,0,.35); }
.btn-gold:active { box-shadow: 0 2px 0 var(--gold-deep); transform: translateY(4px); }
.btn-gold[disabled] { filter: grayscale(.5) brightness(.8); }
.btn-ghost { color: var(--cream); background: transparent; border: 2px solid rgba(255,255,255,.5); }
.btn-dark { color: var(--cream); background: var(--roast); min-height: 50px; font-size: 1.05rem; }
.btn-wa { color: #fff; background: var(--wa); }
.btn-link {
  appearance: none; background: none; border: 0; cursor: pointer; color: var(--cream-2);
  font: 500 .95rem var(--f-body); text-decoration: underline; text-underline-offset: 4px; padding: 10px;
}

/* ---------- الاختيارات ---------- */
.choices { display: grid; gap: 12px; }
.choice {
  appearance: none; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: 14px; padding: 10px 12px;
  border-radius: var(--radius); border: 2px solid transparent;
  background: var(--cream); color: var(--ink);
  font: 700 1.15rem var(--f-body); text-align: right;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  transition: transform .15s, border-color .15s;
}
.choice:active, .choice.is-picked { transform: scale(.98); border-color: var(--gold); }
.choice-img {
  flex: 0 0 84px; height: 84px; border-radius: 16px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #FFF9EC, var(--cream-2));
  display: grid; place-items: center;
}
.choice-img img { width: 100%; height: 100%; object-fit: cover; }
.choice-img img.choice-mascot { object-fit: contain; padding: 6px; }
/* قطرها خفيف: نفس الشخصية بلون أفتح */
.choice-mascot.light { filter: brightness(1.12) saturate(.78); }

.art { position: relative; width: 70px; height: 60px; display: block; }
.art i { position: absolute; width: 34px; height: 34px; }
.art i:nth-child(1) { right: 2px; bottom: 0; }
.art i:nth-child(2) { left: 2px; bottom: 0; }
.art i:nth-child(3) { left: 18px; top: 0; width: 36px; height: 36px; }
/* قطرها خفيف: كرات أفتح */
.art-light i { filter: saturate(.8) brightness(1.12); }
/* المحشية: حشوة قشطة */
.art-stuffed i:nth-child(3)::after {
  content: ""; position: absolute; left: 7px; right: 7px; top: 12px; height: 13px;
  border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff, #F3E6CC);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.15);
}
.art-stuffed::after {
  content: ""; position: absolute; left: 50%; top: -8px; width: 8px; height: 8px; border-radius: 50%;
  background: #6BAF5B; box-shadow: 9px 3px 0 #6BAF5B;
}

/* ---------- النموذج ---------- */
.form { display: grid; gap: 12px; text-align: right; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; color: var(--cream-2); }
.field input {
  width: 100%; min-height: 54px; padding: 0 16px;
  border-radius: 16px; border: 2px solid transparent; outline: none;
  background: var(--cream); color: var(--ink);
  font: 700 1.25rem var(--f-clear);
}
.field input:focus { border-color: var(--gold); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field input[dir="ltr"] { text-align: left; letter-spacing: .04em; }
.hint { margin: 0; font-size: .92rem; color: var(--cream-2); opacity: .85; }
.error { margin: 0; padding: 10px 14px; border-radius: 12px; background: #FDE3DE; color: var(--danger); font-weight: 700; }

/* ---------- الكشط ---------- */
.scratch {
  position: relative; width: 100%; aspect-ratio: 1.45; max-width: 400px; margin: 6px auto;
  border-radius: 26px; overflow: hidden; touch-action: none;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
.ticket {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background:
    radial-gradient(circle at 50% 0%, #FFFDF6, var(--cream) 60%, var(--cream-2));
  color: var(--ink); padding: 18px;
}
.ticket-label { font-weight: 700; color: var(--muted); font-size: 1.1rem; }
.ticket-prize { font-size: clamp(1.6rem, 8vw, 2.2rem); line-height: 1.25; font-weight: 800; }
.ticket-prize.cash { font-size: clamp(3rem, 17vw, 4.4rem); color: #B8001A; }
.foil { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; transition: opacity .5s; }
.foil.gone { opacity: 0; pointer-events: none; }

/* ---------- النتيجة ---------- */
[data-screen="result"] { justify-content: flex-start; gap: 16px; padding-top: 6px; }
.win-title { font-family: var(--f-display); margin: 0; font-size: clamp(2rem, 10vw, 2.8rem); line-height: 1.2; font-weight: 800; color: var(--honey); }
.win-title.cash { font-size: clamp(3.2rem, 18vw, 4.6rem); }
.code-box {
  display: grid; gap: 2px; padding: 12px; border-radius: 18px;
  border: 2px dashed rgba(255,255,255,.6); background: rgba(255,255,255,.07);
}
.code-box span, .code-box small { color: var(--cream-2); }
.code { font-size: 2rem; letter-spacing: .18em; color: var(--cream); font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }

.move-card {
  background: var(--cream); color: var(--ink); border-radius: var(--radius);
  padding: 18px 16px; display: grid; gap: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.3);
}
.move-card p { margin: 0; }
.move-kicker { font-weight: 800; color: var(--gold-deep); font-size: 1.05rem; }
.move-loc { font-size: 1.55rem; font-weight: 800; line-height: 1.3; }
.move-landmark { color: var(--muted); font-weight: 500; }
.move-landmark:empty { display: none; }
.move-note { font-size: .98rem; color: #6B3A34; line-height: 1.6; }

.actions { display: grid; gap: 10px; }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- لعبة المطابقة ---------- */
[data-screen="game"] { justify-content: flex-start; gap: 10px; padding-top: 4px; }
.rules { display: grid; gap: 2px; font-size: .78rem; line-height: 1.7; color: var(--cream-2); }
.rules b { font-size: .95rem; color: #fff; }
.rules em { font-style: normal; color: var(--honey); font-weight: 600; }
.hud { display: flex; align-items: center; gap: 12px; }
.timer { flex: 1; display: flex; align-items: center; gap: 8px; }
.timer-bar { flex: 1; height: 12px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.timer-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--honey), var(--gold)); transform-origin: right; transition: transform .1s linear; }
.timer.is-low .timer-bar i { background: #FF5A4E; }
.timer-num { min-width: 2.2ch; font: 700 1.15rem var(--f-clear); color: #fff; text-align: center; }
.timer.is-low .timer-num { color: #FFB3AC; animation: pulse .6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.2); } }
.hud-pairs { font-size: .8rem; white-space: nowrap; }
.hud-pairs b { font: 700 1rem var(--f-clear); color: var(--honey); }

.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 2vw, 10px); width: 100%; perspective: 900px; }
.card {
  appearance: none; border: 0; padding: 0; background: none; cursor: pointer;
  aspect-ratio: 1; position: relative; -webkit-tap-highlight-color: transparent;
}
.card-inner {
  position: absolute; inset: 0; display: block; transform-style: preserve-3d;
  transition: transform .42s cubic-bezier(.2,.8,.2,1);
}
.card.is-open .card-inner { transform: rotateY(180deg); }
.card.is-pressed .card-inner { transform: scale(.94); }
.card-back, .card-face {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; place-items: center; box-shadow: 0 6px 14px rgba(40,0,0,.35);
}
.card-back {
  background: radial-gradient(circle at 50% 35%, #C8141F, #8E0610 75%);
  border: 2px solid rgba(255,181,71,.55);
}
.card-back img { width: 62%; height: auto; opacity: .95; }
.card-face { background: #fff; transform: rotateY(180deg); border: 2px solid #fff; }
.card-face img { width: 92%; height: 92%; object-fit: contain; }
.card.is-matched .card-face { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(247,148,29,.55), 0 6px 14px rgba(40,0,0,.35); }
.card.pop .card-inner { animation: pop .45s ease; }
@keyframes pop { 50% { transform: rotateY(180deg) scale(1.1); } }
.card.shake .card-inner { animation: shake .4s ease; }
@keyframes shake { 25% { transform: rotateY(180deg) translateX(-5px); } 75% { transform: rotateY(180deg) translateX(5px); } }
.card:disabled { cursor: default; }
.hint.center { text-align: center; }

/* ---------- النتيجة والتسجيل ---------- */
[data-screen="outcome"] { justify-content: center; }
.lead.small { font-size: .9rem; }
.tier-badge {
  margin: 0 auto; padding: 6px 16px; border-radius: 99px; font-weight: 600; font-size: .9rem;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.35);
}
.tier-badge.cash { background: var(--gold); border-color: var(--gold); color: var(--ink); }
[data-screen="done"] { justify-content: flex-start; gap: 14px; }

.boost {
  display: grid; gap: 8px; padding: 16px; border-radius: var(--radius);
  background: rgba(255,255,255,.08); border: 2px dashed rgba(255,181,71,.6);
}
.boost p { margin: 0; }
.boost-title { font-weight: 700; font-size: 1.15rem; color: var(--honey); }
.boost-text { font-size: .85rem; color: var(--cream-2); }
.follow {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 14px;
  color: #fff; text-decoration: none; font-weight: 600; font-size: .95rem;
}
.follow svg { width: 24px; height: 24px; flex: 0 0 24px; }
.follow span { flex: 1; text-align: right; }
.follow.fb { background: #1877F2; }
.follow.ig { background: linear-gradient(45deg, #F58529, #DD2A7B 50%, #8134AF); }
.follow-state { font-style: normal; font-size: .8rem; padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.22); white-space: nowrap; }
.follow.is-done .follow-state { background: #fff; color: #1E7A45; }
.entries { font-size: .95rem; }
.entries b { font: 700 1.4rem var(--f-clear); color: var(--honey); vertical-align: middle; }
.boost-fine { font-size: .72rem; color: var(--cream-2); opacity: .8; }

/* ---------- النتيجة + التسجيل ---------- */
[data-screen="outcome"] { justify-content: flex-start; gap: 10px; }
.outcome-head { display: flex; align-items: center; gap: 12px; text-align: right; }
.outcome-mascot { width: 92px; height: auto; flex: 0 0 92px; filter: drop-shadow(0 8px 10px rgba(40,0,0,.4)); }
.outcome-title { margin: 0; font-family: var(--f-display); font-size: 1.7rem; line-height: 1.35; color: var(--honey); }
.outcome-text { margin: 0; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.1); font-size: .95rem; line-height: 1.7; }
.form-title { margin: 4px 0 0; font-weight: 700; font-size: 1.05rem; }
.field select {
  width: 100%; min-height: 54px; padding: 0 14px; border-radius: 16px; border: 2px solid transparent; outline: none;
  background: var(--cream); color: var(--ink); font: 600 1.05rem var(--f-body); appearance: auto;
}
.field select:focus { border-color: var(--gold); }
.field select[aria-invalid="true"] { border-color: var(--danger); }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; color: var(--cream-2); }
.choices.mini { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choices.mini .choice { flex-direction: column; gap: 4px; padding: 8px 4px; font-size: .78rem; text-align: center; line-height: 1.5; }
.choices.mini .choice-img { flex: 0 0 auto; width: 58px; height: 58px; }
.choices.mini .choice.is-picked { background: #FFF1DC; box-shadow: 0 0 0 3px var(--gold), 0 8px 20px rgba(0,0,0,.25); }
