:root {
  color-scheme: light;
  --ink: #102219;
  --muted: #77847c;
  --line: rgba(48, 92, 69, 0.14);
  --mint: #4de3ac;
  --mint-deep: #23986f;
  --paper: #f8fbf9;
  --paper-2: #eef8f2;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }
html {
  margin: 0;
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
  background: var(--paper);
}
body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.slime-world { position: relative; }
.world-page {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  scroll-snap-align: start;
  isolation: isolate;
}

/* ---------- Page 1: the place the slime lives ---------- */
.world-page-home {
  background:
    radial-gradient(circle at 76% 38%, rgba(108, 231, 181, 0.11), transparent 24%),
    radial-gradient(circle at 26% 72%, rgba(108, 231, 181, 0.07), transparent 28%),
    linear-gradient(180deg, #fbfdfc 0%, #f5faf7 100%);
}
.world-page-home::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(45, 95, 68, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(45, 95, 68, 0.028) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 84%, transparent 100%);
}

.world-header {
  position: absolute;
  z-index: 7;
  top: max(22px, env(safe-area-inset-top));
  left: max(28px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 760;
  letter-spacing: -0.02em;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.world-copy {
  position: absolute;
  z-index: 4;
  top: clamp(112px, 16svh, 178px);
  left: max(7vw, 48px);
  pointer-events: none;
}
.world-copy h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(42px, 5.7vw, 78px);
  line-height: 0.98;
  font-weight: 820;
  letter-spacing: -0.065em;
}

.world-note {
  position: absolute;
  z-index: 4;
  right: max(7vw, 50px);
  top: 19svh;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #839087;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.note-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint-deep);
  box-shadow: 0 0 0 5px rgba(77, 227, 172, 0.10);
}

.slime-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
#slime-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.slime-hit-target {
  position: absolute;
  z-index: 4;
  border: 0;
  border-radius: 44%;
  background: transparent;
  touch-action: none;
  cursor: grab;
}
.slime-hit-target:focus-visible {
  outline: 3px solid rgba(77, 227, 172, 0.34);
  outline-offset: 4px;
}
.slime-stage.is-grabbing .slime-hit-target { cursor: grabbing; }

.touch-prompt {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 158px;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: #7f8c84;
  font-size: 10px;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.touch-prompt strong { color: #536158; font-size: 11px; }
.touch-prompt.is-quiet {
  opacity: 0;
  transform: translateX(-50%) translateY(5px);
}

.dock {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  height: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(71, 106, 87, 0.07), 0 16px 38px rgba(44, 75, 58, 0.08);
  backdrop-filter: blur(16px) saturate(120%);
}
.dock-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, #e7efe9, #d8e5dc);
  box-shadow: inset 0 0 0 1px rgba(74, 105, 86, 0.06);
}
.dock-icon.finder {
  position: relative;
  background: linear-gradient(90deg, #8bd6e8 50%, #e8f8ff 50%);
}
.dock-icon.finder::before {
  content: "⌣";
  position: absolute;
  inset: 4px 0 auto;
  color: #4b7881;
  text-align: center;
  font-weight: 900;
}

.world-file {
  position: absolute;
  z-index: 5;
  appearance: none;
  border: 1px solid rgba(73, 105, 87, 0.16);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 13px 36px rgba(45, 70, 56, 0.08);
  cursor: pointer;
  transition: transform 180ms ease, opacity 240ms ease, filter 180ms ease;
}
.world-file:hover { transform: translateY(-3px) rotate(var(--tilt, 0deg)); }
.world-file:focus-visible,
.move-in-link:focus-visible,
.download-button:focus-visible,
.reset-button:focus-visible {
  outline: 3px solid rgba(77, 227, 172, 0.35);
  outline-offset: 4px;
}
.world-file.is-targeted {
  filter: drop-shadow(0 10px 18px rgba(35, 152, 111, 0.18));
  animation: fileNotice 700ms ease-in-out infinite alternate;
}
.world-file.is-eating {
  pointer-events: none;
  transform: translate(var(--eat-x, 0px), var(--eat-y, 0px)) scale(0.16) rotate(18deg);
  opacity: 0;
}
.world-file.is-gone {
  visibility: hidden;
  opacity: 0;
}

.file-a {
  --tilt: 5deg;
  right: 17vw;
  top: 37svh;
  width: 56px;
  height: 70px;
  border-radius: 12px;
  transform: rotate(5deg);
  padding: 16px 12px 10px;
}
.file-a .file-fold {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 17px;
  height: 17px;
  border-left: 1px solid rgba(73, 105, 87, 0.12);
  border-bottom: 1px solid rgba(73, 105, 87, 0.12);
  border-radius: 0 11px 0 7px;
  background: #eff7f2;
}
.file-a i {
  display: block;
  height: 3px;
  margin-top: 7px;
  border-radius: 99px;
  background: #d9e6de;
}
.file-a i:nth-of-type(2) { width: 72%; }
.file-a i:nth-of-type(3) { width: 46%; }

.file-b {
  --tilt: -4deg;
  left: 13vw;
  top: 55svh;
  width: 76px;
  height: 54px;
  border-radius: 11px;
  transform: rotate(-4deg);
  background: rgba(237, 248, 241, 0.9);
}
.file-b .folder-tab {
  position: absolute;
  left: 10px;
  top: -9px;
  width: 31px;
  height: 13px;
  border: 1px solid rgba(73, 105, 87, 0.14);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #edf8f1;
}

.file-c {
  --tilt: 3deg;
  right: 31vw;
  top: 62svh;
  width: 48px;
  height: 54px;
  display: grid;
  place-content: center;
  gap: 4px;
  border-radius: 11px;
  transform: rotate(3deg);
}
.file-c span {
  display: block;
  width: 22px;
  height: 4px;
  border-radius: 99px;
  background: #d8e5dd;
}
.file-c span:nth-child(2) { width: 17px; }
.file-c span:nth-child(3) { width: 11px; }

.reset-button {
  position: absolute;
  z-index: 6;
  right: max(28px, 4vw);
  bottom: 24px;
  border: 0;
  background: none;
  color: #9aa49e;
  font-size: 10px;
  cursor: pointer;
}
.reset-button:hover { color: #59675e; }

.move-in-link {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: #5b6860;
  text-decoration: none;
  font-size: 11px;
  font-weight: 690;
  letter-spacing: 0.01em;
}
.move-in-link i {
  font-style: normal;
  font-size: 13px;
  animation: invitationDrop 1.8s ease-in-out infinite;
}

/* ---------- Page 2: the place the slime arrives ---------- */
.world-page-download {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(77, 227, 172, 0.14), transparent 26%),
    linear-gradient(180deg, #f2faf5 0%, #fbfdfc 100%);
}
.world-page-download::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.38), transparent 26%);
}
.download-atmosphere { position: absolute; inset: 0; pointer-events: none; }
.soft-orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(67, 145, 103, 0.08);
}
.orbit-a { width: 42vw; height: 42vw; max-width: 620px; max-height: 620px; left: -12vw; bottom: -18vw; }
.orbit-b { width: 28vw; height: 28vw; max-width: 420px; max-height: 420px; right: -7vw; top: 12svh; }
.soft-dot { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: rgba(35, 152, 111, .24); }
.dot-a { left: 19%; top: 28%; }
.dot-b { right: 23%; top: 39%; width: 3px; height: 3px; }
.dot-c { left: 32%; bottom: 22%; width: 4px; height: 4px; }

.download-content {
  position: relative;
  z-index: 4;
  width: min(560px, calc(100% - 48px));
  margin-top: 18svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.download-label {
  margin: 0 0 14px;
  color: var(--mint-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.download-button {
  min-width: 250px;
  min-height: 56px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
  border-radius: 999px;
  background: #102219;
  color: white;
  text-decoration: none;
  font-size: 14px;
  font-weight: 760;
  box-shadow: 0 12px 32px rgba(16, 34, 25, 0.10);
  transition: transform 160ms ease, background 160ms ease;
}
.download-button:hover { transform: translateY(-2px); background: #20362b; }
.download-button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.system-note { margin: 12px 0 0; color: #93a098; font-size: 10px; }

.arrival-zone {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: calc(50% - 224px);
  width: 190px;
  height: 205px;
  transform: translateX(-50%);
  pointer-events: none;
}
.arrival-floor {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 128px;
  height: 2px;
  transform: translateX(-50%);
  border-radius: 99px;
  background: rgba(42, 93, 66, .13);
}
.arrival-slime {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 94px;
  height: 70px;
  opacity: 0;
  transform: translateX(-50%) translateY(-72svh) scale(.84, 1.12);
  transform-origin: 50% 100%;
  border-radius: 49% 51% 45% 45% / 60% 60% 40% 40%;
  background: linear-gradient(180deg, #a6ffda 0%, #4de3ac 48%, #23986f 100%);
  box-shadow: inset 0 -8px 18px rgba(22, 112, 77, .12);
}
.arrival-highlight {
  position: absolute;
  left: 20px;
  top: 13px;
  width: 26px;
  height: 11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .26);
  transform: rotate(-14deg);
}
.arrival-eye {
  position: absolute;
  top: 38px;
  width: 5px;
  height: 10px;
  border-radius: 50%;
  background: #173228;
}
.arrival-eye.left { left: 34px; }
.arrival-eye.right { right: 34px; }
.world-page-download.is-arriving .arrival-slime {
  animation: arrivalFall 980ms cubic-bezier(.22,.76,.28,1) forwards;
}
.world-page-download.is-arrived .arrival-slime {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  animation: arrivalIdle 3.2s ease-in-out 1.05s infinite;
}

@keyframes fileNotice {
  from { transform: translateY(0) rotate(var(--tilt, 0deg)) scale(1); }
  to { transform: translateY(-4px) rotate(var(--tilt, 0deg)) scale(1.035); }
}
@keyframes invitationDrop {
  0%, 100% { transform: translateY(0); opacity: .62; }
  50% { transform: translateY(4px); opacity: 1; }
}
@keyframes arrivalFall {
  0% { opacity: 0; transform: translateX(-50%) translateY(-72svh) scale(.82,1.16); }
  12% { opacity: 1; }
  68% { transform: translateX(-50%) translateY(3px) scale(.88,1.10); }
  78% { transform: translateX(-50%) translateY(0) scale(1.20,.72); }
  88% { transform: translateX(-50%) translateY(-15px) scale(.92,1.08); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes arrivalIdle {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.025,.985); }
}

@media (max-width: 700px) {
  .world-header {
    top: max(18px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
  }
  .brand { font-size: 12px; gap: 7px; }
  .brand img { width: 27px; height: 27px; border-radius: 7px; }

  .world-copy {
    top: 13svh;
    left: 18px;
  }
  .world-copy h1 {
    max-width: calc(100vw - 36px);
    font-size: clamp(34px, 10.5vw, 42px);
    line-height: 1.01;
    white-space: nowrap;
  }
  .world-note {
    top: 29svh;
    right: 18px;
    font-size: 9px;
  }

  .dock {
    bottom: 70px;
    height: 48px;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 15px;
  }
  .dock-icon { width: 34px; height: 34px; border-radius: 9px; }
  .touch-prompt { bottom: 130px; font-size: 9px; }
  .touch-prompt strong { font-size: 10px; }

  .file-a {
    right: 11vw;
    top: 39svh;
    width: 44px;
    height: 57px;
    border-radius: 10px;
    padding: 13px 9px 7px;
  }
  .file-b {
    left: 8vw;
    top: 54svh;
    width: 60px;
    height: 43px;
    border-radius: 9px;
  }
  .file-c {
    right: 18vw;
    top: 62svh;
    width: 39px;
    height: 45px;
    border-radius: 9px;
  }

  .move-in-link {
    bottom: max(13px, env(safe-area-inset-bottom));
    font-size: 10px;
  }
  .reset-button { right: 12px; bottom: 18px; font-size: 9px; }

  .download-content {
    width: calc(100% - 36px);
    margin-top: 19svh;
  }
  .download-button { min-width: 228px; min-height: 54px; margin-top: 8px; }
  .arrival-zone {
    top: calc(50% - 196px);
    width: 150px;
    height: 176px;
  }
  .arrival-slime { width: 66px; height: 49px; }
  .arrival-highlight { left: 14px; top: 9px; width: 19px; height: 8px; }
  .arrival-eye { top: 27px; width: 4px; height: 7px; }
  .arrival-eye.left { left: 23px; }
  .arrival-eye.right { right: 23px; }
  .arrival-floor { width: 92px; }
  .orbit-a { width: 95vw; height: 95vw; left: -43vw; bottom: -30vw; }
  .orbit-b { width: 65vw; height: 65vw; right: -28vw; top: 12svh; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .move-in-link i, .world-file.is-targeted, .world-page-download.is-arrived .arrival-slime { animation: none; }
  .world-page-download.is-arriving .arrival-slime {
    animation-duration: 260ms;
  }
}
