:root {
  --creme: #FBF1D9;
  --creme2: #F6E3B0;
  --marrom: #2E2410;
  --verde: #3F5016;
  --oliva: #A2A12D;
  --amarelo: #FCB51A;
  --amarelo2: #FCCA58;
  --vermelho: #C8362B;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--verde);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Baloo 2", system-ui, sans-serif;
  color: var(--marrom);
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: relative;
  width: min(100vw, 480px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--creme);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#safe {
  position: absolute;
  visibility: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Botões de pausa e som (canto superior direito) */
#controles {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.icone {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid var(--marrom);
  background: rgba(255, 248, 230, 0.9);
  color: var(--marrom);
  font: 800 16px/1 system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

/* Telas sobrepostas */
.tela {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 18px) 20px calc(env(safe-area-inset-bottom) + 24px);
  overflow-y: auto;
  background: rgba(251, 241, 217, 0.88);
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}
.tela.ativa { display: flex; }

.logo { max-height: 24vh; max-height: 24dvh; width: auto; margin-top: 8px; }

h1, h2 { margin: 0; line-height: 1.1; color: var(--verde); }
h1 { font-size: 32px; }
h2 { font-size: 30px; margin-top: 24px; }

.sub { margin: 0; font-size: 17px; font-weight: 600; max-width: 320px; line-height: 1.3; }
.dica { margin: 0; font-size: 15px; font-weight: 600; color: var(--verde); }

.btn {
  font: inherit;
  font-weight: 800;
  font-size: 20px;
  line-height: 1.2;
  border: 3px solid var(--marrom);
  background: var(--amarelo);
  color: var(--marrom);
  border-radius: 16px;
  padding: 8px 22px;
  box-shadow: 0 4px 0 var(--marrom);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--marrom); }
.btn:disabled { opacity: 0.6; }
.btn.grande { font-size: 26px; padding: 10px 44px; }
.btn.sec { background: #FFF8E6; }

.link {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  background: none;
  border: 0;
  color: var(--verde);
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

/* Legenda dos objetos */
.legenda {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  width: 100%;
  max-width: 380px;
  text-align: left;
}
.legenda li { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 1.15; }
.legenda canvas { width: 40px; height: 40px; flex: none; }
.legenda strong { display: block; font-size: 14px; }

/* Fim de jogo */
.placar { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.placar span { font-size: 72px; font-weight: 800; color: var(--marrom); }
.placar small { font-size: 18px; font-weight: 600; }
.recorde { margin: 0; font-weight: 700; color: var(--verde); min-height: 1.2em; }

#form-nome { width: 100%; max-width: 360px; }
#form-nome label { display: block; font-weight: 700; margin-bottom: 6px; }
.linha { display: flex; gap: 8px; }
#nome {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  padding: 6px 12px;
  border: 3px solid var(--marrom);
  border-radius: 14px;
  background: #fff;
  color: var(--marrom);
  -webkit-user-select: text;
  user-select: text;
}
.msg { margin: 6px 0 0; min-height: 1.2em; font-weight: 700; color: var(--vermelho); }
.salvo { margin: 0; font-weight: 800; color: var(--verde); font-size: 18px; }

/* Ranking */
.ranking { width: 100%; max-width: 360px; }
.abas { display: flex; gap: 6px; margin-bottom: 6px; }
.abas button {
  flex: 1;
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  padding: 6px;
  border: 2px solid var(--marrom);
  border-radius: 12px;
  background: #FFF8E6;
  color: var(--marrom);
  cursor: pointer;
}
.abas button.ativa { background: var(--verde); color: var(--creme); }

.lista {
  list-style: none;
  margin: 0;
  padding: 4px;
  border: 2px solid var(--marrom);
  border-radius: 14px;
  background: #FFFBF0;
}
.lista li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
}
.lista li + li { border-top: 1px dashed rgba(46, 36, 16, 0.2); }
.lista .pos { width: 30px; text-align: center; font-weight: 800; }
.lista .nome { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .pts { font-weight: 800; }
.lista li.eu { background: var(--amarelo2); }
.lista li.vazio { justify-content: center; color: var(--verde); }

.acoes { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 6px; }

/* Celular deitado */
#girar {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--verde);
  color: var(--creme);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}
@media (orientation: landscape) and (max-height: 500px) {
  #girar { display: flex; }
}
