* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  overflow: hidden;
  background: #000;
  font-family: Georgia, "Times New Roman", serif;
  color: #f0e6d2;
  width: 100%;
  height: 100%;
}

canvas#canvas-jogo {
  display: block;
  width: 100%;
  height: 100%;
}

#tela-inicial {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #1a0e06 0%, #2d1a0c 50%, #3d2515 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 1.5s ease-out;
}

#tela-inicial h1 {
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 400;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 30px rgba(255, 200, 100, 0.4);
  color: #f6dca5;
}

#tela-inicial .subtitulo {
  font-size: clamp(0.9rem, 1.5vw, 1.2rem);
  font-style: italic;
  opacity: 0.7;
  margin-bottom: 3rem;
  text-align: center;
  padding: 0 1rem;
}

#btn-comecar {
  padding: 1rem 3.5rem;
  font-size: 1.3rem;
  font-family: inherit;
  background: transparent;
  color: #f6dca5;
  border: 2px solid #f6dca5;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
}

#btn-comecar:hover {
  background: #f6dca5;
  color: #1a0e06;
  box-shadow: 0 0 30px rgba(246, 220, 165, 0.4);
}

#tela-inicial .dicas {
  position: absolute;
  bottom: 2rem;
  font-size: 0.85rem;
  opacity: 0.5;
  text-align: center;
  padding: 0 1rem;
}

#tela-inicial.oculto {
  opacity: 0;
  pointer-events: none;
}

#mensagem {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.2rem, 2.5vw, 2rem);
  font-style: italic;
  text-shadow: 0 0 12px #000, 0 2px 4px #000, 0 0 30px rgba(0,0,0,0.8);
  text-align: center;
  z-index: 50;
  opacity: 1;
  transition: opacity 2.5s ease-in-out;
  pointer-events: none;
  max-width: 80vw;
}

#mensagem.oculto {
  opacity: 0;
}

#hud-inventario {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: rgba(20, 12, 6, 0.72);
  color: #f6dca5;
  padding: 0.7rem 1.2rem;
  border: 1px solid rgba(246, 220, 165, 0.25);
  border-radius: 4px;
  font-family: Georgia, serif;
  z-index: 40;
  min-width: 140px;
  pointer-events: none;
}

#hud-inventario .hud-titulo {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  opacity: 0.6;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid rgba(246, 220, 165, 0.15);
  padding-bottom: 0.25rem;
}

#hud-inventario .hud-item {
  font-size: 1rem;
  padding: 0.15rem 0;
}

#hud-inventario .hud-item span {
  color: #fff;
  font-weight: bold;
  margin-left: 0.3rem;
}

#hud-dica {
  position: fixed;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  color: #f6dca5;
  padding: 0.6rem 1.6rem;
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 1.15rem;
  font-style: italic;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

#hud-dica.visivel {
  opacity: 1;
}

/* ========== CONTROLES TOUCH (MOBILE) ========== */
/* Por padrão escondidos. body.mobile mostra. */
#joy-base, #botoes-touch { display: none; }

body.mobile #joy-base {
  display: block;
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(20, 12, 6, 0.4);
  border: 2px solid rgba(246, 220, 165, 0.35);
  z-index: 50;
  touch-action: none;
}

body.mobile #joy-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin-top: -30px;
  margin-left: -30px;
  border-radius: 50%;
  background: rgba(246, 220, 165, 0.7);
  border: 2px solid rgba(246, 220, 165, 0.9);
  pointer-events: none;
  transition: transform 0.05s linear;
}

body.mobile #botoes-touch {
  display: grid;
  grid-template-columns: 70px 70px;
  grid-template-rows: 70px 70px;
  gap: 0.6rem;
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 50;
  touch-action: none;
}

body.mobile .btn-touch {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: rgba(20, 12, 6, 0.7);
  color: #f6dca5;
  border: 2px solid rgba(246, 220, 165, 0.4);
  font-family: Georgia, serif;
  font-size: 0.65rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

body.mobile .btn-touch:active,
body.mobile .btn-touch.ativo {
  background: rgba(246, 220, 165, 0.4);
  color: #1a0e06;
  transform: scale(0.92);
}

/* Botao de camera no canto superior esquerdo (separado dos botoes de acao) */
body.mobile #btn-camera.btn-camera {
  position: fixed;
  top: 0.8rem;
  left: 0.8rem;
  width: 64px;
  height: 64px;
  font-size: 0.6rem;
  z-index: 50;
  touch-action: none;
}

/* HUD inventario menor em mobile */
body.mobile #hud-inventario {
  top: 0.8rem;
  bottom: auto;
  right: 0.8rem;
  padding: 0.5rem 0.8rem;
  min-width: 110px;
  font-size: 0.85rem;
}

body.mobile #hud-inventario .hud-titulo {
  font-size: 0.65rem;
}

body.mobile #hud-inventario .hud-item {
  font-size: 0.85rem;
}

/* Dica nao colide com botoes touch */
body.mobile #hud-dica {
  bottom: auto;
  top: 18%;
  font-size: 1rem;
  padding: 0.5rem 1.2rem;
}

/* Mensagem central tambem ajustada */
body.mobile #mensagem {
  font-size: clamp(0.95rem, 3vw, 1.4rem);
  top: 18%;
  padding: 0 1rem;
}

/* Dicas da tela inicial em mobile (mais compactas) */
body.mobile #tela-inicial .dicas {
  font-size: 0.7rem;
}

/* ========== PAINEL DE CONSTRUÇÃO ========== */
#painel-construcao {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 3, 0.85);
  z-index: 80;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  font-family: Georgia, serif;
}

#painel-construcao.oculto {
  display: none;
}

#painel-construcao h2 {
  color: #f6dca5;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
  font-weight: 400;
}

.x-fechar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  color: #f6dca5;
  border: 2px solid rgba(246, 220, 165, 0.4);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  cursor: pointer;
  font-family: Georgia, serif;
  line-height: 1;
}
.x-fechar:hover {
  background: rgba(246, 220, 165, 0.15);
}

.cards-construcao {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.card-cabana {
  background: rgba(40, 25, 15, 0.85);
  border: 2px solid rgba(246, 220, 165, 0.3);
  border-radius: 6px;
  padding: 1.5rem;
  min-width: 200px;
  text-align: center;
  color: #f6dca5;
  transition: all 0.2s ease;
}

.card-cabana:hover {
  border-color: rgba(246, 220, 165, 0.7);
  transform: translateY(-3px);
}

.card-cabana.indisponivel {
  opacity: 0.4;
  filter: grayscale(0.8);
}

.card-cabana.indisponivel .btn-card {
  cursor: not-allowed;
  opacity: 0.5;
}

.card-cabana h3 {
  font-size: 1.2rem;
  margin-bottom: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.card-cabana .custo {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-style: italic;
  opacity: 0.85;
}

.card-cabana .btn-card {
  background: transparent;
  color: #f6dca5;
  border: 1px solid #f6dca5;
  padding: 0.5rem 1.5rem;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.card-cabana .btn-card:hover {
  background: #f6dca5;
  color: #1a0e06;
}

/* Barra de acoes do posicionamento */
#barra-construcao {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.7rem;
  z-index: 70;
  background: rgba(20, 12, 6, 0.85);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  border: 1px solid rgba(246, 220, 165, 0.3);
}

#barra-construcao.oculto {
  display: none;
}

.btn-construcao {
  background: transparent;
  color: #f6dca5;
  border: 1px solid rgba(246, 220, 165, 0.5);
  padding: 0.5rem 1rem;
  font-family: Georgia, serif;
  font-size: 0.85rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-construcao:hover,
.btn-construcao:active {
  background: rgba(246, 220, 165, 0.2);
}

.btn-construcao.btn-primary {
  background: rgba(120, 180, 90, 0.4);
  border-color: rgba(160, 220, 120, 0.7);
  color: #fff;
}

.btn-construcao.btn-primary:hover,
.btn-construcao.btn-primary:active {
  background: rgba(120, 180, 90, 0.7);
}

/* Mobile — barra mais compacta + cards em coluna */
body.mobile .cards-construcao {
  gap: 0.7rem;
}

body.mobile .card-cabana {
  min-width: 160px;
  padding: 0.9rem;
}

body.mobile .card-cabana h3 {
  font-size: 1rem;
}

body.mobile .card-cabana .custo {
  font-size: 0.75rem;
  margin-bottom: 0.6rem;
}

body.mobile #barra-construcao {
  bottom: 0.6rem;
  padding: 0.4rem 0.7rem;
  gap: 0.4rem;
}

body.mobile .btn-construcao {
  font-size: 0.7rem;
  padding: 0.4rem 0.8rem;
}

@media screen and (orientation: landscape) and (max-height: 500px) {
  body.mobile #painel-construcao h2 {
    font-size: 1.2rem;
    margin-bottom: 0.7rem;
  }
  body.mobile .card-cabana {
    padding: 0.6rem 0.8rem;
    min-width: 130px;
  }
  body.mobile .card-cabana h3 {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
  }
}

/* ========== AVISO DE ROTACIONAR (mobile portrait) ========== */
#aviso-rotate {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #1a0e06 0%, #2d1a0c 100%);
  color: #f6dca5;
  z-index: 200;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  font-family: Georgia, serif;
}

#aviso-rotate .rotate-icone {
  font-size: 5rem;
  margin-bottom: 1rem;
  animation: girar-icone 2s ease-in-out infinite;
  display: inline-block;
}

#aviso-rotate h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

#aviso-rotate p {
  font-size: 1rem;
  font-style: italic;
  opacity: 0.7;
}

@keyframes girar-icone {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

/* So mostra o aviso em mobile + portrait */
@media screen and (orientation: portrait) and (max-width: 900px) {
  body.mobile #aviso-rotate {
    display: flex;
  }
  body.mobile #joy-base,
  body.mobile #botoes-touch,
  body.mobile #btn-camera,
  body.mobile #hud-inventario,
  body.mobile #hud-dica,
  body.mobile #mensagem,
  body.mobile #tela-inicial,
  body.mobile #canvas-jogo,
  body.mobile #painel-construcao,
  body.mobile #barra-construcao {
    visibility: hidden;
  }
}

/* iPhones / Androids em landscape com pouca altura — ajustes finos */
@media screen and (orientation: landscape) and (max-height: 500px) {
  body.mobile #botoes-touch {
    bottom: 0.6rem;
    right: 0.6rem;
    grid-template-columns: 60px 60px;
    grid-template-rows: 60px 60px;
    gap: 0.4rem;
  }
  body.mobile .btn-touch {
    width: 60px;
    height: 60px;
    font-size: 0.55rem;
  }
  body.mobile #joy-base {
    width: 110px;
    height: 110px;
    bottom: 0.8rem;
    left: 0.8rem;
  }
  body.mobile #joy-thumb {
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
  }
  body.mobile #hud-inventario {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.4rem 0.7rem;
  }
  body.mobile #btn-camera.btn-camera {
    top: 0.5rem;
    left: 0.5rem;
    width: 56px;
    height: 56px;
    font-size: 0.55rem;
  }
}
