* { box-sizing: border-box; margin: 0; padding: 0; }
/* No browser gestures anywhere: no pinch or double-tap zoom, no long-press callout or selection. */
* { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #1c130d; overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { position: fixed; inset: 0; }
/* The landscape screen. Normally the whole viewport; on an upright phone main.js gives it the
   viewport's height as its width and turns it a quarter (body.rot), so the game is always landscape.
   --sl / --sr / --sb are the safe-area insets on the stage's own left, right and bottom. */
#stage {
  position: fixed; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0;
  display: flex; align-items: center; justify-content: center;
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --sb: env(safe-area-inset-bottom, 0px);
}
body.rot #stage { --sl: env(safe-area-inset-top, 0px); --sr: env(safe-area-inset-bottom, 0px); --sb: env(safe-area-inset-left, 0px); }
body { font-family: "Lalezar", "Noto Kufi Arabic", Tahoma, sans-serif; }
canvas { display: block; background: #e9d9b0; image-rendering: auto; }
.font-warm { position: absolute; opacity: 0; pointer-events: none; font-family: "Lalezar"; } /* loads the font before the canvas draws text */
.font-latin { font-family: "Lilita One"; } /* the English display face */

/* Touch controls. Ink lines over a faint cream wash, so the scene shows through; a control
   brightens while it is held. Shapes are inline SVG in index.html. */
/* Hidden (and untouchable) outside the play state: main.js sets body.playing. */
.pad, .dpad { position: absolute; display: none; z-index: 5; opacity: 0; pointer-events: none; transition: opacity .2s; }
body.playing .pad, body.playing .dpad { opacity: .72; pointer-events: auto; }
.pad svg, .dpad svg { display: block; overflow: visible; pointer-events: none; }
.pad svg { width: 100%; height: 100%; }
.bg { fill: rgba(246, 236, 210, .26); stroke: #1c130d; stroke-width: 3; stroke-linejoin: round; }
.ln { fill: none; stroke: #1c130d; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.ic { fill: #c9542b; stroke: #1c130d; stroke-width: 2.6; stroke-linejoin: round; }
.wing { fill: #f6ecd2; stroke: #1c130d; stroke-width: 2.2; stroke-linejoin: round; }
.wood-o { fill: none; stroke: #1c130d; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.wood { fill: none; stroke: #b9773a; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.stone { fill: #b8ad98; stroke: #1c130d; stroke-width: 2.4; }
.arm { fill: rgba(28, 19, 13, .78); stroke: #1c130d; stroke-width: 2; stroke-linejoin: round; }

/* D-pad: one touch surface read like a stick (attachStick in input.js); the arrows show what is held.
   The touch area (the element) is wider than the drawn cross (.face), so a thumb that lands a
   little off still steers. */
.dpad {
  --face: 112px; --slop: 34px;
  width: calc(var(--face) + 2 * var(--slop)); height: calc(var(--face) + 2 * var(--slop));
  left: calc(max(18px, var(--sl)) - var(--slop)); bottom: calc(max(18px, var(--sb)) - var(--slop));
}
.dpad .face { position: absolute; left: var(--slop); top: var(--slop); width: var(--face); height: var(--face); }
body.playing .dpad.on { opacity: 1; }
.dpad.left .a-left, .dpad.right .a-right, .dpad.up .a-up, .dpad.down .a-down { fill: #e3b23c; }

/* Actions: one column up the right edge, in the bar beside the picture where there is one.
   Jump is lowest and largest (under the resting thumb), the sling above it, Dabke on top. */
.pad-act {
  right: max(16px, var(--sr)); bottom: max(16px, var(--sb));
  flex-direction: column; align-items: center; gap: 16px;
}
.pad button { position: relative; flex: none; padding: 0; border: 0; background: none; border-radius: 50%; }
.pad button::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; } /* the gaps count as button */
.b-jump { width: 68px; height: 68px; }
.b-fire { width: 60px; height: 60px; }
.b-special { width: 52px; height: 52px; }
.pad .b-alt { position: absolute; width: 56px; height: 56px; right: calc(100% + 16px); bottom: 86px; } /* level with the sling */
.pad .b-dash { position: absolute; width: 56px; height: 56px; right: calc(100% + 16px); bottom: 8px; } /* beside the jump */
.b-dash .bg, .b-alt .bg { fill: rgba(246, 236, 210, .5); }
.b-alt .ammo-ico { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; background: none; } /* not the game canvas's parchment */
.b-alt .ammo-n {
  position: absolute; right: -3px; bottom: -5px; min-width: 20px; padding: 0 4px; border-radius: 10px; pointer-events: none;
  background: #f6ecd2; color: #1c130d; box-shadow: 0 0 0 2px #1c130d; font: 14px/20px "Lalezar", Tahoma, sans-serif; text-align: center;
}
.pad button.on { transform: scale(.92); }
.pad button.on .bg { fill: rgba(227, 178, 60, .75); }
/* A button exists only while the hero has that power (main.js sets .have from game.has): it keeps
   its place in the column, and pops in when the power arrives. */
.pad button:not(.have) { opacity: 0; transform: scale(.3); pointer-events: none; transition: opacity .15s, transform .15s; }
.pad button.have { animation: power-in .5s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes power-in { from { opacity: 0; transform: scale(.3); } 55% { opacity: 1; transform: scale(1.22); } to { transform: none; } }
.b-special .bg { fill: rgba(227, 178, 60, .6); }
.b-special.have svg { animation: power-glow 1.1s ease-in-out infinite alternate; }
@keyframes power-glow { from { filter: drop-shadow(0 0 0 rgba(227, 178, 60, 0)); } to { filter: drop-shadow(0 0 7px rgba(255, 226, 130, .95)); } }
@media (max-height: 330px) { .pad-act { gap: 10px; } .b-jump { width: 60px; height: 60px; } .b-fire { width: 54px; height: 54px; } .b-special { width: 46px; height: 46px; } .pad .b-alt { width: 50px; height: 50px; bottom: 72px; } .pad .b-dash { width: 50px; height: 50px; } .dpad { --face: 100px; } }
@media (pointer: coarse) { .pad { display: flex; } .dpad { display: block; } }

/* Install hint (see main.js): upright, over everything, sized to fit without scrolling. */
#install {
  position: fixed; inset: 0; z-index: 20; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: max(18px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
  background: #1c130d; color: #f6ecd2; text-align: center;
}
#install.show { display: flex; }
#install img { border-radius: 20px; border: 3px solid #f6ecd2; }
#install h1 { font-size: 34px; font-weight: normal; line-height: 1; color: #e3b23c; }
#install .how { display: flex; flex-direction: column; gap: 14px; }
#install ol { list-style: none; font-size: 18px; line-height: 1.55; }
#install .lead { font-size: 22px; color: #e3b23c; }
#install .share { width: 20px; height: 20px; vertical-align: -3px; fill: none; stroke: #6cb2ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#install button {
  margin-top: 6px; padding: 10px 22px; border-radius: 999px; border: 3px solid #1c130d; outline: 2px solid #f6ecd2;
  background: #f6ecd2; color: #1c130d; font: 18px "Lalezar", Tahoma, sans-serif; touch-action: manipulation;
}
/* The native app's offer (js/applink.js): in the install sheet on an iPhone or iPad, a strip on a Mac. */
#install .app, #install #app-get { display: none; }
#install.app .how { display: none; }
#install.app .app { display: flex; flex-direction: column; gap: 14px; }
#install.app #app-get { display: block; background: #e3b23c; }
#install .app p { display: flex; flex-direction: column; gap: 2px; font-size: 18px; line-height: 1.5; }
#install .app .beta { font-size: 15px; color: #c9b890; }
#install:not(.beta) .app .beta { display: none; }
#appbar {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 20; display: none; align-items: center; gap: 14px;
  padding: 8px 12px 8px 18px; border-radius: 0 0 16px 16px; border: 3px solid #1c130d; border-top: 0;
  background: #f6ecd2; color: #1c130d; font: 17px "Lalezar", Tahoma, sans-serif; white-space: nowrap;
}
#appbar.show { display: flex; }
#appbar button { border: 2.5px solid #1c130d; border-radius: 999px; background: #e3b23c; color: #1c130d; font: inherit; padding: 3px 14px; cursor: pointer; }
#appbar #appbar-skip { background: none; border: 0; font-size: 24px; line-height: 1; padding: 0 6px; }
@media (max-height: 460px) { /* a phone on its side: the two languages sit next to each other */
  #install { gap: 8px; }
  #install img { display: none; }
  #install h1 { font-size: 26px; }
  #install .how { flex-direction: row-reverse; gap: 36px; }
  #install ol { font-size: 16px; line-height: 1.4; }
  #install .lead { font-size: 19px; }
  #install.app .app { flex-direction: row-reverse; gap: 36px; }
  #install .app p { font-size: 16px; line-height: 1.4; }
}
