@font-face {
  font-family: AtlasGlyphSimulatorAuthored;
  src: url('../../fonts/Emojinq-Authored.ttf?v=be952ead') format('truetype');
  font-display: block;
}

@font-face {
  font-family: AtlasGlyphSimulatorEmojinq;
  src: url('../../fonts/Emojinq-Atlas.ttf?v=f43effe5') format('truetype');
  font-display: block;
}

.atlas-glyph-simulator {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  perspective: 1100px;
  perspective-origin: 50% 32%;
  transform-style: preserve-3d;
}

.atlas-glyph-simulator[data-scene-camera='oblique'] {
  isolation: isolate;
  background:
    linear-gradient(180deg, #dbe7df 0 9.5%, #b8c99c 9.7% 11%, #d9d1ad 11.2% 100%);
}

.atlas-glyph-simulator[data-scene-camera='oblique']::before {
  content: '';
  position: absolute;
  z-index: 0;
  /* The floor trapezoid must cross the viewport at the horizon. At -10%,
     its 10% top inset left a visible clipped gap on both shoulders. */
  left: -14%;
  right: -14%;
  top: 9%;
  bottom: -8%;
  clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%);
  background: radial-gradient(ellipse at 50% 0, #e8dfbd 0 22%, #d8cca1 72%, #c8bc90 100%);
  box-shadow: inset 0 16px 24px rgb(77 89 59 / 12%);
  pointer-events: none;
  transform: translateZ(-24px);
}

.atlas-glyph-simulator[data-scene-camera='oblique']::after {
  content: '';
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 8%;
  height: 5%;
  background: radial-gradient(ellipse at 50% 100%, rgb(85 112 70 / 32%), transparent 68%);
  pointer-events: none;
  transform: translateZ(-20px);
}

.atlas-glyph-agent {
  --agent-scale: 1;
  --agent-depth-scale: 1;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--agent-size, 150px);
  height: var(--agent-size, 150px);
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  transform: translate3d(var(--agent-x, 0), var(--agent-y, 0), var(--agent-z, 0)) scale(var(--agent-scale)) scale(var(--agent-depth-scale));
  transform-origin: center;
  transform-style: preserve-3d;
  cursor: grab;
  will-change: transform;
}

.atlas-glyph-feature {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  width: var(--feature-width);
  height: var(--feature-height);
  pointer-events: none;
  transform: translate3d(var(--feature-x), var(--feature-y), -18px);
  transform-origin: center;
}

.atlas-glyph-simulator[data-scene-camera='oblique'] .atlas-glyph-agent-mark,
.atlas-glyph-simulator[data-scene-camera='oblique'] .atlas-glyph-agent-indicator {
  /* Profile billboards stay parallel to the camera while their feet occupy
     the projected ground point in the three-dimensional scene. */
  backface-visibility: hidden;
}

.atlas-glyph-simulator[data-scene-camera='oblique'] .atlas-glyph-agent::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 27%;
  right: 27%;
  top: 68%;
  height: 10%;
  border-radius: 50%;
  background: rgb(53 58 43 / 20%);
  filter: blur(2px);
  transform: translate3d(0, var(--agent-ground-offset, 0px), -7px);
  pointer-events: none;
}

.atlas-glyph-simulator[data-scene-camera='oblique'] .atlas-glyph-agent[data-surface='air']::before {
  opacity: .42;
  filter: blur(4px);
}

.atlas-glyph-simulator[data-scene-camera='oblique'] .atlas-glyph-agent[data-surface='underwater']::before {
  display: none;
}

.atlas-glyph-simulator[data-scene-camera='oblique'] .atlas-glyph-agent[data-action='swim']::before {
  display: none;
}

.atlas-glyph-feature[data-kind='water'] {
  overflow: hidden;
  border: 2px solid rgb(77 126 139 / 48%);
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 42% 32%, rgb(225 245 243 / 78%) 0 8%, transparent 9%),
    repeating-radial-gradient(ellipse at center, transparent 0 14px, rgb(255 255 255 / 22%) 15px 17px),
    linear-gradient(155deg, #9bcfd0, #5faeb8 58%, #3f8493);
  box-shadow: inset 8px 10px 20px rgb(255 255 255 / 22%), inset -10px -8px 18px rgb(25 79 91 / 24%), 0 5px 0 rgb(81 104 83 / 16%);
}

.atlas-glyph-feature[data-kind='water']::after {
  content: '🪷';
  position: absolute;
  right: 13%;
  top: 14%;
  font: 28px/1 AtlasGlyphSimulatorEmojinq, serif;
  filter: drop-shadow(0 2px 1px rgb(39 39 32 / 18%));
}

.atlas-glyph-agent.is-dragging {
  --agent-scale: 1.08;
  z-index: 20;
  cursor: grabbing;
}

.atlas-glyph-exit {
  position: absolute;
  z-index: 2147482000;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 4px 4px;
  background: rgb(246 241 228 / 76%);
  color: #322b25;
  box-shadow: 0 5px 14px rgb(40 37 30 / 18%);
  font: 43px/1 AtlasGlyphSimulatorAuthored, AtlasGlyphSimulatorEmojinq, serif;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.atlas-glyph-exit[data-corner='lower-left'] {
  right: auto;
  left: max(12px, env(safe-area-inset-left));
}

.atlas-glyph-exit.is-receiving {
  background: rgb(255 248 220 / 96%);
  box-shadow: 0 0 0 5px rgb(174 116 61 / 28%), 0 7px 18px rgb(40 37 30 / 24%);
  transform: scale(1.12);
}

.atlas-glyph-exit.is-holding {
  transform: scale(.94);
}

.atlas-glyph-agent-mark {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font: var(--agent-glyph-size, 76px)/1 AtlasGlyphSimulatorAuthored, AtlasGlyphSimulatorEmojinq, serif;
  pointer-events: none;
  transform-origin: center;
  transform: rotate(var(--agent-angle, 0deg)) scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) translateZ(4px);
  transform-style: preserve-3d;
  text-shadow: -1px 1px 0 rgb(39 39 32 / 22%), -2px 2px 0 rgb(39 39 32 / 14%);
  clip-path: inset(0 0 var(--agent-occlusion, 0%) 0);
}

.atlas-glyph-agent[data-surface='ground'] .atlas-glyph-agent-mark {
  transform-origin: 50% 82%;
}

.atlas-glyph-agent[data-surface='ground'][data-action='hover'] .atlas-glyph-agent-mark {
  animation: atlas-agent-ground-breathe 1.9s ease-in-out infinite;
}

.atlas-glyph-agent-mark::before {
  content: attr(data-glyph);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgb(39 39 32 / 16%);
  transform: translate3d(-3px, 3px, -7px);
  pointer-events: none;
}

.atlas-glyph-agent-indicator {
  position: absolute;
  left: 60%;
  top: 3%;
  z-index: 2;
  font: calc(var(--agent-glyph-size, 76px) * .48)/1 AtlasGlyphSimulatorEmojinq, serif;
  pointer-events: none;
  transform: translateZ(14px) rotateX(-4deg) rotateY(7deg);
  transform-origin: center;
  text-shadow: -1px 1px 0 rgb(39 39 32 / 18%);
}

.atlas-glyph-agent[data-action='walk'] .atlas-glyph-agent-mark,
.atlas-glyph-agent.is-entering .atlas-glyph-agent-mark {
  animation: atlas-agent-walk .52s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='swim'] .atlas-glyph-agent-mark {
  animation: atlas-agent-swim 1.05s ease-in-out infinite;
  clip-path: inset(0 0 max(38%, var(--agent-occlusion, 0%)) 0);
  filter: drop-shadow(0 5px 2px rgb(45 105 117 / 28%));
}

.atlas-glyph-agent[data-action='fly'] .atlas-glyph-agent-mark {
  animation: atlas-agent-fly .9s ease-in-out infinite;
  filter: drop-shadow(0 7px 4px rgb(39 39 32 / 18%));
}

.atlas-glyph-agent[data-action='hover'] .atlas-glyph-agent-mark {
  animation: atlas-agent-hover 1.7s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='grow'] .atlas-glyph-agent-mark {
  animation: atlas-agent-grow 2.2s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='bloom'] .atlas-glyph-agent-mark {
  animation: atlas-agent-bloom 1.5s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='gather'] .atlas-glyph-agent-mark,
.atlas-glyph-agent[data-action='pollinate'] .atlas-glyph-agent-mark {
  animation: atlas-agent-gather .76s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgb(183 140 53 / 42%));
}

.atlas-glyph-agent[data-action='swim'][data-feature-kind='water']::after {
  content: '';
  position: absolute;
  z-index: 2;
  left: 19%;
  right: 19%;
  top: 56%;
  height: 27%;
  border-top: 2px solid rgb(225 245 243 / 76%);
  border-radius: 50%;
  background: linear-gradient(180deg, rgb(139 218 221 / 88%), rgb(66 158 178 / 96%) 72%, transparent 74%);
  pointer-events: none;
  transform: translateZ(10px) rotateX(4deg);
  animation: atlas-agent-waterline 1.05s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='eat'] .atlas-glyph-agent-mark,
.atlas-glyph-agent[data-action='drink'] .atlas-glyph-agent-mark {
  animation: atlas-agent-bow .72s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='produce'] .atlas-glyph-agent-mark {
  animation: atlas-agent-produce 1.1s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='sleep'] .atlas-glyph-agent-mark {
  animation: atlas-agent-sleep 2.8s ease-in-out infinite;
}

.atlas-glyph-agent[data-state='sleeping'] .atlas-glyph-agent-indicator {
  animation: atlas-agent-sleep-indicator 1.8s ease-in-out infinite;
}

.atlas-glyph-agent[data-action='sound'] .atlas-glyph-agent-mark,
.atlas-glyph-agent.is-responding .atlas-glyph-agent-mark {
  animation: atlas-agent-respond .34s ease-in-out;
}

.atlas-glyph-agent.is-counting .atlas-glyph-agent-mark {
  animation: atlas-agent-count-jump .58s cubic-bezier(.2,.78,.24,1);
}

.atlas-glyph-agent.is-interacting .atlas-glyph-agent-mark {
  filter: drop-shadow(0 0 8px rgb(83 113 93 / 38%));
}

@keyframes atlas-agent-walk {
  50% { transform: translate3d(0, 0, 4px) rotate(var(--agent-angle, 0deg)) scaleX(var(--agent-facing, 1)) scaleY(.975) rotateX(-4deg) rotateY(7deg) rotateZ(-2deg); }
}

@keyframes atlas-agent-ground-breathe {
  50% { transform: translate3d(0, 0, 5px) rotate(var(--agent-angle, 0deg)) scaleX(var(--agent-facing, 1)) scale(1.018, .988) rotateX(-4deg) rotateY(7deg); }
}

@keyframes atlas-agent-swim {
  50% { transform: translate3d(0, -2px, 8px) scaleX(var(--agent-facing, 1)) rotateX(-2deg) rotateY(7deg) rotateZ(1.5deg); }
}

@keyframes atlas-agent-fly {
  50% { transform: translate3d(4px, -11px, 13px) scaleX(var(--agent-facing, 1)) rotateX(-2deg) rotateY(7deg) rotateZ(-3deg); }
}

@keyframes atlas-agent-hover {
  50% { transform: translate3d(0, -5px, 10px) scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) scale(1.025); }
}

@keyframes atlas-agent-grow {
  0%, 100% { transform: scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) translateZ(4px) scale(.94); }
  50% { transform: translate3d(0, -5px, 8px) scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) scale(1.07); }
}

@keyframes atlas-agent-bloom {
  50% { transform: scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) translateZ(12px) rotateZ(4deg) scale(1.11); }
}

@keyframes atlas-agent-gather {
  50% { transform: translate3d(3px, 5px, 9px) scaleX(var(--agent-facing, 1)) rotateX(1deg) rotateY(7deg) rotateZ(5deg) scale(.95); }
}

@keyframes atlas-agent-waterline {
  50% { left: 16%; right: 22%; transform: translate3d(2px, 1px, 10px) rotateX(4deg); opacity: .72; }
}

@keyframes atlas-agent-bow {
  50% { transform: translate3d(0, 7px, 4px) scaleX(var(--agent-facing, 1)) rotateX(3deg) rotateY(7deg) rotateZ(7deg) scale(.96); }
}

@keyframes atlas-agent-produce {
  50% { transform: scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) translateZ(10px) scale(1.08); }
}

@keyframes atlas-agent-sleep {
  50% { transform: scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) translateZ(4px) scale(1.025, .975); }
}

@keyframes atlas-agent-sleep-indicator {
  50% { opacity: .55; transform: translate3d(3px, -6px, 14px) rotateX(-4deg) rotateY(7deg) scale(1.08); }
}

@keyframes atlas-agent-respond {
  25% { transform: scaleX(var(--agent-facing, 1)) rotate(-8deg); }
  50% { transform: scaleX(var(--agent-facing, 1)) rotate(8deg); }
  75% { transform: scaleX(var(--agent-facing, 1)) rotate(-5deg); }
}

@keyframes atlas-agent-count-jump {
  0%, 100% { transform: translate3d(0, 0, 4px) scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg); }
  42% { transform: translate3d(0, -15mm, 20px) scaleX(var(--agent-facing, 1)) rotateX(-4deg) rotateY(7deg) scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .atlas-glyph-agent-mark,
  .atlas-glyph-agent-indicator,
  .atlas-glyph-agent[data-action='swim']::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
