/* Al Thubabah — sticker-style UI. Brand palette only (plus alpha). */
:root {
  --purple: #C4C3E3;
  --ink: #504E76;
  --beige: #FDF8E2;
  --green: #A3B565;
  --peach: #FCDD9D;
  --orange: #F1642E;

  --ink-rgb: 80, 78, 118;
  --beige-rgb: 253, 248, 226;
  --orange-rgb: 241, 100, 46;
  --peach-rgb: 252, 221, 157;

  --font: "Baloo Bhaijaan 2", "Trebuchet MS", "Segoe UI", "Geeza Pro", "Noto Sans Arabic", system-ui, sans-serif;
  --line: 3px;
  --r-card: 28px;
  --r-btn: 22px;
  --lift: 0 6px 0 var(--ink);
  --lift-sm: 0 4px 0 var(--ink);
  --pop: cubic-bezier(0.2, 0.9, 0.3, 1.25);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-t: max(14px, env(safe-area-inset-top));
  --safe-b: max(14px, env(safe-area-inset-bottom));
  --safe-l: max(14px, env(safe-area-inset-left));
  --safe-r: max(14px, env(safe-area-inset-right));
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-touch-callout: none;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

[hidden],
.hidden {
  display: none !important;
}

svg {
  fill: currentColor;
}

.svg-sprite {
  position: absolute;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--beige);
}

/* ---------- layers ---------- */

.layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera {
  object-fit: cover;
  background: var(--ink);
}

#camera.mirror {
  transform: scaleX(-1);
}

#game {
  z-index: 3;
  touch-action: none;
  pointer-events: none;
}

body.is-playing #game {
  pointer-events: auto;
}

#pests3d {
  z-index: 1;
  pointer-events: none;
}

.shade {
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.4s var(--ease);
  background:
    linear-gradient(180deg, rgba(var(--ink-rgb), 0.55) 0%, rgba(var(--ink-rgb), 0) 34%),
    linear-gradient(0deg, rgba(var(--ink-rgb), 0.82) 0%, rgba(var(--ink-rgb), 0) 52%);
}

body.is-playing .shade {
  opacity: 0;
}

body.is-modal .shade,
body.on-results .shade,
body.on-pick .shade,
body.on-permission .shade {
  opacity: 1;
  background: rgba(var(--ink-rgb), 0.55);
}

body.is-playing:not(.is-live-camera) .shade {
  opacity: 0;
}

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

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 22px;
  border: var(--line) solid var(--ink);
  border-radius: var(--r-btn);
  font-weight: 800;
  font-size: 20px;
  line-height: 1.1;
  box-shadow: var(--lift);
  transform: translateY(0);
  transition: transform 90ms ease, box-shadow 90ms ease, filter 120ms ease;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--ink);
}

.btn:disabled {
  filter: grayscale(0.6) opacity(0.7);
}

.btn svg {
  width: 22px;
  height: 22px;
}

.btn-primary {
  background: var(--orange);
  color: var(--beige);
  text-shadow: 0 2px 0 rgba(var(--ink-rgb), 0.35);
  box-shadow: var(--lift), inset 0 4px 0 rgba(var(--peach-rgb), 0.45);
}

.btn-primary:active {
  box-shadow: 0 2px 0 var(--ink), inset 0 4px 0 rgba(var(--peach-rgb), 0.45);
}

.btn-secondary {
  background: var(--beige);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: 17px;
  min-height: 44px;
}

.btn-ghost:active {
  transform: none;
  box-shadow: none;
  opacity: 0.7;
}

.btn-xl {
  min-height: 72px;
  font-size: 30px;
  letter-spacing: 0.02em;
}

.btn-sm {
  min-height: 48px;
  font-size: 17px;
  padding: 8px 16px;
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(var(--beige-rgb), 0.22);
}

.btn-icon svg {
  width: 26px;
  height: 26px;
}

.btn-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.btn-stack small {
  font-size: 14px;
  font-weight: 700;
  opacity: 0.9;
  letter-spacing: 0;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  background: var(--beige);
  color: var(--ink);
  box-shadow: var(--lift-sm);
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.icon-btn svg {
  width: 24px;
  height: 24px;
}

.icon-btn.is-off {
  background: var(--purple);
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 16px;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  background: var(--beige);
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--lift-sm);
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.chip-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.chip-btn svg {
  width: 22px;
  height: 22px;
  color: var(--orange);
}

[dir="rtl"] .flip-rtl svg {
  transform: scaleX(-1);
}

/* ---------- cards & screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: screen-in 260ms var(--ease) both;
}

.screen.center {
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
}

/* Centre when it fits, scroll from the top when it doesn't (no clipped headers). */
.screen.center > :first-child {
  margin-top: auto;
}

.screen.center > :last-child {
  margin-bottom: auto;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.card {
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 24px 22px 22px;
  border: var(--line) solid var(--ink);
  border-radius: var(--r-card);
  background: var(--beige);
  box-shadow: 0 10px 0 var(--ink), 0 26px 50px rgba(var(--ink-rgb), 0.35);
  text-align: center;
  animation: card-in 380ms var(--pop) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
}

.card h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
}

.card p {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 600;
}

.card .muted {
  opacity: 0.75;
}

.card .warn {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(var(--orange-rgb), 0.14);
  color: var(--orange);
  font-weight: 800;
}

.card-art {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: -6px auto 2px;
  border: var(--line) solid var(--ink);
  border-radius: 26px;
  background: var(--peach);
  color: var(--orange);
  box-shadow: var(--lift-sm);
  transform: rotate(-6deg);
}

.card-art svg {
  width: 48px;
  height: 48px;
}

.kicker {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange);
}

[dir="rtl"] .kicker {
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

/* ---------- cover ---------- */

.cover {
  justify-content: space-between;
}

.level-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 14px;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  background: var(--beige);
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--lift-sm);
}

.xp-bar {
  position: relative;
  display: block;
  width: 64px;
  height: 10px;
  border-radius: 99px;
  background: rgba(var(--ink-rgb), 0.18);
  overflow: hidden;
}

.xp-bar b {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--green);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 900ms var(--ease);
}

[dir="rtl"] .xp-bar b {
  transform-origin: right center;
}

.logo {
  text-align: center;
  margin-top: 2vh;
}

.logo h1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0;
}

.logo-ar {
  font-size: clamp(76px, 25vw, 132px);
  line-height: 1.05;
  font-weight: 800;
  color: var(--beige);
  text-shadow:
    0 3px 0 var(--ink),
    0 -3px 0 var(--ink),
    3px 0 0 var(--ink),
    -3px 0 0 var(--ink),
    3px 3px 0 var(--ink),
    -3px 3px 0 var(--ink),
    3px -3px 0 var(--ink),
    -3px -3px 0 var(--ink),
    0 10px 0 var(--ink),
    0 18px 26px rgba(var(--ink-rgb), 0.45);
  animation: logo-bob 3.2s ease-in-out infinite;
}

@keyframes logo-bob {
  50% {
    transform: translateY(-5px) rotate(-1deg);
  }
}

.logo-en {
  margin-top: 4px;
  padding: 4px 16px 2px;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  background: var(--orange);
  color: var(--beige);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  box-shadow: var(--lift-sm);
  transform: rotate(-2deg);
}

.tagline {
  margin: 14px 0 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--beige);
  text-shadow: 0 2px 0 var(--ink), 0 4px 12px rgba(var(--ink-rgb), 0.6);
}

.dock {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(100%, 420px);
  margin: 0 auto;
}

.best {
  align-self: center;
  margin: 0;
  padding: 4px 16px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.55);
  color: var(--peach);
  font-weight: 800;
  font-size: 17px;
}

.best b {
  color: var(--beige);
  font-size: 20px;
}

.dock .btn-xl {
  justify-content: flex-start;
  padding-inline: 14px 22px;
}

.dock .btn-xl .btn-stack {
  flex: 1;
  align-items: center;
  padding-inline-end: 44px;
}

.dock-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.dock-row .chip-btn {
  flex: 1 1 auto;
  justify-content: center;
  padding-inline: 10px;
  white-space: nowrap;
  font-size: 15px;
}

.dock-row .chip-btn svg {
  flex: none;
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 2px 0 0;
  color: var(--beige);
  font-size: 14px;
  font-weight: 700;
  opacity: 0.92;
}

.privacy-note svg {
  width: 16px;
  height: 16px;
  color: var(--green);
}

.legal {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 13px;
  font-weight: 700;
}

.legal a {
  color: var(--purple);
  text-decoration: none;
  padding: 4px;
}

.card .legal a {
  color: var(--ink);
  opacity: 0.7;
}

/* ---------- weapon pick ---------- */

.pick-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(100%, 440px);
  margin: auto;
  text-align: center;
}

.pick-body h2 {
  margin: -6px 0 6px;
  font-size: 34px;
  font-weight: 800;
  color: var(--beige);
  text-shadow: 0 3px 0 var(--ink);
}

.pick .kicker {
  color: var(--peach);
}

.weapons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.weapon {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: var(--line) solid var(--ink);
  border-radius: 24px;
  background: var(--beige);
  text-align: start;
  box-shadow: var(--lift);
  transition: transform 120ms var(--ease), box-shadow 120ms ease, background 120ms ease;
}

.weapon:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--ink);
}

.weapon[aria-checked="true"] {
  background: var(--peach);
  box-shadow: var(--lift), 0 0 0 4px var(--orange);
}

.weapon-art {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(var(--ink-rgb), 0.08);
}

.weapon[aria-checked="true"] .weapon-art {
  animation: wiggle 600ms var(--pop);
}

@keyframes wiggle {
  30% {
    transform: rotate(-12deg) scale(1.08);
  }
  60% {
    transform: rotate(8deg);
  }
}

.weapon-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.weapon-text b {
  font-size: 22px;
  line-height: 1.1;
}

.weapon-text small {
  font-size: 15px;
  font-weight: 600;
  opacity: 0.78;
}

.weapon-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: var(--line) solid var(--ink);
  border-radius: 50%;
  background: var(--beige);
  color: transparent;
}

.weapon[aria-checked="true"] .weapon-mark {
  background: var(--orange);
  color: var(--beige);
}

.weapon-mark svg {
  width: 20px;
  height: 20px;
}

.weapon.is-locked {
  background: rgba(var(--beige-rgb), 0.72);
}

.weapon.is-locked .weapon-art {
  filter: grayscale(1) opacity(0.5);
}

.weapon.is-locked .weapon-mark {
  background: var(--purple);
  color: var(--ink);
}

.weapon.is-locked .weapon-text small {
  color: var(--orange);
  opacity: 1;
  font-weight: 800;
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  inset: 0 0 auto;
  z-index: 6;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
  pointer-events: none;
}

.timer-track {
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: rgba(var(--ink-rgb), 0.35);
}

.timer-track i {
  position: absolute;
  inset: 0;
  background: var(--orange);
  transform-origin: left center;
}

[dir="rtl"] .timer-track i {
  transform-origin: right center;
}

.hud-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}

.hud-row .icon-btn {
  pointer-events: auto;
  align-self: center;
}

.pill {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 4px 6px 2px;
  border: var(--line) solid var(--ink);
  border-radius: 18px;
  background: var(--beige);
  box-shadow: var(--lift-sm);
  overflow: hidden;
}

.pill b {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.pill span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
}

[dir="rtl"] .pill span {
  letter-spacing: 0;
  font-size: 12px;
}

.pill-time b.urgent {
  color: var(--orange);
  animation: urgent 0.5s ease-in-out infinite alternate;
}

@keyframes urgent {
  to {
    transform: scale(1.14);
  }
}

.pill-combo.hot {
  background: var(--orange);
  color: var(--beige);
}

.pill-combo b.pulse {
  animation: pulse 320ms var(--pop);
}

@keyframes pulse {
  40% {
    transform: scale(1.45) rotate(-6deg);
  }
}

#combo-decay {
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: var(--peach);
  transform-origin: left center;
  transform: scaleX(0);
}

.boss-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 6px 12px;
  border: var(--line) solid var(--ink);
  border-radius: 16px;
  background: var(--beige);
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--lift-sm);
  animation: card-in 360ms var(--pop) both;
}

.boss-bar i {
  position: relative;
  flex: 1;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: rgba(var(--ink-rgb), 0.15);
  overflow: hidden;
}

.boss-bar b {
  position: absolute;
  inset: 0;
  background: var(--orange);
  transform-origin: left center;
  transition: transform 160ms var(--ease);
}

[dir="rtl"] #combo-decay,
[dir="rtl"] .boss-bar b {
  transform-origin: right center;
}

/* ---------- in-round overlays ---------- */

.banner {
  position: absolute;
  inset: 30% 0 auto;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  animation: banner 1.9s var(--pop) both;
}

.banner strong {
  padding: 6px 26px 2px;
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  background: var(--orange);
  color: var(--beige);
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 800;
  line-height: 1.1;
  box-shadow: var(--lift);
  transform: rotate(-3deg);
}

.banner span {
  margin-top: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.8);
  color: var(--beige);
  font-size: 17px;
  font-weight: 800;
}

.banner.boss strong {
  background: var(--ink);
  color: var(--peach);
  border-color: var(--peach);
}

.banner.event strong {
  background: var(--green);
}

@keyframes banner {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  14% {
    opacity: 1;
    transform: scale(1.06);
  }
  22% {
    transform: scale(1);
  }
  82% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.92) translateY(-12px);
  }
}

.callout {
  position: absolute;
  inset: 21% 0 auto;
  z-index: 7;
  text-align: center;
  pointer-events: none;
  font-size: 34px;
  font-weight: 800;
  color: var(--peach);
  text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(var(--ink-rgb), 0.5);
  animation: callout 900ms var(--pop) both;
}

@keyframes callout {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  25% {
    opacity: 1;
    transform: scale(1.12);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-16px);
  }
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: clamp(110px, 40vw, 200px);
  font-weight: 800;
  color: var(--beige);
  text-shadow: 0 6px 0 var(--ink), 0 -3px 0 var(--ink), 4px 0 0 var(--ink), -4px 0 0 var(--ink), 0 20px 40px rgba(var(--ink-rgb), 0.5);
}

.countdown.pop {
  animation: count 560ms var(--pop) both;
}

.countdown.go {
  color: var(--peach);
  font-size: clamp(80px, 28vw, 150px);
}

@keyframes count {
  0% {
    opacity: 0;
    transform: scale(2.2);
  }
  35% {
    opacity: 1;
    transform: scale(0.94);
  }
  55% {
    transform: scale(1);
  }
  100% {
    opacity: 0.2;
    transform: scale(0.86);
  }
}

.toast {
  position: absolute;
  inset: auto var(--safe-r) calc(var(--safe-b) + 8px) var(--safe-l);
  z-index: 40;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 18px;
  border: var(--line) solid var(--ink);
  border-radius: 18px;
  background: var(--ink);
  color: var(--beige);
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(var(--ink-rgb), 0.4);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 260ms var(--pop);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* On the results screen messages sit right above the card, not down at the bottom. */
.toast.above-card {
  transform: translateY(-14px);
}

.toast.above-card.show {
  transform: translateY(0);
}

/* ---------- AR ---------- */

body.is-xr,
body.is-xr #app {
  background: transparent;
}

body.is-xr #pests3d,
body.is-xr #camera,
body.is-xr #fallback,
body.is-xr .shade {
  display: none !important;
}

.scan {
  position: absolute;
  inset: auto var(--safe-r) calc(var(--safe-b) + 24px) var(--safe-l);
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 420px;
  margin: 0 auto;
  padding: 18px 20px;
  border: var(--line) solid var(--ink);
  border-radius: 24px;
  background: var(--beige);
  text-align: center;
  box-shadow: var(--lift);
  animation: card-in 360ms var(--pop) both;
}

.scan strong {
  font-size: 22px;
  line-height: 1.15;
}

.scan span {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.8;
}

.scan .scan-ring {
  width: 54px;
  height: 22px;
  border: 4px solid var(--orange);
  border-radius: 50%;
  opacity: 1;
  animation: scan-ring 1.2s ease-in-out infinite;
}

@keyframes scan-ring {
  50% {
    transform: scale(1.25);
    opacity: 0.5;
  }
}

/* ---------- results ---------- */

.results .card {
  gap: 8px;
  padding-block: 18px;
}

.results h2 {
  font-size: 26px;
  color: var(--orange);
}

.res-score {
  position: relative;
  display: flex;
  justify-content: center;
}

.res-score b {
  font-size: clamp(64px, 21vw, 96px);
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 5px 0 rgba(var(--ink-rgb), 0.18);
}

.badge {
  position: absolute;
  top: -26px;
  inset-inline-end: -6px;
  padding: 4px 12px;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  background: var(--green);
  color: var(--beige);
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--lift-sm);
  transform: rotate(8deg);
  animation: badge 700ms var(--pop) 500ms both;
}

@keyframes badge {
  from {
    opacity: 0;
    transform: rotate(30deg) scale(0.2);
  }
}

.xp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 15px;
}

.xp-row .xp-bar {
  flex: 1;
  height: 14px;
  border: 2px solid var(--ink);
}

#res-xp-gain {
  color: var(--green);
}

.res-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 8px;
  margin: 4px 0;
  padding: 0;
  list-style: none;
}

.results .res-stats {
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.results .res-stats li {
  padding: 6px 2px;
}

.results .res-stats b {
  font-size: 20px;
}

.results .res-stats span {
  font-size: 11px;
  line-height: 1.15;
}

.res-stats li {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 16px;
  background: rgba(var(--peach-rgb), 0.6);
}

.res-stats b {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
}

.res-stats span {
  font-size: 12px;
  font-weight: 800;
  opacity: 0.75;
}

/* ---------- "share with friends" pop-up ---------- */

.share-card {
  gap: 10px;
}

.share-icon {
  align-self: center;
  width: 64px;
  height: 64px;
  padding: 14px;
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  background: var(--peach);
  color: var(--orange);
  box-shadow: var(--lift-sm);
  animation: share-wiggle 900ms var(--pop) 250ms both;
}

.card .share-score {
  margin: 0;
  color: var(--orange);
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(var(--ink-rgb), 0.18);
}

.card .share-body {
  font-size: 16px;
  font-weight: 700;
  opacity: 0.8;
}

@keyframes share-wiggle {
  0% {
    transform: scale(0.4) rotate(-12deg);
  }
  60% {
    transform: scale(1.12) rotate(6deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .share-icon {
    animation: none;
  }
}

.res-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------- ads ---------- */

.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.ad-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple);
}

.ad-frame,
.ad-preview {
  display: block;
  max-width: 100%;
  border: 0;
  border-radius: 12px;
  background: rgba(var(--beige-rgb), 0.9);
}

.ad-preview {
  display: grid;
  place-items: center;
  border: 2px dashed var(--purple);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}

/* ---------- leaderboard ---------- */

.challenge {
  margin: 0;
  padding: 10px 14px;
  border: var(--line) solid var(--ink);
  border-radius: 18px;
  background: var(--green);
  color: var(--beige);
  font-weight: 800;
  font-size: 17px;
  text-align: center;
  box-shadow: var(--lift-sm);
  animation: card-in 420ms var(--pop) both;
}

.friends-news {
  background: var(--orange);
  font-size: 16px;
}

/* a moment worth showing off: the challenge button lights up and breathes until tapped */
.btn-secondary.pulse {
  background: var(--peach);
  animation: share-pulse 1.5s ease-in-out infinite;
}

@keyframes share-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-secondary.pulse {
    animation: none;
  }
}

.res-rank,
.res-challenge {
  margin: -2px 0 0;
  font-weight: 800;
  font-size: 16px;
}

.res-rank {
  color: var(--ink);
}

.res-challenge {
  color: var(--orange);
}

/* fits between the notch and the home bar; the board / trophies scroll inside */
.ranks {
  max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 12px);
  /* small phones with the name editor open: the whole card scrolls */
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ranks > * {
  flex-shrink: 0;
}

.ranks > .board,
.ranks > #trophy-pane {
  flex: 0 1 auto;
  min-height: 96px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.me-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(var(--peach-rgb), 0.7);
  text-align: start;
}

.me-row small {
  display: block;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.7;
}

.me-row b {
  font-size: 18px;
}

.chip-btn.small {
  min-height: 40px;
  padding: 4px 12px;
  font-size: 14px;
  box-shadow: 0 3px 0 var(--ink);
}

.save-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: -4px;
}

.link-btn {
  min-height: 36px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 14px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.8;
}

.save-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: var(--line) dashed var(--ink);
  border-radius: 16px;
  text-align: center;
}

.save-box[hidden] {
  display: none;
}

.card .save-code {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  user-select: all;
  -webkit-user-select: all;
}

.card .save-hint {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.75;
}

.name-form .small-btn {
  min-height: 48px;
  font-size: 18px;
}

.name-form input {
  min-width: 0;
  min-height: 44px;
  padding: 4px 12px;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: var(--beige);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.card .name-error {
  margin: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--peach);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.card .name-error[hidden] {
  display: none;
}

.suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
}

.suggest-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.suggest-chip {
  min-height: 36px;
  padding: 4px 12px;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: var(--peach);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
}

.suggest-chip:active {
  transform: translateY(1px);
}

.confirm-modal {
  z-index: 31;
}

.confirm-card {
  max-width: 360px;
}

.card .confirm-name {
  margin: 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(var(--peach-rgb), 0.7);
  font-size: 26px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.card .confirm-body {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  opacity: 0.8;
}

.restore-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.restore-row .chip-btn {
  flex: 1 0 auto;
  justify-content: center;
}

.restore-row input {
  flex: 1 1 200px;
  min-width: 0;
  text-align: center;
  min-height: 40px;
  padding: 4px 10px;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: var(--beige);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tabs {
  align-self: stretch;
  justify-content: stretch;
}

.tabs button {
  flex: 1;
  padding-inline: 4px;
  white-space: nowrap;
  font-size: 14px;
}

.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--beige);
}

.board {
  min-height: 120px;
  overflow-y: auto;
  text-align: start;
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.board-list li {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  font-weight: 700;
}

.board-list li:nth-child(odd) {
  background: rgba(var(--ink-rgb), 0.05);
}

.board-list li.me {
  background: var(--orange);
  color: var(--beige);
}

.board-list .rank {
  font-weight: 800;
  opacity: 0.75;
}

.board-list li:nth-child(-n + 3) .rank {
  color: var(--orange);
  opacity: 1;
}

.board-list li.me .rank {
  color: var(--beige);
}

.board-list .pts {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.board-mine {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--beige);
  font-weight: 800;
  text-align: center;
}

/* ---------- modals ---------- */

.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: rgba(var(--ink-rgb), 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: fade 200ms ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.how-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 6px;
  padding: 0;
  list-style: none;
  text-align: start;
}

.how-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.how-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: var(--line) solid var(--ink);
  border-radius: 12px;
  background: var(--peach);
  font-weight: 800;
}

.how-list p {
  font-size: 16px;
}

.trophy-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: start;
}

.trophy-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 2px solid rgba(var(--ink-rgb), 0.2);
  border-radius: 16px;
  font-weight: 800;
  opacity: 0.5;
}

.trophy-list li.got {
  border-color: var(--ink);
  background: var(--peach);
  opacity: 1;
}

.trophy-list svg {
  width: 26px;
  height: 26px;
  color: var(--ink);
}

.trophy-list li.got svg {
  color: var(--orange);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 4px;
  border-bottom: 2px solid rgba(var(--ink-rgb), 0.12);
  font-weight: 800;
  font-size: 18px;
}

.switch {
  position: relative;
  width: 60px;
  height: 34px;
  padding: 0;
  border: var(--line) solid var(--ink);
  border-radius: 99px;
  background: var(--purple);
  transition: background 160ms ease;
}

.switch i {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 22px;
  height: 22px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--beige);
  transition: transform 180ms var(--pop);
}

.switch[aria-checked="true"] {
  background: var(--green);
}

.switch[aria-checked="true"] i {
  transform: translateX(26px);
}

[dir="rtl"] .switch[aria-checked="true"] i {
  transform: translateX(-26px);
}

.segmented {
  display: flex;
  padding: 3px;
  border: var(--line) solid var(--ink);
  border-radius: 14px;
  background: rgba(var(--ink-rgb), 0.08);
}

.segmented button {
  padding: 6px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 800;
  font-size: 15px;
}

.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--beige);
}

.noscript {
  position: fixed;
  inset: 40% 20px auto;
  text-align: center;
  font-size: 20px;
}

/* ---------- responsive ---------- */

@media (max-height: 640px) {
  .logo-ar {
    font-size: clamp(60px, 18vw, 96px);
  }

  .tagline {
    margin-top: 6px;
    font-size: 18px;
  }

  .btn-xl {
    min-height: 62px;
    font-size: 26px;
  }

  .dock {
    gap: 9px;
  }

  .weapon {
    padding: 8px 12px;
  }

  .weapon-art {
    width: 52px;
    height: 52px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .cover {
    display: grid;
    grid-template-columns: 1fr minmax(300px, 380px);
    grid-template-rows: auto 1fr;
    column-gap: 24px;
  }

  .cover .topbar {
    grid-column: 1 / -1;
  }

  .cover .logo {
    align-self: center;
    margin: 0;
  }

  .cover .dock {
    align-self: center;
  }

  .privacy-note,
  .cover .legal {
    display: none;
  }

  .weapons {
    flex-direction: row;
  }

  .weapon {
    flex-direction: column;
    flex: 1;
    text-align: center;
  }

  .weapon-mark {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
  }

  .pick-body h2 {
    font-size: 26px;
    margin: -4px 0 2px;
  }

  .results {
    flex-direction: row;
  }

  .res-score b {
    font-size: 64px;
  }
}

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