/* =============================================
   AVATAR.CSS — Tela de identificação do jogador
   ============================================= */

.tela-identificacao {
  background-image: url('../assets/img/telas/tela-avatar/fundo.webp');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  min-height: 100vh;
  min-height: 100svh;
}

/* Container principal — relativo para os botões absolutos */
.avatar-bg-frame {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 0;
  position: relative;
}

/* ---- Botões topo ---- */
.btn-topo {
  position: absolute;
  top: 16px;
  width: clamp(52px, 14vw, 72px);
  height: clamp(52px, 14vw, 72px);
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 5;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease;
}

.btn-topo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.btn-topo:active { transform: scale(0.9); }

.btn-retornar    { left: 12px; }
.btn-configuracoes { right: 12px; }

/* ---- Banner ---- */
.avatar-banner {
  width: 82%;
  max-width: 350px;
  height: auto;
  object-fit: contain;
  display: block;
  margin-top: 80px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

/* ---- Card principal ---- */
.avatar-card {
  width: 100%;
  background: rgba(255, 243, 214, 0.97);
  border: 3px solid rgba(224, 169, 72, 0.95);
  border-radius: 28px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.25);
  padding: 20px 14px 24px;
  text-align: center;
  flex-shrink: 0;
}

/* ---- Como chamado ---- */
.avatar-como-chamado {
  width: 90%;
  max-width: 320px;
  height: auto;
  display: block;
  margin: 0 auto 10px;
}

.avatar-como-chamado-fallback {
  font-size: 1.15rem;
  font-weight: 900;
  color: #4a2a0a;
  margin: 0 0 10px;
  text-align: center;
}

/* ---- Campo nome ---- */
.campo-nome-wrap {
  position: relative;
  margin-bottom: 16px;
}

.campo-nome-wrap input {
  width: 100%;
  min-height: 54px;
  border-radius: 18px;
  border: 2px solid #d8b26b;
  background: #fff8ea;
  padding: 0 68px 0 18px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #5a3a17;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.campo-nome-wrap input:focus {
  border-color: #f0b331;
  box-shadow: 0 0 0 3px rgba(240, 179, 49, 0.2);
}

.campo-nome-wrap input::placeholder {
  color: #c4a06b;
  font-weight: 500;
}

.contador-nome {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #9b7a48;
  font-weight: 800;
  font-size: 0.82rem;
  pointer-events: none;
  user-select: none;
}

/* ---- Título grade ---- */
.avatar-titulo-grade {
  margin: 6px 0 12px;
  font-size: 0.95rem;
  font-weight: 900;
  color: #4a2a0a;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ---- Grade de avatares ---- */
.grade-avatares {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.avatar-item {
  position: relative;
  border: 2.5px solid #d8b26b;
  border-radius: 16px;
  background: #fffaf2;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.avatar-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 11px;
  display: block;
}

/* Placeholder quando imagem falha */
.avatar-sem-img img {
  visibility: hidden;
}

.avatar-sem-img::after {
  content: '👤';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  opacity: 0.35;
}

.avatar-item:active { transform: scale(0.91); }

.avatar-item.selecionado {
  border-color: #f0b331;
  box-shadow: 0 0 0 3px rgba(240, 179, 49, 0.35);
  background: #fff5dd;
}

.avatar-check {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f0b331;
  color: #553100;
  font-size: 0.6rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

/* ---- Botão Usar minha imagem ---- */
.btn-usar-imagem {
  width: 100%;
  min-height: 52px;
  margin: 0 0 14px;
  border: 2px dashed #c9923a;
  border-radius: 18px;
  background: rgba(255, 248, 234, 0.92);
  color: #5a3510;
  font-size: 1rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-usar-imagem:active {
  transform: scale(0.97);
}

.btn-usar-imagem .icone-camera {
  font-size: 1.35rem;
  line-height: 1;
}

.btn-usar-imagem.foto-selecionada {
  border-style: solid;
  border-color: #f0b331;
  background: #fff8ea;
  box-shadow: 0 0 0 3px rgba(240, 179, 49, 0.25);
}

.preview-foto-jogador {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #f0b331;
  flex-shrink: 0;
}

/* ---- Botão Começar ---- */
.btn-comecar-avatar {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s ease, filter 0.15s ease;
  width: 100%;
}

.btn-comecar-avatar img {
  width: auto;
  max-width: 240px;
  height: auto;
  display: block;
}

.btn-comecar-avatar:active:not(:disabled) {
  transform: scale(0.94);
  filter: brightness(0.88);
}

.btn-comecar-avatar:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-comecar-fallback {
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dourado-biblico), var(--dourado-claro));
  color: var(--marrom-escuro);
  font-size: 1.15rem;
  font-weight: 900;
  padding: 18px 56px;
  border-radius: 50px;
  box-shadow: 0 6px 20px rgba(246, 198, 91, 0.5);
  letter-spacing: 0.5px;
}

/* ---- Landscape: manter vertical, permitir scroll ---- */
@media (orientation: landscape) and (max-height: 520px) {
  .tela-identificacao {
    min-height: 100svh;
    overflow-y: auto;
  }

  .avatar-banner {
    margin-top: 70px;
    margin-bottom: 10px;
    max-width: 260px;
  }

  .avatar-card {
    padding: 14px 12px 18px;
  }

  .avatar-titulo-grade {
    margin: 4px 0 8px;
  }

  .grade-avatares {
    gap: 6px;
    margin-bottom: 14px;
  }
}
