@font-face {
  font-family: Amiri;
  src: url("/shared/fonts/amiri.woff2") format("woff2");
  font-display: swap;
  ascent-override: 79%;
  descent-override: 28%;
  line-gap-override: 0%;
}
@font-face {
  font-family: DigitalKhatt;
  src: url("digitalkhatt-indopak.woff2") format("woff2");
  font-display: swap;
  ascent-override: 107%;
  descent-override: 35%;
  line-gap-override: 0%;
}
@font-face {
  font-family: Nastaliq;
  src: url("/shared/fonts/noto-nastaliq-urdu.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #0e1830;
  --paper: #f5eedb;
  --ink: #1d2433;
  --gold: #c9a24a;
  --light-gold: #f0cf8e;
  --muted: #c0c8ce;
  --edge: #29484c;
  font: 16px/1.35 Amiri, Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--paper);
  background: url("lattice.svg") center top / 104px 104px,
    radial-gradient(ellipse at 50% 28%, #38404c, transparent 53%),
    radial-gradient(ellipse at 50% 66%, #192843, var(--night) 75%);
}
h1, h2, p { margin: 0; }
[lang="ar"] { font-family: DigitalKhatt, Amiri, serif; }
[lang="ur"] { font-family: Nastaliq, serif; line-height: 2.15; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff3c7; outline-offset: 4px; }

.topbar {
  width: min(94%, 1720px);
  margin-inline: auto;
  min-height: 85px;
  padding-block: 10px;
  display: grid;
  grid-template-columns: 1fr minmax(0, 1.25fr) 1fr;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #b88c4d56;
}
.topbar > a { justify-self: start; }
.topbar nav, .actions { display: flex; justify-content: center; align-items: center; gap: 14px; }
.topbar nav { grid-column: 3; justify-content: flex-end; }
#location { display: flex; justify-content: center; align-items: baseline; gap: 16px; text-align: center; font-size: 1.37rem; color: var(--muted); }
#round-label { color: var(--light-gold); font-size: 1.7rem; line-height: 1; }
.control, .switch button {
  display: inline-grid;
  place-items: center;
  min-height: 52px;
  min-width: 72px;
  padding: 7px 20px 4px;
  border: 1px solid #977749;
  border-radius: 7px;
  background: linear-gradient(#243550, #162740);
  box-shadow: inset 0 0 0 2px #0e183077, 0 4px 9px #070d16a0;
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
  font: 1.3rem/1.12 Amiri, Georgia, serif;
  transition: transform .22s, background .22s, border-color .22s;
}
.control.primary { background: linear-gradient(#f1d39a, #d0a459); color: #28202a; border-color: #f3d49d; box-shadow: inset 0 0 0 2px #754c2d44, 0 4px 9px #070d16a0; }
.control.quiet { color: var(--muted); border-color: #94774969; font-size: 1.07rem; }
.control:active, .switch button:active, .station:active, .tablet:not([aria-disabled]):active { transform: translateY(3px); }
.control:disabled { opacity: .55; }
.loading { text-align: center; font-size: 2rem; padding: 100px 20px; }

.map-view { width: min(93%, 1550px); margin: auto; padding-top: clamp(18px, 4.2vh, 48px); text-align: center; }
.heading-mark {
  display: block;
  width: min(310px, 70vw);
  height: 32px;
  margin: 0 auto 14px;
  background: url("rosette.svg") center / 32px 32px no-repeat,
    linear-gradient(90deg, transparent, #a98548 39%, transparent 39% 61%, #a98548 61%, transparent) center / 100% 1px no-repeat;
}
.map-heading h1 { color: var(--light-gold); font-size: clamp(3.9rem, 8.3vh, 6.1rem); font-weight: 400; line-height: .94; }
.map-heading h1 span { display: block; margin-top: 7px; color: var(--paper); font-size: .49em; line-height: 1.05; }
.map-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 23px; margin-top: clamp(17px, 3.2vh, 35px); }
.map-controls p { flex-basis: 100%; color: var(--muted); font-size: 1.15rem; }
.switch { display: flex; border: 1px solid #ac8b578c; border-radius: 8px; padding: 3px; background: #111d32; }
.switch-label { align-self: center; padding: 3px 14px 0; color: var(--paper); font-size: 1.3rem; white-space: nowrap; }
.switch button { min-height: 46px; border-color: transparent; background: transparent; box-shadow: none; }
.switch button[aria-pressed="true"] { background: #34474d; border-color: #b59760; color: #ffdfa0; }

.route {
  position: relative;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(7, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  height: clamp(293px, 43vh, 465px);
  padding-block: 10px;
  margin-top: 8px;
}
.route-line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.route-line path { fill: none; stroke: #b88a55; stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; }
.station {
  --point: 0px;
  position: relative;
  top: var(--point);
  isolation: isolate;
  width: min(91%, 183px);
  height: clamp(123px, 15.6vh, 170px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding-top: 7px;
  border: 1px solid #bea16d;
  border-radius: 38% 38% 38% 38% / 44% 44% 44% 44%;
  background: radial-gradient(ellipse at 50% 15%, #394d56, #202e49 78%);
  box-shadow: 0 9px 21px #080f20cf, inset 0 0 0 4px #151f34, inset 0 0 0 5px #ae8b56aa;
  transition: transform .22s, box-shadow .28s;
}
.station::before, .station::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 17px;
  left: calc(50% - 8.5px);
  background: url("rosette.svg") center / contain no-repeat;
}
.station::before { top: -8px; }
.station::after { bottom: -8px; }
.station:nth-of-type(2), .station:nth-of-type(6), .station:nth-of-type(13) { --point: -15px; }
.station:nth-of-type(4), .station:nth-of-type(9), .station:nth-of-type(10) { --point: 12px; }
.station:nth-of-type(8) { grid-area: 2 / 7; }
.station:nth-of-type(9) { grid-area: 2 / 6; }
.station:nth-of-type(10) { grid-area: 2 / 5; }
.station:nth-of-type(11) { grid-area: 2 / 4; }
.station:nth-of-type(12) { grid-area: 2 / 3; }
.station:nth-of-type(13) { grid-area: 2 / 2; }
.station:nth-of-type(14) { grid-area: 2 / 1; }
.next-station { background: radial-gradient(ellipse at 50% 22%, #625646, #283747 83%); box-shadow: 0 0 37px #eca65a4d, inset 0 0 0 4px #463b38, inset 0 0 0 5px #d8b578; }
.range { color: #ffe0a0; font-size: clamp(1.65rem, 2.35vw, 2.5rem); white-space: nowrap; }
.best { color: #f3eddf; margin-top: 4px; font-size: 1.28rem; }
.stars { color: #f1cb79; display: inline-block; font-size: 1.15rem; letter-spacing: .13em; margin-top: 7px; white-space: nowrap; }
.stars span { color: #b5a17f; }
.map-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 0 16px; text-align: left; }
.credit { color: var(--muted); font-size: 1rem; }

.card-view {
  position: relative;
  width: min(92%, 1500px);
  margin: auto;
  display: grid;
  gap: 20px;
  padding: clamp(20px, 5.5vh, 62px) 0 16px;
}
.card-view.revealed { padding-top: 19px; gap: 14px; }
.card-view:has(.team-board) { padding-top: 15px; gap: 12px; }
.card-view.translate-first:not(.revealed) { padding-top: clamp(34px, 7.5vh, 82px); }
.card-view.translate-first:has(.team-board):not(.revealed) { padding-top: clamp(16px, 3vh, 33px); }
.team-board { display: flex; justify-content: center; gap: 13px; }
.team {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  padding: 4px 15px 1px;
  border: 1px solid #8c816b80;
  border-radius: 6px;
  font-size: 1.35rem;
  line-height: 1.15;
}
.team.current { color: #ffdfa0; background: #654e3b66; border-color: #b69457; }
.team small { color: var(--paper); font-size: .83em; }
.team-score { min-width: 1ch; color: var(--paper); }
.page {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  min-height: 268px;
  padding: 29px 62px 32px;
  border: 2px solid #d6af61;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 18%, #fff8e6, #eee1c3);
  color: var(--ink);
  box-shadow: 0 0 65px #edad6062, 0 10px 36px #090f21ac, inset 0 0 24px #9b683736;
  animation: enter .39s ease both;
}
.page::before {
  position: absolute;
  content: "";
  z-index: -1;
  inset: 6px;
  border: 1px solid #a37838;
  border-radius: 4px;
  background: url("grain.svg") 0 0 / 160px 160px repeat;
  pointer-events: none;
}
.revealed .page { min-height: 178px; padding-block: 15px 23px; gap: 3px; animation: none; }
.translate-first:not(.revealed) .page { min-height: clamp(230px, 32vh, 350px); }
.corner { position: absolute; width: 28px; height: 28px; background: url("rosette.svg") center / contain no-repeat; }
.corner:nth-child(1) { top: 12px; left: 12px; }
.corner:nth-child(2) { top: 12px; right: 12px; }
.corner:nth-child(3) { bottom: 12px; left: 12px; }
.corner:nth-child(4) { bottom: 12px; right: 12px; }
.reference, .letter {
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 5%, #fdf1c9, #eacb88);
  color: #593a18;
  border: 1px solid #95703b;
  border-radius: 45% 45% 45% 45% / 55% 55% 55% 55%;
  box-shadow: inset 0 0 0 2px #fff1cd9c;
  line-height: 1;
}
.reference { min-width: 76px; min-height: 36px; padding: 5px 14px 0; font-size: 1.32rem; }
.ayah {
  width: 100%;
  text-align: center;
  text-wrap: balance;
  font-size: 5rem;
  line-height: 1.44;
  animation: enter .36s .08s ease both;
}
.word { display: inline-block; }
.word.lit {
  position: relative;
  border-radius: .17em;
  color: #352009;
  background: radial-gradient(ellipse at center, #ffe486 15%, #ffcc476b 55%, transparent 76%);
  text-shadow: 0 0 .21em #ffdc78, 0 0 .4em #eab545;
}
.revealed .ayah { animation: none; }

.translate-prompt {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 20px;
  min-height: 270px;
  padding: 14px 0;
  text-align: center;
  animation: enter .39s .12s ease both;
}
.translate-prompt p {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0 24px;
  padding-bottom: .25em;
  font-size: clamp(1.65rem, 3.35vh, 2.4rem);
}
.translate-prompt [lang="ur"] { color: var(--light-gold); font-size: .83em; }
#show-choices {
  width: min(100%, 380px);
  min-height: 120px;
  font-size: clamp(1.75rem, 4vh, 2.65rem);
}

.tablets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tablet {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  gap: 12px;
  width: 100%;
  min-height: 222px;
  padding: 18px 28px;
  color: var(--ink);
  background: linear-gradient(165deg, #fbf4df, #e9dcbd);
  border: 5px solid var(--edge);
  border-radius: 13px;
  box-shadow: inset 0 0 0 1px #b69154, inset 0 0 0 4px #fbefd4, 0 8px 14px #0a1324a0;
  transition: transform .22s, background .3s;
  animation: enter .36s .15s ease both;
}
.tablet:nth-child(2) { animation-delay: .22s; }
.letter { width: 42px; height: 42px; padding-top: 5px; font-size: 1.53rem; }
.tablet-text { display: block; width: 100%; font-size: 2.62rem; line-height: 1.14; text-wrap: pretty; }
.revealed .tablet { min-height: 170px; padding: 8px 22px; gap: 5px; cursor: default; animation: none; }
.revealed .letter { width: 33px; height: 33px; font-size: 1.23rem; }
.revealed [data-kind="right"] { border-color: #6f783f; background: linear-gradient(155deg, #fff5d9, #efe1b9); }
.revealed [data-kind="right"] .changed { text-decoration: underline .1em #ad781c; text-underline-offset: .14em; }
.revealed [data-kind="wrong"] { border-color: #614239; background: linear-gradient(155deg, #e1d5c2, #c8b9a5); }
.revealed [data-kind="wrong"] .changed { text-decoration: line-through .11em #992e20; color: #752d23; }
.seal {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: 12px;
  padding: 1px 13px;
  border: 1px solid currentColor;
  border-radius: 5px;
  color: #314321;
  background: #fff5d9a6;
  font-size: 1.24rem;
  line-height: 1.16;
}
.seal [lang="ur"] { line-height: 1.98; font-size: .86em; }
[data-kind="wrong"] .seal { color: #752d23; }
.revealed .picked-wrong { animation: shake .33s ease; }
.teacher { min-height: 54px; }
.teacher .control { min-width: 155px; }
.thread { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.thread path { fill: none; stroke: #e5b658; stroke-width: 1.75px; stroke-linecap: round; filter: drop-shadow(0 0 2px #ffe5a5); stroke-dasharray: 1; stroke-dashoffset: 1; }
.thread circle { fill: #f5d38b; stroke: #916423; stroke-width: 1px; }
.revealed .thread path { animation: draw .7s ease-out forwards; }
.particles { position: absolute; inset: 50% auto auto 50%; pointer-events: none; }
.particles i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #eac165; box-shadow: 0 0 4px #fff4c4; animation: spark .58s ease-out both; }

.why {
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  color: var(--paper);
  background: linear-gradient(115deg, #1f3347, #18283c);
  border: 1px solid #b28a52;
  border-radius: 9px;
  box-shadow: inset 0 0 0 4px #1525399c;
  animation: enter .32s ease both;
}
.why > div { min-width: 0; padding: 12px 25px 16px; }
.reason-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 15px; margin-bottom: 4px; }
.why h2 { color: var(--light-gold); font-size: 1.66rem; font-weight: 400; line-height: 1.1; }
.chip {
  display: inline-flex;
  align-items: center;
  column-gap: 8px;
  padding-inline: 10px;
  font-size: 1.05rem;
  color: #ffdfab;
  background: #152137;
  border: 1px solid #91754f;
  border-radius: 100px;
}
.chip [lang="ur"] { font-size: .85em; line-height: 2; }
.why-en { font-size: calc(2rem * var(--why-scale, 1)); line-height: 1.37; }
.why-en bdi { color: #ffdfa0; }
.why-ur { margin-top: 6px; }
.translation { border-left: 1px solid #b28a525c; }
.why-ur, .translation p { font-size: calc(2.1rem * var(--why-scale, 1)); padding-bottom: .4em; }

.end-view {
  width: min(90%, 760px);
  margin: clamp(23px, 5vh, 58px) auto 18px;
  padding: 28px 40px;
  text-align: center;
  border: 1px solid #be9b62;
  border-radius: 11px;
  box-shadow: inset 0 0 0 5px #14233b, inset 0 0 0 6px #a7814c80, 0 10px 38px #080e1b80;
  background: radial-gradient(ellipse at top, #37424c, #162640 72%);
}
.end-view h1, dialog h2 { color: var(--light-gold); font-weight: 400; font-size: clamp(2.6rem, 6.4vh, 4.5rem); line-height: 1.04; }
.end-view h2 { font-size: 1.65rem; font-weight: 400; color: var(--light-gold); margin-top: 10px; }
.end-scores { display: flex; align-items: center; justify-content: center; gap: 24px; font-size: 2rem; margin-top: 10px; }
.end-scores strong { color: #ffe1a1; }
.end-view .stars { font-size: 1.75rem; margin-top: 0; }
.missed-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  max-height: 29vh;
  overflow: auto;
  margin: 8px 0 7px;
  padding: 3px;
  list-style: none;
}
.missed-list li { padding: 6px 10px; border: 1px solid #a587585c; border-radius: 5px; font-size: 1.24rem; }
.missed-list li [lang="ar"] { display: block; font-size: 1.6rem; color: var(--light-gold); overflow-wrap: anywhere; }
.end-view .actions { margin-top: 20px; }
dialog {
  color: var(--paper);
  background: #1c2e47;
  border: 1px solid #c39d5b;
  border-radius: 9px;
  padding: 24px 35px;
  text-align: center;
  box-shadow: inset 0 0 0 5px #132139, 0 20px 80px #070b14;
}
dialog::backdrop { background: #0a1022b0; }
dialog h2 { font-size: 2.5rem; }
dialog p { margin: 12px 0; font-size: 1.25rem; }

@keyframes enter { from { opacity: 0; transform: translateY(11px); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes shake { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes spark { from { opacity: .95; } to { transform: translate(var(--x), var(--y)); opacity: 0; } }

@media (max-height: 850px) {
  .topbar { min-height: 65px; padding-block: 6px; }
  .control { min-height: 48px; padding-inline: 15px; }
  .card-view { gap: 15px; padding-top: 27px; }
  .card-view.revealed { padding: 10px 0 5px; gap: 9px; }
  .card-view:has(.team-board) { padding-top: 8px; gap: 7px; }
  .page { min-height: 210px; padding: 18px 44px; gap: 5px; }
  .revealed .page { min-height: 125px; padding-block: 9px 12px; }
  .reference { min-height: 30px; }
  .ayah { font-size: 4.05rem; }
  .tablets { gap: 13px; }
  .tablet { min-height: 177px; gap: 8px; }
  .revealed .tablet { min-height: 120px; }
  .tablet-text { font-size: 2.23rem; }
  .why > div { padding: 8px 17px 11px; }
  .why h2 { font-size: 1.45rem; }
  .why-en { font-size: calc(1.65rem * var(--why-scale, 1)); }
  .why-ur, .translation p { font-size: calc(1.7rem * var(--why-scale, 1)); }
  .teacher { min-height: 48px; }
}
@media (max-width: 900px) {
  .topbar { display: flex; flex-wrap: wrap; justify-content: space-between; }
  #location { order: 1; flex-basis: 100%; }
  .route { height: auto; grid-template: none / repeat(auto-fit, minmax(112px, 1fr)); gap: 18px 9px; margin-block: 18px; }
  .route .station { grid-area: auto; top: 0; }
  .route-line { display: none; }
  .map-footer { flex-wrap: wrap; }
  .tablets, .why { gap: 8px; }
  .tablet, .revealed .tablet { padding-inline: 10px; }
  .why > div { padding-inline: 12px; }
}
@media (max-width: 560px) {
  .topbar nav, .actions { gap: 6px; flex-wrap: wrap; }
  .control { padding-inline: 9px; font-size: 1.05rem; min-width: 50px; }
  .why { grid-template-columns: 1fr; }
  .translation { border-left: 0; border-top: 1px solid #b28a525c; }
  .page { padding-inline: 24px; }
  .corner { width: 17px; height: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .revealed .thread path { stroke-dashoffset: 0; }
  .particles { display: none; }
}
