*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--c-bg);
}

body {
  position: fixed;
  inset: 0;
  font-family: var(--font);
  color: var(--c-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; -webkit-user-drag: none; }
img.is-broken { visibility: hidden; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible { outline: 3px solid var(--c-teal); outline-offset: 4px; }

/* The stage is the phone-shaped canvas: full screen on phones, a centred column on bigger screens. */
.stage {
  position: relative;
  width: var(--stage-w);
  height: var(--app-h);
  margin: 0 auto;
  overflow: hidden;
  background-color: var(--c-bg);
  background-image: var(--pattern-url, none);
  background-repeat: no-repeat;
  background-position: right center;
  background-size: calc(var(--u) * 699) auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    calc(var(--safe-t) + var(--u) * 70)
    calc(var(--safe-r) + var(--gutter))
    calc(var(--safe-b) + var(--u) * 70)
    calc(var(--safe-l) + var(--gutter));
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility 0s linear .28s;
}
.screen.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity .28s ease, visibility 0s;
}

/* Loading veil: keeps the first paint clean until fonts + images are ready. */
.boot-veil {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: var(--c-bg);
  pointer-events: none;
  transition: opacity .35s ease;
}
.boot-veil::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--c-blue);
  animation: boot-pulse 1s ease-in-out infinite;
}
.is-ready .boot-veil { opacity: 0; }
.is-ready .boot-veil::after { animation: none; }

@keyframes boot-pulse { 50% { transform: scale(1.6); opacity: .4; } }

/* Phones held sideways */
.rotate-notice {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--c-bg);
  font-weight: 800;
  font-size: 18px;
  text-align: center;
}
.is-landscape .rotate-notice { display: grid; }

.noscript {
  position: absolute; inset: 0; z-index: 70; display: grid; place-items: center;
  background: var(--c-bg); font-weight: 700; padding: 24px; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

/* ═════════ Arabic / right-to-left ═════════ */
[lang='ar'] body, [lang='ar'] button { letter-spacing: 0; }
[lang='ar'] * { letter-spacing: 0 !important; }   /* tracking breaks Arabic letter joining */
/* Cairo sits taller than Montserrat: tuned so each Arabic text block takes the same space as the
   English one and the two layouts line up element for element. */
[lang='ar'] .title-xl { font-size: calc(var(--u) * 86); line-height: 1.12; }
[lang='ar'] .level-readout__label { font-size: calc(var(--u) * 56); line-height: 1.1; }
[lang='ar'] .result-heading { font-size: calc(var(--u) * 64); line-height: 1.1; }
[lang='ar'] .instruction { line-height: 1.3; }
[lang='ar'] .result-tagline { font-size: max(calc(var(--u) * 46), 15px); line-height: 1.25; }
[lang='ar'] .hud__hint { line-height: 1.45; }
/* Numbers stay left-to-right inside Arabic text */
.result-percent, .level-readout__value, .countdown, .fx-float { direction: ltr; unicode-bidi: isolate; }
