:root {
  color-scheme: dark;
  --ink: #11110f;
  --porcelain: #f8f2e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 420px;
  background:
    linear-gradient(160deg, rgba(17, 17, 15, 0.98) 0%, rgba(31, 30, 27, 0.98) 58%, rgba(36, 33, 27, 1) 100%),
    radial-gradient(circle at 50% 100%, rgba(216, 199, 160, 0.16), transparent 46%);
}

#globe-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  opacity: 1;
  transition: opacity 520ms ease;
}

#globe-canvas:active {
  cursor: grabbing;
}

.stage.is-hovering-country #globe-canvas {
  cursor: pointer;
}

.stage.is-country-selected #globe-canvas {
  cursor: default;
}

.stage.is-loading #globe-canvas {
  pointer-events: none;
  opacity: 0;
}

.title-lockup {
  position: absolute;
  top: clamp(18px, 4vw, 44px);
  left: clamp(18px, 4vw, 48px);
  pointer-events: none;
  color: var(--porcelain);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.38);
}

.title-lockup p {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0;
}

.selection-panel {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 4vh, 36px);
  z-index: 2;
  width: min(680px, calc(100vw - 36px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  pointer-events: auto;
}

.selection-chip {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  color: var(--porcelain);
  border: 1px solid rgba(248, 242, 232, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(31, 30, 27, 0.76), rgba(19, 18, 16, 0.72)),
    radial-gradient(circle at 20% 0%, rgba(248, 242, 232, 0.09), transparent 42%);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease;
}

.selection-chip span {
  color: rgba(248, 242, 232, 0.56);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.selection-chip strong {
  min-width: 0;
  overflow: hidden;
  color: rgba(248, 242, 232, 0.92);
  font-size: clamp(0.92rem, 1.6vw, 1.08rem);
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hover-chip.is-active {
  border-color: rgba(123, 190, 242, 0.46);
  box-shadow:
    0 18px 55px rgba(0, 0, 0, 0.28),
    0 0 22px rgba(92, 160, 218, 0.12);
}

.selected-chip.is-active {
  border-color: rgba(140, 202, 232, 0.58);
  box-shadow:
    0 18px 55px rgba(0, 0, 0, 0.28),
    0 0 26px rgba(101, 172, 215, 0.16);
}

.selection-chip.is-empty {
  opacity: 0.72;
}

#clear-selection {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(248, 242, 232, 0.2);
  border-radius: 6px;
  padding: 7px 10px;
  color: rgba(248, 242, 232, 0.86);
  background: rgba(248, 242, 232, 0.08);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

#clear-selection:hover {
  color: #18140f;
  background: linear-gradient(180deg, #fff8ec, #d9c7a0);
  transform: translateY(-1px);
}

.selected-chip.is-empty #clear-selection {
  display: none;
}

.zoom-controls {
  position: absolute;
  right: clamp(16px, 3vw, 36px);
  bottom: clamp(96px, 16vh, 142px);
  z-index: 2;
  display: grid;
  gap: 8px;
  pointer-events: auto;
}

.zoom-controls button {
  display: grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border: 1px solid rgba(248, 242, 232, 0.18);
  border-radius: 8px;
  color: rgba(248, 242, 232, 0.9);
  background:
    linear-gradient(180deg, rgba(31, 30, 27, 0.74), rgba(19, 18, 16, 0.7)),
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.13), transparent 42%);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  font: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.zoom-controls button:hover {
  border-color: rgba(140, 202, 232, 0.54);
  color: #fbf8ef;
  background:
    linear-gradient(180deg, rgba(51, 68, 74, 0.76), rgba(20, 27, 31, 0.72)),
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.16), transparent 42%);
  transform: translateY(-1px);
}

.zoom-controls button:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
}

.stage.is-loading .selection-panel {
  opacity: 0;
}

.stage.is-loading .zoom-controls {
  opacity: 0;
  pointer-events: none;
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--porcelain);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 250, 238, 0.1), transparent 23rem),
    linear-gradient(160deg, rgba(17, 17, 15, 1) 0%, rgba(31, 30, 27, 0.98) 62%, rgba(36, 33, 27, 1) 100%);
  opacity: 1;
  transition:
    opacity 420ms ease,
    visibility 420ms ease;
}

.stage:not(.is-loading) .loading-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-mark {
  width: clamp(84px, 16vw, 136px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(248, 242, 232, 0.18);
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.92) 0 9%, transparent 10%),
    radial-gradient(circle at 68% 64%, rgba(196, 219, 243, 0.24), transparent 21%),
    linear-gradient(135deg, #fffaf0, #e9dfcf 46%, #fffdf6);
  box-shadow:
    inset -18px -22px 38px rgba(52, 48, 40, 0.24),
    inset 15px 18px 30px rgba(255, 255, 255, 0.7),
    0 26px 80px rgba(0, 0, 0, 0.36);
  animation: porcelain-breathe 1.8s ease-in-out infinite;
}

.loading-screen p {
  margin: 4px 0 0;
  font-size: clamp(1.1rem, 2vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0;
}

.loading-screen span {
  min-height: 1.4em;
  color: rgba(248, 242, 232, 0.7);
  font-size: 0.92rem;
  font-weight: 700;
}

@keyframes porcelain-breathe {
  0%,
  100% {
    transform: scale(0.985);
    filter: brightness(0.98);
  }

  50% {
    transform: scale(1.015);
    filter: brightness(1.05);
  }
}

@media (max-width: 680px) {
  .title-lockup {
    top: 16px;
    left: 18px;
  }

  .selection-panel {
    grid-template-columns: 1fr;
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  .zoom-controls {
    right: 14px;
    bottom: max(148px, calc(env(safe-area-inset-bottom) + 132px));
  }

  .zoom-controls button {
    width: 46px;
  }
}
