:root {
  --bg: #3174de;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --accent: #7c5cff;
  --accent2: #36d1dc;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);
  background: url("/assets/img/background.png") center / cover no-repeat, var(--bg);
  overflow: hidden;
}

/* Hide scrollbars globally while preserving scroll functionality */
html, body {
  -ms-overflow-style: none; /* IE and old Edge */
  scrollbar-width: none;    /* Firefox */
  touch-action: pan-y;
  overscroll-behavior-x: none;
}
html.no-scroll,
body.no-scroll {
  overflow: hidden !important;
  touch-action: none;
  overscroll-behavior: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar,
.popupBody::-webkit-scrollbar {
  display: none;            /* Chrome, Safari, new Edge */
}
.popupBody {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Disable text selection across the app */
* {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.intro-active .intro {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Intro Overlay */
.mobileIntroOverlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: url("img/background.png") center/cover no-repeat, var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 600ms ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobileIntroOverlay.active {
  opacity: 1;
  pointer-events: auto;
}

.mobileIntroContent {
  max-width: 500px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 24px;
  color: #fff;
  font-size: 15px;
  line-height: 1.5;
  text-align: justify;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  margin: auto 0; /* Centers content if it's smaller than screen, otherwise allows scrolling */
}

.mobileIntroContent p {
  margin-bottom: 1em;
}

.mobileIntroContent .signature {
  margin-top: 1.5em;
  text-align: right;
  font-weight: 600;
  font-size: 0.9em;
  color: rgba(255, 255, 255, 0.8);
}

.mobileIntroButton {
  display: block;
  width: 100%;
  margin-top: 1.5em;
  padding: 14px;
  background: linear-gradient(135deg, #7c5cff, #36d1dc);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(124, 92, 255, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobileIntroButton:active {
  transform: scale(0.98);
  box-shadow: 0 5px 10px rgba(124, 92, 255, 0.2);
}

@media (min-width: 768px) {
  .mobileIntroOverlay {
    display: none !important;
  }
}

.phone {
  height: 100svh;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  position: relative;
  display: grid;
  grid-template-rows: clamp(170px, 32svh, 240px) 1fr;
  gap: 0;
  transition: opacity 520ms ease, transform 520ms ease, filter 520ms ease;
}

body.intro-active .phone {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(10px);
  pointer-events: none;
}

.intro {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  opacity: 1;
  transition: opacity 520ms ease;
}

.intro.out {
  opacity: 0;
  pointer-events: none;
}

.intro video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stage {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  display: grid;
  place-items: center;
  position: relative;
  --ring-center-y: 100%;
  --ring-shift: 20%;
}

.carousel {
  width: 100%;
  height: 100%;
  position: relative;
  pointer-events: auto;
  touch-action: pan-y;
  user-select: none;
}

.stageTitleContainer {
  position: absolute;
  left: 50%;
  top: calc(var(--ring-center-y, 50%) - 72%);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 100;
  pointer-events: none;
  max-width: 92%;
}

.stageTitleMain {
  color: rgba(255, 255, 255, 0.98);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(14px, 3.8vw, 16px);
  text-align: center;
  white-space: nowrap;
}

.stageTitleSub {
  color: rgba(255, 255, 255, 0.95);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: clamp(18px, 4.8vw, 21px);
  opacity: 0.95;
  white-space: nowrap;
  overflow: hidden;
}

.mapArea {
  width: min(100%, 440px, 100svh);
  height: auto;
  aspect-ratio: 1 / 1;
  max-height: 100%;
  border: 0;
  padding: 0;
  margin: 30% 0 0;
  border-radius: 0;
  overflow: hidden;
  background: #2b6fd6;
  box-shadow: none;
  position: relative;
  cursor: pointer;
  align-self: start;
  justify-self: center;
  display: block;
}

.mapStill,
.mapVideo,
.mapAfter {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  transform: none;
  transition: opacity 520ms ease;
}

.mapStill {
  z-index: 1;
  opacity: 1;
}

.mapVideo {
  z-index: 2;
  opacity: 0;
}

.mapAfter {
  z-index: 3;
  opacity: 0;
}

.mapArea.playing .mapStill {
  opacity: 0;
}

.mapArea.playing .mapVideo {
  opacity: 1;
}

.mapArea.finished {
  cursor: default;
}

.mapArea:disabled {
  cursor: default;
}

.mapArea.finished .mapStill {
  opacity: 0;
}

.mapArea.finished .mapVideo {
  opacity: 0;
}

.mapArea.finished .mapAfter {
  opacity: 1;
}

.houses {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
}

.house {
  --house-x: 50%;
  --house-y: 80%;
  width: clamp(18px, 4.8vw, 24px);
  height: clamp(18px, 4.8vw, 24px);
  background: transparent;
  transform-origin: center bottom;
  position: absolute;
  left: var(--house-x);
  top: var(--house-y);
  transform: translate(-50%, 0) scaleY(0.1);
  opacity: 0;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center bottom;
}

.house::before,
.house::after {
  content: none;
  display: none;
}

.house { background-image: url("/assets/img/hiska.png"); }

.house-1 {
  --house-x: 53.88%;
  --house-y: 45.96%;
}

.house-2 {
  --house-x: 44.83%;
  --house-y: 40.36%;
}

.house-3 {
  --house-x: 52.91%;
  --house-y: 35.51%;
}

.house-4 {
  --house-x: 47.20%;
  --house-y: 30.76%;
}

.house-5 {
  --house-x: 41.27%;
  --house-y: 27.85%;
}

.house-6 {
  --house-x: 24.57%;
  --house-y: 54.80%;
}

.house-7 {
  --house-x: 59.27%;
  --house-y: 53.83%;
}

.house-8 {
  --house-x: 66.92%;
  --house-y: 62.02%;
}

.house-door { display: none; }

.popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 12000;
  transition: opacity 220ms ease;
}

.popup.open {
  opacity: 1;
  pointer-events: auto;
}

.popupDialog {
  width: min(92vw, 380px);
  border-radius: 18px;
  background: #fdfdff;
  box-shadow: 0 20px 50px rgba(6, 16, 40, 0.68);
  padding: 16px 16px 14px;
  color: #081020;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(13, 40, 80, 0.14);
  max-height: 86vh;
  grid-template-rows: auto 1fr;
}

.popupHeader {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(15, 32, 70, 0.08);
}

.popupTitle {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(9, 23, 60, 0.96);
  grid-column: 2;
  justify-self: center;
  text-align: center;
}

.popupClose {
  border: 0;
  background: rgba(9, 23, 60, 0.06);
  color: rgba(9, 23, 60, 0.9);
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 999px;
  cursor: pointer;
  grid-column: 3;
  justify-self: end;
}

.popupBody {
  display: grid;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.popupSvg {
  width: 100%;
  height: auto;
  border-radius: 14px;
  overflow: hidden;
  max-height: 36vh;
  object-fit: contain;
}

.popupQuestion {
  display: none;
}

.popupLocation {
  display: none;
}

.popupActions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.popupButton {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  color: #fdfdff;
  background: linear-gradient(135deg, #2b6fd6, #36d1dc);
  box-shadow: 0 6px 16px rgba(6, 16, 40, 0.4);
}

@keyframes houseDraw {
  0% {
    transform: scaleY(0.1) translateY(10px);
    opacity: 0;
  }
  70% {
    transform: scaleY(1.05) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scaleY(1) translateY(0);
    opacity: 1;
  }
}

.mapArea.finished .houses {
  opacity: 1;
  pointer-events: auto;
}

.mapArea.finished .house {
  animation: houseDraw 900ms ease-out forwards;
}

.mapArea.finished .house-1 {
  animation-delay: 0.1s;
}

.mapArea.finished .house-2 {
  animation-delay: 0.25s;
}

.mapArea.finished .house-3 {
  animation-delay: 0.4s;
}

.mapArea.finished .house-4 {
  animation-delay: 0.55s;
}

.mapArea.finished .house-5 {
  animation-delay: 0.7s;
}

.mapArea.finished .house-6 {
  animation-delay: 0.85s;
}

.mapArea.finished .house-7 {
  animation-delay: 1s;
}

.mapArea.finished .house-8 {
  animation-delay: 1.15s;
}

.ring {
  position: absolute;
  inset: 0;
}

.item {
  position: absolute;
  left: 50%;
  top: calc(var(--ring-center-y, 50%) + var(--ring-shift, 0%));
  width: clamp(98px, 30.75vw, 135px);
  height: clamp(98px, 30.75vw, 135px);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  line-height: 1.1;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 740;
  font-size: clamp(10px, 2.8vw, 13px);
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #7c5cff, #36d1dc);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  will-change: transform, opacity;
  pointer-events: none;
  text-decoration: none;
}

.item::after {
  content: "";
  position: absolute;
  inset: clamp(-8px, -2vw, -6px);
  border-radius: inherit;
  background: radial-gradient(20px 20px at 50% 35%, rgba(124, 92, 255, 0.22), transparent 65%);
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}

.item.selected::after {
  opacity: 1;
}

.item.selected {
  pointer-events: auto;
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 18px 40px hsla(0, 0%, 0%, 0.50), 0 0 0 2px rgba(124, 92, 255, 0.35),
    0 0 40px rgba(124, 92, 255, 0.25);
}

.item.orange {
  background: linear-gradient(135deg, #ff8c3a, #ffb347);
  box-shadow: 0 14px 26px rgba(255, 140, 58, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .item::after {
    transition: none;
  }
}

.sponsors {
  display: none !important;
}

.sponsorsTitle {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  margin-top: 20%;
  position: relative;
  z-index: 100;
}

.sponsorsCarousel {
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.sponsorsTrack {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  will-change: transform;
  animation: sponsors-scroll 22s linear infinite;
  margin-top: 5%;
}

.sponsorLogo {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  background: #ffffff14;
  border: 1px solid rgba(255,255,255,0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.sponsorLogo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes sponsors-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.desktopIntro {
  display: none;
}

@media (min-width: 768px) {
  .phone {
    max-width: 100%;
    height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(380px, 500px) 1fr;
    grid-template-rows: 1fr;
    grid-template-areas:
      "sidebar message map";
    gap: 0;
    padding: 0;
    overflow: hidden;
  }

  .desktopIntro {
    display: block;
    grid-area: message;
    padding: clamp(25px, 4vh, 45px) clamp(15px, 2.5vw, 30px);
    color: rgba(255, 255, 255, 0.95);
    font-size: clamp(13px, 0.9vw, 15px);
    line-height: 1.6;
    overflow-y: auto;
    max-height: 100vh;
    scrollbar-width: none;
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .desktopIntro::-webkit-scrollbar {
    display: none;
  }

  .desktopIntro p {
    margin-bottom: clamp(12px, 1.5vh, 20px);
    text-align: justify;
  }

  .desktopIntro .signature {
    margin-top: clamp(25px, 4vh, 45px);
    text-align: right;
    font-weight: 600;
    font-size: clamp(12px, 0.85vw, 14px);
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.8);
  }

  .stage {
    grid-area: sidebar;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 30px;
    padding-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 20;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
  }

  .stageTitleContainer {
    position: static;
    transform: none;
    margin-bottom: 20px;
    margin-top: 10px;
    width: 100%;
  }
  
  .stageTitleMain {
    font-size: 15px;
    white-space: normal;
    text-align: center;
    padding: 0 10px;
  }
  
  .stageTitleSub {
    font-size: 18px;
    margin-top: 5px;
    white-space: normal;
    text-align: center;
    padding: 0 10px;
  }

  .carousel {
    width: 100%;
    height: auto;
    flex: 1;
    overflow: visible;
    padding: 0 15px;
    mask-image: none;
    margin-bottom: 0;
    pointer-events: auto;
  }

  .ring {
    position: relative;
    inset: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    padding-bottom: 20px;
    pointer-events: auto;
  }

  .item {
    position: relative;
    left: auto;
    top: auto;
    transform: none !important;
    width: 100%;
    aspect-ratio: 1;
    height: auto;
    margin: 0;
    pointer-events: auto !important;
    z-index: 1000 !important;
    font-size: 10px;
    padding: 8px;
  }
  
  .item::after {
    inset: -4px;
  }

  .mapArea {
    grid-area: map;
    margin: auto;
    width: min(96%, 96vh);
    max-width: 1200px;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 0;
    position: relative;
    display: block;
    overflow: visible;
  }

  .mapStill, .mapAfter, .mapVideo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .house {
    width: clamp(40px, 6vw, 80px);
    height: clamp(40px, 6vw, 80px);
  }
}
