/* The Big Relay Seek-and-Find — styles
   Mobile-first. ACS palette. Fallbacks for older phones:
   solid colors before gradients, margins instead of flex gap,
   plain font-size before clamp, -webkit prefixes. */

:root {
  --purple: #5F249F;
  --purple-light: #A054FF;
  --gold: #FFC600;
  --blue: #2746F8;
  --teal: #2CD5C4;
  --pink: #FF3C96;
  --orange: #FF7500;
  --ink: #1A1A1A;
  --paper: #F6F6F6;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #DCEBFF; /* sky color while loading */
  font-family: 'Source Sans 3', -apple-system, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  touch-action: none;
  -ms-touch-action: none;
  overscroll-behavior: none;
}

h1, h2, h3, .btn, .chip-count {
  font-family: 'Poppins', 'Source Sans 3', -apple-system, Arial, sans-serif;
}

button {
  font: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- the world ---------- */

#world {
  position: fixed;
  top: 61px; left: 0; right: 0; bottom: 0;   /* below the Global Relay Track header */
  cursor: -webkit-grab;
  cursor: grab;
}
#world.dragging { cursor: -webkit-grabbing; cursor: grabbing; }
#world svg { display: block; width: 100%; height: 100%; }

/* injected scene */
#world .find { cursor: pointer; }
#world .find.found { cursor: default; }
#world .hit { fill: rgba(0,0,0,0); stroke: none; }

.hint-ring {
  pointer-events: none;
  animation: hintPulse 1.3s ease-out 3;
  opacity: 0;
}
@keyframes hintPulse {
  0%   { opacity: 0.9; -webkit-transform: scale(0.4); transform: scale(0.4); }
  100% { opacity: 0;   -webkit-transform: scale(1.5); transform: scale(1.5); }
}

/* ---------- top bar ---------- */

#topbar {
  position: fixed;
  top: 61px; left: 0; right: 0;
  padding: 10px 12px;
  padding-top: -webkit-calc(10px + env(safe-area-inset-top));
  padding-top: calc(10px + env(safe-area-inset-top));
  pointer-events: none;
  z-index: 20;
}
#topbar .pill {
  display: inline-block;
  vertical-align: top;
  background: #fff;
  background: rgba(255,255,255,0.94);
  border-radius: 22px;
  box-shadow: 0 2px 8px rgba(31,10,61,0.18);
  pointer-events: auto;
}
#level-pill {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple);
  font-family: 'Poppins', Arial, sans-serif;
}
#level-pill .lv-name { color: var(--ink); font-weight: 400; font-family: 'Source Sans 3', Arial, sans-serif; }
#progress-pill {
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-left: 6px;
}
#topbar .right { float: right; }
.iconbtn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: #fff;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 2px 8px rgba(31,10,61,0.18);
  margin-left: 8px;
  color: var(--purple);
  pointer-events: auto;
}
.iconbtn svg { width: 22px; height: 22px; vertical-align: middle; }
.iconbtn.off { color: #A7A8A9; }

/* ---------- tray ---------- */

#traybar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  background: #fff;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 -3px 14px rgba(31,10,61,0.18);
  padding: 8px 8px;
  padding-bottom: -webkit-calc(8px + env(safe-area-inset-bottom));
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  touch-action: pan-x;
  -ms-touch-action: pan-x;
}
#tray {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  margin-right: 66px; /* room for the hint button */
}
#tray::-webkit-scrollbar { display: none; }

.chip {
  display: inline-block;
  vertical-align: top;
  width: 58px;
  min-height: 66px;
  margin-right: 4px;
  padding: 4px 2px 2px;
  border-radius: 12px;
  text-align: center;
  position: relative;
}
.chip:active { background: #F1E9FB; }
.chip .chip-art { width: 34px; height: 34px; margin: 0 auto; position: relative; }
.chip .chip-art svg { width: 34px; height: 34px; }
.chip-count {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 3px;
}
.chip.done .chip-art { opacity: 0.45; }
.chip.done .chip-count { color: var(--purple); }
.chip .tick {
  display: none;
  position: absolute;
  top: -2px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 9px;
  background: var(--gold);
  color: var(--purple);
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
}
.chip.done .tick { display: block; }
.chip.bump .chip-art { animation: chipBump 0.45s ease; }
@keyframes chipBump {
  0% { -webkit-transform: scale(1); transform: scale(1); }
  40% { -webkit-transform: scale(1.35); transform: scale(1.35); }
  100% { -webkit-transform: scale(1); transform: scale(1); }
}

#hintbtn {
  position: absolute;
  right: 8px;
  bottom: -webkit-calc(8px + env(safe-area-inset-bottom));
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: 58px;
  min-height: 66px;
  border-radius: 12px;
  background: var(--purple);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Poppins', Arial, sans-serif;
}
#hintbtn svg { width: 22px; height: 22px; display: block; margin: 2px auto 2px; }
#hintbtn:disabled { background: #A7A8A9; }
#hintbtn .cool { font-size: 12px; font-weight: 600; display: block; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  top: 61px; left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: var(--purple); /* fallback */
  background: -webkit-linear-gradient(300deg, #4B1C80, #5F249F 55%, #7A35C4);
  background: linear-gradient(150deg, #4B1C80, #5F249F 55%, #7A35C4);
  color: #fff;
  text-align: center;
  padding: 30px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.overlay.hidden, .hidden { display: none; }

.overlay-inner { max-width: 460px; margin: 0 auto; padding-top: 6vh; }

.overlay h1 {
  font-size: 30px;
  font-size: -webkit-clamp(26px, 7vw, 40px);
  font-size: clamp(26px, 7vw, 40px);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 12px;
}
.overlay .tagline {
  font-size: 17px;
  opacity: 0.92;
  margin-bottom: 26px;
}
.overlay .howto {
  font-size: 15px;
  margin-bottom: 8px;
}
.overlay .howto .ico { margin-right: 8px; }
.overlay .soundnote {
  font-size: 13px;
  opacity: 0.78;
  margin-top: 20px;
}

#title-art { width: 190px; max-width: 55%; margin: 0 auto 18px; }
#title-art svg { width: 100%; height: auto; }

.btn {
  display: inline-block;
  min-height: 52px;
  padding: 14px 34px;
  border-radius: 26px;
  font-size: 17px;
  font-weight: 600;
  margin-top: 24px;
}
.btn-gold { background: var(--gold); color: #3B1663; }
.btn-gold:active { background: #E5B200; }
.btn-ghost {
  background: transparent;
  border: 2px solid #fff;
  border: 2px solid rgba(255,255,255,0.75);
  color: #fff;
  margin-top: 12px;
}
.btn-row .btn { margin-left: 6px; margin-right: 6px; }

/* help + item sheet share a light card look */
.card-overlay {
  position: fixed;
  top: 61px; left: 0; right: 0; bottom: 0;
  z-index: 45;
  background: rgba(26,10,50,0.55);
}
.card {
  position: absolute;
  left: 50%;
  bottom: 0;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 22px 22px;
  padding-bottom: -webkit-calc(24px + env(safe-area-inset-bottom));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(31,10,61,0.35);
  text-align: center;
}
.card h2 {
  font-size: 20px;
  color: var(--purple);
  margin-bottom: 10px;
}
.card p { font-size: 15px; line-height: 1.5; margin-bottom: 10px; text-align: left; }
.card .big-art { width: 96px; height: 96px; margin: 4px auto 10px; }
.card .big-art svg { width: 96px; height: 96px; }
.card .find-line { font-size: 16px; font-weight: 600; text-align: center; }
.card .closebtn {
  min-height: 48px;
  width: 100%;
  border-radius: 24px;
  background: var(--purple);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Poppins', Arial, sans-serif;
  margin-top: 10px;
}

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 108px;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  z-index: 30;
  background: var(--ink);
  background: rgba(26,26,26,0.92);
  color: #fff;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 20px;
  max-width: 86%;
  text-align: center;
  opacity: 0;
  -webkit-transition: opacity 0.3s ease;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
#toast.show { opacity: 1; }

/* sparkle burst at the tap point */
.burst {
  position: fixed;
  z-index: 35;
  width: 0; height: 0;
  pointer-events: none;
}
.burst span {
  position: absolute;
  left: -5px; top: -5px;
  width: 10px; height: 10px;
  border-radius: 5px;
  background: var(--gold);
  animation: burstFly 0.7s ease-out forwards;
}
.burst span:nth-child(2n) { background: var(--purple-light); }
.burst span:nth-child(3n) { width: 7px; height: 7px; border-radius: 3.5px; }
@keyframes burstFly {
  0%   { opacity: 1; -webkit-transform: translate(0,0) scale(1); transform: translate(0,0) scale(1); }
  100% { opacity: 0; -webkit-transform: translate(var(--bx,0), var(--by,-40px)) scale(0.4); transform: translate(var(--bx,0), var(--by,-40px)) scale(0.4); }
}

/* confetti on the complete screen */
.confetti { position: absolute; top: -20px; width: 10px; height: 16px; opacity: 0.95; animation: confFall 4.2s linear infinite; }
@keyframes confFall {
  0%   { -webkit-transform: translateY(-30px) rotate(0deg); transform: translateY(-30px) rotate(0deg); }
  100% { -webkit-transform: translateY(110vh) rotate(680deg); transform: translateY(110vh) rotate(680deg); }
}

#complete .stats {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 19px;
  margin: 18px 0 6px;
}
#complete .nexty {
  font-size: 15px;
  opacity: 0.9;
  margin-top: 16px;
}

/* no-JS + load error */
#fallback {
  position: fixed;
  top: 61px; left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: var(--purple);
  color: #fff;
  text-align: center;
  padding: 20vh 24px 0;
  font-size: 17px;
  line-height: 1.5;
}
#fallback a { color: var(--gold); }

@media (min-width: 700px) {
  .chip { width: 64px; margin-right: 6px; }
  #tray { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .burst span, .confetti, .chip.bump .chip-art { animation: none; }
  .hint-ring { animation: none; opacity: 0.55; }
}
