@font-face { font-family: "Reem Kufi"; src: url(assets/fonts/ReemKufi-Var.ttf) format("truetype"); font-weight: 400 700; font-display: block; }
@font-face { font-family: "Plex"; src: url(assets/fonts/IBMPlexSansArabic-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: block; }
@font-face { font-family: "Plex"; src: url(assets/fonts/IBMPlexSansArabic-Bold.ttf) format("truetype"); font-weight: 700; font-display: block; }
/* title + Abu's speech: easier to read than Reem Kufi (his request) */
@font-face { font-family: "Lalezar"; src: url(assets/fonts/Lalezar-Regular.ttf) format("truetype"); font-weight: 400; font-display: block; }
@font-face { font-family: "Tajawal"; src: url(assets/fonts/Tajawal-ExtraBold.ttf) format("truetype"); font-weight: 800; font-display: block; }

:root {
  --sand: #f1ead2;
  --panel: #1c2414;
  --panel-2: #2a361e;
  --line: #4a5c34;
  --accent: #e8802c;
  --accent-d: #9c4b12;
  --bad: #c0392b;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #18200f;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
body { font-family: "Plex", system-ui, sans-serif; font-weight: 600; color: var(--sand); }
canvas { position: fixed; inset: 0; display: block; }
body.aim canvas { cursor: none; }
#sat { position: fixed; top: 0; height: var(--sat); width: 1px; visibility: hidden; }
#sab { position: fixed; bottom: 0; height: var(--sab); width: 1px; visibility: hidden; }

#app { position: fixed; top: 0; bottom: 0; left: 0; width: 100%; pointer-events: none; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sat) + 64px) 14px calc(var(--sab) + 14px);
  box-sizing: border-box;
  opacity: 0; transition: opacity .25s ease;
}
.screen.show { opacity: 1; pointer-events: auto; }

.panel {
  width: min(100%, 370px); box-sizing: border-box;
  background: rgba(26, 34, 18, .96); border: 1px solid var(--line); border-radius: 20px;
  padding: 14px 16px 10px; text-align: center;
  box-shadow: 0 10px 28px rgba(8, 12, 4, .45);
}
.panel h2 { margin: 0 0 12px; font-family: "Reem Kufi", serif; font-weight: 700; font-size: 21px; color: #fbf5e2; }

/* ---------- menu ---------- */
/* box sits above Safari's bottom bar and below his chest */
#menu { justify-content: flex-end; padding-top: calc(var(--sat) + 12px); padding-bottom: calc(var(--sab) * 1.33 + min(77px, 9.3vh)); }
#menu .panel { padding: 10px 14px 6px; }
.logo { position: relative; text-align: center; margin: 0 0 8px; }
.logo .scope {
  display: block; margin: 0 auto; width: 32px; height: 32px; color: #fbf5e2; --dot: var(--accent);
}
.logo h1 {
  margin: 2px 0 0; font-family: "Lalezar", "Plex", sans-serif; font-weight: 400;
  font-size: clamp(38px, 11.5vw, 50px); line-height: 1.2; color: #fbf5e2;
  text-shadow: 0 3px 0 #9c4b12;
}
.logo h1 span { color: var(--accent); text-shadow: 0 3px 0 #3a1a05; }
.logo .rifle { display: block; width: 72%; height: auto; margin: 2px auto 0; }
.logo .en {
  margin: 8px 0 0; font: 700 12px/1 system-ui, sans-serif; letter-spacing: .32em;
  color: #fbf5e2; opacity: .9; direction: ltr; padding-left: .32em;
  display: flex; align-items: center; justify-content: center;
}
.logo .en .o { width: 13px; height: 13px; color: #fbf5e2; --dot: var(--accent); margin-right: .32em; flex: none; }
.how { display: flex; gap: 8px; margin-bottom: 10px; }
.how div {
  flex: 1 1 0; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); border-radius: 14px; padding: 6px 5px 7px; font-size: clamp(12px, 3.55vw, 14px); color: #ece3c8;
  white-space: nowrap;
}
.how img { height: 30px; width: auto; flex: none; }
#menu .btn { margin-bottom: 8px; padding: 12px 10px; }
.how div.no { box-shadow: inset 0 0 0 2px rgba(192, 57, 43, .6); }

.btn {
  display: block; width: 100%; margin: 0 0 10px; padding: 13px 10px;
  border: 0; border-radius: 14px; cursor: pointer;
  font: 700 20px/1.2 "Plex", system-ui, sans-serif;
  background: var(--panel-2); color: var(--sand); box-shadow: 0 4px 0 #0e1309;
}
.btn.primary { background: var(--accent); color: #1f0e03; box-shadow: 0 4px 0 var(--accent-d); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0e1309; }
.btn.primary:active { box-shadow: 0 1px 0 var(--accent-d); }
.best { margin: 2px 0 2px; font-size: 14px; color: #c9c09f; }
.best b { color: #fbf5e2; font-size: 16px; }

/* ---------- in-game HUD ---------- */
#hud {
  position: absolute; top: calc(var(--sat) + 10px); right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  opacity: 0; transition: opacity .2s;
}
#hud.show { opacity: 1; }
.hud-r { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.hud-r .row { display: flex; gap: 6px; align-items: center; }
#scoreBox {
  display: flex; align-items: center; gap: 6px;
  background: rgba(26, 34, 18, .92); border: 1px solid var(--line); border-radius: 14px;
  padding: 2px 12px 3px;
}
#score { font-family: "Reem Kufi", serif; font-weight: 700; font-size: 30px; line-height: 1.2; color: #fbf5e2; display: inline-block; }
#score.pop { animation: pop .18s ease-out; }
@keyframes pop { 50% { transform: scale(1.2); } }
#combo { display: none; font: 700 15px/1 "Plex", sans-serif; color: #1f0e03; background: #f2c14b; border-radius: 999px; padding: 4px 8px 5px; }
#combo.show { display: inline-block; }
#hearts { display: flex; gap: 3px; padding: 0 4px; }
#hearts svg { width: 22px; height: 22px; display: block; filter: drop-shadow(0 1px 0 rgba(10, 14, 4, .7)); }
#hearts svg path { fill: #d9443a; stroke: #4a160f; stroke-width: 1.4; }
#hearts svg.off path { fill: #3d4632; stroke: #1c2414; }
#hearts svg.hit { animation: hit .5s ease-out; }
#hearts svg.gain { animation: pop .35s ease-out; }
@keyframes hit { 20% { transform: scale(1.4); } 40% { transform: scale(.8) rotate(-10deg); } 70% { transform: rotate(8deg); } }
#lvl, #left {
  padding: 5px 12px 6px; border-radius: 999px;
  background: rgba(26, 34, 18, .92); border: 1px solid var(--line);
  font-size: 15px; color: #fbf5e2;
}
#left { display: flex; align-items: center; gap: 5px; padding: 3px 10px 4px 12px; }
#left img { height: 20px; width: auto; display: block; }
#left b { font-family: "Reem Kufi", serif; font-size: 17px; line-height: 1.2; }

#ammo {
  position: absolute; right: 12px; bottom: calc(var(--sab) + 12px);
  display: flex; gap: 3px; align-items: flex-end;
  padding: 7px 10px 6px; border-radius: 14px;
  background: rgba(26, 34, 18, .9); border: 1px solid var(--line);
  opacity: 0; transition: opacity .2s;
}
#ammo.show { opacity: 1; }
#ammo svg { width: 11px; height: 32px; display: block; transition: opacity .12s, transform .12s; }
#ammo svg.spent { opacity: .22; transform: translateY(3px); }
#ammo.reload svg { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }

#bubble {
  position: absolute; top: 0; left: 0; max-width: 72%;
  background: #fffaf0; color: #1f2410; border: 2px solid #1c2414; border-radius: 16px;
  padding: 7px 14px 7px; font: 800 20px/1.35 "Tajawal", "Plex", sans-serif; white-space: nowrap;
  transform: translateY(-100%) scale(.6); transform-origin: 30px 100%;
  opacity: 0; transition: opacity .15s, transform .15s;
}
#bubble::after {
  content: ""; position: absolute; bottom: -12px; left: 26px;
  border-width: 12px 9px 0 0; border-style: solid; border-color: #1c2414 transparent transparent transparent;
}
#bubble::before {
  content: ""; position: absolute; bottom: -8px; left: 28px; z-index: 1;
  border-width: 9px 6px 0 0; border-style: solid; border-color: #fffaf0 transparent transparent transparent;
}
#bubble.show { opacity: 1; transform: translateY(-100%) scale(1); }
#bubble.bad { background: #ffe9e2; }
#bubble.bad::before { border-top-color: #ffe9e2; }

#banner {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.8);
  min-width: 190px; text-align: center; white-space: nowrap;
  background: rgba(26, 34, 18, .95); border: 1px solid var(--line); border-radius: 18px;
  padding: 10px 22px 12px; opacity: 0; transition: opacity .2s, transform .2s;
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner b { display: block; font: 700 30px/1.3 "Reem Kufi", serif; color: #fbf5e2; }
#banner span { display: block; font-size: 15px; color: #e2d6b0; }
#banner span:empty { display: none; }

/* ---------- game over ---------- */
#over { justify-content: center; padding-top: calc(var(--sat) + 14px); background: rgba(10, 14, 6, .35); }
#over .panel { padding: 20px 18px 10px; }
#over h2 { font-size: 32px; margin-bottom: 14px; }
.stats { display: flex; gap: 10px; margin-bottom: 10px; }
.stats div { flex: 1; background: var(--panel-2); border-radius: 14px; padding: 10px 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.stats span { font-size: 14px; color: #c9c09f; }
.stats b { font-family: "Reem Kufi", serif; font-size: 40px; line-height: 1.1; color: #fbf5e2; }
.reached { margin: 0 0 12px; font-size: 15px; color: #c9c09f; }
.reached b { color: #fbf5e2; }
#newBest {
  display: none; margin: -2px auto 14px; padding: 5px 14px; width: fit-content;
  border-radius: 999px; background: #f2c14b; color: #2a1505; font-weight: 700; font-size: 15px;
}
#newBest.show { display: block; }
#over .btn.locked { pointer-events: none; opacity: .55; }

.icon-btn {
  position: absolute; z-index: 5; top: calc(var(--sat) + 10px); left: 12px; pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(26, 34, 18, .92); color: var(--sand); padding: 10px; cursor: pointer;
}
.icon-btn svg { width: 100%; height: 100%; fill: currentColor; display: block; }
#icoOff { display: none; }
.icon-btn.off #icoOn { display: none; }
.icon-btn.off #icoOff { display: block; }
