@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; }

:root {
  --sand: #f3dcb4;
  --ink: #1f130a;
  --panel: #2a1b10;
  --panel-2: #3a2616;
  --line: #5e3f25;
  --accent: #e2802f;
  --accent-d: #9c4d16;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #d9a868;
  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; }

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

/* ---------- menu ---------- */
.logo { text-align: center; margin-top: 3vh; }
.logo h1 {
  margin: 0; font-family: "Reem Kufi", serif; font-weight: 700;
  font-size: clamp(46px, 14vw, 76px); line-height: 1.15; color: #fff6e6;
  text-shadow: 0 3px 0 #8a4416, 0 7px 0 rgba(40, 18, 6, .28);
}
.logo p {
  margin: 20px 0 0; font: 700 12px/1 system-ui, sans-serif; letter-spacing: .45em;
  color: #fff6e6; opacity: .9; direction: ltr; padding-left: .45em;
}
#birdZone { flex: 1 1 auto; min-height: 90px; width: 100%; }
.ground-gap { flex: 0 0 auto; height: 20vh; }

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

#cards { display: flex; gap: 10px; margin-bottom: 14px; }
.ch-card {
  flex: 1 1 0; min-width: 0; padding: 8px 4px 8px; border-radius: 14px;
  background: var(--panel-2); border: 2px solid transparent; color: var(--sand);
  font: inherit; font-size: 15px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.ch-card img { width: 100%; height: min(84px, 11vh); object-fit: contain; pointer-events: none; }
.ch-card.sel { border-color: var(--accent); background: #4a2f19; transform: translateY(-3px); }
.ch-card:active { transform: scale(.96); }

.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 #1a0f07;
}
.btn.primary { background: var(--accent); color: #1c0e05; box-shadow: 0 4px 0 var(--accent-d); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1a0f07; }
.btn.primary:active { box-shadow: 0 1px 0 var(--accent-d); }
.best { margin: 2px 0 2px; font-size: 14px; color: #d6bb93; }
.best b { color: #fff1da; font-size: 16px; }

/* ---------- in-game ---------- */
#hud {
  position: fixed; top: calc(var(--sat) + 18px); left: 0; right: 0;
  text-align: center; pointer-events: none; opacity: 0; transition: opacity .2s;
}
#hud.show { opacity: 1; }
#score {
  display: inline-block; font-family: "Reem Kufi", serif; font-weight: 700;
  font-size: 64px; line-height: 1; color: #fff6e6;
  text-shadow: 0 3px 0 #7a3a12, 0 6px 0 rgba(40, 18, 6, .3);
}
#score.pop { animation: pop .18s ease-out; }
@keyframes pop { 50% { transform: scale(1.18); } }

#ready { justify-content: flex-end; padding-bottom: calc(var(--sab) + 30vh); }
.tap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: #fff6e6; font-size: 19px; text-shadow: 0 2px 0 rgba(60, 28, 8, .55);
}
.tap svg { width: 46px; height: 46px; fill: currentColor; color: #fff6e6; animation: tap 1s ease-in-out infinite; }
@keyframes tap { 50% { transform: translateY(5px) scale(.94); } }

#over { justify-content: center; }
#over .panel { padding: 20px 18px 10px; }
#over h2 { font-size: 34px; margin-bottom: 14px; }
.stats { display: flex; gap: 10px; margin-bottom: 12px; }
.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: #d6bb93; }
.stats b { font-family: "Reem Kufi", serif; font-size: 40px; line-height: 1.1; color: #fff6e6; }
#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: fixed; z-index: 5; top: calc(var(--sat) + 12px); left: 14px;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(34, 21, 12, .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; }
