.sky {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 49, 92, 0.15), rgba(8, 49, 92, 0.35)),
    url("sky.webp") center/cover no-repeat;
  z-index: 0;
}

.sky-float, .spark {
  position: absolute;
  display: block;
  animation: drift 14s linear infinite;
}

.sky-coin {
  width: 42px;
  height: 42px;
  left: 8%;
  top: 18%;
  background: url("coin.webp") center/contain no-repeat;
}

.sky-coin-b {
  left: auto;
  right: 6%;
  top: 32%;
  width: 28px;
  height: 28px;
  animation-duration: 18s;
}

.sky-house {
  width: 70px;
  height: 70px;
  right: 12%;
  bottom: 18%;
  background: url("house.webp") center/contain no-repeat;
  animation-duration: 16s;
}

.spark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--highlight);
  box-shadow: 0 0 12px var(--highlight);
}

.spark-a { left: 20%; top: 12%; }
.spark-b { left: 70%; top: 22%; animation-delay: -4s; }
.spark-c { left: 40%; top: 70%; animation-delay: -8s; }

@keyframes drift {
  0% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
  100% { transform: translateY(0); }
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  background: linear-gradient(#1286f0, #08315c);
  transition: opacity 0.45s ease;
}

.boot.is-done { opacity: 0; pointer-events: none; }

.boot strong { font-size: clamp(2rem, 8vw, 3.4rem); }

.boot-hook {
  width: 54px;
  height: 54px;
  border: 6px solid var(--secondary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: calc(8px + var(--safe-top)) 12px 8px;
}

.brand, .star-chip, .round-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark, .star-glyph {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 2px solid var(--line);
  background:
    radial-gradient(circle at 50% 30%, #fff1a8, #ffc107 45%, #d98400);
  box-shadow: 0 4px 0 #8a5600;
}

.star-glyph {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  clip-path: polygon(50% 0, 61% 35%, 100% 38%, 70% 60%, 79% 100%, 50% 78%, 21% 100%, 30% 60%, 0 38%, 39% 35%);
}

.brand-text { min-width: 0; display: grid; }
.brand-text strong, .brand-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { color: var(--highlight); }

.topbar-tools { display: flex; align-items: center; gap: 8px; }

.star-chip, .round-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 4px 0 var(--shadow);
}

.round-btn { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; }

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px var(--dock-space);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.stage > * { min-width: 0; max-width: 100%; }

.stage.is-entering { animation: rise 0.35s ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 16px));
  z-index: 15;
}

.dock-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  padding: 10px 16px 8px;
  border-radius: 30px;
  background:
    linear-gradient(#16498a, #0a2d5c);
  border: 3px solid var(--line);
  box-shadow: 0 8px 0 #04182e, 0 14px 24px rgba(4, 18, 36, 0.35);
}

.dock-track::before, .dock-track::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: 8px;
  border-radius: 6px;
  background: repeating-linear-gradient(#1b1b1b 0 6px, #ffd21f 6px 12px);
}

.dock-track::before { left: 6px; }
.dock-track::after { right: 6px; }

.dock-blob {
  position: absolute;
  left: var(--blob-x, 0);
  top: var(--blob-y, 0);
  width: var(--blob-w, 0);
  height: var(--blob-h, 0);
  border-radius: 16px;
  background: rgba(255, 214, 80, 0.28);
  transition: left 0.38s cubic-bezier(0.2, 1.45, 0.32, 1), top 0.38s cubic-bezier(0.2, 1.45, 0.32, 1), width 0.38s, height 0.38s;
  pointer-events: none;
}

.dock-blob.is-hidden { opacity: 0; }

.dock-item {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.72rem;
}

.dock-item span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dock-item.is-active { color: var(--highlight); }

.dock-play { transform: translateY(-16px); color: #3a2504; }

.hook-orb {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff4bf, #ffc107 42%, #e09000);
  border: 3px solid #fff8dc;
  box-shadow: 0 6px 0 #8a5600;
}

.hook-house {
  width: 26px;
  height: 22px;
  background:
    linear-gradient(#e23b3b, #e23b3b) top/100% 8px no-repeat,
    linear-gradient(#f6d27a, #f6d27a) bottom/100% 14px no-repeat;
  clip-path: polygon(50% 0, 100% 32%, 88% 32%, 88% 100%, 12% 100%, 12% 32%, 0 32%);
}

.modal-root, .toast-root {
  position: fixed;
  z-index: 30;
  pointer-events: none;
}

.modal-root { inset: 0; }
.toast-root {
  left: 12px;
  right: 12px;
  top: calc(12px + var(--safe-top));
  display: grid;
  justify-items: center;
  gap: 8px;
}

body.is-play .topbar,
body.is-play .dock { display: none; }

body.is-play .stage {
  padding: 0;
  overflow: hidden;
  display: flex;
}

body.is-play .app { grid-template-rows: minmax(0, 1fr); }

@media (max-height: 420px) {
  .dock-item span:last-child { display: none; }
  .dock-play { transform: translateY(-8px); }
}

@media (min-width: 880px), (orientation: landscape) and (max-height: 520px) {
  .app {
    grid-template-columns: 112px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .topbar, .stage { grid-column: 2; }
  .stage { padding: 12px 18px 18px; }
  .dock {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    width: auto;
    grid-column: 1;
    grid-row: 1 / span 2;
    padding: 10px 8px;
    height: 100%;
  }
  .dock-track {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 26px;
    padding: 12px 8px;
  }
  .dock-play { transform: none; }
  .hook-orb { width: 54px; height: 54px; }
  body.is-play .app { grid-template-columns: minmax(0, 1fr); }
  body.is-play .stage { grid-column: 1; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sky-float, .spark, .boot-hook, .stage.is-entering { animation: none; }
}

body[data-motion="off"] .sky-float,
body[data-motion="off"] .spark,
body[data-motion="off"] .bob,
body[data-motion="off"] .stage.is-entering { animation: none; }
