/* Falak Arcade — shared look for the games at falaklabs.com/games/.
   Brand tokens mirror assets/css/style.css. Every game page loads this first. */

@font-face {
  font-family: "El Messiri";
  src: url("../../assets/fonts/el-messiri-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("../../assets/fonts/hanken-grotesk-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --lapis: #0A1440;
  --lapis-deep: #070D2C;
  --lapis-raise: #111E5A;
  --ultramarine: #2440B8;
  --gold: #E8B65A;
  --gold-soft: #F3D497;
  --parchment: #F2EAD8;
  --mist: #B4BADB;
  --mist-dim: #8990BB;
  --hairline: rgba(232, 182, 90, 0.2);
  --turquoise: #3CC8BE;
  --rose: #E7709E;
  --emerald: #47C285;
  --sky: #78A2FF;
  --danger: #FF7A6B;

  /* Arabic text has no web font here: it falls through to the phone's own Arabic face, which keeps letters joined. */
  --font-display: "El Messiri", Optima, Candara, "Segoe UI", system-ui, sans-serif;
  --font-text: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --bar-h: 56px;
  --radius: 18px;
  --ease-out: cubic-bezier(0.16, 0.84, 0.24, 1);
  color-scheme: dark;
}

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

html {
  height: 100%;
  background: var(--lapis-deep);
  color: var(--parchment);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body.fa {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.45;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(36, 64, 184, 0.42), rgba(10, 20, 64, 0) 70%),
    radial-gradient(1px 1px at 12% 22%, rgba(242, 234, 216, 0.55), transparent 60%),
    radial-gradient(1px 1px at 78% 14%, rgba(242, 234, 216, 0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 71%, rgba(243, 212, 151, 0.5), transparent 60%),
    radial-gradient(1px 1px at 28% 84%, rgba(242, 234, 216, 0.4), transparent 60%),
    radial-gradient(1px 1px at 90% 52%, rgba(242, 234, 216, 0.35), transparent 60%),
    var(--lapis);
}

img, svg, canvas { display: block; }
p, h1, h2, h3, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* Arabic letters must stay joined: no tracking, no forced capitals. */
html[lang="ar"] .fa-chip__label,
html[lang="ar"] .fa-panel__eyebrow,
html[lang="ar"] .fa-eyebrow,
html[lang="ar"] .fa-stats dt { letter-spacing: 0; text-transform: none; }

.fa-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- app frame */

.fa-app {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}

.fa-bar {
  position: relative;
  z-index: 5;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--bar-h);
  padding: 0 8px;
}
.fa-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fa-scores { display: flex; gap: 6px; flex: none; }

.fa-chip {
  min-width: 62px;
  padding: 5px 10px 4px;
  border-radius: 12px;
  background: rgba(17, 30, 90, 0.72);
  box-shadow: inset 0 0 0 1px var(--hairline);
  text-align: center;
  line-height: 1.1;
}
.fa-chip__label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mist);
}
.fa-chip__value {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--parchment);
}
.fa-chip.is-bump .fa-chip__value { animation: fa-bump 0.32s var(--ease-out); }

.fa-icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--parchment);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s linear;
}
.fa-icon-btn:active { background: rgba(242, 234, 216, 0.1); }
.fa-icon-btn svg { width: 24px; height: 24px; }
[dir="rtl"] .fa-flip svg,
[dir="rtl"] svg.fa-flip { transform: scaleX(-1); }

.fa-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  -ms-touch-action: none;
}
.fa-stage canvas { touch-action: none; }

.fa-dock {
  position: relative;
  z-index: 5;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 12px 10px;
}

/* ---------------------------------------------------------------- buttons */

.fa-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0.8em 1.5em;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--lapis);
  font-family: var(--font-text);
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s linear, transform 0.25s var(--ease-out), box-shadow 0.3s var(--ease-out);
}
.fa-btn:active { transform: scale(0.97); }
@media (hover: hover) {
  .fa-btn:hover { background: var(--gold-soft); box-shadow: 0 0 0 6px rgba(232, 182, 90, 0.16); }
  .fa-btn--ghost:hover { background: rgba(242, 234, 216, 0.08); box-shadow: inset 0 0 0 1px rgba(242, 234, 216, 0.4); }
}
.fa-btn--ghost {
  background: transparent;
  color: var(--parchment);
  box-shadow: inset 0 0 0 1px rgba(242, 234, 216, 0.28);
}
.fa-btn--small { min-height: 40px; padding: 0.6em 1.1em; font-size: 0.93rem; }
.fa-btn--block { width: 100%; }
.fa-btn[disabled] { opacity: 0.45; pointer-events: none; }
.fa-btn svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- overlays & panels */

.fa-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  background: rgba(7, 13, 44, 0.8);
  touch-action: manipulation;
  animation: fa-fade 0.2s linear;
}
.fa-overlay[hidden] { display: none; }
.fa-overlay.is-closing { animation: fa-fade-out 0.16s linear forwards; }

.fa-panel {
  position: relative;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 26px 22px 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #14225F 0%, #0C1748 100%);
  box-shadow: 0 0 0 1px var(--hairline), 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
  touch-action: pan-y;
  animation: fa-pop 0.3s var(--ease-out);
}
.fa-panel__close {
  position: absolute;
  top: 8px;
  right: 8px;
}
[dir="rtl"] .fa-panel__close { right: auto; left: 8px; }
.fa-panel__art { display: flex; justify-content: center; margin: -4px 0 12px; }
.fa-panel__eyebrow,
.fa-eyebrow {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.fa-panel__title {
  margin: 4px 0 8px;
  font-family: var(--font-display);
  font-size: 1.95rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.fa-panel__text {
  margin: 0 auto 16px;
  max-width: 30em;
  color: var(--mist);
  text-wrap: pretty;
}
.fa-panel__body { margin-bottom: 16px; }
.fa-panel__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fa-panel__actions .fa-btn { width: 100%; }
.fa-panel__row { display: flex; gap: 10px; }
.fa-panel__row > * { flex: 1 1 0; min-width: 0; }

.fa-stats {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
}
.fa-stats > div {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 6px 9px;
  border-radius: 14px;
  background: rgba(242, 234, 216, 0.05);
}
.fa-stats dt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mist);
}
.fa-stats dd {
  margin: 2px 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.fa-stats .is-accent dd { color: var(--gold); }

.fa-howto {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  text-align: start;
}
.fa-howto li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--parchment);
}
.fa-howto li::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 0.5em;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(232, 182, 90, 0.16);
}

/* menu */
.fa-menu { display: grid; gap: 8px; margin-bottom: 14px; }
.fa-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: rgba(242, 234, 216, 0.06);
  color: var(--parchment);
  font-weight: 550;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.fa-row:active { background: rgba(242, 234, 216, 0.12); }
.fa-row__state { font-weight: 650; color: var(--mist-dim); }
.fa-row[aria-pressed="true"] .fa-row__state { color: var(--gold); }
.fa-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(7, 13, 44, 0.6);
}
.fa-seg button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--mist);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.fa-seg button[aria-pressed="true"] { background: var(--gold); color: var(--lapis); }

/* ---------------------------------------------------------------- toasts */

.fa-toasts {
  position: fixed;
  z-index: 60;
  top: calc(var(--safe-t) + var(--bar-h) + 6px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  pointer-events: none;
}
.fa-toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(17, 30, 90, 0.96);
  box-shadow: inset 0 0 0 1px var(--hairline), 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 0.92rem;
  font-weight: 600;
  animation: fa-toast-in 0.28s var(--ease-out);
}
.fa-toast.is-gold { background: var(--gold); color: var(--lapis); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.fa-toast.is-out { animation: fa-toast-out 0.25s linear forwards; }

/* ---------------------------------------------------------------- motion */

@keyframes fa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fa-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes fa-pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes fa-bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes fa-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fa-toast-out { to { opacity: 0; transform: translateY(-6px); } }

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

@media (max-width: 360px) {
  :root { --bar-h: 52px; }
  .fa-title { font-size: 1.05rem; }
  .fa-chip { min-width: 54px; padding: 4px 8px 3px; }
  .fa-chip__value { font-size: 15px; }
}
