.carregamento-vila {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: safe center;
  overflow: auto;
  padding: clamp(12px, 4vw, 32px);
  background: radial-gradient(ellipse at 50% 28%, #365446, var(--forest, #253a31) 68%);
  color: var(--ink, #263a31);
  font: 1rem/1.5 system-ui, sans-serif;
  text-align: center;
  /* Libera a página se o próprio módulo de carregamento estiver indisponível. */
  animation: vila-liberar-pagina 15s step-end both;
}

.carregamento-vila [hidden] {
  display: none !important;
}

.carregamento-vila__cartao {
  box-sizing: border-box;
  width: min(100%, 26rem);
  padding: clamp(16px, 5vw, 28px);
  border: 1px solid #c1a875;
  border-radius: 12px;
  background: var(--card, #faf5e7);
  box-shadow: 0 18px 54px #14271d90;
}

.carregamento-vila__local {
  margin: 0;
  color: #80513d;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.carregamento-vila__titulo {
  margin: 5px 0 15px;
  font: clamp(1.6rem, 6vw, 2.45rem)/1.12 Georgia, serif;
  letter-spacing: -.035em;
}

.carregamento-vila__trilha {
  position: relative;
  isolation: isolate;
  display: block;
  width: 100%;
  height: clamp(104px, 35vw, 142px);
  overflow: hidden;
  border: 1px solid #a78053;
  border-radius: 7px;
  padding: 0;
  background: #d9ad77 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 124' preserveAspectRatio='none' shape-rendering='crispEdges'%3E%3Cpath fill='%23edcc91' d='M0 0h320v124H0z'/%3E%3Cpath fill='%23f9e5b6' d='M241 11h16v4h6v6h4v14h-4v6h-6v4h-16v-4h-6v-6h-4V21h4v-6h6z'/%3E%3Cpath fill='%23c88b61' d='M0 48h16v-4h16v-6h17v-5h22v5h15v5h16v7h18v5h39v-4h19v-6h19v-6h12v-5h15v7h17v5h17v8h32v-5h20v-4h10v79H0z'/%3E%3Cpath fill='%23577f77' d='M0 62h61v-3h56v3h66v-3h39v3h98v62H0z'/%3E%3Cpath fill='%237ea199' d='M27 65h49v2H27zM190 66h64v2h-64zM271 70h36v2h-36zM1 73h65v2H1zM118 68h35v2h-35z'/%3E%3Cpath fill='%23bd8a55' d='M0 77h45v-4h33v5h35v-3h26v4h43v-4h41v3h46v-3h51v49H0z'/%3E%3Cpath fill='%23daa971' d='M0 86h44v-5h53v4h37v-3h48v3h43v-4h41v4h54v39H0z'/%3E%3Cpath fill='%23496343' d='M49 38h8v45h-8V67H35v-7h-4V48h5v9h4v4h9zM57 58h8v-7h4V41h5v14h-4v10H57z'/%3E%3Cpath fill='%23758652' d='M51 40h2v43h-2zM65 53h2v7h-2zM33 50h2v8h-2z'/%3E%3Cpath fill='%23976c49' d='M35 91h15v2H35zM75 88h10v2H75zM262 90h15v2h-15zM277 94h20v2h-20zM223 84h7v2h-7z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  color: #263a31;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.carregamento-vila__trilha:disabled {
  cursor: default;
}

.carregamento-vila__trilha:focus-visible,
.carregamento-vila__recarregar:focus-visible {
  outline: 3px solid #9a593f;
  outline-offset: 3px;
}

.carregamento-vila__passos {
  position: absolute;
  bottom: 31%;
  left: 33%;
  width: clamp(42px, 14vw, 62px);
  aspect-ratio: 1.5;
  animation: vila-passo-da-cabra 5.4s steps(18, end) infinite;
}

.carregamento-vila__passos::before {
  position: absolute;
  inset: auto 6% -1% 7%;
  height: 8%;
  border-radius: 50%;
  background: #61473170;
  content: "";
}

.carregamento-vila__cabra {
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 32' shape-rendering='crispEdges'%3E%3Cpath fill='%23594035' d='M5 11h4v4h17v-2h4V9h2V6h-2V2h3v4h3V3h3v6h4v3h3v7h-4v2h-6v4h-3v7h-5v-8h-7v4h-3v4h-5v-8H9v4H5v-4h2V17H5z'/%3E%3Cpath fill='%23f8e5b5' d='M9 15h19v-2h4v-4h9v4h3v5h-4v2h-7v5h-2v4h-2v-7H19v3h-3v4h-2v-8H9z'/%3E%3Cpath fill='%23d9ae7f' d='M9 19h20v-2h4v-3h5v4h5v2h-7v4h-3v-3h-4v1H18v4h-3v-5H9zM32 3h1v4h3v2h-3V7h-1zM37 4h1v4h-1z'/%3E%3Cpath fill='%23594035' d='M39 11h2v2h-2zM38 21h3v4h-3zM13 29h5v3h-5zM28 29h5v3h-5z'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: vila-balanco-da-cabra .34s steps(2, end) infinite alternate;
}

.carregamento-vila__dica {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  width: fit-content;
  margin-inline: auto;
  border-radius: 4px;
  padding: 2px 8px;
  background: #faf5e7;
  font-size: .75rem;
  font-weight: 700;
}

.carregamento-vila__trilha:disabled .carregamento-vila__dica {
  visibility: hidden;
}

.carregamento-vila__status {
  margin: 14px 0 0;
  color: #4d5949;
  font-size: .9rem;
  font-weight: 650;
}

.carregamento-vila[data-estado="falha"] {
  inset: auto 12px 12px;
  width: fit-content;
  max-width: calc(100% - 24px);
  margin-inline: auto;
  overflow: visible;
  padding: 0;
  background: none;
  animation: none;
}

.carregamento-vila[data-estado="falha"] .carregamento-vila__cartao {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 12px;
  width: auto;
  padding: 8px 12px;
  text-align: left;
}

.carregamento-vila[data-estado="falha"] :is(.carregamento-vila__local, .carregamento-vila__titulo, .carregamento-vila__trilha) {
  display: none;
}

.carregamento-vila[data-estado="falha"] .carregamento-vila__status {
  margin: 0;
}

.carregamento-vila__recarregar {
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid #58715e;
  border-radius: 5px;
  background: var(--forest, #253a31);
  color: var(--card, #faf5e7);
  font: 700 .85rem/1.2 system-ui, sans-serif;
  cursor: pointer;
}

@keyframes vila-liberar-pagina {
  to { visibility: hidden; }
}

@keyframes vila-passo-da-cabra {
  0%, 100% { translate: 0; scale: 1 1; }
  49% { translate: 72%; scale: 1 1; }
  50% { translate: 72%; scale: -1 1; }
  99% { translate: 0; scale: -1 1; }
}

@keyframes vila-balanco-da-cabra {
  to { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .carregamento-vila__passos,
  .carregamento-vila__cabra {
    animation: none;
  }
}
