/* Forja dos Mundos v4.3.18 — Correção responsiva 01 */
:root {
  --forja-mobile-bar: 68px;
  --forja-safe-bottom: max(10px, env(safe-area-inset-bottom));
}

html,
body,
.app-shell,
main,
.page {
  max-width: 100%;
}

html,
body {
  overflow-x: clip;
}

/* Evita o estouro do cabeçalho antes de os atalhos serem recolhidos. */
.topbar-actions > :not(#soundToggle):not(#loginButton):not(#menuButton):not(#forgeToolsButton) {
  display: none !important;
}

.forge-tools-grid > *,
.forge-tools-grid .beta-mobile-diagnostics {
  display: inline-flex !important;
}

.topbar {
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.desktop-nav {
  min-width: 0;
  justify-content: center;
  overflow: hidden;
}

.desktop-nav .nav-ciel {
  color: #dcb4ff;
  background: rgba(138, 105, 184, .08);
}

.forge-tools-button {
  position: relative;
}

.forge-tools-button::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-400);
  box-shadow: 0 0 9px rgba(219, 180, 90, .8);
}

.forge-tools-backdrop {
  position: fixed;
  inset: 0;
  z-index: 88;
  background: rgba(0, 0, 0, .68);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}

.forge-tools-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.forge-tools-drawer {
  position: fixed;
  z-index: 89;
  top: 0;
  right: 0;
  width: min(420px, 94vw);
  height: 100dvh;
  padding: max(1rem, env(safe-area-inset-top)) 1rem var(--forja-safe-bottom);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1rem;
  border-left: 1px solid rgba(199, 154, 59, .32);
  background: linear-gradient(180deg, rgba(17, 14, 12, .99), rgba(6, 5, 4, .99));
  box-shadow: -28px 0 80px rgba(0, 0, 0, .58);
  transform: translateX(104%);
  transition: transform .28s ease;
  overflow: hidden;
}

.forge-tools-drawer.is-open {
  transform: none;
}

.forge-tools-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}

.forge-tools-head p {
  margin: 0 0 .2rem;
  color: var(--gold-300);
  font-size: .68rem;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.forge-tools-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.forge-tools-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: .2rem;
  scrollbar-color: var(--bronze-600) #090706;
}

.forge-tools-section + .forge-tools-section {
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line-soft);
}

.forge-tools-section h3 {
  margin: 0 0 .7rem;
  color: var(--parchment-300);
  font-family: var(--font-display);
  font-size: .9rem;
}

.forge-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .6rem;
}

.forge-tools-grid > button,
.forge-tools-grid > .cloud-sync-button,
.forge-tools-grid > .forge-security-button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 70px !important;
  height: auto !important;
  padding: .55rem !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: .25rem !important;
  border: 1px solid rgba(199, 154, 59, .22) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, .025) !important;
  color: var(--parchment-300) !important;
  font-size: .64rem !important;
  text-align: center !important;
  white-space: normal !important;
  box-shadow: none !important;
}

.forge-tools-grid > button:hover,
.forge-tools-grid > .cloud-sync-button:hover,
.forge-tools-grid > .forge-security-button:hover {
  border-color: rgba(219, 180, 90, .58) !important;
  background: rgba(199, 154, 59, .09) !important;
}

.forge-tools-grid button svg {
  width: 22px;
  height: 22px;
}

.forge-tools-grid button b,
.forge-tools-grid button strong,
.forge-tools-grid button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Aba própria da Ciel */
.ciel-hub-page {
  padding-bottom: 6rem;
}

.ciel-hub-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.4rem, 5vw, 3.2rem);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
  align-items: center;
  gap: 2rem;
  border: 1px solid rgba(138, 105, 184, .35);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 82% 16%, rgba(138, 105, 184, .25), transparent 34%),
    radial-gradient(circle at 10% 100%, rgba(74, 127, 167, .16), transparent 34%),
    linear-gradient(135deg, rgba(20, 15, 27, .98), rgba(9, 8, 10, .98));
  box-shadow: var(--shadow-lg);
}

.ciel-hub-hero::after {
  content: "✦";
  position: absolute;
  right: clamp(1rem, 6vw, 5rem);
  top: 50%;
  transform: translateY(-50%);
  color: rgba(220, 180, 255, .12);
  font-size: clamp(9rem, 20vw, 17rem);
  line-height: 1;
  pointer-events: none;
}

.ciel-hub-copy,
.ciel-hub-status {
  position: relative;
  z-index: 1;
}

.ciel-hub-copy h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 1;
}

.ciel-hub-copy h2 span {
  color: #dcb4ff;
}

.ciel-hub-copy > p:not(.eyebrow) {
  max-width: 670px;
  color: var(--parchment-300);
  line-height: 1.7;
}

.ciel-hub-actions {
  margin-top: 1.2rem;
  display: flex;
  gap: .7rem;
  flex-wrap: wrap;
}

.ciel-hub-status {
  padding: 1.1rem;
  border: 1px solid rgba(220, 180, 255, .2);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, .28);
}

.ciel-hub-status small,
.ciel-hub-status span {
  display: block;
  color: var(--muted);
}

.ciel-hub-status strong {
  display: block;
  margin: .25rem 0 .5rem;
  color: #e8d3ff;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.ciel-module-grid {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
}

.ciel-module-card {
  min-height: 150px;
  padding: 1rem;
  display: grid;
  align-content: center;
  gap: .45rem;
  border: 1px solid rgba(138, 105, 184, .25);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(138, 105, 184, .08), rgba(255, 255, 255, .015));
  color: var(--parchment-100);
  text-align: left;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.ciel-module-card:hover {
  transform: translateY(-3px);
  border-color: rgba(220, 180, 255, .62);
  background: linear-gradient(145deg, rgba(138, 105, 184, .16), rgba(255, 255, 255, .025));
}

.ciel-module-card > span:first-child {
  color: #dcb4ff;
  font-size: 1.55rem;
}

.ciel-module-card strong {
  font-family: var(--font-display);
  font-size: .92rem;
}

.ciel-module-card small {
  color: var(--muted);
  line-height: 1.45;
}

.mobile-bottom-nav {
  display: none;
}

/* Entrada dos portões: enquadramento completo em telas pequenas. */
@media (max-width: 1020px) {
  :root {
    --topbar-height: 64px;
  }

  body {
    min-width: 0 !important;
  }

  .arrival {
    width: 100dvw;
    height: 100dvh;
    min-width: 0;
    min-height: 0;
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .arrival-world {
    inset:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    border: 1px solid rgba(199, 154, 59, .28);
    background: #080604;
    box-shadow: inset 0 0 55px #000;
  }

  .arrival-backdrop {
    inset: 0;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: none;
    filter: brightness(.42) saturate(.72) contrast(1.04);
  }

  .arrival.is-opening .arrival-backdrop {
    transform: scale(1.025);
  }

  .gate-frame {
    box-shadow: inset 0 0 52px #000;
    background:
      linear-gradient(90deg, rgba(0, 0, 0, .88) 0 2%, transparent 8% 92%, rgba(0, 0, 0, .88) 98% 100%),
      linear-gradient(180deg, rgba(0, 0, 0, .82), transparent 8% 91%, rgba(0, 0, 0, .86));
  }

  .gate {
    width: 50.2%;
    min-width: 0;
    box-shadow: inset 0 0 34px #000, 0 0 20px #000;
  }

  .gate::before {
    inset: 2% 4%;
    border-width: 1px;
  }

  .gate::after {
    width: 12px;
  }

  .gate-rivets {
    inset: 6% 9%;
    background-size: 46px 46px;
    background-image: radial-gradient(circle, #6e5742 0 1.6px, transparent 2.7px);
  }

  .gate-seal {
    width: clamp(68px, 20vw, 92px);
    border-width: 2px;
    box-shadow: 0 0 0 6px rgba(0, 0, 0, .42), 0 0 25px rgba(199, 154, 59, .18), inset 0 0 22px #000;
  }

  .arrival-content {
    width: min(92dvw, 440px);
    padding: 1rem .85rem;
  }

  .arrival h1 {
    font-size: clamp(2.15rem, 10dvw, 3.5rem);
    line-height: .94;
  }

  .arrival h1 span {
    font-size: .42em;
    letter-spacing: .22em;
    padding-left: .22em;
  }

  .arrival-slogan {
    max-width: 32rem;
    margin: .85rem auto 1.15rem;
    font-size: clamp(.82rem, 3.6dvw, 1rem);
    line-height: 1.55;
  }

  .arrival .btn-xl {
    width: min(100%, 280px);
    min-height: 52px;
    padding: .8rem 1rem;
    font-size: .78rem;
  }

  .arrival-hint {
    max-width: 300px;
    margin: .7rem auto .1rem;
    font-size: .68rem;
    line-height: 1.4;
  }

  .arrival-caption {
    bottom: max(1rem, env(safe-area-inset-bottom));
    width: calc(100% - 2rem);
    text-align: center;
    font-size: .58rem;
    letter-spacing: .12em;
  }

  .topbar {
    min-height: var(--topbar-height);
    height: var(--topbar-height);
    padding: 0 .65rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .5rem;
  }

  .brand {
    min-width: 0;
    max-width: 100%;
    gap: .55rem;
  }

  .brand-crest {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
  }

  .brand strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    min-width: 0;
    gap: .35rem;
  }

  #soundToggle,
  #forgeToolsButton {
    display: none !important;
  }

  .mobile-menu {
    z-index: 86;
    top: var(--topbar-height);
    width: min(370px, 92vw);
    height: calc(100dvh - var(--topbar-height) - var(--forja-mobile-bar));
    padding: .75rem 1rem calc(1rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .mobile-menu a,
  .mobile-menu > button:not(.beta-mobile-diagnostics) {
    min-height: 48px;
    width: 100%;
    display: flex;
    align-items: center;
    padding: .8rem .75rem;
    border: 0;
    border-bottom: 1px solid var(--line-soft);
    background: transparent;
    color: var(--parchment-300);
    text-align: left;
  }

  .mobile-menu .beta-mobile-diagnostics {
    display: none !important;
  }

  main {
    width: 100%;
    padding-bottom: calc(var(--forja-mobile-bar) + var(--forja-safe-bottom));
  }

  .hero,
  .hub-section,
  .inner-page,
  .discord-cta,
  footer {
    width: min(100% - 1rem, 100%);
    max-width: 100%;
  }

  .hero {
    min-height: auto;
    padding: 2.25rem 0 2rem;
    gap: 1.4rem;
  }

  .hero-copy h2 {
    font-size: clamp(2rem, 10dvw, 3.35rem);
  }

  .hero-copy > p:not(.eyebrow) {
    font-size: .95rem;
    line-height: 1.65;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .hero-facts {
    justify-content: flex-start;
  }

  .hero-art {
    width: 100%;
    max-width: 520px;
  }

  .hub-section,
  .inner-page {
    padding: 2.4rem 0;
  }

  .section-heading,
  .page-heading {
    margin-bottom: 1.25rem;
  }

  .hub-grid {
    grid-template-columns: 1fr;
    gap: .7rem;
  }

  .hub-card {
    width: 100%;
    min-height: 104px;
    padding: .9rem;
  }

  .hub-card > svg {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    padding: 10px;
  }

  .hub-card strong {
    font-size: .9rem;
  }

  .hub-card small {
    font-size: .76rem;
  }

  .discord-cta {
    margin-bottom: 2rem;
  }

  footer {
    margin: 0 auto;
    padding: 2rem .4rem calc(2rem + var(--forja-mobile-bar));
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 84;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--forja-mobile-bar) + env(safe-area-inset-bottom));
    padding: 5px 4px env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top: 1px solid rgba(199, 154, 59, .28);
    background: rgba(9, 8, 7, .97);
    backdrop-filter: blur(18px);
    box-shadow: 0 -12px 36px rgba(0, 0, 0, .42);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    min-width: 0;
    min-height: 54px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: .61rem;
  }

  .mobile-bottom-nav a > span:first-child,
  .mobile-bottom-nav button > span:first-child {
    font-size: 1.18rem;
    line-height: 1;
  }

  .mobile-bottom-nav a.active,
  .mobile-bottom-nav button:active {
    color: var(--gold-300);
    background: rgba(199, 154, 59, .08);
  }

  .ciel-hub-hero {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.25rem;
  }

  .ciel-hub-hero::after {
    right: -1rem;
    top: 1rem;
    transform: none;
    font-size: 8rem;
  }

  .ciel-hub-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ciel-hub-actions .btn {
    width: 100%;
  }

  .ciel-module-grid {
    grid-template-columns: 1fr;
  }

  .ciel-module-card {
    min-height: 104px;
  }

  .forge-tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1021px) and (max-width: 1380px) {
  .topbar {
    padding-inline: 1rem;
    gap: .75rem;
  }

  .brand {
    min-width: 190px;
  }

  .brand small {
    display: none;
  }

  .desktop-nav {
    gap: .12rem;
  }

  .desktop-nav a {
    padding: .62rem .56rem;
    font-size: .78rem;
  }
}

@media (max-width: 520px) {
  .brand strong {
    font-size: .73rem;
  }

  #loginButton {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }

  #menuButton {
    width: 40px;
    height: 40px;
  }

  .arrival-content .eyebrow {
    font-size: .58rem;
    letter-spacing: .15em;
  }

  .arrival-caption {
    display: none;
  }
}
