.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(58, 28, 103, 0.52), rgba(42, 18, 80, 0.88)), url('backdrop.webp') center bottom / cover no-repeat, var(--ink-deep);
}

.sky-cloud {
  position: absolute;
  width: 220px;
  opacity: 0.32;
  filter: saturate(1.1);
  animation: cloudDrift 60s linear infinite;
}

.sky-cloud-a {
  top: 8%;
  left: -240px;
}

.sky-cloud-b {
  top: 46%;
  left: -240px;
  width: 280px;
  opacity: 0.2;
  animation-duration: 90s;
  animation-delay: -34s;
}

.sky-cloud-c {
  top: 74%;
  left: -240px;
  width: 180px;
  opacity: 0.26;
  animation-duration: 74s;
  animation-delay: -52s;
}

.sky-spark {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  opacity: 0;
  animation: twinkle 4.2s ease-in-out infinite;
}

.sky-spark-a {
  top: 14%;
  left: 22%;
}

.sky-spark-b {
  top: 28%;
  left: 82%;
  animation-delay: 1.3s;
}

.sky-spark-c {
  top: 58%;
  left: 10%;
  animation-delay: 2.1s;
}

.sky-spark-d {
  top: 80%;
  left: 70%;
  animation-delay: 3s;
}

@keyframes cloudDrift {
  to {
    transform: translateX(calc(100vw + 520px));
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.4) rotate(0deg);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.2) rotate(45deg);
  }
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: radial-gradient(circle at 50% 38%, #7a3cc4, var(--ink-deep) 72%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

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

.boot-pot {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: repeating-conic-gradient(#ff7ae6 0 20deg, #ffe3fa 20deg 40deg);
  box-shadow: 0 8px 0 #a21f9b, 0 16px 30px rgba(0, 0, 0, 0.4);
  animation: bootSpin 2.2s linear infinite;
}

.boot-title {
  font-size: 34px;
  color: #fff;
  text-shadow: 0 3px 0 #a21f9b;
}

.boot-note {
  font-size: 14px;
  color: var(--lavender);
  letter-spacing: 0.08em;
}

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

.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;
  padding: calc(8px + var(--safe-top)) calc(14px + var(--safe-right)) 6px calc(14px + var(--safe-left));
  min-height: 58px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  filter: drop-shadow(0 3px 0 rgba(106, 26, 143, 0.9));
  animation: markBob 3.6s ease-in-out infinite;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

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

.brand-name {
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 0 #a21f9b, 0 5px 10px rgba(20, 6, 50, 0.4);
}

.brand-sub {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

@keyframes markBob {
  0%,
  100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(6deg) translateY(-1px);
  }
}

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

.star-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06)), rgba(42, 18, 80, 0.75);
  border: 2px solid rgba(255, 210, 63, 0.7);
  box-shadow: 0 4px 0 rgba(20, 6, 50, 0.45);
  font-family: var(--font-display);
  font-size: 19px;
  color: #fff;
}

.star-chip svg {
  width: 22px;
  height: 22px;
  fill: var(--gold);
  stroke: #b97200;
  stroke-width: 1.5;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.8));
}

.round-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.06)), rgba(42, 18, 80, 0.75);
  box-shadow: 0 4px 0 rgba(20, 6, 50, 0.45);
  color: #fff;
  font-size: 20px;
  transition: transform 0.12s ease;
}

.round-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(20, 6, 50, 0.45);
}

.stage {
  position: relative;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 6px calc(14px + var(--safe-right)) calc(var(--dock-h) + 44px + var(--safe-bottom)) calc(14px + var(--safe-left));
}

.stage::-webkit-scrollbar {
  display: none;
}

.stage > .screen {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.stage.is-entering > .screen {
  animation: screenIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  z-index: 30;
  width: min(calc(100% - 20px), 460px);
  transform: translateX(-50%);
  transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.5, 1);
}

.dock-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr 1fr 1fr;
  align-items: stretch;
  height: var(--dock-h);
  padding: 0 6px;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 45%), linear-gradient(180deg, #6a35b8, #36175f);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 0 #1f0b40, 0 16px 30px rgba(10, 2, 30, 0.55);
}

.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));
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(0.3, 1.5, 0.5, 1), width 0.4s ease, height 0.4s ease, opacity 0.25s ease;
}

.dock.is-ready .dock-blob {
  will-change: transform;
}

.dock-blob::before {
  content: '';
  position: absolute;
  inset: 7px 3px;
  border-radius: 22px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 45%), linear-gradient(180deg, #ff7ae6, #d23cc6);
  box-shadow: 0 3px 0 #8a1a84, 0 0 16px rgba(255, 90, 220, 0.6);
}

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

.dock-item {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  color: #d3c3fb;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.2s ease, transform 0.2s ease;
}

.dock-item svg {
  width: 24px;
  height: 24px;
  transition: transform 0.35s cubic-bezier(0.3, 1.8, 0.5, 1);
}

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

.dock-item.is-active {
  color: #fff;
}

.dock-item.is-active svg {
  transform: translateY(-1px) scale(1.12);
}

.dock-item:active svg {
  transform: scale(0.85);
}

.dock-play {
  justify-content: flex-end;
  padding-bottom: 6px;
  overflow: visible;
}

.dock-play-orb {
  position: absolute;
  top: -28px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-left: -32px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.9) 0 8%, rgba(255, 255, 255, 0) 24%), repeating-radial-gradient(circle at 50% 50%, #ff7ae6 0 6px, #ff4fd0 6px 12px);
  box-shadow: 0 6px 0 #a21f9b, 0 14px 22px rgba(10, 2, 30, 0.5);
  color: #fff;
  transition: transform 0.2s ease;
}

.dock-play-orb svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 0 rgba(120, 20, 110, 0.8));
}

.dock-play:active .dock-play-orb {
  transform: translateY(4px);
}

.dock-play.is-active .dock-play-orb {
  animation: orbPulse 1.8s ease-in-out infinite;
}

.dock-play-label {
  color: var(--gold);
}

@keyframes orbPulse {
  0%,
  100% {
    box-shadow: 0 6px 0 #a21f9b, 0 14px 22px rgba(10, 2, 30, 0.5), 0 0 0 0 rgba(255, 210, 63, 0.7);
  }
  50% {
    box-shadow: 0 6px 0 #a21f9b, 0 14px 22px rgba(10, 2, 30, 0.5), 0 0 0 12px rgba(255, 210, 63, 0);
  }
}

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

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

body.is-play .dock {
  transform: translate(-50%, 190%);
  pointer-events: none;
}

body.is-play .toast-root {
  top: calc(var(--safe-top) + 56px);
}

body.is-play .stage {
  overflow: hidden;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

body.is-play .stage > .screen {
  max-width: none;
  height: 100%;
  margin: 0;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--safe-top) + 64px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}

@media (min-width: 880px), (orientation: landscape) and (max-height: 520px) {
  .app {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .topbar,
  .stage {
    grid-column: 2;
  }

  .stage {
    padding-bottom: 36px;
  }

  .dock {
    left: 0;
    top: 0;
    bottom: 0;
    width: 104px;
    display: grid;
    align-items: center;
    padding: calc(10px + var(--safe-top)) 10px calc(10px + var(--safe-bottom)) calc(10px + var(--safe-left));
    transform: none;
  }

  .dock-track {
    grid-template-columns: 1fr;
    grid-auto-rows: 62px;
    align-content: center;
    gap: 4px;
    height: auto;
    padding: 8px 4px;
    border-radius: 30px;
  }

  .dock-blob::before {
    inset: 2px 4px;
  }

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

  .dock-play-orb {
    position: relative;
    top: auto;
    left: auto;
    width: 52px;
    height: 52px;
    margin: 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) {
  .dock-track {
    grid-auto-rows: clamp(40px, calc((100dvh - 56px) / 5.3), 58px);
  }

  .dock-item span {
    display: none;
  }

  .dock-play-orb {
    width: 46px;
    height: 46px;
  }

  .topbar {
    min-height: 50px;
  }
}

@media (max-width: 340px) {
  .brand-sub {
    display: none;
  }

  .brand-name {
    font-size: 20px;
  }

  .dock-item {
    font-size: 9.5px;
  }
}
