.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(73, 79, 223, 0.45), transparent 36%),
    radial-gradient(circle at 90% 80%, rgba(255, 75, 138, 0.22), transparent 32%),
    linear-gradient(180deg, rgba(5, 4, 12, 0.2), rgba(5, 4, 12, 0.82)),
    url('backdrop.webp') center / cover no-repeat,
    var(--ink-deep);
}

.sky-token {
  position: absolute;
  width: min(28vw, 140px);
  opacity: 0.28;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.4));
  animation: tokenDrift 28s ease-in-out infinite;
}

.sky-token-a { top: 12%; left: -8%; }
.sky-token-b { top: 62%; right: -10%; width: min(22vw, 110px); animation-delay: -12s; }

.sky-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--highlight);
  box-shadow: 0 0 12px var(--accent);
  animation: twinkle 4.8s ease-in-out infinite;
}

.sky-spark-a { top: 18%; left: 22%; }
.sky-spark-b { top: 30%; left: 78%; animation-delay: 1.2s; }
.sky-spark-c { top: 72%; left: 16%; animation-delay: 2s; }

@keyframes tokenDrift {
  50% { transform: translate3d(18px, -24px, 0) rotate(8deg); }
}

@keyframes twinkle {
  50% { opacity: 0.25; transform: scale(0.6); }
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  background:
    radial-gradient(circle at 50% 40%, rgba(73, 79, 223, 0.55), transparent 42%),
    var(--ink-deep);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.boot.is-done { opacity: 0; visibility: hidden; }

.boot-mark {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 32%),
    linear-gradient(160deg, var(--accent), var(--primary) 55%, var(--secondary));
  box-shadow: 0 8px 0 #1a1440, 0 16px 30px rgba(0, 0, 0, 0.45);
  animation: bootBob 1.6s ease-in-out infinite;
}

.boot strong { font-size: clamp(28px, 8vw, 40px); }
.boot span { color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; }

@keyframes bootBob {
  50% { transform: translateY(-6px); }
}

.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

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

.brand, .brand-text, .topbar-tools { min-width: 0; }

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

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 34%),
    linear-gradient(160deg, #7aa6ff, var(--primary) 50%, #8a4bff);
  box-shadow: 0 4px 0 #24185a;
}

.brand-mark svg { width: 24px; height: 24px; }

.brand-text { display: grid; line-height: 1; }

.brand-name {
  font-size: clamp(18px, 5vw, 24px);
  text-shadow: 0 2px 0 #241448;
}

.brand-sub {
  margin-top: 3px;
  color: var(--highlight);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

.star-chip, .round-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 10, 22, 0.72);
  color: var(--highlight);
}

.star-chip { padding: 0 12px; }
.star-chip svg { width: 16px; height: 16px; fill: var(--highlight); }
.round-btn { width: 38px; padding: 0; }

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 4px 12px calc(108px + var(--safe-bottom));
  scroll-padding-bottom: 24px;
}

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

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

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

.dock-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  min-height: 74px;
  padding: 8px 6px 8px;
  border-radius: 28px;
  background: rgba(8, 8, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(16px);
}

.dock-blob {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--blob-w, 0);
  height: var(--blob-h, 0);
  transform: translate(var(--blob-x, 0), var(--blob-y, 0));
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.42), rgba(60, 141, 255, 0.16));
  transition: transform 0.55s cubic-bezier(0.2, 1.45, 0.36, 1);
  pointer-events: none;
}

.dock.is-ready .dock-blob { transition: transform 0.55s cubic-bezier(0.2, 1.45, 0.36, 1); }
.dock-blob.is-hidden { opacity: 0; }

.dock-item {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
  min-height: 52px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dock-item svg { width: 22px; height: 22px; }
.dock-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-item.is-active { color: white; }

.dock-play { justify-content: flex-end; padding-bottom: 0; }

.dock-play-orb {
  width: 62px;
  height: 62px;
  margin-top: -28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #2a2108;
  background:
    radial-gradient(circle at 32% 28%, #fff6d2, transparent 28%),
    linear-gradient(180deg, #ffe7a0, var(--highlight) 46%, #b8882e);
  border: 2px solid #fff4cc;
  box-shadow: 0 6px 0 #7a5a16, 0 12px 18px rgba(0, 0, 0, 0.35);
}

.dock-play-orb svg { width: 28px; height: 28px; }
.dock-play:active .dock-play-orb { transform: translateY(3px); }
.dock-play-label { color: var(--highlight); }

body.is-play .topbar { display: none; }
body.is-play .app { grid-template-rows: minmax(0, 1fr); }
body.is-play .dock { transform: translate(-50%, 160%); pointer-events: none; }
body.is-play .stage {
  overflow: hidden;
  padding: calc(4px + var(--safe-top)) calc(8px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(8px + var(--safe-left));
}

.modal-root, .toast-root { position: fixed; inset: 0; pointer-events: none; }
.modal-root { z-index: 30; }
.toast-root {
  z-index: 35;
  inset: auto 0 auto 0;
  top: calc(var(--safe-top) + 70px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

@media (min-width: 880px), (orientation: landscape) and (max-height: 520px), (max-height: 520px) and (min-width: 640px) {
  .app { grid-template-columns: 108px minmax(0, 1fr); }
  .topbar, .stage { grid-column: 2; }
  .stage { padding-bottom: 28px; }
  .dock {
    left: 0;
    top: 0;
    bottom: 0;
    width: 108px;
    transform: none;
    display: grid;
    align-items: center;
    padding: calc(8px + var(--safe-top)) 8px calc(8px + var(--safe-bottom));
  }
  .dock-track {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(48px, 64px);
    align-content: center;
    height: auto;
    padding: 10px 6px;
  }
  .dock-play { justify-content: center; }
  .dock-play-orb { width: 52px; height: 52px; margin-top: 0; }
  .dock-play-label { display: none; }
  body.is-play .app { grid-template-columns: minmax(0, 1fr); }
  body.is-play .stage { grid-column: 1; }
  body.is-play .dock { transform: translateX(-130%); }
}

@media (orientation: landscape) and (max-height: 520px), (max-height: 520px) and (min-width: 640px) {
  .dock-item span { display: none; }
  .topbar { min-height: 48px; }
}

@media (max-width: 350px) {
  .brand-sub { display: none; }
  .dock-item { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

body[data-motion='off'] .sky-token,
body[data-motion='off'] .sky-spark,
body[data-motion='off'] .boot-mark,
body[data-motion='off'] .mascot,
body[data-motion='off'] .stage.is-entering {
  animation: none !important;
}
