/* Marcianin is the single floating service entry point for the Invasion landing. */
:root {
  --marcianin-edge: max(12px, env(safe-area-inset-right));
  --marcianin-bottom: calc(var(--sponsor-strip-h, 56px) + env(safe-area-inset-bottom) + 16px);
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* Header-only 2D mark. The 3D hero/cortina assets keep their existing rules. */
#nav .brand-visual.brand-visual--2d {
  width: 72px;
  height: 56px;
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  box-sizing: border-box;
  padding: 0;
  background: transparent;
}

#nav .brand-header-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  background: transparent;
  filter: drop-shadow(0 0 10px rgba(140, 252, 152, .28));
}

#nav .brand-visual--2d .brand-logo3d {
  display: none !important;
}

/* Legacy entry points stay in the DOM as functional adapters, never as extra FABs. */
#event-notification-bell,
#help-fab {
  display: none !important;
}

/* Marcianin replaces the decorative journey avatars and their duplicate controls. */
#journey-canvas,
.journey-slot,
.journey-hero-control,
.journey-footer-control,
[data-journey-toggle] {
  display: none !important;
}

.marcianin-hub {
  position: fixed;
  right: var(--marcianin-edge);
  bottom: var(--marcianin-bottom);
  z-index: 1275;
  width: 92px;
  display: grid;
  justify-items: end;
  pointer-events: none;
  isolation: isolate;
}

.marcianin-hub[data-side="left"] {
  right: auto;
  left: max(12px, env(safe-area-inset-left));
  justify-items: start;
}

.marcianin-trigger {
  position: relative;
  width: 82px;
  min-width: 56px;
  height: 88px;
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: rgba(5, 16, 10, .86);
  color: #8cfc98;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 14px 38px rgba(0, 0, 0, .48), inset 0 0 0 1px rgba(140, 252, 152, .36);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.marcianin-trigger::after {
  content: "Marcianín";
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translate(-50%, 100%);
  padding: 4px 7px;
  border: 1px solid rgba(140, 252, 152, .38);
  border-radius: 8px;
  background: #07100b;
  color: #dfffe4;
  font: 700 10px/1 "Space Grotesk", system-ui, sans-serif;
  letter-spacing: .02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}

.marcianin-trigger:hover,
.marcianin-trigger[aria-expanded="true"] {
  transform: translateY(-3px);
  background: rgba(8, 29, 16, .94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .56), inset 0 0 0 2px rgba(140, 252, 152, .64);
}

.marcianin-trigger:hover::after,
.marcianin-trigger:focus-visible::after {
  opacity: 1;
}

.marcianin-trigger:focus-visible,
.marcianin-panel :is(button, a, input):focus-visible {
  outline: 3px solid #8cfc98;
  outline-offset: 3px;
}

.marcianin-trigger__pet {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
  filter: drop-shadow(0 7px 10px rgba(0, 0, 0, .5));
  animation: marcianin-idle 4.8s ease-in-out infinite;
}

.marcianin-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border: 2px solid #07100b;
  border-radius: 999px;
  background: #ef474f;
  color: #fff;
  font: 800 11px/1 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-badge[hidden] {
  display: none;
}

.marcianin-trigger.has-unread {
  animation: marcianin-nudge .55s cubic-bezier(.2, .8, .2, 1) 1;
}

.marcianin-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  width: min(370px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  min-height: 0;
  max-height: min(640px, calc(100vh - var(--header-h, 76px) - var(--sponsor-strip-h, 56px) - 40px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
  border: 1.5px solid rgba(140, 252, 152, .68);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(12, 24, 17, .98), rgba(7, 10, 8, .99));
  color: #f5f5f5;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .68), inset 0 0 0 1px rgba(255, 255, 255, .03);
  pointer-events: auto;
  transform-origin: right bottom;
  animation: marcianin-panel-in .2s cubic-bezier(.2, .8, .2, 1) both;
}

.marcianin-hub[data-side="left"] .marcianin-panel {
  left: 0;
  right: auto;
  transform-origin: left bottom;
}

.marcianin-panel[hidden] {
  display: none !important;
}

.marcianin-panel__head {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.marcianin-panel__portrait {
  width: 52px;
  height: 58px;
  object-fit: contain;
  image-rendering: pixelated;
}

.marcianin-panel__kicker {
  margin: 0 0 4px;
  color: #8cfc98;
  font: 700 10px/1.2 "Press Start 2P", monospace;
  letter-spacing: .02em;
}

.marcianin-panel h2 {
  margin: 0;
  color: #fff;
  font: 800 clamp(19px, 5.5vw, 24px)/1.05 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-panel__close {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  color: #fff;
  cursor: pointer;
  font: 700 22px/1 system-ui, sans-serif;
}

.marcianin-panel__lead {
  margin: 0 0 14px;
  color: #b8c2ba;
  font: 500 13px/1.45 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-actions {
  display: grid;
  gap: 9px;
}

.marcianin-action {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(140, 252, 152, .22);
  border-radius: 13px;
  background: rgba(255, 255, 255, .035);
  color: #f5f5f5;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.marcianin-action:hover {
  border-color: rgba(140, 252, 152, .65);
  background: rgba(140, 252, 152, .08);
}

.marcianin-action__icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(140, 252, 152, .1);
  color: #8cfc98;
}

.marcianin-action__icon svg {
  width: 20px;
  height: 20px;
}

.marcianin-action__copy {
  min-width: 0;
}

.marcianin-action__copy strong,
.marcianin-action__copy small {
  display: block;
}

.marcianin-action__copy strong {
  color: #fff;
  font-size: 14px;
  line-height: 1.25;
}

.marcianin-action__copy small {
  margin-top: 3px;
  color: #9fac9f;
  font-size: 11px;
  line-height: 1.35;
}

.marcianin-action__meta {
  color: #8cfc98;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.marcianin-action__meta[hidden] {
  display: none;
}

.marcianin-contact-note {
  margin: 8px 2px 0;
  color: #8f9991;
  font: 500 10px/1.45 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-plugin {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(140, 252, 152, .28);
  border-radius: 13px;
  background: rgba(140, 252, 152, .055);
}

.marcianin-plugin[hidden] {
  display: none;
}

.marcianin-plugin h3 {
  margin: 0 0 5px;
  color: #dfffe4;
  font: 800 13px/1.25 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-plugin p {
  margin: 0;
  color: #aab7ac;
  font: 500 11px/1.45 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-plugin__link {
  display: inline-flex;
  margin-top: 10px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid rgba(140, 252, 152, .58);
  border-radius: 9px;
  background: rgba(140, 252, 152, .1);
  color: #8cfc98;
  font: 700 11px/1.2 "Space Grotesk", system-ui, sans-serif;
  text-decoration: none;
}

.marcianin-plugin__link[hidden] {
  display: none;
}

.marcianin-plugin__dismiss {
  margin-top: 9px;
  border: 0;
  background: transparent;
  color: #8cfc98;
  padding: 4px 0;
  cursor: pointer;
  font: 700 11px/1.2 "Space Grotesk", system-ui, sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.marcianin-side {
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 13px;
}

.marcianin-side legend {
  padding: 0 5px;
  color: #cdd4ce;
  font: 700 11px/1.2 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-side__options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.marcianin-side label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  color: #d6dcd7;
  cursor: pointer;
  font: 700 12px/1 "Space Grotesk", system-ui, sans-serif;
}

.marcianin-side label:has(input:checked) {
  border-color: #8cfc98;
  background: rgba(140, 252, 152, .11);
  color: #8cfc98;
}

.marcianin-side input {
  accent-color: #8cfc98;
}

@keyframes marcianin-idle {
  0%, 82%, 100% { transform: translateY(0); }
  88% { transform: translateY(-4px); }
  94% { transform: translateY(0); }
}

@keyframes marcianin-nudge {
  0%, 100% { transform: rotate(0); }
  30% { transform: rotate(-4deg); }
  65% { transform: rotate(4deg); }
}

@keyframes marcianin-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 1024px) {
  #nav .brand-visual.brand-visual--2d {
    width: 56px;
    height: 44px;
    flex-basis: 56px;
    padding: 0;
    background: transparent;
  }
}

@media (max-width: 520px) {
  :root { --marcianin-bottom: calc(var(--sponsor-strip-h, 56px) + env(safe-area-inset-bottom) + 10px); }

  #nav .brand-visual.brand-visual--2d {
    width: 52px;
    height: 42px;
    flex-basis: 52px;
    padding: 0;
    background: transparent;
  }

  .marcianin-hub {
    width: 72px;
  }

  .marcianin-trigger {
    width: 66px;
    height: 72px;
    border-radius: 18px;
  }

  .marcianin-panel {
    position: fixed;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: calc(var(--sponsor-strip-h, 56px) + env(safe-area-inset-bottom) + 10px);
    width: auto;
    max-height: calc(100dvh - var(--header-h, 76px) - var(--sponsor-strip-h, 56px) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
    padding: 15px;
    border-radius: 17px;
    transform-origin: center bottom;
  }
}

@media (max-width: 360px) {
  #nav .brand-visual.brand-visual--2d {
    width: 48px;
    height: 38px;
    flex-basis: 48px;
    padding: 0;
    background: transparent;
  }

  #nav .brand-text--void {
    font-size: 9.5px !important;
  }

  .marcianin-panel {
    padding: 12px;
  }

  .marcianin-panel__head {
    grid-template-columns: 44px minmax(0, 1fr) 36px;
  }

  .marcianin-panel__portrait {
    width: 44px;
    height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marcianin-trigger,
  .marcianin-trigger__pet,
  .marcianin-panel {
    animation: none !important;
    transition: none !important;
  }
}

@supports not (overflow: clip) {
  html,
  body { overflow-x: hidden; }
}
