.app-body {
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
}

.app-body--guest {
  padding-bottom: var(--safe-bottom);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--color-jungle);
  color: var(--text-inverse);
  border-bottom: 3px solid var(--color-jungle-dark);
  box-shadow: var(--shadow-md);
}

.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  max-width: var(--chrome-max-width);
  min-height: var(--header-height);
  margin: 0 auto;
  padding: var(--space-2) var(--chrome-gutter);
  box-sizing: border-box;
}

.app-header__start {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}

.app-header__end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
}

.app-header__hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  min-width: 0;
}

.app-header__menu-toggle {
  flex: 0 0 auto;
}

.app-header__dst,
.app-header__profile {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  color: var(--text-inverse);
  text-decoration: none;
  font-weight: 800;
  font-size: var(--font-size-sm);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.app-header__dst:hover,
.app-header__profile:hover {
  background: rgba(255, 255, 255, 0.18);
}

.app-header__dst-label,
.app-header__profile-label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 950;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.app-header__profile-label {
  display: none;
}

.app-header__dst-label {
  background: var(--color-treasure);
  color: #3a2700;
}

.app-header__dst-value,
.app-header__profile-name {
  font-variant-numeric: tabular-nums;
}

.app-header__zmt {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  color: rgba(255, 255, 255, 0.92);
  font-size: var(--font-size-sm);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-header__logout {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--font-size-xs);
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 6px;
}

.app-header__logout:hover {
  color: #fff;
}

.app-header__nav--guest {
  display: flex;
  gap: var(--space-2);
}

.pet-widget {
  position: fixed;
  inset: 0;
  z-index: var(--z-pet-widget);
  pointer-events: none;
}

.pet-widget__shell {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pet-strip-width);
  max-width: calc(100vw - 16px);
  pointer-events: auto;
}

.pet-widget.is-dragging .pet-widget__shell {
  transition: none;
}

.pet-widget:not([data-state]) .pet-widget__shell {
  visibility: hidden;
}

.pet-widget__panel,
.pet-widget__empty {
  display: none;
}

.pet-widget[data-state="ready"] .pet-widget__panel {
  display: block;
}

.pet-widget[data-state="empty"] .pet-widget__empty {
  display: grid;
}

.pet-widget__panel {
  border-radius: var(--radius-lg);
  background: rgba(255, 254, 249, 0.92);
  border: 2px solid rgba(13, 74, 50, 0.14);
  box-shadow: 0 8px 24px rgba(13, 74, 50, 0.16);
  backdrop-filter: blur(8px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.pet-widget.is-dragging .pet-widget__panel,
.pet-widget.is-dragging .pet-widget__empty {
  cursor: grabbing;
}

.pet-widget__head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 6px 4px 4px;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(13, 74, 50, 0.08);
  user-select: none;
}

.pet-widget__grip {
  flex: 0 0 12px;
  width: 12px;
  height: 20px;
  margin-left: 2px;
  border-radius: 4px;
  background:
    radial-gradient(circle, rgba(13, 74, 50, 0.42) 1.5px, transparent 2px) center 3px / 8px 7px repeat-y;
  opacity: 0.85;
}

.pet-widget__avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.82);
  border: 2px solid rgba(13, 74, 50, 0.1);
  overflow: hidden;
}

.pet-widget__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.pet-widget__avatar-fallback {
  font-weight: 800;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.pet-widget__name {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-weight: 800;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pet-widget__toggle {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(13, 74, 50, 0.08);
  color: var(--text-primary);
  font-weight: 800;
  cursor: pointer;
}

.pet-widget__toggle:hover {
  background: rgba(13, 74, 50, 0.14);
}

.pet-widget__toggle-icon::before {
  content: '−';
  font-size: 1.1rem;
  line-height: 1;
}

.pet-widget.is-collapsed .pet-widget__toggle-icon::before {
  content: '+';
}

.pet-widget__body {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 8px 10px 10px;
  user-select: none;
}

.pet-widget__stats {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px 6px;
  margin: 0;
}

.pet-widget__stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin: 0;
}

.pet-widget__stat dt {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pet-widget__stat dd {
  margin: 0;
  font-size: var(--font-size-xs);
  font-weight: 800;
  color: var(--text-primary);
}

.pet-widget__player {
  flex: 0 0 58px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding-left: 8px;
  border-left: 2px solid rgba(13, 74, 50, 0.1);
  text-align: right;
}

.pet-widget__player-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pet-widget__player-level,
.pet-widget__player-exp {
  font-size: var(--font-size-xs);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
}

.pet-widget__empty {
  margin: 0;
  min-height: 40px;
  padding: 8px 12px;
  place-items: center;
  border-radius: var(--radius-lg);
  background: rgba(255, 254, 249, 0.92);
  border: 2px dashed rgba(13, 74, 50, 0.16);
  box-shadow: 0 8px 24px rgba(13, 74, 50, 0.12);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--text-muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.pet-widget.is-collapsed .pet-widget__body {
  display: none;
}

.pet-widget.is-collapsed .pet-widget__head {
  border-bottom: 0;
}

.pet-widget.is-collapsed .pet-widget__shell {
  width: auto;
  max-width: min(220px, calc(100vw - 16px));
}

.pet-widget.is-collapsed .pet-widget__panel {
  width: max-content;
  min-width: 148px;
}

@media (max-width: 719px) {
  .app-header__inner {
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  .app-header__start {
    flex: 1 1 auto;
  }

  .app-header__end {
    flex: 0 0 auto;
  }

  .app-header__hud {
    flex: 1 1 100%;
    justify-content: flex-end;
    gap: 6px var(--space-2);
  }

  .app-header__dst,
  .app-header__profile,
  .app-header__zmt {
    padding: 5px 8px;
    font-size: var(--font-size-xs);
  }

  .app-header__logout {
    display: none;
  }
}

@media (min-width: 768px) {
  .app-header__inner {
    flex-wrap: nowrap;
    align-items: center;
  }

  .app-header__hud {
    flex-wrap: nowrap;
  }
}

body.app-body--scene .pet-widget__panel,
body.app-body--scene .pet-widget__empty {
  background: rgba(8, 40, 28, 0.88);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

body.app-body--scene .pet-widget__head {
  background: rgba(255, 255, 255, 0.08);
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

body.app-body--scene .pet-widget__name,
body.app-body--scene .pet-widget__stat dd,
body.app-body--scene .pet-widget__player-level,
body.app-body--scene .pet-widget__player-exp {
  color: #f4fff8;
}

body.app-body--scene .pet-widget__stat dt,
body.app-body--scene .pet-widget__player-label {
  color: rgba(244, 255, 248, 0.72);
}

body.app-body--scene .pet-widget__avatar {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

body.app-body--scene .pet-widget__player {
  border-left-color: rgba(255, 255, 255, 0.18);
}

body.app-body--scene .pet-widget__toggle {
  background: rgba(255, 255, 255, 0.12);
  color: #f4fff8;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: inherit;
  text-decoration: none;
  font-weight: 800;
}

.app-brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--color-yellow);
  color: var(--text-primary);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.app-brand__text {
  font-size: var(--font-size-lg);
}

.app-header__nav {
  display: none;
  gap: var(--space-2);
}

.app-header__link {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text-inverse);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--font-size-sm);
}

.app-header__link.is-active,
.app-header__link:hover {
  background: rgba(255, 255, 255, 0.18);
}

.app-header__link--accent {
  background: var(--color-yellow);
  color: var(--text-primary);
}

.app-header__menu-toggle {
  color: var(--text-inverse);
}

.app-shell {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-4);
}

.app-shell--guest {
  padding-top: var(--space-6);
}

.app-main {
  min-height: 40dvh;
}

.app-main--guest {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.player-strip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  background: var(--surface-panel);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

.player-strip__avatar {
  flex-shrink: 0;
}

.player-strip__avatar-inner {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-orange);
  color: var(--text-inverse);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.player-strip__info {
  flex: 1;
  min-width: 0;
}

.player-strip__name {
  font-weight: 800;
  font-size: var(--font-size-md);
}

.player-strip__meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.player-strip__stats {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-end;
}

.player-strip__stat {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.player-strip__stat--link {
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-md);
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 0.15s ease;
}

.player-strip__stat--link:hover {
  background: #fff9e8;
}

.player-strip__stat--link:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.player-strip__value {
  font-weight: 800;
  font-size: var(--font-size-sm);
}

.section-subnav {
  margin-bottom: var(--space-4);
  margin-left: calc(-1 * var(--space-1));
  margin-right: calc(-1 * var(--space-1));
}

.section-subnav__scroll {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.section-subnav__scroll::-webkit-scrollbar {
  display: none;
}

.section-subnav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  border: 2px solid var(--border-color);
  background: var(--surface-panel);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.section-subnav__link:hover {
  border-color: var(--color-jungle);
  background: var(--surface-inset);
}

.section-subnav__link.is-active {
  background: var(--color-jungle);
  border-color: var(--color-jungle-dark);
  color: var(--text-inverse);
}

.section-subnav__link--soon:not(.is-active) {
  border-style: dashed;
}

.section-subnav__badge {
  font-size: 0.65rem;
  padding: 1px 6px;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bottom-nav);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  min-height: var(--bottom-nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--surface-panel);
  border-top: 2px solid var(--border-color);
  box-shadow: 0 -3px 0 rgba(26, 29, 38, 0.04);
}

.app-body--guest .bottom-nav,
.app-body--guest .player-strip,
.app-body--guest .pet-widget {
  display: none;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-1) var(--space-1);
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 700;
  min-height: 44px;
}

.bottom-nav__label {
  font-size: 0.62rem;
  line-height: 1.1;
  text-align: center;
  max-width: 4.5rem;
}

.bottom-nav__item.is-active {
  color: var(--color-jungle-dark);
}

.bottom-nav__icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-inset);
  border: 2px solid var(--border-color);
}

.bottom-nav__item.is-active .bottom-nav__icon {
  background: var(--color-jungle);
  border-color: var(--color-jungle-dark);
}

.mobile-nav {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  pointer-events: none;
}

.mobile-nav.is-open {
  pointer-events: auto;
}

.mobile-nav__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 29, 38, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-nav.is-open .mobile-nav__backdrop {
  opacity: 1;
}

.mobile-nav__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(88vw, 320px);
  height: 100%;
  background: var(--surface-panel);
  border-left: 3px solid var(--color-jungle);
  box-shadow: -4px 0 0 rgba(26, 29, 38, 0.08);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}

.mobile-nav.is-open .mobile-nav__panel {
  transform: translateX(0);
}

.mobile-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 2px solid var(--border-color);
}

.mobile-nav__title {
  font-weight: 800;
  font-size: var(--font-size-lg);
}

.mobile-nav__links {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.mobile-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  border: 2px solid transparent;
}

.mobile-nav__link.is-active,
.mobile-nav__link:hover {
  background: var(--surface-inset);
  border-color: var(--border-color);
}

.mobile-nav__icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--color-blue);
}

.mobile-nav__icon--wallet {
  background: var(--color-gold);
}

.mobile-nav__footer {
  padding: var(--space-4);
  border-top: 2px solid var(--border-color);
}

.mobile-nav__note {
  margin-bottom: var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.app-footer {
  max-width: var(--content-max-width);
  margin: var(--space-6) auto var(--space-4);
  padding: 0 var(--space-4) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.app-footer__brand {
  font-weight: 800;
  color: var(--text-secondary);
}

.app-footer__links {
  margin-top: var(--space-2);
}

.app-footer__links a {
  font-weight: 700;
}

@media (min-width: 768px) {
  .app-header__nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 62%;
  }

  .app-header__nav--guest {
    max-width: none;
  }

  .app-header__link {
    padding: var(--space-2);
    font-size: var(--font-size-xs);
  }

  .bottom-nav {
    display: none;
  }

  .app-body {
    padding-bottom: var(--space-6);
  }
}

