.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(8, 32, 64, 0.12), rgba(7, 24, 48, 0.55)),
    url("backdrop.webp") center / cover no-repeat;
}

.sky-coin, .sky-cloud {
  position: absolute;
  pointer-events: none;
}

.sky-coin {
  width: min(72px, 16vw);
  opacity: 0.55;
  animation: floaty 9s ease-in-out infinite;
}

.sky-coin-a { top: 12%; right: 8%; }
.sky-coin-b { top: 42%; left: 4%; width: min(48px, 12vw); animation-delay: -3s; }

.sky-cloud {
  width: min(180px, 40vw);
  opacity: 0.7;
  animation: drift 32s linear infinite;
}

.sky-cloud-a { top: 6%; left: -20%; }
.sky-cloud-b { top: 24%; left: -30%; animation-duration: 44s; animation-delay: -12s; }

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

.spark-a { top: 16%; left: 18%; }
.spark-b { top: 10%; right: 22%; animation-delay: -1s; }
.spark-c { bottom: 28%; left: 62%; animation-delay: -1.6s; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(140vw); }
}

@keyframes floaty {
  50% { transform: translateY(-10px); }
}

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

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

.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  background:
    linear-gradient(#49c2ff, #0c2e52);
  transition: opacity 0.25s ease;
}

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

.boot strong { font-family: var(--font-display); font-size: clamp(1.6rem, 6vw, 2.2rem); }

.boot-hook {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background:
    linear-gradient(#fff4b0, #ffc400 46%, #e09600);
  border: 3px solid #fff6c8;
  box-shadow: 0 6px 0 #8a5300, inset 0 2px 0 rgba(255, 255, 255, 0.7);
  animation: bob 1.4s ease-in-out infinite;
}

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

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

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

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

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(#ffd24a, #e09600);
  border: 2px solid #fff6c8;
  box-shadow: 0 4px 0 #8a5300;
}

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

.brand-name {
  display: block;
  font-size: clamp(1rem, 3.4vw, 1.2rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub { color: var(--muted); }

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

.star-chip, .round-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(#1d4e86, #12325c);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 var(--shadow);
  color: var(--text);
}

.star-chip svg { width: 18px; height: 18px; fill: var(--primary); }

.round-btn {
  width: 40px;
  padding: 0;
  justify-content: center;
}

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 4px 14px calc(18px + env(safe-area-inset-bottom));
}

.dock {
  padding: 0 12px calc(10px + env(safe-area-inset-bottom));
  overflow: visible;
}

.dock-track {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2px;
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 8px 8px;
  border-radius: 28px;
  background:
    repeating-linear-gradient(-45deg, #111 0 8px, #ffc400 8px 16px) top / 100% 8px no-repeat,
    linear-gradient(180deg, #1b4f8c, #0d2b52);
  border: 3px solid rgba(255, 224, 138, 0.85);
  box-shadow: 0 7px 0 #071525, inset 0 0 0 2px rgba(8, 20, 40, 0.25);
}

.dock-blob {
  position: absolute;
  z-index: 0;
  left: var(--blob-x, 0);
  top: var(--blob-y, 0);
  width: var(--blob-w, 0);
  height: var(--blob-h, 0);
  border-radius: 16px;
  background: linear-gradient(#ffe56a, #f0a400);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7);
  transition: left 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.35s ease, height 0.35s ease;
}

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

.dock-item {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  color: #d5e6fb;
  font-size: 0.72rem;
}

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

.dock-glyph, .dock-glyph svg { width: 22px; height: 22px; }

.dock-glyph svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.dock-play {
  flex: 0 0 74px;
  margin-top: -28px;
  color: #3a2500;
}

.dock-play-orb {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(#fff4b0, #ffc400 48%, #e09600);
  border: 3px solid #fff6c8;
  box-shadow: 0 6px 0 #8a5300, inset 0 2px 0 rgba(255, 255, 255, 0.75);
}

.dock-play-orb svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: #3a2500;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-play-label { color: #fff6c8; text-shadow: 0 1px 0 #071525; }

#modalRoot, #toasts {
  position: fixed;
  z-index: 30;
  pointer-events: none;
}

#modalRoot { inset: 0; }

#toasts {
  left: 12px;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  justify-items: center;
}

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

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

body.is-play .stage {
  grid-column: 1;
  grid-row: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}

body.is-play #toasts { bottom: calc(12px + env(safe-area-inset-bottom)); }

@media (max-width: 350px) {
  .brand-sub { display: none; }
  .stage { padding-left: 10px; padding-right: 10px; }
  .dock { padding-left: 8px; padding-right: 8px; }
  .dock-label { font-size: 0.64rem; }
}

@media (max-height: 640px) {
  .topbar { padding-top: calc(4px + env(safe-area-inset-top)); }
  .dock-track { padding-top: 14px; }
  .dock-play { margin-top: -18px; }
  .dock-play-orb { width: 52px; height: 52px; }
}

@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 { grid-column: 2; grid-row: 1; }
  .stage { grid-column: 2; grid-row: 2; padding-bottom: 16px; }

  .dock {
    grid-column: 1;
    grid-row: 1 / span 2;
    padding: calc(10px + env(safe-area-inset-top)) 8px calc(10px + env(safe-area-inset-bottom));
  }

  .dock-track {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 10px 6px;
    background:
      repeating-linear-gradient(-45deg, #111 0 8px, #ffc400 8px 16px) left / 8px 100% no-repeat,
      linear-gradient(180deg, #1b4f8c, #0d2b52);
  }

  .dock-item { flex: 0 0 auto; padding: 8px 4px; }
  .dock-play { flex: 0 0 auto; margin: 8px 0; }
  .dock-play-label { color: #3a2500; text-shadow: none; }

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

  body.is-play .stage { grid-column: 1; grid-row: 1; }
}

@media (max-height: 420px) {
  .dock-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sky-coin, .sky-cloud, .spark, .boot-hook, .hero-mascot, .dock-blob {
    animation: none;
    transition: none;
  }
}

body[data-motion="off"] .sky-coin,
body[data-motion="off"] .sky-cloud,
body[data-motion="off"] .spark,
body[data-motion="off"] .boot-hook,
body[data-motion="off"] .hero-mascot {
  animation: none;
}
