:root {
  color-scheme: dark;
  --bg: #111411;
  --panel: #17201b;
  --panel-2: #202a22;
  --line: rgba(228, 218, 185, .18);
  --text: rgba(255, 250, 229, .92);
  --muted: rgba(255, 250, 229, .62);
  --accent: #8edfd1;
  --gold: #d8bd72;
  --danger: #e07c65;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

button, input, select, textarea {
  font: inherit;
}

button, .file-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 229, .08);
  color: var(--text);
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover, .file-button:hover {
  border-color: rgba(142, 223, 209, .48);
  background: rgba(142, 223, 209, .12);
}

button.is-active {
  border-color: rgba(216, 189, 114, .76);
  background: rgba(216, 189, 114, .18);
  color: #fff4cf;
}

.app {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: linear-gradient(180deg, var(--panel), #101713);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  min-height: 0;
}

.brand p, .stage-top p {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0 0 18px;
  font-family: Georgia, serif;
  font-size: 29px;
  font-weight: 400;
}

.tools, .layer-list, .editor, .data-tools {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.layer-list summary,
.place-picker summary {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 229, .08);
  color: rgba(255, 250, 229, .82);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  padding: 0 12px;
  text-transform: uppercase;
}

.layer-list summary::-webkit-details-marker,
.place-picker summary::-webkit-details-marker {
  display: none;
}

.layer-list summary::after,
.place-picker summary::after {
  content: '+';
  margin-left: auto;
  color: var(--accent);
  font-size: 16px;
}

.layer-list[open] summary::after,
.place-picker[open] summary::after {
  content: '-';
}

.layer-list[open] summary,
.place-picker[open] summary {
  margin-bottom: 12px;
}

.tool-row {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  gap: 8px;
  align-items: center;
}

.tool-row.compact {
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.wide-tool {
  width: 100%;
  margin-top: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle, .layer-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

.layer-list h2, .section-title h2 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.subsection-title {
  margin-top: 14px !important;
  color: rgba(255, 250, 229, .72);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.search-field {
  display: grid;
  gap: 5px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.search-field input {
  width: 100%;
  border: 1px solid rgba(142, 223, 209, .24);
  border-radius: 6px;
  background: rgba(4, 8, 6, .34);
  color: var(--text);
  padding: 9px 10px;
}

.place-list {
  display: grid;
  gap: 7px;
  max-height: 130px;
  overflow: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}

.place-picker {
  margin-bottom: 10px;
}

.place-list button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  text-align: left;
}

.place-list button.active {
  border-color: rgba(216, 189, 114, .7);
  background: rgba(216, 189, 114, .14);
}

.place-list-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 2px;
}

.place-form {
  display: grid;
  gap: 10px;
}

.place-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

.place-form input, .place-form select, .place-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(4, 8, 6, .34);
  color: var(--text);
  padding: 9px 10px;
}

.place-form textarea {
  resize: vertical;
}

.note-field {
  border: 1px solid rgba(216, 189, 114, .42);
  border-radius: 6px;
  background: rgba(216, 189, 114, .1);
  padding: 10px;
  color: rgba(255, 242, 196, .92) !important;
}

.note-field textarea {
  min-height: 170px;
  border-color: rgba(216, 189, 114, .5);
  background: rgba(45, 34, 15, .52);
  color: rgba(255, 250, 229, .96);
  font-size: 14px;
  line-height: 1.45;
}

.note-field textarea:focus {
  outline: 2px solid rgba(216, 189, 114, .45);
  outline-offset: 2px;
}

.place-info-panel {
  margin-top: 12px;
  border: 1px solid rgba(216, 189, 114, .28);
  border-radius: 6px;
  background: rgba(216, 189, 114, .08);
  padding: 12px;
}

.place-info-panel h3 {
  margin: 0 0 8px;
  color: rgba(216, 189, 114, .95);
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 400;
}

.place-info-panel p {
  margin: 0;
  color: rgba(255, 250, 229, .76);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.gallery-editor {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.gallery-editor .section-title {
  align-items: center;
}

.gallery-editor h3 {
  margin: 0;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 400;
}

.gallery-upload {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  font-size: 12px;
}

.gallery-editor-hint,
.gallery-empty {
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.gallery-editor-list {
  display: grid;
  gap: 8px;
}

.gallery-editor-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 229, .04);
  padding: 7px;
}

.gallery-editor-item img {
  width: 72px;
  height: 54px;
  border-radius: 4px;
  object-fit: cover;
}

.gallery-editor-item div {
  min-width: 0;
}

.gallery-editor-item span {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-editor-item label {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.gallery-editor-item textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(4, 8, 6, .5);
  color: var(--text);
  padding: 6px 7px;
  font-size: 12px;
  line-height: 1.35;
}

.gallery-editor-item button {
  min-height: 28px;
  margin-top: 6px;
  padding: 0 9px;
  color: #f0a28f;
  font-size: 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.asset-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.asset-transform-tools {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) 1fr;
  gap: 8px;
  align-items: end;
}

.asset-transform-tools label {
  min-width: 0;
}

#savePlace {
  background: rgba(142, 223, 209, .18);
  border-color: rgba(142, 223, 209, .42);
}

#deletePlace {
  color: #ffd7cf;
  border-color: rgba(224, 124, 101, .36);
}

.data-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.data-tools #placeSelected {
  grid-column: 1 / -1;
  border-color: rgba(216, 189, 114, .36);
  background: rgba(216, 189, 114, .1);
}

.file-button {
  display: grid;
  place-items: center;
  text-align: center;
}

.file-button input {
  display: none;
}

.stage-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(142, 223, 209, .12), transparent 30%),
    linear-gradient(145deg, #161814, #0e1210 58%, #17201b);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.stage-top strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 400;
}

#zoomReadout {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  touch-action: none;
  overscroll-behavior: none;
  cursor: grab;
}

.map-loader {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(11, 16, 13, .9);
  color: var(--text);
  text-align: center;
  transition: opacity .35s ease, visibility .35s ease;
}

.map-loader.is-complete {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.map-loader-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(142, 223, 209, .18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: map-loader-spin .8s linear infinite;
}

.map-loader strong {
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 400;
}

.map-loader > span:not(.map-loader-spinner):not(.map-loader-track) {
  color: var(--muted);
  font-size: 12px;
}

.map-loader-track {
  width: min(260px, 58%);
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
}

.map-loader-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease;
}

@keyframes map-loader-spin {
  to { transform: rotate(360deg); }
}


.stage.is-placing {
  cursor: crosshair;
}

.stage.dragging {
  cursor: grabbing;
}

.map-content {
  position: absolute;
  left: 0;
  top: 0;
  width: 800px;
  height: 566px;
  transform-origin: 0 0;
  user-select: none;
  opacity: 0;
  transition: opacity .35s ease;
}

body.is-map-ready .map-content {
  opacity: 1;
}

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

.map-layer {
  object-fit: contain;
  pointer-events: none;
  transition: opacity .18s ease;
}

/* The white ground belongs only to the glass sphere. Outside the sphere the
   map editor's dark stage background remains visible. */
.layer-background {
  clip-path: circle(48.4% at 50% 50%);
}

/* Isolated cosmic-background experiment. This class exists only in the test
   copy and leaves the production guest view unchanged. */
.cosmic-test .stage-wrap {
  background:
    linear-gradient(rgba(2, 7, 8, .08), rgba(2, 7, 8, .18)),
    url('assets/cosmic-background.png') center bottom / cover no-repeat;
}

.cosmic-test .layer-background {
  opacity: 0;
}

.cosmic-test .layer-bubble,
.cosmic-test .layer-waterline {
  opacity: 0;
}

.cosmic-test .map-content::before {
  content: '';
  position: absolute;
  inset: 1.55%;
  z-index: 0;
  border-radius: 50%;
  border: 5px solid rgba(210, 245, 250, .48);
  background: rgba(177, 215, 221, .105);
  box-shadow:
    0 0 10px rgba(174, 235, 245, .28),
    inset 0 0 54px rgba(189, 229, 235, .1);
  pointer-events: none;
  animation: bubble-edge-drift 14s ease-in-out infinite;
}

.cosmic-test .map-content::after {
  content: '';
  position: absolute;
  inset: 1.25%;
  z-index: 18;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: conic-gradient(
    from 205deg,
    transparent 0 46%,
    rgba(139, 222, 239, .04) 52%,
    rgba(205, 249, 255, .78) 61%,
    rgba(132, 216, 235, .16) 70%,
    transparent 78% 100%
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 34px), #000 calc(100% - 22px), transparent 100%);
  mask: radial-gradient(farthest-side, transparent calc(100% - 34px), #000 calc(100% - 22px), transparent 100%);
  filter: blur(5px) drop-shadow(0 0 12px rgba(143, 226, 241, .7));
  animation: bubble-gradient-flare 17s ease-in-out infinite;
}

.cosmic-test .layer-bubble-rim {
  display: none;
  z-index: 48;
  opacity: 0;
  pointer-events: none;
  animation: bubble-cosmic-pulse 13s ease-in-out infinite;
}

.cosmic-test .layer-water-new {
  position: absolute;
  z-index: auto;
  width: 53.3%;
  height: auto;
  left: 50%;
  bottom: 2.1%;
  transform: translateX(-50%);
  pointer-events: none;
}

.cosmic-test .stage-wrap::before,
.cosmic-test .stage-wrap::after {
  content: none;
}

.cosmic-starfield {
  position: absolute;
  inset: 0 0 21% 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  background-size: 67% 71%;
  background-position: center;
  filter: brightness(1.45) drop-shadow(0 0 2.5px rgba(188, 242, 250, .82));
  animation: cosmic-star-cycle 15s ease-in-out infinite;
}

.cosmic-starfield-1 {
  background-image:
    radial-gradient(circle at 6% 15%, #e8fdff 0 .7px, transparent 1.8px), radial-gradient(circle at 17% 38%, #bcecf3 0 .8px, transparent 2px),
    radial-gradient(circle at 29% 10%, #dffaff 0 .6px, transparent 1.7px), radial-gradient(circle at 42% 29%, #e9fdff 0 .8px, transparent 2px),
    radial-gradient(circle at 55% 12%, #c6eff5 0 .6px, transparent 1.7px), radial-gradient(circle at 68% 43%, #e1fbff 0 .7px, transparent 1.9px),
    radial-gradient(circle at 81% 18%, #edfeff 0 .7px, transparent 1.8px), radial-gradient(circle at 93% 55%, #c4edf5 0 .6px, transparent 1.8px),
    radial-gradient(circle at 14% 76%, #e7fcff 0 .7px, transparent 1.9px), radial-gradient(circle at 38% 68%, #b9e8f0 0 .6px, transparent 1.8px),
    radial-gradient(circle at 64% 81%, #e9fdff 0 .7px, transparent 1.9px), radial-gradient(circle at 88% 72%, #c4eef5 0 .6px, transparent 1.7px);
}

.cosmic-starfield-2 {
  animation-delay: 5s;
  background-image:
    radial-gradient(circle at 9% 51%, #e6fcff 0 .7px, transparent 1.8px), radial-gradient(circle at 20% 19%, #bcebf3 0 .6px, transparent 1.8px),
    radial-gradient(circle at 31% 59%, #efffff 0 .8px, transparent 2px), radial-gradient(circle at 45% 8%, #c3edf4 0 .6px, transparent 1.7px),
    radial-gradient(circle at 52% 47%, #e4fbff 0 .7px, transparent 1.9px), radial-gradient(circle at 61% 23%, #bdeaf2 0 .7px, transparent 1.8px),
    radial-gradient(circle at 73% 61%, #eafeff 0 .8px, transparent 2px), radial-gradient(circle at 85% 33%, #c1edf4 0 .6px, transparent 1.8px),
    radial-gradient(circle at 96% 14%, #e5fcff 0 .7px, transparent 1.9px), radial-gradient(circle at 24% 85%, #bceaf2 0 .6px, transparent 1.7px),
    radial-gradient(circle at 57% 76%, #e9fdff 0 .8px, transparent 2px), radial-gradient(circle at 91% 88%, #c3eef5 0 .6px, transparent 1.8px);
}

.cosmic-starfield-3 {
  animation-delay: 10s;
  background-image:
    radial-gradient(circle at 4% 32%, #eaffff 0 .8px, transparent 2px), radial-gradient(circle at 15% 61%, #c0edf4 0 .6px, transparent 1.8px),
    radial-gradient(circle at 27% 27%, #e5fcff 0 .7px, transparent 1.9px), radial-gradient(circle at 36% 52%, #bceaf2 0 .7px, transparent 1.8px),
    radial-gradient(circle at 48% 17%, #efffff 0 .8px, transparent 2px), radial-gradient(circle at 59% 65%, #c3edf4 0 .6px, transparent 1.8px),
    radial-gradient(circle at 70% 9%, #e4fbff 0 .7px, transparent 1.9px), radial-gradient(circle at 79% 39%, #bdeaf2 0 .6px, transparent 1.7px),
    radial-gradient(circle at 90% 67%, #eafeff 0 .8px, transparent 2px), radial-gradient(circle at 97% 29%, #c1edf4 0 .6px, transparent 1.8px),
    radial-gradient(circle at 41% 88%, #e5fcff 0 .7px, transparent 1.9px), radial-gradient(circle at 75% 84%, #bcebf3 0 .6px, transparent 1.8px);
}

.cosmic-starfield::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse 7px 1px at 13% 24%, rgba(246, 255, 255, .95), transparent 72%),
    radial-gradient(ellipse 1px 7px at 13% 24%, rgba(246, 255, 255, .95), transparent 72%),
    radial-gradient(circle at 13% 24%, #fff 0 .8px, rgba(190, 244, 251, .8) 1.2px, transparent 2.2px),
    radial-gradient(ellipse 6px 1px at 38% 67%, rgba(239, 253, 255, .92), transparent 72%),
    radial-gradient(ellipse 1px 6px at 38% 67%, rgba(239, 253, 255, .92), transparent 72%),
    radial-gradient(circle at 38% 67%, #fff 0 .75px, rgba(180, 239, 248, .76) 1.2px, transparent 2px),
    radial-gradient(ellipse 8px 1px at 71% 18%, rgba(247, 255, 255, .96), transparent 72%),
    radial-gradient(ellipse 1px 8px at 71% 18%, rgba(247, 255, 255, .96), transparent 72%),
    radial-gradient(circle at 71% 18%, #fff 0 .8px, rgba(190, 244, 251, .8) 1.2px, transparent 2.2px),
    radial-gradient(ellipse 6px 1px at 89% 56%, rgba(238, 253, 255, .9), transparent 72%),
    radial-gradient(ellipse 1px 6px at 89% 56%, rgba(238, 253, 255, .9), transparent 72%),
    radial-gradient(circle at 89% 56%, #fff 0 .75px, rgba(178, 238, 248, .74) 1.1px, transparent 2px);
  filter: drop-shadow(0 0 1.5px rgba(180, 238, 248, .48));
}

.cosmic-starfield-2::after {
  transform: rotate(180deg) scale(.96);
}

.cosmic-starfield-3::after {
  transform: rotate(94deg) scale(.92);
}

@keyframes bubble-cosmic-pulse {
  0%, 57%, 64%, 100% { opacity: .82; filter: brightness(1) drop-shadow(0 0 2px rgba(175, 240, 249, .35)); }
  59% { opacity: 1; filter: brightness(1.55) drop-shadow(0 0 12px rgba(155, 233, 247, .95)); }
  61% { opacity: .9; filter: brightness(1.15) drop-shadow(0 0 5px rgba(189, 246, 255, .65)); }
  62.5% { opacity: 1; filter: brightness(1.7) drop-shadow(0 0 16px rgba(144, 224, 243, .9)); }
}

@keyframes cosmic-star-cycle {
  0%, 33%, 100% { opacity: 0; }
  5% { opacity: .3; }
  11%, 24% { opacity: 1; }
  29% { opacity: .26; }
}

.guest-zoom-controls {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 70;
  display: none;
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(202, 241, 247, .28);
  border-radius: 999px;
  background: rgba(7, 17, 18, .72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  backdrop-filter: blur(8px);
}

.guest-mode .guest-zoom-controls { display: flex; }

.guest-zoom-controls button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border-color: rgba(188, 235, 243, .32);
  color: rgba(231, 252, 255, .95);
  background: rgba(21, 45, 47, .76);
  font-size: 24px;
  line-height: 1;
}

.guest-depth-toggle {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  z-index: 70;
  display: none;
  width: auto;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid rgba(190, 237, 244, .36);
  border-radius: 999px;
  color: rgba(234, 252, 255, .96);
  background: rgba(7, 21, 23, .82);
  box-shadow: 0 7px 22px rgba(0, 0, 0, .3);
  backdrop-filter: blur(8px);
}

.guest-mode.guest-depth-option .guest-depth-toggle { display: block; }
.guest-mode.guest-depth-reveal .guest-depth-toggle {
  border-color: rgba(132, 222, 237, .72);
  background: rgba(29, 82, 88, .86);
}

.guest-depth-reveal .layer-front:not(.is-hidden) { opacity: 0; }
.guest-depth-reveal .location-layer[data-location-layer="front"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes bubble-edge-drift {
  0%, 100% {
    border-color: rgba(210, 245, 250, .42);
    box-shadow: -22px 0 34px rgba(151, 229, 242, .52), 9px 0 18px rgba(193, 244, 250, .2), inset 18px 0 38px rgba(184, 237, 245, .13);
  }
  25% {
    border-color: rgba(221, 249, 252, .55);
    box-shadow: 0 -22px 36px rgba(169, 237, 247, .5), 0 10px 17px rgba(183, 237, 245, .18), inset 0 18px 40px rgba(192, 241, 247, .14);
  }
  50% {
    border-color: rgba(205, 242, 248, .46);
    box-shadow: 23px 1px 35px rgba(146, 225, 240, .53), -9px 0 17px rgba(190, 242, 249, .19), inset -18px 0 39px rgba(181, 235, 244, .13);
  }
  75% {
    border-color: rgba(222, 249, 252, .52);
    box-shadow: 0 21px 33px rgba(160, 231, 243, .46), 0 -9px 17px rgba(192, 243, 249, .18), inset 0 -18px 39px rgba(188, 239, 246, .13);
  }
}

@keyframes bubble-gradient-flare {
  0%, 51%, 74%, 100% { opacity: 0; transform: rotate(-8deg) scale(.995); }
  57% { opacity: .24; }
  62% { opacity: .9; transform: rotate(5deg) scale(1.005); }
  68% { opacity: .34; transform: rotate(13deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .cosmic-test .layer-bubble-rim,
  .cosmic-test .map-content::before,
  .cosmic-test .map-content::after,
  .cosmic-starfield {
    animation: none;
  }
}

.map-layer.is-hidden {
  opacity: 0;
}

.location-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.location-layer.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.stage.is-editing-places .place-label {
  pointer-events: none;
}

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
}

body.is-map-ready .label-layer {
  opacity: 1;
}

.marker {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  min-width: 28px;
  height: 24px;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  min-height: 24px;
  transform: translate(-7px, -12px);
  pointer-events: auto;
  cursor: pointer;
}

.stage.is-editing-places .marker {
  cursor: grab;
}

.stage.is-editing-places .marker:active {
  cursor: grabbing;
}

.stage.is-editing-places .marker.has-asset {
  width: var(--asset-width, 44px);
  min-width: var(--asset-width, 44px);
  height: var(--asset-height, 44px);
}

.stage.is-editing-places .marker.has-asset .place-asset {
  pointer-events: auto;
}

.marker.has-asset {
  width: 44px;
  min-width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

.marker:active {
  cursor: pointer;
}

.pin {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 250, 229, .88);
  border-radius: 50% 50% 50% 0;
  background: var(--accent);
  transform: rotate(-45deg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .38);
}

.marker[data-type="city"] .pin { background: var(--gold); }
.marker[data-type="nature"] .pin { background: #81c36d; }
.marker[data-type="naja"] .pin { background: #68aee8; }
.marker[data-type="production"] .pin { background: #d58fdc; }

.place-asset {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--asset-width, 120px);
  height: auto;
  max-width: none;
  pointer-events: none;
  user-select: none;
  transform: translate(-50%, -50%) scaleX(var(--asset-flip, 1)) rotate(var(--asset-rotation, 0deg));
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .28));
  z-index: 0;
}

.marker.has-asset .pin {
  display: block;
  position: relative;
  z-index: 2;
  width: 20px;
  height: 20px;
  margin: auto;
  border-width: 3px;
  background: rgba(142, 223, 209, .88);
  opacity: .9;
  box-shadow: 0 0 0 5px rgba(12, 16, 13, .42), 0 4px 12px rgba(0, 0, 0, .35);
}

.marker.has-asset .marker-label {
  display: none;
}

.marker-label {
  display: none !important;
}

.place-label {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 250, 229, .9);
  font-size: 18px;
  line-height: 1.15;
  transform: translate(44px, -170%);
  z-index: 21;
  pointer-events: auto;
}

.place-label-name {
  display: block;
  border: 1px solid rgba(17, 20, 17, .42);
  border-radius: 4px;
  background: rgba(12, 16, 13, .5);
  padding: 6px 10px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  cursor: pointer;
}

.place-label.active .place-label-name {
  background: rgba(216, 189, 114, .68);
  color: rgba(23, 19, 10, .92);
}

.place-info-button {
  display: inline-grid;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  place-items: center;
  border: 1px solid rgba(142, 223, 209, .72);
  border-radius: 50%;
  background: rgba(12, 16, 13, .82);
  color: var(--accent);
  padding: 0;
  font-family: Georgia, serif;
  font-size: 19px;
  font-style: italic;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}

.place-info-dialog {
  width: min(820px, calc(100vw - 36px));
  max-height: min(82dvh, 900px);
  overflow: auto;
  border: 1px solid rgba(216, 189, 114, .42);
  border-radius: 10px;
  background: linear-gradient(155deg, rgba(25, 35, 29, .98), rgba(10, 15, 12, .98));
  color: var(--text);
  padding: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .62);
}

.place-info-dialog::backdrop {
  background: rgba(4, 8, 6, .72);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: sticky;
  z-index: 3;
  top: 0;
  float: right;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 50%;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.dialog-copy {
  padding-right: 44px;
}

.dialog-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.dialog-copy h2 {
  margin: 0 0 14px;
  color: #fff4cf;
  font-family: Georgia, serif;
  font-size: clamp(25px, 4vw, 38px);
  font-weight: 400;
}

.dialog-copy > p:last-child {
  margin: 0;
  color: rgba(255, 250, 229, .8);
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.dialog-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.gallery-thumbnail {
  display: block;
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 189, 114, .24);
  border-radius: 7px;
  background: rgba(255, 255, 255, .035);
  padding: 0;
  aspect-ratio: 4 / 3;
}

.gallery-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s ease, opacity .2s ease;
}

.gallery-thumbnail:hover img {
  opacity: .88;
  transform: scale(1.035);
}

.gallery-thumbnail-caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  background: linear-gradient(transparent, rgba(5, 8, 6, .9));
  color: rgba(255, 250, 229, .9);
  padding: 24px 8px 7px;
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-lightbox {
  width: min(1180px, calc(100vw - 24px));
  height: min(94dvh, 940px);
  overflow: hidden;
  border: 1px solid rgba(216, 189, 114, .38);
  border-radius: 10px;
  background: rgba(5, 8, 6, .97);
  color: var(--text);
  padding: 18px 70px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .75);
}

.gallery-lightbox::backdrop {
  background: rgba(2, 4, 3, .88);
  backdrop-filter: blur(7px);
}

.gallery-lightbox figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  margin: 0;
}

.gallery-lightbox figure img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.gallery-lightbox figcaption {
  min-height: 30px;
  padding-top: 9px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(15, 21, 17, .86);
  padding: 0;
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  font-size: 27px;
}

.lightbox-nav {
  top: 50%;
  width: 46px;
  min-width: 46px;
  min-height: 54px;
  transform: translateY(-50%);
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 38px;
}

.lightbox-previous { left: 14px; }
.lightbox-next { right: 14px; }

.lightbox-nav[hidden] {
  display: none;
}

.guest-mode .app {
  display: block;
}

.guest-mode .panel,
.guest-mode .stage-top {
  display: none;
}

.guest-mode .stage-wrap,
.guest-mode .stage {
  width: 100vw;
  height: 100dvh;
}

.place-info {
  position: absolute;
  width: min(320px, calc(100vw - 48px));
  border: 1px solid rgba(216, 189, 114, .38);
  border-radius: 6px;
  background: rgba(14, 18, 15, .84);
  color: rgba(255, 250, 229, .92);
  padding: 12px 14px;
  line-height: 1.45;
  font-size: 14px;
  transform: translate(44px, 18px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .32);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  z-index: 22;
}

.place-info strong {
  display: block;
  margin-bottom: 6px;
  color: rgba(216, 189, 114, .95);
  font-size: 15px;
}

.place-info p {
  margin: 0;
  white-space: pre-wrap;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 44dvh) minmax(320px, 1fr);
  }

  .panel {
    min-height: 0;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    min-height: 62vh;
  }

  .place-info-dialog {
    padding: 20px;
  }

  .gallery-lightbox {
    padding: 58px 12px 12px;
  }

  .lightbox-nav {
    top: auto;
    bottom: 10px;
    transform: none;
  }

  .guest-mode .stage {
    min-height: 100dvh;
  }

  .guest-zoom-controls {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .guest-depth-toggle {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px);
  }
}
