.sky {
  position: fixed;
  inset: 0;
  background: var(--ink) center/cover no-repeat;
  z-index: 0;
  pointer-events: none;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 215, 0, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(26, 8, 51, 0.2), rgba(26, 8, 51, 0.78) 55%, #1a0833);
}

.sky-road { background-image: url("blaze-road.webp"); }
.sky-farm { background-image: url("coop-meadow.webp"); }
.sky-wash { background-image: url("yolk-wash.webp"); }

.mote {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
  animation: drift 14s linear infinite;
}

.mote-a { top: 18%; left: 12%; }
.mote-b { top: 40%; right: 10%; animation-duration: 18s; }
.mote-c { bottom: 22%; left: 30%; animation-duration: 16s; }

@keyframes drift {
  from { transform: translateY(0); }
  to { transform: translateY(-28px); }
}

#app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  min-height: 100vh;
}

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: var(--top);
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px;
}

.rank-chip, .coin-chip, .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(26, 8, 51, 0.72);
  border: 2px solid rgba(255, 215, 0, 0.7);
  color: var(--cream);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.top-title {
  flex: 1;
  min-width: 0;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coin-chip { margin-left: auto; color: var(--gold); }

#stage {
  position: absolute;
  top: var(--top);
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px 14px var(--dock-space);
  min-width: 0;
}

#app.is-immersive #topbar,
#app.is-immersive #dock { display: none; }

#app.is-immersive #stage {
  top: 0;
  padding: 0;
  overflow: hidden;
}

#dock {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(460px, calc(100% - 18px));
  height: 84px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 8px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(74, 24, 110, 0.95), rgba(32, 8, 58, 0.96));
  border: 3px solid rgba(255, 215, 0, 0.85);
  box-shadow: 0 10px 0 rgba(90, 16, 32, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

.dock-blob {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: calc((100% - 16px) / 4);
  height: 52px;
  border-radius: 18px;
  background: rgba(255, 215, 0, 0.2);
  transform: translateX(calc(var(--dock-index, 1) * 100%));
  transition: transform 0.38s cubic-bezier(0.2, 1.35, 0.32, 1);
  pointer-events: none;
}

.dock-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: var(--cream);
  font-size: 0.72rem;
}

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

.dock-btn.is-on { color: var(--gold); }

.dock-play {
  flex: 0 0 68px;
  width: 68px;
  height: 68px;
  margin-bottom: 16px;
  border-radius: 50%;
  color: #4a1408;
  background: linear-gradient(180deg, #fff1a8, #ffd700 45%, #ff8a00);
  border: 3px solid #fff8ee;
  box-shadow: 0 6px 0 #9a3412, inset 0 2px 0 rgba(255, 255, 255, 0.75);
}

.dock-play.is-on { color: #4a1408; }

.dock-play:active { transform: translateY(3px); box-shadow: 0 3px 0 #9a3412; }

#modals, #toasts {
  position: fixed;
  z-index: 20;
  pointer-events: none;
}

#modals { inset: 0; }

#toasts {
  left: 12px;
  right: 12px;
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: radial-gradient(circle at 50% 40%, #5a1d8a, #1a0833 70%);
  transition: opacity 0.35s ease;
}

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

.boot img { width: min(180px, 46vw); animation: bob 1.1s ease-in-out infinite; }

.boot p {
  font-family: var(--display);
  font-size: clamp(28px, 8vw, 44px);
  text-align: center;
  padding: 0 16px;
}

.boot-bar {
  width: min(180px, 50vw);
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.boot-bar span {
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  animation: load 0.9s ease-in-out infinite;
}

@keyframes load { from { transform: translateX(-80%); } to { transform: translateX(280%); } }
@keyframes bob { 50% { transform: translateY(-8px); } }

@media (min-width: 880px) {
  #topbar { left: 118px; }
  #stage { left: 118px; padding-bottom: 28px; }
  #app.is-immersive #stage { left: 0; top: 0; }
  #dock {
    left: 0;
    top: 0;
    bottom: 0;
    width: 118px;
    height: auto;
    transform: none;
    border-radius: 0 28px 28px 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
  }
  .dock-blob {
    left: 8px;
    top: 16px;
    bottom: auto;
    width: calc(100% - 16px);
    height: calc((100% - 32px) / 4);
    transform: translateY(calc(var(--dock-index, 1) * 100%));
  }
  .dock-btn { width: 100%; height: auto; flex: 1; }
  .dock-play { margin: 0; flex: 0 0 68px; }
  #toasts { bottom: 18px; left: 140px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  #topbar { left: 84px; height: 52px; padding-top: 6px; }
  #stage { left: 84px; top: 52px; padding: 8px 12px 12px; }
  #app.is-immersive #stage { left: 0; top: 0; }
  #dock {
    left: 0;
    top: 0;
    bottom: 0;
    width: 84px;
    height: auto;
    transform: none;
    border-radius: 0;
    flex-direction: column;
    padding: 8px 6px;
  }
  .dock-btn span { display: none; }
  .dock-blob {
    left: 6px;
    top: 8px;
    width: calc(100% - 12px);
    height: calc((100% - 16px) / 4);
    transform: translateY(calc(var(--dock-index, 1) * 100%));
  }
  .dock-play { width: 56px; height: 56px; flex-basis: 56px; margin: 0; }
}

.reduce-motion .mote,
.reduce-motion .boot img,
.reduce-motion .boot-bar span,
.reduce-motion .hero-hen,
.reduce-motion .primer-hen,
.reduce-motion .dock-blob {
  animation: none;
  transition: none;
}
