@font-face {
  font-family: "Lalezar";
  src: url("../fonts/lalezar-arabic.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #2b1a0d;
  --panel: rgba(38, 22, 10, 0.62);
  --line: rgba(255, 226, 170, 0.22);
  --cream: #fdf0d2;
  --sand: #f3d9a4;
  --amber: #f0a534;
  --amber-deep: #c9741a;
  --palm: #3f9a5a;
  --red: #e2483d;
  --display: "Lalezar", "Segoe UI", Tahoma, sans-serif;
  --body: "Segoe UI", Tahoma, "Dubai", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c120a; color: var(--cream); font-family: var(--body); }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
kbd {
  display: inline-block; min-width: 1.9em; padding: .12em .45em; margin: 0 .12em; text-align: center;
  font: 600 .85em/1.5 "Segoe UI", sans-serif; color: var(--ink); background: var(--sand);
  border-radius: .4em; box-shadow: 0 2px 0 var(--amber-deep);
}

/* ───── شريط المعلومات ───── */
#hud {
  position: fixed; inset: 0 0 auto 0; padding: 18px 22px; display: flex; justify-content: space-between;
  align-items: flex-start; gap: 14px; pointer-events: none; z-index: 5;
}
.hud-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 18px;
  backdrop-filter: blur(6px); box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.score-box { min-width: 150px; }
.label { font-size: 13px; opacity: .8; letter-spacing: .02em; }
.big { font-family: var(--display); font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; color: #fff; }
.mult { font-family: var(--display); font-size: 20px; color: var(--amber); height: 24px; transition: transform .15s; }
.mult.hot { transform: scale(1.25); color: #ffd35a; }
.level-box { min-width: 300px; text-align: center; }
.lvl-line { font-family: var(--display); font-size: 24px; line-height: 1.2; }
.lvl-line .dot { margin: 0 .45em; color: var(--amber); }
#lvlName { color: var(--amber); }
.bar { height: 10px; margin: 8px 0 6px; background: rgba(255, 255, 255, .14); border-radius: 99px; overflow: hidden; direction: rtl; }
#bar { height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(270deg, var(--amber-deep), #ffd35a); transition: width .2s; }
.dates-line { display: flex; align-items: center; justify-content: center; gap: .35em; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dates-line .slash { opacity: .5; }
.dates-line .unit { opacity: .8; font-weight: 400; margin-inline-start: .2em; }
.ico-date { width: 20px; height: 20px; }
.side-box { min-width: 150px; text-align: left; }
#hearts { display: flex; gap: 5px; justify-content: flex-end; direction: ltr; }
#hearts svg { width: 28px; height: 28px; fill: var(--red); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); transition: transform .25s, fill .25s, opacity .25s; }
#hearts svg.off { fill: #6b5a4b; opacity: .55; transform: scale(.8); }
.speed { margin-top: 4px; font-family: var(--display); font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.speed small { font-family: var(--body); font-size: 13px; opacity: .8; margin-inline-start: .35em; }

#demoBadge {
  position: fixed; bottom: 22px; inset-inline: 0; margin-inline: auto; width: max-content; max-width: 92vw; z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 10px 22px;
  font-weight: 600; font-size: 17px; backdrop-filter: blur(6px); display: flex; align-items: center; gap: .6em; pointer-events: none;
}
#demoBadge small { font-weight: 400; opacity: .85; margin-inline-start: .6em; }
.rec { width: 11px; height: 11px; border-radius: 50%; background: var(--red); animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: .25; } }

#hint {
  position: fixed; bottom: 26px; inset-inline: 0; margin-inline: auto; width: max-content; max-width: 92vw; z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 9px 18px; font-size: 16px;
  pointer-events: none; animation: fadeHint 6s forwards;
}
@keyframes fadeHint { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }

/* ───── لافتة المرحلة ───── */
#banner {
  position: fixed; top: 27%; inset-inline: 0; text-align: center; z-index: 7; pointer-events: none;
  opacity: 0; transform: scale(.85); transition: opacity .35s, transform .35s;
}
#banner.show { opacity: 1; transform: scale(1); }
#banner h2 { margin: 0; font-family: var(--display); font-size: clamp(54px, 9vw, 112px); line-height: 1; color: #fff; text-shadow: 0 5px 0 var(--amber-deep), 0 10px 30px rgba(0, 0, 0, .45); }
#banner p { margin: 10px 0 0; font-size: clamp(18px, 2.4vw, 28px); font-weight: 600; color: var(--cream); text-shadow: 0 2px 10px rgba(0, 0, 0, .6); }

#popups { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.pop {
  position: absolute; transform: translate(-50%, -50%); font-family: var(--display); font-size: 30px; color: #ffe08a;
  text-shadow: 0 2px 0 #7a4300, 0 4px 12px rgba(0, 0, 0, .5); white-space: nowrap; animation: pop .9s ease-out forwards;
}
.pop.gold { color: #fff3b0; font-size: 42px; }
.pop.bad { color: #ff8478; text-shadow: 0 2px 0 #6b0f08, 0 4px 12px rgba(0, 0, 0, .5); font-size: 36px; }
.pop.air { color: #bfe9ff; text-shadow: 0 2px 0 #124a6b, 0 4px 12px rgba(0, 0, 0, .5); }
@keyframes pop { 0% { opacity: 0; margin-top: 0; scale: .6; } 15% { opacity: 1; scale: 1.15; } 100% { opacity: 0; margin-top: -90px; scale: 1; } }

#flash { position: fixed; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(ellipse at center, transparent 45%, rgba(226, 40, 30, .55)); opacity: 0; transition: opacity .4s; }
#flash.on { opacity: 1; transition: none; }

/* ───── الشاشات ───── */
.screen {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at center, rgba(28, 16, 6, .25), rgba(28, 16, 6, .7));
}
.card {
  width: min(620px, 100%); text-align: center; padding: 30px 36px 26px; border-radius: 26px;
  background: linear-gradient(180deg, rgba(58, 34, 14, .88), rgba(34, 19, 8, .92));
  border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 230, 180, .15);
  backdrop-filter: blur(8px);
}
.card.small { width: min(480px, 100%); }
.kicker { margin: 0; font-size: 15px; letter-spacing: .04em; color: var(--amber); font-weight: 600; }
h1 { margin: 2px 0 0; font-family: var(--display); font-weight: 400; font-size: clamp(84px, 15vw, 150px); line-height: 1.05; color: #fff; text-shadow: 0 6px 0 var(--amber-deep), 0 14px 34px rgba(0, 0, 0, .5); }
.card h2 { margin: 4px 0 14px; font-family: var(--display); font-weight: 400; font-size: 58px; line-height: 1.1; color: #fff; text-shadow: 0 4px 0 var(--amber-deep); }
.tag { margin: 4px 0 20px; font-size: 19px; color: var(--cream); }
.btns { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn {
  font: 400 23px/1 var(--display); padding: 14px 26px 12px; border-radius: 14px; cursor: pointer; color: var(--cream);
  background: rgba(255, 226, 170, .12); border: 1px solid var(--line); transition: transform .12s, background .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-2px); background: rgba(255, 226, 170, .2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn.primary { color: var(--ink); background: linear-gradient(180deg, #ffd35a, var(--amber)); border-color: transparent; box-shadow: 0 5px 0 var(--amber-deep), 0 12px 24px rgba(0, 0, 0, .3); font-size: 27px; padding-inline: 38px; }
.btn.primary:hover { background: linear-gradient(180deg, #ffe07f, #f7b347); }
.btn.primary:active { box-shadow: 0 2px 0 var(--amber-deep); transform: translateY(3px); }
.btn.ghost { font-family: var(--body); font-size: 16px; font-weight: 600; padding: 14px 18px; }
.keys { list-style: none; margin: 22px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: center; font-size: 15px; }
.keys li { display: flex; align-items: center; gap: .3em; }
.keys b { margin-inline-start: .35em; color: var(--sand); font-weight: 600; }
.best { margin: 16px 0 0; font-size: 16px; opacity: .9; }
.best b { font-family: var(--display); font-size: 22px; color: var(--amber); font-weight: 400; margin-inline-start: .3em; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 18px; }
.stats div { background: rgba(255, 226, 170, .08); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.stats span { display: block; font-size: 14px; opacity: .8; }
.stats b { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; }
.newbest { margin: -4px 0 16px; font-family: var(--display); font-size: 24px; color: #ffd35a; }

@media (max-width: 760px) {
  #hud { padding: 10px; gap: 8px; }
  .hud-box { padding: 8px 10px; border-radius: 12px; }
  .score-box, .side-box { min-width: 0; }
  .level-box { min-width: 0; flex: 1; }
  .big { font-size: 30px; } .lvl-line { font-size: 18px; } .speed { font-size: 22px; }
  #hearts svg { width: 20px; height: 20px; }
  .card { padding: 22px 18px; }
}
@media (prefers-reduced-motion: reduce) { .pop, .rec, #hint { animation-duration: .01s; } }

@media (min-width: 1100px) {
  #menu { justify-items: start; padding-inline-start: 6vw; background: linear-gradient(to left, rgba(28, 16, 6, .72), rgba(28, 16, 6, .05) 62%); }
}

/* ───── الجوال: شاشة تتمرّر + أزرار لمس (إضافة بدون تغيير اللعبة) ───── */
.screen { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen .card { margin: auto; }
@media (max-height: 520px) {
  h1 { font-size: 64px; } .card { padding: 14px 18px; } .tag { margin: 2px 0 10px; font-size: 15px; }
  .card h2 { font-size: 40px; margin-bottom: 8px; } .btn { font-size: 19px; padding: 10px 18px 8px; } .btn.primary { font-size: 21px; }
}
#touch { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: none; justify-content: space-between; padding: 0 18px calc(18px + env(safe-area-inset-bottom)); pointer-events: none; direction: ltr; }
#touch.on { display: flex; }
#touch button {
  pointer-events: auto; width: min(32vw, 150px); height: min(32vw, 150px); max-height: 30vh; border-radius: 28px; border: 2px solid rgba(255, 226, 170, .45);
  background: rgba(40, 22, 8, .55); color: #ffe7b0; font-size: 64px; line-height: 1; backdrop-filter: blur(4px);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
#touch button.down { background: rgba(255, 190, 70, .8); color: #2a1604; transform: scale(.95); }
