/* App shell: loading scene, hub (header band, tab bar / rail, park backdrop) and flows. */

.app {
  position: absolute;
  inset: 0;
}
/* a phone held sideways (app.js RotateHint): navy chrome, the searching robot and one white line */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px max(32px, env(safe-area-inset-right)) 24px max(32px, env(safe-area-inset-left));
  background: radial-gradient(120% 140% at 50% 30%, #12307a 0%, var(--navy) 70%);
  color: #fff;
}
.rotate-hint__robot {
  position: relative;
  flex: none;
  width: min(150px, 34vh);
  height: min(180px, 42vh);
}
.rotate-hint__text {
  max-width: 320px;
  margin: 0;
  font-size: 24px;
  font-weight: var(--w-semibold);
  line-height: 1.3;
  text-shadow: var(--on-colour-shadow);
}
.screen-loading {
  position: absolute;
  inset: 0;
}

/* ---- Loading scene (Loading.unity) ----------------------------------------------------------- */
.loading-screen {
  position: absolute;
  inset: 0;
  background-color: #bfe9f5;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.loading-screen__canvas {
  /* Fit the complete authored loading composition, including its studio footer. */
  --u: min(calc(100vw / 1080), calc(100dvh / 1920));
  /* a 1080x1920 canvas centred on the viewport; children use canvas coordinates */
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(1080 * var(--u));
  height: calc(1920 * var(--u));
  transform: translate(-50%, -50%);
}
.loading-screen__floater {
  position: absolute;
  left: calc(50% + var(--x) * var(--u));
  top: calc(50% - var(--y) * var(--u));
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--r)));
  animation: floater 5.5s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.8s);
}
@keyframes floater {
  to {
    transform: translate(-50%, calc(-50% - 14 * var(--u))) rotate(calc(-1 * var(--r) + 5deg));
  }
}
.reduced-motion .loading-screen__floater {
  animation: none;
}
.loading-screen__robot {
  position: absolute;
  left: calc(50% - 41 * var(--u));
  top: calc(50% - 220 * var(--u));
  width: calc(460 * 0.85 * var(--u));
  height: calc(356 * 0.85 * var(--u));
  transform: translate(-50%, -50%);
}
.loading-screen__logo {
  position: absolute;
  left: 50%;
  top: calc(50% + 12 * var(--u));
  width: calc(900 * var(--u));
  height: calc(429 * 0.85 * var(--u));
  object-fit: contain;
  transform: translate(-50%, -50%);
}
.loading-screen__bar {
  position: absolute;
  left: 50%;
  top: calc(50% + 368 * var(--u));
  width: calc(617 * var(--u));
  height: calc(75 * var(--u));
  transform: translate(-50%, -50%);
  padding: calc(9.5 * var(--u));
}
.loading-screen__bar::before {
  /* Match the original pale face and cream rim with a seamless capsule.
     Stretching its complete sprite flattened the caps; raster slice joins
     also introduced visible hairlines at fractional responsive scales. */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: calc(5 * var(--u)) solid #fff8e6;
  background: linear-gradient(180deg, #e7f5f6, #f9fcfc);
  box-shadow: 0 calc(4 * var(--u)) calc(6 * var(--u)) rgba(49, 111, 103, 0.25);
  pointer-events: none;
}
.loading-screen__fill {
  position: relative;
  display: block;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffe22e, #ffcc09 45%, #ffb500);
  transition: width var(--t-slow) var(--ease-out);
}
.loading-screen__status {
  position: absolute;
  left: 50%;
  top: calc(50% + 458 * var(--u));
  width: calc(800 * var(--u));
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: calc(33 * var(--u));
  color: #140f29;
}
.loading-screen__error {
  position: absolute;
  left: 50%;
  top: calc(50% + 300 * var(--u));
  width: calc(900 * var(--u));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(28 * var(--u));
  text-align: center;
  font-size: calc(32 * var(--u));
  color: #140f29;
}
.loading-screen__studio {
  position: absolute;
  left: 50%;
  bottom: calc(300 * var(--u));
  width: calc(380 * var(--u));
  height: calc(285 * var(--u));
  object-fit: contain;
  transform: translate(-50%, 50%);
}
.loading-screen__error .loading-screen__studio {
  position: static;
  flex: none;
  height: calc(230 * var(--u));
  margin-top: calc(70 * var(--u));
  transform: none;
}
.loading-screen__floater,
.loading-screen__robot,
.loading-screen__logo,
.loading-screen__studio { pointer-events: none; }

/* ---- Hub ---------------------------------------------------------------------------------------- */
.hub {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
}
.hub__main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.hub__page {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.app--phone .hub__page {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

/* park backdrop (HubLandscapeBackdropView): cover-fit layers with slow drift */
.hub-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #9fd9f0;
}
.hub-backdrop__layer {
  position: absolute;
  inset: calc(-24 * var(--u));
  background-size: cover;
  background-position: center bottom;
  will-change: transform;
}
.hub-backdrop__layer--sky {
  animation: drift 15s ease-in-out infinite alternate;
}
.hub-backdrop__layer--hills {
  animation: drift 20s ease-in-out infinite alternate-reverse;
  --drift: calc(12 * var(--u));
}
.hub-backdrop__layer--meadow {
  animation: drift 24s ease-in-out infinite alternate;
  --drift: calc(8 * var(--u));
}
@keyframes drift {
  from {
    transform: translateX(calc(-1 * var(--drift, calc(20 * var(--u)))));
  }
  to {
    transform: translateX(var(--drift, calc(20 * var(--u))));
  }
}
.hub-backdrop__rays {
  position: absolute;
  right: 18%;
  top: -4%;
  width: calc(520 * var(--u));
  height: calc(520 * var(--u));
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.18;
  transform: rotate(-10deg);
  animation: rays 8s ease-in-out infinite alternate;
}
@keyframes rays {
  to {
    opacity: 0.3;
  }
}
.hub-backdrop.is-still * {
  animation: none !important;
}

/* header band (Main.unity HubHeader/Band): frosted aurora fill, 44u corners, 16u inset */
.hub-header {
  position: relative;
  z-index: 3;
  flex: none;
  padding: calc(var(--safe-top) + 16 * var(--u)) calc(16 * var(--u)) 0;
}
.hub-header__band {
  display: flex;
  align-items: center;
  gap: calc(12 * var(--u));
  height: var(--hub-band-h);
  padding: 0 calc(16 * var(--u)) 0 calc(26 * var(--u));
  border-radius: var(--radius-card);
  background: var(--aurora-band);
  box-shadow:
    inset 0 calc(2 * var(--u)) 0 rgba(255, 255, 255, 0.92),
    0 calc(6 * var(--u)) calc(12 * var(--u)) rgba(27, 37, 89, 0.18);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
}
.hub-header__hud {
  display: flex;
  align-items: center;
  gap: calc(14 * var(--u));
  min-width: 0;
}
.hub-header__hud .pill {
  background: transparent;
  box-shadow: none;
  padding: 0 calc(6 * var(--u));
}
.hub-header__divider {
  width: calc(2 * var(--u));
  height: calc(44 * var(--u));
  background: var(--aurora-hairline);
  flex: none;
}
.hub-header__spacer {
  flex: 1;
}
.hub-header__band > .hub-header__round + .hub-header__round {
  margin-left: calc(4 * var(--u));
}
.hub-header__offline {
  font-size: calc(28 * var(--u));
}
@media (max-width: 759px) {
  .hub-header__band.is-offline {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    height: auto;
    min-height: var(--hub-band-h);
    padding-top: calc(16 * var(--u));
    padding-bottom: calc(16 * var(--u));
  }
  .hub-header__band.is-offline .hub-header__spacer { display: none; }
  .hub-header__band.is-offline .hub-header__offline {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }
}
.hub-header__round {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(92 * var(--u));
  height: calc(92 * var(--u));
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 calc(3 * var(--u)) calc(6 * var(--u)) rgba(27, 37, 89, 0.18);
}
.hub-header__round .tinted-icon {
  width: calc(46 * var(--u));
  height: calc(46 * var(--u));
}
.hub-header__dot {
  position: absolute;
  left: calc(50% + 18 * var(--u));
  top: calc(50% - 42 * var(--u));
  width: calc(24 * var(--u));
  height: calc(24 * var(--u));
  border-radius: 50%;
  background: var(--alert);
  box-shadow: 0 0 0 calc(3 * var(--u)) #fff;
}

/* avatar with level ring (UserContainer: 116u disc, XpRing filled radially, LevelBadge) */
.avatar-ring {
  --size: calc(116 * var(--u));
  position: relative;
  width: var(--size);
  height: var(--size);
  flex: none;
  border-radius: 50%;
}
.avatar-ring__disc {
  position: absolute;
  inset: calc(var(--size) * 0.086);
  border-radius: 50%;
  overflow: hidden;
  background-size: cover;
}
.avatar-ring__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-ring__track,
.avatar-ring__fill {
  position: absolute;
  inset: 0;
  mask-size: 100% 100%;
  -webkit-mask-size: 100% 100%;
}
.avatar-ring__track {
  background: var(--aurora-ring-track);
}
.avatar-ring__fill {
  background: conic-gradient(var(--yellow) calc(var(--progress) * 360deg), transparent 0);
}
.avatar-ring__level {
  position: absolute;
  left: 50%;
  bottom: calc(-15 * var(--u));
  min-width: calc(46 * var(--u));
  height: calc(46 * var(--u));
  padding: 0 calc(8 * var(--u));
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--yellow);
  border: calc(3 * var(--u)) solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 calc(3 * var(--u)) calc(4 * var(--u)) rgba(27, 37, 89, 0.35);
  font-weight: var(--w-medium);
  font-size: calc(26 * var(--u));
  color: var(--ink);
}

/* bottom tab bar (BottomMenuController): navy bar, sliding dome behind the selected tab */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--tabbar);
  box-shadow: inset 0 calc(5 * var(--u)) 0 var(--tabbar-top);
}
.tabbar__items {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--count), 1fr);
  height: var(--tabbar-h);
}
.tabbar__dome {
  position: absolute;
  left: calc((100% / var(--count)) * (var(--index) + 0.5));
  /* measured against the native capture (04-home, 25-leaderboards at 430x932): the dome rises ~8.5 px above the bar */
  top: calc(-51 * var(--u));
  width: calc(236 * 0.92 * var(--u));
  height: calc(236 * 0.92 * var(--u));
  transform: translateX(-50%);
  background-size: 100% 100%;
  transition: left var(--t-med) var(--ease-out);
  pointer-events: none;
  filter: drop-shadow(0 calc(-3 * var(--u)) calc(6 * var(--u)) rgba(0, 0, 0, 0.2));
}
.tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.tabbar__item img {
  width: calc(100 * var(--u));
  height: calc(100 * var(--u));
  object-fit: contain;
  transition: transform var(--t-med) var(--ease-out);
}
.tabbar__item.is-selected img {
  transform: translateY(calc(-40 * var(--u))) scale(1.1);
}
.tabbar__label {
  position: absolute;
  left: 50%;
  bottom: calc(13 * var(--u));
  transform: translateX(-50%);
  font-weight: var(--w-semibold);
  font-size: calc(28 * var(--u));
  color: #fff;
  text-shadow: var(--on-colour-shadow);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t-med);
}
.tabbar__item.is-selected .tabbar__label {
  opacity: 1;
}
.tab-dot {
  position: absolute;
  top: calc(30 * var(--u));
  left: calc(50% + 26 * var(--u));
  width: calc(30 * var(--u));
  height: calc(30 * var(--u));
  border-radius: 50%;
  background: var(--alert);
  box-shadow: 0 0 0 calc(3 * var(--u)) var(--tabbar);
}

/* left rail on wide screens */
.rail {
  position: relative;
  z-index: 4;
  flex: none;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 20px) 0 calc(var(--safe-bottom) + 20px);
  background: linear-gradient(180deg, #0a1f55, var(--tabbar));
  box-shadow: inset -4px 0 0 var(--tabbar-top);
}
.rail__brand {
  width: 56px;
  height: 56px;
  margin-bottom: 28px;
  display: none;
}
.rail__items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  justify-content: center;
}
.rail__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
  padding: 10px 4px 8px;
  border-radius: 22px;
  color: rgba(255, 255, 255, 0.82);
  transition:
    background var(--t-fast),
    transform var(--t-fast);
}
.rail__item img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  transition: transform var(--t-med) var(--ease-out);
}
.rail__item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.rail__item.is-selected {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
  color: #fff;
}
.rail__item.is-selected img {
  transform: scale(1.12);
}
.rail__label {
  font-weight: var(--w-semibold);
  font-size: 15px;
  text-shadow: var(--on-colour-shadow);
}
.rail .tab-dot {
  top: 6px;
  left: auto;
  right: 14px;
  width: 14px;
  height: 14px;
  box-shadow: 0 0 0 2px var(--tabbar);
}

/* Wide destinations keep the full label clear of the shared selected rim. */
@media (min-width: 760px) {
  .rail {
    width: 148px;
  }
  .rail__item {
    width: 126px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* wide hub: header and page share one centred column */
.app--wide .hub-header,
.app--wide .hub__page > * {
  width: 100%;
  max-width: var(--column-max);
  margin-left: auto;
  margin-right: auto;
}
.app--wide .hub-header {
  padding: calc(var(--safe-top) + 18px) 24px 0;
}
/* the phone band hugs its right edge like the prefab; a wide band gives both ends the same air */
.app--wide .hub-header__band {
  padding-right: calc(26 * var(--u));
}

/* full-screen flows */
.flow {
  --flow-viewport-safe-top: var(--safe-top);
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.flow__content {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* connection banner */
.connection-banner {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: 50%;
  z-index: 70;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 18, 66, 0.9);
  color: #fff;
  font-weight: var(--w-medium);
  font-size: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
}
.connection-banner.is-inline {
  position: static;
  z-index: auto;
  transform: none;
  flex: none;
  align-self: center;
  justify-content: center;
  width: calc(100% - 24px);
  max-width: 720px;
  margin: 6px 12px;
  padding: 8px 16px;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font-weight: var(--w-semibold);
  font-size: 14px;
  box-shadow: 0 2px 0 rgba(0, 18, 66, 0.12);
}
/* A flow notice owns the top safe area; the screen beneath it starts below that row. */
.flow > .connection-banner.is-inline {
  margin-top: calc(var(--safe-top) + 6px);
}
.flow > .connection-banner.is-inline + .flow__content {
  --safe-top: 0px;
}
/* These overlays still cover the viewport, including when their screen has a notice row. */
.flow__content :is(.picture-zoom, .popup-layer, .quiz-overlay, .reveal-banner-layer,
  .adv-sheet-layer, .adv-overlay-screen, .fr-overlay, .cat-sheet-layer) {
  --safe-top: var(--flow-viewport-safe-top);
}
.connection-banner button {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: var(--w-bold);
}
