/* ============================================================
   FANTASMA NA TORRE - Folha de estilos
   Cores de aventura, mistério e fantasia (roxos, dourados, azuis)
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
}

body {
  /* Fundo escuro com leve degradê roxo para dar clima de mistério */
  background: radial-gradient(circle at 50% 0%, #2a1a4a 0%, #140d29 60%, #0a0617 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: #f3e9ff;
}

/* Contêiner que limita o tamanho do jogo */
#game-container {
  width: 100%;
  max-width: 680px;
  position: relative;
}

/* ---------- Sistema de telas ---------- */
.screen {
  display: none;
  animation: fadeIn 0.4s ease;
}
.screen.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Painéis (telas de menu/vitória/derrota) ---------- */
.panel {
  background: linear-gradient(160deg, #3a2566 0%, #241646 100%);
  border: 3px solid #ffce54;
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 0 30px rgba(255, 206, 84, 0.25), inset 0 0 20px rgba(0,0,0,0.4);
  text-align: center;
}

.title {
  font-size: 2.2rem;
  color: #ffce54;
  text-shadow: 0 0 12px rgba(255, 206, 84, 0.6);
  margin-bottom: 6px;
}
.title.win  { color: #7ee787; text-shadow: 0 0 14px rgba(126,231,135,0.6); }
.title.lose { color: #ff6b6b; text-shadow: 0 0 14px rgba(255,107,107,0.6); }

.subtitle {
  font-size: 1.1rem;
  color: #c8b6ff;
  margin-bottom: 18px;
}

.lore {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: left;
  margin-bottom: 18px;
}
.lore p { margin-bottom: 8px; }
.lore strong { color: #ffce54; }

.instructions {
  text-align: left;
  margin-bottom: 22px;
}
.instructions h2 {
  color: #ffce54;
  font-size: 1.3rem;
  margin-bottom: 10px;
  text-align: center;
}
.instructions ul {
  list-style: none;
}
.instructions li {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 7px;
  font-size: 0.95rem;
}
.instructions strong { color: #ffe08a; }

.final-score {
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: #ffe08a;
}

/* ---------- Botões ---------- */
.btn {
  background: linear-gradient(145deg, #ffce54, #f6a623);
  color: #2a1a4a;
  font-size: 1.2rem;
  font-weight: bold;
  border: none;
  border-radius: 50px;
  padding: 14px 36px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b9750f, 0 6px 14px rgba(0,0,0,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b9750f;
}

/* ---------- HUD (barra superior do jogo) ---------- */
#hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 6px;
  background: linear-gradient(160deg, #3a2566, #241646);
  border: 2px solid #ffce54;
  border-radius: 12px;
  padding: 10px 8px;
  margin-bottom: 10px;
}
.hud-item {
  font-size: 1.05rem;
  font-weight: bold;
  background: rgba(0,0,0,0.25);
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

/* ---------- Canvas do jogo ---------- */
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  background: #0a0617;
  border: 3px solid #6b4fa3;
  border-radius: 12px;
  box-shadow: 0 0 24px rgba(107, 79, 163, 0.5);
  /* Mantém os pixels nítidos (estilo retrô 2D) */
  image-rendering: pixelated;
}

/* ---------- Controles de toque (mobile) ---------- */
#touch-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
}
.touch-row {
  display: flex;
  gap: 8px;
}
.touch-btn {
  width: 64px;
  height: 64px;
  font-size: 1.6rem;
  background: linear-gradient(145deg, #6b4fa3, #4a3577);
  color: #fff;
  border: 2px solid #ffce54;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.touch-btn:active {
  background: #ffce54;
  color: #2a1a4a;
}

/* Mostra os controles de toque em telas pequenas / com toque */
@media (max-width: 700px), (pointer: coarse) {
  #touch-controls { display: flex; }
}

/* Ajustes para telas bem pequenas */
@media (max-width: 480px) {
  .title { font-size: 1.6rem; }
  .hud-item { font-size: 0.85rem; padding: 4px 7px; }
  .panel { padding: 20px 16px; }
}
