:root {
  --sand: #F3D5A2;
  --dune: #E2672E;
  --dune-deep: #A8431A;
  --date: #3E200E;
  --date-soft: rgba(62, 32, 14, 0.82);
  --palm: #3F7A3A;
  --gold: #F2B630;
  --cream: #FFF7E6;
  --display: 'Lalezar', 'Tajawal', system-ui, sans-serif;
  --body: 'Tajawal', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  height: 100%;
  overflow: hidden;
  background: #f0c88f;
  font-family: var(--body);
  color: var(--cream);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

/* ---------- الشعار: حروف بارزة مثل طبقات الكثيب ---------- */
.logo {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(58px, 16vw, 104px);
  line-height: 0.92;
  text-align: center;
  color: var(--cream);
  letter-spacing: 0;
  text-shadow:
    0 2px 0 #F7B866, 0 4px 0 #EE9A48, 0 6px 0 #E2802F,
    0 8px 0 #C9621F, 0 10px 0 #A8471A, 0 12px 0 #7F3214,
    0 22px 28px rgba(70, 28, 6, 0.45);
}
.logo.small { font-size: 56px; }

/* ---------- شاشات ---------- */
.screen { position: fixed; inset: 0; z-index: 10; }
.menu {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 14px) 18px calc(var(--safe-b) + 22px);
  background: linear-gradient(to bottom, rgba(95, 178, 227, 0.0) 55%, rgba(62, 32, 14, 0.55) 100%);
  pointer-events: none;
}
.menu > * { pointer-events: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { margin-top: 0; pointer-events: none; flex: 1; }
.tagline {
  margin-top: 18px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--date);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}
.menu-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 420px; margin: 0 auto; }

.icon-btn {
  width: 48px; height: 48px;
  border-radius: 16px;
  background: var(--date-soft);
  display: grid; place-items: center;
  color: var(--cream);
  box-shadow: 0 4px 0 rgba(30, 14, 4, 0.5);
}
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(30, 14, 4, 0.5); }
#btnSound .mute { display: none; }
#btnSound.off .mute { display: inline; }
#btnSound.off .wave { display: none; }

.bank-pill, .pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--date-soft);
  border-radius: 14px;
  padding: 6px 14px 4px;
  font-family: var(--display);
  font-size: 24px;
  line-height: 1;
}
.bank-pill svg, .pill svg { width: 24px; height: 24px; margin-top: -3px; }

.picker {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  background: var(--date-soft);
  border-radius: 22px;
  padding: 8px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.arrow {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: rgba(255, 247, 230, 0.12);
  font-size: 40px;
  line-height: 1;
  padding-bottom: 6px;
}
.arrow:active { background: rgba(255, 247, 230, 0.25); }
.char-info { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.char-info strong { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.1; }
.char-info span { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--sand); }
.lock { width: 16px; height: 16px; color: var(--gold); }

.btn {
  display: block;
  width: 100%;
  border-radius: 20px;
  padding: 14px 18px 10px;
  font-family: var(--display);
  font-size: 28px;
  line-height: 1.1;
  text-align: center;
  transition: transform 0.06s;
}
.btn-primary { background: var(--dune); color: #fff; box-shadow: 0 6px 0 var(--dune-deep), 0 12px 22px rgba(80, 30, 5, 0.35); }
.btn-primary:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--dune-deep); }
.btn-primary:disabled { background: #8b6a52; box-shadow: 0 6px 0 #5e4636; font-size: 21px; cursor: default; transform: none; }
.btn-gold { background: var(--gold); color: var(--date); box-shadow: 0 6px 0 #B7801A; font-size: 22px; }
.btn-gold:active { transform: translateY(5px); box-shadow: 0 1px 0 #B7801A; }
.btn-ghost { background: rgba(255, 247, 230, 0.12); color: var(--cream); font-size: 22px; padding: 11px 14px 8px; }
.btn-ghost:active { background: rgba(255, 247, 230, 0.22); }
.btn-small { width: auto; padding: 10px 18px 7px; font-size: 20px; background: var(--palm); box-shadow: 0 4px 0 #26502a; border-radius: 14px; }
.btn-small:disabled { opacity: 0.6; }

.best { font-weight: 700; font-size: 15px; color: var(--sand); }
.credit { font-size: 11px; color: var(--sand); opacity: .6; margin: 2px 0 0; }
.best b { font-family: var(--display); font-weight: 400; font-size: 20px; color: var(--cream); margin-inline-start: 4px; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.hud-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(var(--safe-t) + 12px) 14px 0;
}
.hud-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
html[dir="rtl"] .hud-stats { align-items: flex-start; }
.score-pill { font-size: 34px; padding: 8px 16px 4px; min-width: 120px; justify-content: center; }
.dates-pill { font-size: 24px; }
.mult {
  background: var(--gold); color: var(--date);
  border-radius: 9px; padding: 3px 7px 0; font-size: 20px;
}
.pause-btn { pointer-events: auto; display: flex; gap: 6px; }
.pause-btn i { display: block; width: 6px; height: 20px; border-radius: 3px; background: var(--cream); }

.zone-toast {
  position: absolute; top: 26%; left: 0; right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(38px, 11vw, 64px);
  color: var(--cream);
  text-shadow: 0 3px 0 var(--dune-deep), 0 8px 18px rgba(60, 20, 0, 0.45);
  opacity: 0;
}
.zone-toast.on { animation: zone 2.6s ease-out forwards; }
@keyframes zone {
  0% { opacity: 0; transform: scale(0.8); }
  15% { opacity: 1; transform: scale(1.04); }
  25% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}
.hint {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 128px);
  transform: translate(-50%, 10px);
  background: var(--date-soft);
  padding: 10px 18px 8px;
  border-radius: 16px;
  font-weight: 800; font-size: 17px;
  white-space: normal; width: max-content; max-width: min(88vw, 420px); text-align: center; line-height: 1.45;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.hint.on { opacity: 1; transform: translate(-50%, 0); }

.power-bar {
  position: absolute; bottom: calc(var(--safe-b) + 18px); inset-inline-start: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.power {
  display: grid; grid-template-columns: 30px auto; grid-template-rows: auto 6px;
  column-gap: 8px; align-items: center;
  background: var(--date-soft);
  border-radius: 14px;
  padding: 7px 12px 8px 12px;
  min-width: 132px;
}
.power svg { width: 30px; height: 30px; grid-row: 1 / 3; }
.power span { font-weight: 800; font-size: 14px; }
.power i { display: block; height: 6px; border-radius: 3px; background: rgba(255, 247, 230, 0.2); overflow: hidden; }
.power b { display: block; height: 100%; background: var(--gold); transform-origin: right; }

/* ---------- النوافذ ---------- */
.modal {
  display: grid; place-items: center;
  background: rgba(40, 18, 6, 0.45);
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  z-index: 20;
}
.panel {
  width: 100%; max-width: 380px;
  background: rgba(62, 32, 14, 0.92);
  border: 2px solid rgba(243, 213, 162, 0.25);
  border-radius: 28px;
  padding: 24px 20px 20px;
  display: flex; flex-direction: column; gap: 12px;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: pop 0.28s cubic-bezier(.2, 1.4, .4, 1);
  max-height: 100%;
  overflow-y: auto;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.panel h2 { font-family: var(--display); font-weight: 400; font-size: 36px; }
.over-title { font-family: var(--display); font-size: 26px; color: var(--sand); }
.big-score {
  font-family: var(--display);
  font-size: 72px; line-height: 1;
  color: var(--cream);
  text-shadow: 0 3px 0 #C9621F, 0 6px 0 #7F3214;
}
.record {
  align-self: center;
  background: var(--gold); color: var(--date);
  border-radius: 10px; padding: 4px 12px 2px;
  font-weight: 800; font-size: 15px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0; }
.stats div { background: rgba(255, 247, 230, 0.08); border-radius: 14px; padding: 8px 4px 6px; }
.stats dt { font-size: 12px; font-weight: 700; color: var(--sand); }
.stats dd { font-family: var(--display); font-size: 26px; line-height: 1.2; }
.submit-box { display: flex; gap: 8px; }
.submit-box input {
  flex: 1; min-width: 0;
  background: rgba(255, 247, 230, 0.95);
  color: var(--date);
  border: 0; border-radius: 14px;
  padding: 10px 14px;
  font: 700 17px var(--body);
  user-select: text; -webkit-user-select: text;
}
.submit-msg { font-size: 14px; font-weight: 700; color: var(--sand); min-height: 1em; }
.row { display: flex; gap: 10px; }

.board-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.board-list li {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px;
  background: rgba(255, 247, 230, 0.07);
  border-radius: 12px; padding: 8px 12px 6px;
  text-align: start;
}
.board-list li.me { background: rgba(242, 182, 48, 0.25); }
.board-list li:nth-child(1) .rk { background: var(--gold); color: var(--date); }
.board-list .rk { font-family: var(--display); font-size: 20px; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 247, 230, 0.12); }
.board-list .nm { font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .sc { font-family: var(--display); font-size: 22px; }
.board-list .empty { display: block; text-align: center; color: var(--sand); font-weight: 700; }

/* ---------- التحميل ---------- */
.loader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  background: linear-gradient(#a9d7ee, #f6dcae 60%, #f0c88f);
  transition: opacity 0.5s;
}
.loader.done { opacity: 0; pointer-events: none; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 5px solid rgba(62, 32, 14, 0.2); border-top-color: var(--dune);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ld-wrap { width: min(78vw, 320px); text-align: center; margin-top: -12px; }
.ld-bar { height: 12px; border-radius: 8px; background: rgba(62, 32, 14, 0.18); overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 4%; border-radius: 8px; background: linear-gradient(90deg, var(--dune), #f2b04a); transition: width 0.25s ease-out; }
.ld-text { margin-top: 10px; font-weight: 800; font-size: 16px; color: #3e200e; }
.ld-ver { margin-top: 4px; font-size: 12px; color: rgba(62, 32, 14, 0.55); direction: ltr; }
/* زر البدء أثناء تحميل الشخصية: شريط تقدّم داخله */
.btn.loading { position: relative; overflow: hidden; background: #8a7058 !important; color: #fff7e6; box-shadow: 0 4px 0 #5e4a38 !important; pointer-events: none; }
.btn.loading::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p, 5%); background: rgba(255, 255, 255, 0.28); transition: width 0.25s; }


@media (orientation: landscape) and (max-height: 500px) {
  .logo { font-size: 56px; }
  .tagline { margin-top: 8px; font-size: 14px; }
  .menu-bottom { max-width: 360px; gap: 8px; }
  .btn { font-size: 22px; padding: 10px 14px 7px; }
  .big-score { font-size: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .zone-toast.on, .panel { animation-duration: 0.01s; }
}

/* لوحة الترحيب */
.welcome {
  display: flex; align-items: center; gap: 12px;
  margin: 12px auto 0; width: 100%; max-width: 440px;
  padding: 10px 12px 10px 14px;
  background: var(--date-soft); backdrop-filter: blur(6px);
  border: 1.5px solid rgba(243, 213, 162, 0.35); border-radius: 18px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 10px 24px rgba(0, 0, 0, 0.25);
  animation: welcomeIn .7s cubic-bezier(.2, 1.1, .3, 1) both .3s;
}
.w-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.w-text strong { font-family: var(--display); font-weight: 400; font-size: 19px; color: var(--cream); line-height: 1.2; }
.w-text span { font-size: 13px; font-weight: 700; color: var(--sand); }
.w-link {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 9px 14px; border-radius: 12px; text-decoration: none;
  background: var(--gold); color: var(--date); font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 0 #b9871a; transition: transform .08s, box-shadow .08s;
}
.w-link svg { width: 15px; height: 15px; }
.w-link:active { transform: translateY(4px); box-shadow: 0 0 0 #b9871a; }
.w-close {
  flex: none; width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 247, 230, 0.14); color: var(--cream); font-size: 18px; line-height: 1;
}
@keyframes welcomeIn { from { opacity: 0; transform: translateY(-18px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-height: 520px) { .welcome { display: none; } }

/* شريط السباق: التقدم نحو برج بريدة وخطر الذئب */
.race { position: absolute; top: calc(var(--safe-t) + 66px); left: 50%; transform: translateX(-50%); width: min(60vw, 280px); display: grid; gap: 6px; pointer-events: none; }
.r-row { display: grid; gap: 2px; }
.r-row span { font-size: 12px; font-weight: 800; color: var(--cream); text-shadow: 0 1px 2px rgba(0,0,0,.5); display: flex; justify-content: space-between; }
.r-row b { font-weight: 800; color: var(--gold); }
.bar { height: 8px; border-radius: 6px; background: rgba(62,32,14,.55); overflow: hidden; border: 1px solid rgba(243,213,162,.3); }
.bar i { display: block; height: 100%; width: 100%; transform-origin: right; transform: scaleX(0); background: #7ac26a; transition: transform .15s linear; }
.bar:not(.danger) i { background: linear-gradient(to left, #f2b630, #e2672e); }

/* العنوان الفرعي: بنفس هوية الشعار (كريمي بظلال برتقالية متدرّجة) */
.tagline { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 22px; color: var(--cream); text-shadow: none; }
.tg-title {
  font-family: var(--display); font-weight: 400; font-size: clamp(24px, 6.6vw, 38px); line-height: 1.1; color: var(--cream);
  text-shadow: 0 2px 0 #F7B866, 0 4px 0 #EE9A48, 0 6px 0 #E2802F, 0 8px 0 #C9621F, 0 10px 0 #A8471A, 0 16px 20px rgba(70, 28, 6, 0.45);
}
.tg-sub {
  font-weight: 800; font-size: clamp(14px, 3.8vw, 19px); color: var(--gold); letter-spacing: 0;
  padding: 3px 16px; border-radius: 999px; background: rgba(62, 32, 14, 0.62); border: 1px solid rgba(242, 182, 48, 0.5);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
@media (max-height: 520px) { .tg-title { font-size: 22px; text-shadow: 0 2px 0 #E2802F, 0 4px 0 #A8471A; } .tagline { margin-top: 10px; gap: 4px; } }

/* زر «حول» صغير وخفيف + لوحة الشكر */
.credits-link { align-self: center; margin-top: 2px; padding: 4px 14px; border: 0; background: transparent; color: var(--sand); opacity: .45; font: 700 11px var(--body); cursor: pointer; }
.credits-link:hover, .credits-link:focus-visible { opacity: .9; }
.credit-list { list-style: none; display: grid; gap: 8px; margin: 14px 0 6px; text-align: center; font-size: 14px; font-weight: 700; color: var(--sand); }
.credit-list li { direction: ltr; unicode-bidi: plaintext; }
.credit-list li:last-child { direction: rtl; color: var(--cream); }

/* أزرار المشاركة والاقتراح في القائمة */
.menu-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pill-btn { padding: 8px 16px; border: 1.5px solid rgba(243, 213, 162, 0.4); border-radius: 999px; background: rgba(62, 32, 14, 0.55); color: var(--cream); font: 800 13px var(--body); cursor: pointer; backdrop-filter: blur(4px); transition: transform .08s, background .15s; }
.pill-btn:active { transform: translateY(2px); }
.pill-btn:hover { background: rgba(62, 32, 14, 0.8); }

/* لوحة المشاركة */
.share-msg { font-size: 14px; font-weight: 700; color: var(--sand); line-height: 1.6; margin: 8px 0 14px; max-width: 320px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 330px; margin: 0 auto 8px; }
.share-btn { padding: 12px 8px; border: 0; border-radius: 14px; background: var(--c, #8a6a4c); color: #fff; font: 800 15px var(--body); cursor: pointer; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); transition: transform .08s, box-shadow .08s; }
.share-btn:active { transform: translateY(4px); box-shadow: 0 0 0 transparent; }
.share-note { min-height: 20px; margin: 6px 0; font-size: 13px; font-weight: 700; color: var(--gold); }

/* نموذج الاقتراحات */
#suggestForm { width: min(92vw, 380px); }
#suggestForm textarea, #suggestForm input:not([type=radio]) { width: 100%; margin-top: 8px; padding: 10px 12px; border: 0; border-radius: 12px; background: #F4EAD2; color: var(--date); font: 700 15px var(--body); resize: vertical; }
.kinds { display: flex; gap: 8px; justify-content: center; margin: 10px 0 2px; }
.kinds label { cursor: pointer; }
.kinds input { position: absolute; opacity: 0; pointer-events: none; }
.kinds span { display: block; padding: 7px 14px; border-radius: 999px; background: rgba(243, 213, 162, 0.16); color: var(--sand); font: 800 13px var(--body); border: 1.5px solid transparent; }
.kinds input:checked + span { background: var(--gold); color: var(--date); }
.kinds input:focus-visible + span { border-color: var(--cream); }

/* المحاولات (قلوب) */
.lives { display: flex; gap: 4px; direction: ltr; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.life { width: 28px; height: 28px; transition: transform .2s, opacity .3s, filter .3s; }
.life svg { width: 100%; height: 100%; }
.life.off { opacity: .28; filter: grayscale(1); transform: scale(.85); }
.life.pop { animation: lifePop .5s ease-out; }
@keyframes lifePop { 0% { transform: scale(.4); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* صورة عند البرج */
.photo-bar { position: fixed; left: 0; right: 0; bottom: max(22px, env(safe-area-inset-bottom)); z-index: 20; display: flex; gap: 12px; justify-content: center; padding: 0 16px; }
.photo-bar[hidden] { display: none; }
.photo-panel video { display: block; max-width: 100%; max-height: 58vh; margin: 0 auto 14px; border-radius: 14px; box-shadow: 0 6px 22px rgba(0,0,0,.4); background: #000; }
.photo-panel video[hidden], .photo-panel img[hidden] { display: none; }
.rec-ind { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 30; padding: 8px 18px; border-radius: 999px; background: rgba(200,30,20,.92); color: #fff; font: 800 16px var(--body); box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.rec-ind[hidden] { display: none; }
.photo-panel img { display: block; max-width: 100%; max-height: 58vh; margin: 0 auto 14px; border-radius: 14px; box-shadow: 0 6px 22px rgba(0,0,0,.4); }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 60; }
.flash.on { animation: flashShot .4s ease-out; }
@keyframes flashShot { 0% { opacity: .9; } 100% { opacity: 0; } }

/* حقل الاسم على القميص */
.name-field { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 330px; padding: 6px 12px; border-radius: 14px; background: rgba(62, 32, 14, 0.55); border: 1.5px solid rgba(243, 213, 162, 0.3); backdrop-filter: blur(4px); }
.name-field span { flex: 0 0 auto; font: 800 13px var(--body); color: var(--sand); }
.name-field input { flex: 1; min-width: 0; padding: 7px 10px; border: 0; border-radius: 10px; background: #F4EAD2; color: var(--date); font: 800 15px var(--body); text-align: center; }
.name-field input::placeholder { color: rgba(110, 70, 30, 0.55); }
.photo-bar { flex-direction: column; align-items: center; }
.photo-btns { display: flex; gap: 12px; justify-content: center; width: 100%; }

/* الجوال: ترتيب شاشة اللعب. شريطا السباق في صف علوي بجانب زر الإيقاف، ثم صف واحد للنقاط والتمر والقلوب */
@media (max-width: 640px) {
  .race { top: calc(var(--safe-t) + 18px); left: 14px; right: 74px; width: auto; transform: none; gap: 4px; }
  .r-row span { font-size: 11px; }
  .hud-stats { position: absolute; top: calc(var(--safe-t) + 74px); left: 14px; right: 14px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px; }
  html[dir="rtl"] .hud-stats { align-items: center; }
  .score-pill { font-size: 26px; min-width: 0; padding: 6px 14px 2px; }
  .dates-pill { font-size: 20px; padding: 6px 12px 2px; }
  .lives { margin-inline-start: auto; gap: 3px; }
  .life { width: 24px; height: 24px; }
  .hint { top: calc(var(--safe-t) + 132px); }
  .photo-bar .name-field { max-width: 92vw; }
}

/* زر الإيقاف: الخطان في منتصف الزر تماماً */
.pause-btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0; }
.pause-btn i { margin: 0; flex: 0 0 auto; }

/* عدّادات اللعب: عرض ثابت وأرقام متساوية العرض، فلا تتغير أحجامها ولا يتحرك ما حولها (القلوب وغيرها) عند تغيّر الرقم */
.hud .pill { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; justify-content: center; flex: 0 0 auto; }
.score-pill { width: 132px; min-width: 132px; }
.dates-pill { width: 96px; min-width: 96px; }
.hud-stats { min-width: 132px; }
.lives { min-height: 28px; flex: 0 0 auto; }
@media (max-width: 640px) {
  .score-pill { width: 112px; min-width: 112px; }
  .dates-pill { width: 84px; min-width: 84px; }
}

/* قائمة مختصرة: عناصر أقل وأصغر ليظهر اللاعب والخيل والذئب */
.menu-bottom { gap: 8px; }
.picker { padding: 4px 6px; border-radius: 16px; }
.arrow { width: 38px; height: 38px; border-radius: 12px; font-size: 28px; padding-bottom: 4px; }
.char-info { gap: 0; }
.char-info strong { font-size: 19px; }
.char-info .char-sub { font-size: 11px; }
.name-field { padding: 4px 8px; border-radius: 12px; max-width: 100%; }
.name-field input { padding: 6px 8px; font-size: 14px; }
.btn { font-size: 24px; padding: 11px 16px 7px; border-radius: 18px; }
.menu-actions { gap: 6px; }
.menu-actions .pill-btn { padding: 6px 12px; font-size: 12px; }
.best-pill { display: inline-flex; align-items: center; gap: 4px; cursor: default; }
.best-pill b { font-family: var(--display); font-weight: 400; font-size: 14px; color: var(--cream); }
.logo { font-size: clamp(46px, 13vw, 84px); }
.menu { padding-bottom: calc(var(--safe-b) + 14px); }
@media (max-width: 640px) {
  .menu { padding-left: 14px; padding-right: 14px; }
  .welcome { margin-top: 8px; padding: 6px 8px 6px 10px; gap: 8px; border-radius: 14px; }
  .w-text span { display: none; }
  .w-text strong { font-size: 15px; }
  .w-link { padding: 6px 10px; font-size: 12px; }
  .brand .tagline { display: none; }
}

/* اختيار المرحلة في القائمة */
.level-pick { display: flex; gap: 8px; width: 100%; max-width: 330px; justify-content: center; }
.level-pick[hidden] { display: none; }
.lv-chip { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 8px; border-radius: 14px; border: 1.5px solid rgba(243, 213, 162, 0.3); background: rgba(62, 32, 14, 0.55); color: var(--sand); font: 800 13px var(--body); cursor: pointer; backdrop-filter: blur(4px); }
.lv-chip small { font: 700 11px var(--body); opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lv-chip.on { background: #F4EAD2; color: var(--date); border-color: #fff; }
.lv-chip.lock { opacity: 0.6; }
.lv-chip svg { width: 13px; height: 13px; vertical-align: -2px; }
.lv-chip.dev::after { content: 'مطوّر'; font: 700 10px var(--body); background: #2f6b3a; color: #fff; border-radius: 8px; padding: 0 6px; margin-top: 2px; }

/* ========== قائمة احترافية: بطاقات المراحل (2026-10-20) ========== */
.menu-bottom {
  max-width: 440px; gap: 10px; padding: 12px 12px 10px;
  background: linear-gradient(180deg, rgba(48, 22, 8, 0.50), rgba(34, 15, 5, 0.66));
  border: 1px solid rgba(255, 240, 210, 0.16); border-radius: 28px;
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 -8px 40px rgba(30, 12, 2, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  animation: sheetUp 0.6s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}
.menu-bottom .picker { background: rgba(255, 247, 230, 0.08); backdrop-filter: none; -webkit-backdrop-filter: none; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.lv-wrap { width: calc(100% + 24px); margin: 0 -12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.lv-track {
  display: flex; gap: 10px; width: 100%; overflow-x: auto; overflow-y: hidden; padding: 4px 19% 8px;
  scroll-snap-type: x mandatory; scroll-padding: 0 19%; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; outline: none;
}
.lv-track::-webkit-scrollbar { display: none; }
.lv-card {
  position: relative; flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; min-height: 100px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 10px 10px 12px;
  border-radius: 22px; color: #fff; text-align: center; overflow: hidden; isolation: isolate;
  background: linear-gradient(165deg, var(--c1), var(--c2) 60%, var(--c3));
  border: 2px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 6px 18px rgba(20, 8, 2, 0.35);
  transform: scale(0.88); opacity: 0.72; transition: transform 0.3s cubic-bezier(0.2, 0.85, 0.25, 1), opacity 0.3s, border-color 0.3s;
}
.lv-card::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.42)); }
.lv-card.on { transform: scale(1); opacity: 1; border-color: #fff; box-shadow: 0 8px 26px rgba(20, 8, 2, 0.5), 0 0 0 3px rgba(242, 182, 48, 0.55); }
.lv-num { font: 400 34px/1 var(--display); text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.lv-name { font: 400 22px/1.1 var(--display); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.lv-sub { font: 700 12px/1.3 var(--body); opacity: 0.92; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lv-state { margin-top: 3px; font: 800 12px var(--body); padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); }
.lv-card.done .lv-state { background: rgba(63, 122, 58, 0.85); }
.lv-lockico { display: none; position: absolute; top: 8px; inset-inline-start: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, 0.5); place-items: center; }
.lv-lockico svg { width: 16px; height: 16px; color: #fff; }
.lv-card.lock { background: linear-gradient(165deg, #5d5750, #3c3631); border-color: rgba(255, 255, 255, 0.16); }
.lv-card.lock::before { background: linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.35)); }
.lv-card.lock .lv-num, .lv-card.lock .lv-name, .lv-card.lock .lv-sub { opacity: 0.55; filter: blur(0.6px); }
.lv-card.lock .lv-lockico { display: grid; }
.lv-card.lock .lv-state { background: rgba(242, 182, 48, 0.92); color: var(--date); }
.lv-badge { position: absolute; top: 9px; inset-inline-end: 9px; font: 800 11px var(--body); padding: 1px 9px; border-radius: 999px; background: var(--gold); color: var(--date); display: none; }
.lv-card.new .lv-badge, .lv-card.dev .lv-badge { display: block; }
.lv-card.dev .lv-badge { background: #2f6b3a; color: #fff; }
.lv-card.new.on { animation: lvGlow 1.6s ease-in-out infinite; }
@keyframes lvGlow { 50% { box-shadow: 0 8px 26px rgba(20, 8, 2, 0.5), 0 0 0 6px rgba(242, 182, 48, 0.8); } }
.lv-card.shake { animation: lvShake 0.4s; }
@keyframes lvShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.lv-dots { display: flex; gap: 6px; }
.lv-dots i { width: 7px; height: 7px; border-radius: 99px; background: rgba(255, 247, 230, 0.35); transition: width 0.25s, background 0.25s; cursor: pointer; }
.lv-dots i.done { background: #7fd07a; }
.lv-dots i.lock { background: rgba(255, 247, 230, 0.18); }
.lv-dots i.on { width: 20px; background: var(--gold); }

.btn-primary.locked { background: #6e5a49; color: #f2e2c4; font-size: 18px; box-shadow: 0 6px 0 #45362a; }
.menu-bottom .btn { min-height: 52px; }

/* قائمة «المزيد» */
.menu-actions { position: relative; align-items: center; }
.more-pop { position: absolute; bottom: calc(100% + 8px); inset-inline-end: 0; display: flex; flex-direction: column; min-width: 150px; padding: 6px; border-radius: 16px; background: rgba(40, 18, 6, 0.94); border: 1px solid rgba(255, 240, 210, 0.2); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); z-index: 5; animation: sheetUp 0.18s ease-out both; }
.more-pop button { padding: 12px 14px; border-radius: 10px; text-align: start; font: 800 14px var(--body); color: var(--cream); min-height: 44px; }
.more-pop button:active { background: rgba(255, 247, 230, 0.14); }
.menu-actions .pill-btn { min-height: 36px; }

/* لمس iPhone: أهداف 44pt، ضغط محسوس، لا تحديد */
.btn, .pill-btn, .icon-btn, .lv-card { touch-action: manipulation; -webkit-touch-callout: none; }
.lv-card:active { transform: scale(0.97); }
.lv-card.on:active { transform: scale(0.985); }
@media (prefers-reduced-motion: reduce) {
  .menu-bottom, .lv-card, .more-pop { animation: none !important; transition: none !important; }
  .lv-track { scroll-behavior: auto; }
}
@media (max-height: 640px) { .lv-card { min-height: 92px; } .lv-num { font-size: 30px; } .lv-name { font-size: 18px; } .lv-sub { display: none; } }

/* ===== نسخة مدمجة: تُظهر اللاعب، وبطاقات بصور من المراحل (2026-10-20) ===== */
.menu-bottom { gap: 8px; padding: 10px 10px 8px; border-radius: 24px; background: linear-gradient(180deg, rgba(48, 22, 8, 0.38), rgba(34, 15, 5, 0.58)); }
.lv-wrap { width: calc(100% + 20px); margin: 0 -10px; gap: 5px; }
.lv-track { padding: 2px 12% 4px; scroll-padding: 0 12%; gap: 8px; }
.lv-card { min-height: 0; height: 96px; justify-content: flex-end; align-items: stretch; padding: 8px 10px; background-size: cover; background-position: center; border-radius: 18px; transform: scale(0.92); }
.lv-card::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.78)), var(--img) center / cover; }
.lv-bot { display: flex; align-items: center; gap: 8px; }
.lv-num { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--date); font: 400 19px/1 var(--display); padding-top: 3px; text-shadow: none; }
.lv-name { font: 400 22px/1 var(--display); text-align: start; padding-top: 3px; }
.lv-state { position: absolute; top: 7px; inset-inline-end: 7px; margin: 0; font-size: 11px; padding: 2px 9px; }
.lv-badge { top: 7px; inset-inline-start: 7px; inset-inline-end: auto; }
.lv-lockico { top: 6px; inset-inline-start: 6px; width: 28px; height: 28px; }
.lv-card.lock::before { filter: grayscale(0.95) brightness(0.55); background: linear-gradient(180deg, rgba(0, 0, 0, 0.1) 30%, rgba(0, 0, 0, 0.8)), var(--img) center / cover; }
.lv-card.lock { border-color: rgba(255, 255, 255, 0.18); }
.lv-card.lock .lv-num, .lv-card.lock .lv-name { opacity: 1; filter: none; }
.lv-card.lock .lv-num { background: #cfc6b8; }
.lv-card.on { transform: scale(1); }
.lv-dots i { width: 6px; height: 6px; } .lv-dots i.on { width: 16px; }
.opt-row { display: flex; gap: 8px; width: 100%; align-items: stretch; }
.opt-row .picker, .opt-row .name-field { flex: 1 1 0; min-width: 0; margin: 0; }
.opt-row .picker { padding: 3px 4px; border-radius: 14px; }
.opt-row .picker .arrow { width: 32px; height: 32px; font-size: 22px; padding-bottom: 3px; flex: none; }
.opt-row .char-info strong { font-size: 16px; white-space: nowrap; }
.opt-row .name-field { display: flex; align-items: center; padding: 3px 6px; border-radius: 14px; }
.opt-row .name-field input { width: 100%; padding: 6px 6px; font-size: 13px; min-height: 30px; }
.menu-bottom .btn { min-height: 48px; font-size: 22px; padding: 9px 14px 6px; }
.btn-primary.locked { font-size: 17px; }
.menu-actions { gap: 6px; flex-wrap: nowrap; }
.menu-actions .pill-btn { padding: 4px 12px; font-size: 12px; min-height: 30px; }
@media (max-height: 760px) { .lv-card { height: 84px; } .lv-name { font-size: 19px; } .tagline { display: none; } }

/* ===== البدء من بطاقة المرحلة نفسها + أيقونات صغيرة (2026-10-20) ===== */
#btnStart:not(.keep) { display: none; }
.lv-play { position: absolute; bottom: 8px; inset-inline-end: 9px; width: 38px; height: 38px; border-radius: 50%; display: none; place-items: center; color: #fff; background: linear-gradient(160deg, #ff8a4a, var(--dune) 55%, var(--dune-deep)); box-shadow: 0 3px 0 rgba(90, 30, 8, 0.7), 0 6px 14px rgba(0, 0, 0, 0.4); border: 2px solid rgba(255, 255, 255, 0.9); }
.lv-play svg { width: 18px; height: 18px; margin-inline-start: 2px;; }
.lv-card.on:not(.lock) .lv-play { display: grid; animation: playPulse 2.2s ease-in-out infinite; }
@keyframes playPulse { 50% { box-shadow: 0 3px 0 rgba(90, 30, 8, 0.7), 0 0 0 7px rgba(255, 255, 255, 0.28); } }
.lv-card.on:not(.lock):active .lv-play { transform: scale(0.92); }
.lv-card.loading .lv-play { background: conic-gradient(var(--gold) var(--p, 5%), rgba(30, 14, 4, 0.7) 0); animation: none; }
.lv-card.loading .lv-play svg { opacity: 0.35; }
.lv-card.on:not(.lock):not(.loading) { cursor: pointer; }
.lv-bot { padding-inline-end: 44px; }
.menu-actions { justify-content: space-between; width: 100%; padding: 0 4px; gap: 8px; }
.act-gap { flex: 1; }
.best-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 3px; border-radius: 999px; background: rgba(255, 247, 230, 0.1); border: 1px solid rgba(255, 240, 210, 0.18); color: var(--gold); }
.best-pill svg { width: 18px; height: 18px; margin-top: -2px; }
.best-pill b { font: 400 17px/1 var(--display); color: var(--cream); }
.ic-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--cream); background: rgba(255, 247, 230, 0.1); border: 1px solid rgba(255, 240, 210, 0.18); touch-action: manipulation; transition: background 0.15s, transform 0.1s; }
.ic-btn svg { width: 20px; height: 20px; }
.ic-btn:active { background: rgba(255, 247, 230, 0.24); transform: scale(0.93); }
