@font-face {
  font-family: Nastaliq;
  src: url('/shared/fonts/noto-nastaliq-urdu.woff2') format('woff2');
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: 'Trebuchet MS', system-ui, sans-serif;
  color: #fff5dc;
  background: #261c43;
  --lilac: #d4c4ff;
  --gold: #ffda8d;
  --gap: clamp(8px, 1.15vh, 14px);
  --pad: clamp(16px, 2.7vw, 52px);
  --braid: repeating-linear-gradient(115deg, #6e3b22 0 3px, #ac6635 4px 7px, #f3c47b 10px 14px, #c1884d 16px 20px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 20% 25%, #503774, transparent 54%),
    radial-gradient(ellipse at 85% 76%, #6c364c, transparent 59%), #261c43;
}
button, a {
  font: inherit;
  font-weight: 700;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 4px solid #fff2a7; outline-offset: 4px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px var(--pad);
  min-height: clamp(82px, 9.4vh, 106px);
  border-bottom: 1px solid #ffffff26;
  background: #201833bf;
}
.brand { display: flex; align-items: center; gap: clamp(12px, 1.9vw, 35px); white-space: nowrap; }
.brand h1 { margin: 0; font-size: clamp(26px, 3.3vw, 60px); letter-spacing: -.045em; }
.urdu { font: 400 1em/2.2 Nastaliq, serif; }
.brand .urdu { font-size: clamp(20px, 2vw, 39px); color: var(--gold); padding-bottom: .26em; }
nav { display: flex; gap: 8px; align-items: center; }
nav :is(a, button), .quiet, dialog button {
  display: grid;
  place-items: center;
  text-decoration: none;
  text-align: center;
  min-height: 56px;
  padding: 8px 16px;
  border: 1px solid #e2ceff64;
  border-radius: 12px;
  background: #3a2b52;
  font-size: clamp(15px, 1.35vw, 24px);
}
main { flex: 1; min-height: 0; display: grid; padding: var(--gap) var(--pad) 16px; }
.map {
  align-self: center;
  width: min(100%, 1520px);
  justify-self: center;
  text-align: center;
  display: grid;
  gap: clamp(22px, 4.4vh, 52px);
}
.map-intro h2, .finish h2 {
  margin: 0;
  font-size: clamp(46px, 6vw, 112px);
  letter-spacing: -.05em;
  line-height: 1.06;
  text-shadow: 0 5px 0 #241936;
}
.map-intro p, .finish p { font-size: clamp(19px, 2.1vw, 34px); margin: 12px 0 0; }
.map-animals {
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(64px, 9.5vh, 110px);
  filter: drop-shadow(0 8px 6px #20142b80);
}
.map-animals span {
  position: relative;
  width: clamp(90px, 13vw, 240px);
  height: 19px;
  background: var(--braid);
  border-radius: 30px;
  box-shadow: inset 0 -4px 3px #572d22a0;
}
.map-animals span::after, .ribbon {
  content: '';
  position: absolute;
  left: 50%;
  top: -4px;
  width: 20px;
  height: 43px;
  background: linear-gradient(90deg, #a62b54, #f78091 55%, #d64166);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  translate: -50% 0;
}
.path { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(12px, 2vw, 30px); isolation: isolate; position: relative; }
.path::before {
  content: '';
  position: absolute;
  top: 50%;
  inset-inline: 5%;
  z-index: -1;
  height: 16px;
  border-radius: 15px;
  background: var(--braid);
  box-shadow: 0 5px 12px #20142b80;
}
.level {
  min-height: clamp(190px, 29vh, 320px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  gap: 5px;
  border: 3px solid #fff2c0;
  border-radius: 40% 40% 24px 24px / 22% 22% 24px 24px;
  background: linear-gradient(155deg, #fff1cf, #ebbf76);
  color: #382446;
  box-shadow: 0 8px 0 #ac744a, 0 16px 22px #21132d77, inset 0 0 0 3px #b788604f;
}
.level:disabled {
  background: linear-gradient(150deg, #554368, #3f2e53);
  border-color: #9b82ac;
  color: #eee0f4;
  box-shadow: 0 8px 0 #271c3a, 0 16px 22px #21132d77;
}
.level:disabled .level-icon { filter: saturate(.35); opacity: .68; }
.level-number { font-size: clamp(15px, 1.4vw, 23px); }
.level-icon { font-size: clamp(47px, 8vh, 95px); line-height: 1.2; }
.level strong { font-size: clamp(19px, 2vw, 34px); line-height: 1.15; }
.level-stars { font-size: clamp(18px, 1.65vw, 29px); }
.quiet { justify-self: end; }
.race {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: var(--gap);
  min-width: 0;
}
#scoreboard, .words, .lanes { --players-gap: clamp(16px, 4.4vw, 96px); }
.words, .lanes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--players-gap); }
.player-badge { box-shadow: 0 5px 0 #1d153566; }
.round-clock {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: center;
  font-size: clamp(15px, 1.3vw, 23px);
  font-weight: 700;
  color: #f6e9ff;
}
.sand-timer { width: clamp(76px, 9vw, 165px); height: 8px; background: #1c142dcc; border-radius: 9px; overflow: hidden; }
.sand-timer span { display: block; height: 100%; background: var(--gold); transform-origin: left; border-radius: inherit; }
.word-card {
  display: grid;
  place-items: center;
  min-height: clamp(93px, 14.8vh, 165px);
  padding: 0 .5rem .45rem;
  border-radius: 18px;
  background: #231a3994;
  border: 1px solid #d4c4ff63;
  box-shadow: inset 0 3px 12px #1f142f70;
}
.word-card:nth-child(2) { border-color: #ffda8d63; }
.round-word { font-size: clamp(36px, min(5vw, 5.85vh), 72px); line-height: 1.63; }
.arena {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 2vw, 35px);
  min-height: clamp(65px, 11vh, 122px);
  position: relative;
}
.animal {
  font-size: clamp(58px, 10vh, 112px);
  line-height: 1;
  filter: drop-shadow(0 8px 5px #1b132e75);
}
.rope { position: relative; height: 29px; --pull: 0; }
.rope-strand {
  position: absolute;
  inset: 0;
  border-radius: 30px;
  background: var(--braid);
  background-position-x: calc(var(--pull) * 9px);
  box-shadow: inset 0 3px 3px #ffebaa8c, inset 0 -6px 5px #623624b0, 0 9px 10px #170e2d6e;
  transition: background-position .32s ease-out;
}
.rope-marks {
  position: absolute;
  inset: -9px 8% auto;
  display: flex;
  justify-content: space-between;
}
.rope-marks i { height: 6px; width: 3px; background: #f7daab; border-radius: 3px; opacity: .62; }
.rope-marks i:is(:first-child, :nth-child(6), :last-child) { opacity: 1; height: 10px; }
.ribbon {
  left: calc(50% + var(--pull) * 8.4%);
  top: -5px;
  width: clamp(18px, 2vw, 40px);
  height: clamp(49px, 6.8vh, 75px);
  transition: left .32s cubic-bezier(.18,.83,.33,1.12);
}
#listen {
  position: absolute;
  bottom: 1px;
  left: 50%;
  translate: -50% 56%;
  min-height: 48px;
  padding: 6px 18px;
  border: 1px solid #edca91;
  border-radius: 999px;
  background: #2a2040;
  font-size: clamp(17px, 1.4vw, 26px);
  z-index: 1;
}
.lane { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 7px; min-width: 0; --edge: #a48ccf; --shadow: #45305f; }
.lane[data-side="1"] { --edge: #d3a066; --shadow: #623447; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); grid-template-rows: repeat(2, minmax(150px, 1fr)); gap: var(--gap); }
.answer {
  min-height: 150px;
  padding: 8px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  appearance: none;
  border: 3px solid var(--edge);
  border-radius: clamp(15px, 1.75vw, 33px);
  color: #372749;
  background: linear-gradient(155deg, #fffae8, #eadcf6);
  box-shadow: 0 5px 0 var(--shadow), inset 0 0 0 3px #ffffff91;
  touch-action: none;
}
[data-side="1"] .answer { background: linear-gradient(155deg, #fffae8, #f9dfb1); }
.answer:not(:disabled):active { translate: 0 3px; }
.picture {
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif;
  font-size: clamp(56px, 9.2vh, 116px);
  line-height: 1.04;
  filter: drop-shadow(0 5px 3px #3d2c4729);
}
.answer-label { font-size: clamp(18px, 1.8vw, 32px); line-height: 1.14; }
.answer:disabled { opacity: .66; }
.answer.correct {
  opacity: 1;
  background: #e9f6c9;
  border-color: #769d57;
  box-shadow: 0 5px 0 #395c44, inset 0 0 0 3px #fff9;
}
.answer.wrong { animation: wobble .38s ease-in-out; }
@keyframes wobble { 25% { transform: rotate(-2deg); } 70% { transform: rotate(2deg); } }
.feedback {
  min-height: 1.2em;
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: clamp(18px, 2.3vh, 29px);
  color: #fff3d0;
}
.finish { align-self: center; text-align: center; }
.finish-stars {
  display: flex;
  justify-content: center;
  gap: .2em;
  color: var(--gold);
  margin-bottom: 10px;
  font-size: clamp(60px, 11vh, 120px);
  text-shadow: 0 5px 0 #9b573b, 0 0 30px #ffda8d55;
}
.finish-stars span { animation: land .55s cubic-bezier(.12,.84,.31,1.35) both; }
.finish-stars span:nth-child(2) { animation-delay: .12s; }
.finish-stars span:nth-child(3) { animation-delay: .24s; }
@keyframes land { from { opacity: 0; transform: translateY(-50px) scale(.6) rotate(-20deg); } }
.finish-scores, .finish-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin-top: 26px; }
.finish-scores div {
  display: grid;
  gap: .25em;
  min-width: 255px;
  padding: 16px 24px;
  border-radius: 18px;
  background: #2d2254;
  color: var(--lilac);
  font-size: clamp(22px, 2.5vw, 43px);
  border: 2px solid currentColor;
}
.finish-scores div + div { color: var(--gold); background: #542a46; }
.finish-scores span { font-size: .8em; color: #fff5dc; }
.finish-actions button {
  min-width: 180px;
  min-height: 120px;
  padding: 12px 26px;
  border-radius: 20px;
  background: var(--gold);
  border: 2px solid #fff1bd;
  color: #2d2254;
  font-size: clamp(22px, 2vw, 34px);
  box-shadow: 0 6px 0 #9b573b;
}
.finish-actions button + button { background: var(--lilac); border-color: #ebe2ff; box-shadow: 0 6px 0 #523877; }
dialog { background: #2d2254; color: #fff5dc; border: 2px solid var(--lilac); border-radius: 20px; padding: 24px; }
dialog::backdrop { background: #1a102bd4; }
dialog form { display: flex; gap: 10px; }
@media (min-width: 850px) and (min-height: 770px) {
  body { height: 100dvh; }
}
@media (max-width: 650px) {
  .topbar { flex-wrap: wrap; }
  nav { flex-wrap: wrap; }
  .path { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #scoreboard, .words, .lanes { --players-gap: 8px; }
  #scoreboard { --players-size: 16px; }
  .answers { grid-template-columns: 1fr; }
  .round-word { font-size: clamp(25px, 7vw, 40px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
