:root {
  color-scheme: dark;
  --void: #06100f;
  --void-soft: #0c1816;
  --ink: #eff8f3;
  --line: rgba(218, 239, 229, 0.28);
  --focus: #f2ce70;
  --control: rgba(9, 24, 22, 0.78);
  --control-hover: rgba(21, 48, 43, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 18% 72%, rgba(95, 124, 73, 0.32) 0 17%, transparent 18%),
    radial-gradient(ellipse at 48% 64%, rgba(79, 116, 91, 0.28) 0 19%, transparent 20%),
    radial-gradient(ellipse at 78% 70%, rgba(105, 82, 56, 0.3) 0 17%, transparent 18%),
    linear-gradient(145deg, #06100f, #10211a 44%, #141718);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

button:focus-visible,
.skip-link:focus-visible,
.observatory-canvas:focus-visible,
.entity-info-card__close:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 40;
  transform: translateY(-140%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
  backdrop-filter: blur(18px);
}

.skip-link:focus {
  transform: translateY(0);
}

.observatory {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 520px;
  isolation: isolate;
}

.observatory::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 24% 64%, rgba(136, 160, 98, 0.2) 0 7%, transparent 8%),
    radial-gradient(ellipse at 42% 54%, rgba(111, 145, 92, 0.18) 0 9%, transparent 10%),
    radial-gradient(ellipse at 69% 62%, rgba(83, 124, 108, 0.18) 0 11%, transparent 12%),
    linear-gradient(118deg, transparent 0 34%, rgba(218, 188, 119, 0.12) 35% 38%, transparent 39% 100%),
    linear-gradient(154deg, transparent 0 49%, rgba(218, 188, 119, 0.09) 50% 52%, transparent 53% 100%);
  background-size: auto;
}

.observatory::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  background:
    linear-gradient(180deg, rgba(8, 18, 16, 0.98), rgba(4, 9, 9, 0.98) 100%),
    #06100f;
  opacity: 1;
  pointer-events: none;
  transition: opacity 520ms ease;
}

.observatory-loader {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7, 17, 15, 0.94), rgba(4, 10, 10, 0.98));
  opacity: 1;
  transform: scale(1);
  transition: opacity 520ms ease, transform 700ms ease, visibility 0s linear 0s;
}

.loader-village {
  position: relative;
  display: block;
  width: min(560px, 82vw);
  height: min(300px, 46vh);
  min-height: 210px;
  overflow: hidden;
  filter: drop-shadow(0 28px 46px rgba(0, 0, 0, 0.32));
  opacity: 0.34;
}

.loader-village::before,
.loader-village::after {
  content: "";
  display: none;
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 14%;
  height: 48%;
  border: 1px solid rgba(218, 239, 229, 0.08);
  border-radius: 50% 48% 42% 48%;
  background:
    radial-gradient(circle at 22% 42%, rgba(242, 206, 112, 0.18) 0 1.8%, transparent 2.1%),
    radial-gradient(circle at 43% 34%, rgba(242, 206, 112, 0.14) 0 1.5%, transparent 1.9%),
    radial-gradient(circle at 67% 45%, rgba(242, 206, 112, 0.16) 0 1.7%, transparent 2%),
    linear-gradient(130deg, rgba(40, 66, 53, 0.16), rgba(79, 91, 57, 0.12));
}

.loader-village::after {
  left: 12%;
  right: 12%;
  bottom: 36%;
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(222, 191, 124, 0.2), transparent);
  box-shadow:
    0 32px 0 rgba(222, 191, 124, 0.08),
    0 -30px 0 rgba(143, 198, 169, 0.07);
  transform: none;
}

.loader-village::before,
.loader-village::after {
  display: block;
}

.loader-village__hut {
  position: absolute;
  bottom: 38%;
  width: 88px;
  height: 54px;
  border: 1px solid rgba(218, 239, 229, 0.18);
  border-radius: 8px;
  background: rgba(16, 27, 23, 0.74);
}

.loader-village__hut::before {
  content: "";
  position: absolute;
  left: -12%;
  right: -12%;
  top: -34px;
  height: 44px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: rgba(111, 73, 48, 0.78);
}

.loader-village__hut::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 18px;
  width: 16px;
  height: 11px;
  border-radius: 4px;
  background: rgba(242, 206, 112, 0.32);
}

.loader-village__hut--one {
  left: 18%;
  transform: scale(0.9);
}

.loader-village__hut--two {
  left: 45%;
  bottom: 47%;
  transform: scale(1.08);
}

.loader-village__hut--three {
  right: 14%;
  bottom: 36%;
  transform: scale(0.82);
}

.loader-village__path {
  position: absolute;
  left: 22%;
  bottom: 31%;
  width: 45%;
  height: 18px;
  border-radius: 999px;
  background: rgba(190, 160, 94, 0.22);
  transform: rotate(9deg);
}

.loader-village__path--two {
  left: 48%;
  bottom: 34%;
  width: 30%;
  transform: rotate(-12deg);
  opacity: 0.66;
}

.loader-village__hut,
.loader-village__path {
  display: block;
  opacity: 0.42;
}

.loader-village__path {
  opacity: 0.18;
}

.observatory-canvas::selection {
  background: transparent;
}

.observatory-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.985);
  filter: blur(6px) saturate(0.8);
  transition: opacity 520ms ease, transform 700ms ease, filter 360ms ease, visibility 0s linear 520ms;
}

body:not([data-observatory-reveal="ready"]) .observatory::after {
  opacity: 1;
}

body:not([data-observatory-reveal="ready"]) .observatory-canvas {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: scale(0.985);
  transition: none !important;
}

body:not([data-observatory-reveal="ready"]) .visual-key {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body[data-observatory-reveal="ready"] .observatory::after {
  opacity: 0;
}

body[data-observatory-reveal="ready"] .observatory-loader {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.025);
  transition: opacity 520ms ease, transform 700ms ease, visibility 0s linear 700ms;
}

body[data-observatory-reveal="ready"] .observatory-canvas {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
  filter: blur(0) saturate(1);
  animation: observatory-village-reveal 760ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transition: opacity 520ms ease, transform 700ms ease, filter 360ms ease, visibility 0s linear 0s;
}

@keyframes observatory-village-reveal {
  0% {
    opacity: 0;
    transform: scale(0.982);
    filter: blur(9px) saturate(0.82) brightness(0.78);
  }

  58% {
    opacity: 1;
    transform: scale(1.006);
    filter: blur(1.5px) saturate(1.04) brightness(1.04);
  }

  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0) saturate(1) brightness(1);
  }
}

.observatory-controls {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  gap: 10px;
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.icon-button:hover {
  background: var(--control-hover);
}

.icon-button[aria-pressed="true"] .icon-motion::after {
  transform: translate(-50%, -50%) rotate(45deg);
  opacity: 1;
}

.icon {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
}

.icon-motion::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.icon-motion::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 26px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(0deg);
  transition: transform 160ms ease, opacity 160ms ease;
}

.icon-scope::before,
.icon-scope::after {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-scope::before {
  inset: 3px;
}

.icon-scope::after {
  inset: 9px;
  background: currentColor;
  box-shadow:
    0 -8px 0 -4px currentColor,
    7px 5px 0 -4px currentColor,
    -7px 5px 0 -4px currentColor;
}

.visual-key {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 28;
  display: flex;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.entity-info-card {
  position: fixed;
  z-index: 35;
  width: min(286px, calc(100vw - 28px));
  max-height: min(430px, calc(100dvh - 104px));
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(218, 239, 229, 0.34);
  border-radius: 8px;
  background: rgba(7, 18, 17, 0.9);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
}

.entity-info-card[hidden] {
  display: none;
}

.entity-info-card__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(218, 239, 229, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: transparent;
  cursor: pointer;
}

.entity-info-card__close::before,
.entity-info-card__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.entity-info-card__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.entity-info-card__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.entity-info-card__title {
  margin: 0;
  padding-right: 42px;
  color: #eff8f3;
  font-size: 0.98rem;
  line-height: 1.18;
  font-weight: 740;
}

.entity-info-card__meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 10px;
  margin: 12px 0 0;
  font-size: 0.78rem;
  line-height: 1.22;
}

.entity-info-card__meta dt {
  color: rgba(239, 248, 243, 0.6);
}

.entity-info-card__meta dd {
  margin: 0;
  min-width: 0;
  color: rgba(239, 248, 243, 0.92);
  overflow-wrap: anywhere;
}

.entity-info-card__description,
.entity-info-card__boundary {
  margin: 12px 0 0;
  color: rgba(239, 248, 243, 0.78);
  font-size: 0.8rem;
  line-height: 1.35;
}

.entity-info-card__boundary {
  color: rgba(242, 206, 112, 0.78);
  font-size: 0.72rem;
}

.key-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: 0 0 16px currentColor;
}

.state-active {
  color: #65d89f;
  background: #65d89f;
}

.state-review {
  color: #82b7f2;
  background: #82b7f2;
}

.state-wait {
  color: #f1c56f;
  background: #f1c56f;
}

.state-guard {
  color: #d98975;
  background: #d98975;
}

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

@media (max-width: 680px) {
  .observatory {
    min-height: 100dvh;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .visual-key {
    gap: 6px;
    padding: 8px;
  }

  .entity-info-card {
    width: min(300px, calc(100vw - 24px));
    padding: 13px;
  }

  .entity-info-card__meta {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .entity-info-card__meta dd + dt {
    margin-top: 5px;
  }
}
