/* Tela inicial: fundo do campo à noite, título, tabuleiro de exemplo, vagalumes voando e botão Jogar */

.title-screen[hidden] { display: none; }
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 60; /* acima do botão de tema */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(28px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  background: #2b1a20 url("../img/fundo.webp") center bottom / cover no-repeat;
  color: #fff4e6;
  text-align: center;
}

/* ---------- Título ---------- */
.title-logo {
  position: relative;
  margin: 4vh 0 0;
  font-family: var(--font-title);
  font-size: clamp(2.8rem, 14vw, 4.9rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  animation: title-in 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
/* Logo desenhado pelo dono (img/logo.webp, recortado do Gemini): o abdômen do vagalume pousado no "l" brilha por cima */
.logo-img { display: block; width: min(90vw, 460px); height: auto; filter: drop-shadow(0 4px 0 rgba(60, 20, 32, 0.55)) drop-shadow(0 0 14px rgba(255, 196, 120, 0.35)); }
.title-logo, .loading-logo { position: relative; }
.logo-glow {
  position: absolute;
  left: 60.6%;
  top: 31.4%;
  width: 20%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 140, 0.75) 0%, rgba(255, 220, 100, 0.3) 35%, rgba(255, 210, 90, 0) 70%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: logo-glow 2.2s ease-in-out infinite alternate;
}
@keyframes logo-glow { from { opacity: 0.35; transform: translate(-50%, -50%) scale(0.8); } to { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } }
.title-spark {
  position: absolute;
  color: #ffe28a;
  font-size: 0.32em;
  -webkit-text-stroke: 0;
  text-shadow: 0 0 8px rgba(255, 220, 110, 0.9);
  animation: twinkle 1.8s ease-in-out infinite alternate;
}
.title-spark.s1 { left: -0.62em; top: -0.35em; }
.title-spark.s2 { right: -1.25em; top: -0.7em; font-size: 0.42em; animation-delay: 0.6s; }
.title-spark.s3 { right: -3em; bottom: 0.5em; font-size: 0.24em; animation-delay: 1.1s; }

/* ---------- Tabuleiro de exemplo ---------- */
.title-board {
  --size: min(76vw, 340px, 40vh);
  --tile: calc(var(--size) / var(--n));
  width: var(--size);
  height: var(--size);
  box-sizing: content-box;
  padding: calc(var(--tile) * 0.12);
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: calc(var(--tile) * 0.09);
  border-radius: calc(var(--tile) * 0.28);
  background: rgba(28, 16, 20, 0.82);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: rotate(-3deg);
  animation: board-in 0.8s 0.15s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.title-board .tcell {
  display: grid;
  place-items: center;
  border-radius: calc(var(--tile) * 0.16);
  box-shadow: inset 0 calc(var(--tile) * -0.07) 0 rgba(0, 0, 0, 0.18);
}
/* Casa com vagalume fica escura para o brilho aparecer, como na arte */
.title-board .tcell.lit {
  background: #5a3a44 !important;
  box-shadow: inset 0 0 calc(var(--tile) * 0.35) rgba(255, 210, 100, 0.35);
}

/* ---------- Vagalumes voando ao fundo (também no mapa) ---------- */
.title-sky { position: absolute; inset: 0; pointer-events: none; }
/* O laço de cada um é animado pelo renderDrifters (fireflies.js) */
.drifter {
  position: absolute;
  left: 0;
  top: 0;
  filter: drop-shadow(0 0 6px rgba(255, 210, 90, 0.9));
}
.drifter .mark-cat { width: 100%; height: 100%; animation: none; }

/* ---------- Botão e progresso ---------- */
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.btn-play {
  min-width: min(64vw, 260px);
  padding: 16px 40px;
  border: 0;
  border-radius: 999px;
  background: #e0707f;
  color: #fff;
  font: inherit;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 0 #a94a5a, 0 10px 24px rgba(0, 0, 0, 0.4);
  animation: title-in 0.7s 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) both, breathe 2.4s 1.2s ease-in-out infinite;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-play:hover { filter: brightness(1.06); }
.btn-play:active { transform: translateY(4px); box-shadow: 0 2px 0 #a94a5a, 0 6px 16px rgba(0, 0, 0, 0.4); }
.btn-play:focus-visible { outline: 3px solid #ffe28a; outline-offset: 4px; }
.title-progress {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: rgba(255, 244, 230, 0.8);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

@keyframes title-in { from { opacity: 0; transform: translateY(-14px) scale(0.9); } }
@keyframes board-in { from { opacity: 0; transform: rotate(-3deg) translateY(24px) scale(0.92); } }
@keyframes twinkle { from { opacity: 0.35; transform: scale(0.8); } to { opacity: 1; transform: scale(1.1); } }
@keyframes breathe { 50% { transform: scale(1.04); } }

/* Tela deitada: a arte é vertical, então sobe o enquadramento para mostrar o céu e as árvores */
@media (orientation: landscape) {
  .title-screen { background-position: center 22%; }
}

@media (prefers-reduced-motion: reduce) {
  .title-screen *, .title-screen *::before, .title-screen *::after,
  .map-sky * { animation: none !important; }
}

/* ---------- Engrenagem das configurações e atalho para recuperar o progresso ---------- */
.title-gear {
  position: absolute;
  left: 14px;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(28, 16, 20, 0.62);
  color: #fff4e6;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.title-gear:active { transform: scale(0.92) rotate(40deg); }
.title-link {
  margin: 4px 0 0;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: rgba(255, 244, 230, 0.85);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: underline;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}
