:root {
  --bg-color: #f0f8ff;
  --text-color: #222;
  --primary-color: #3b4cca;
  --secondary-color: #ffde00;
  --border-color: #333;
  --font-retro: 'Press Start 2P', cursive;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-retro);
  background: #222;
  color: var(--text-color);
  image-rendering: pixelated;
}

header#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #f8f8f8;
  border-bottom: 4px solid var(--border-color);
  font-size: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

header .logo {
  color: var(--primary-color);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-image {
  width: 32px;
  height: 32px;
  image-rendering: auto;
  /* Use smooth rendering for the logo */
}

header .points span {
  margin-left: 12px;
  display: inline-block;
}

main#app {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-color);
  min-height: 100vh;
  padding: 20px;
  position: relative;
}

/* Layouts */

.center {
  text-align: center;
  margin-top: 40px;
}

h1,
h2 {
  text-transform: uppercase;
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 24px;
}

p {
  font-size: 12px;
  line-height: 1.8;
  margin-bottom: 16px;
}

.form {
  max-width: 600px;
  margin: 0 auto;
  background: #fff;
  padding: 24px;
  border: 4px solid var(--border-color);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2);
}

label {
  display: block;
  margin: 16px 0 8px;
  font-size: 10px;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border: 2px solid var(--border-color);
  font-family: var(--font-retro);
  font-size: 10px;
  background: #fafafa;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

button {
  padding: 12px 24px;
  margin-top: 16px;
  background: #fff;
  border: 2px solid var(--border-color);
  font-family: var(--font-retro);
  font-size: 10px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}

button:hover {
  background: var(--secondary-color);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.2);
}

button:active {
  transform: translate(0, 0);
  box-shadow: none;
}

/* Mapa */

.map-wrapper {
  position: relative;
  width: fit-content;
  margin: 20px auto;
  border: 4px solid var(--border-color);
  background: #000;
}

.map-grid {
  display: grid;
  /* Grid template columns set by JS */
  position: relative;
}

.tile {
  width: 32px;
  height: 32px;
  background-color: #8bc34a;
  /* Fallback grass */
  background-image: url('grass.png');
  background-size: cover;
  position: relative;
}

/* Tile Types */
.tile-decor {
  background-image: url('wall.png');
}

.tile-start {
  background-image: url('path.png');
}

.tile-mission {
  background-color: #ffe4a3;
  border: 2px dashed #f57f17;
  box-sizing: border-box;
}

.tile-tematica {
  background-image: url('library.png');
  background-size: cover;
  border: 2px solid #8d6e63;
}

/* Special Biomes - using colors + opacity or icons if available */
.tile-laje {
  background-color: #e1bee7;
}

.tile-feira {
  background-color: #ffccbc;
}

.tile-quadra {
  background-color: #c8e6c9;
}

.tile-igreja {
  background-color: #e8eaf6;
}

.tile-ponto {
  background-color: #fff9c4;
}

.tile-lit {
  background-color: #ffcdd2;
}

/* Player Sprite - Ensuring Visibility */
.player-sprite {
  position: absolute;
  width: 32px;
  height: 32px;
  background-image: url('player.png');
  background-size: cover;
  z-index: 20;
  /* High z-index to ensure visibility */
  transition: top 0.2s linear, left 0.2s linear;
  pointer-events: none;
}

/* NPC Avatars (Emojis) */
.npc-base {
  position: absolute;
  width: 32px;
  height: 32px;
  z-index: 15;
  font-size: 24px;
  text-align: center;
  line-height: 32px;
  transform: none;
  box-shadow: none;
  animation: bob 1s infinite alternate;
  cursor: pointer;
  /* Ensure no background color makes it look like a square */
  background: transparent;
}

/* Specific tweaks if needed, currently handled by Emojis in JS */
.npc-vivencia,
.npc-imaginacao,
.npc-territorio,
.npc-fugaz {
  box-shadow: none;
}

@keyframes bob {
  0% {
    margin-top: 0;
  }

  100% {
    margin-top: -2px;
  }
}

/* Legend */
.biome-legend {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.legend-tile {
  font-size: 8px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  background: #fff;
}

.legend-tile.laje {
  background: #f2d0ff;
}

.legend-tile.feira {
  background: #ffd1c1;
}

.legend-tile.quadra {
  background: #c9ffd1;
}

.legend-tile.igreja {
  background: #f0f0ff;
}

.legend-tile.ponto {
  background: #fff9c4;
}

.legend-tile.lit {
  background: #ffcdd2;
}

.legend-tile.tematica {
  background-color: #8d6e63;
  color: #fff;
}

/* Controls */
.controls {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.controls button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 16px;
}

.hint {
  text-align: center;
  font-size: 8px;
  color: #666;
  margin-top: 8px;
}

/* Dialog Box */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 40px;
  z-index: 999;
}

.dialog-box {
  background: #fff;
  width: 90%;
  max-width: 600px;
  border: 4px solid var(--border-color);
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 0 0 4px #fff inset;
  /* Double border effect */
}

.dialog-box::after {
  content: '▼';
  position: absolute;
  bottom: 8px;
  right: 16px;
  animation: blink 1s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* ========== TRANSITION SCENE ========== */

.transition-scene {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  animation: fadeIn 1s ease-in;
}

.player-transform {
  margin: 40px 0;
  text-align: center;
}

.player-small {
  font-size: 48px;
  transition: all 1s ease-in-out;
  display: inline-block;
}

.player-small.growing {
  font-size: 96px;
  transform: scale(1.5);
}

#transition-content {
  animation: slideIn 0.8s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.fade-out {
  animation: fadeOut 1s ease-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* ========== WORD CHALLENGE ========== */

.word-challenge {
  text-align: center;
}

.timer {
  background: #fff9c4;
  padding: 16px;
  margin: 20px 0;
  border: 2px solid var(--border-color);
  font-size: 14px;
  font-weight: bold;
}

.scrambled-word {
  font-size: 28px;
  letter-spacing: 8px;
  font-weight: bold;
  color: var(--primary-color);
  background: #e3f2fd;
  padding: 24px;
  margin: 20px 0;
  border: 3px solid var(--primary-color);
  border-radius: 8px;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

#word-feedback {
  margin-top: 16px;
  font-size: 14px;
  min-height: 30px;
}

/* ========== CITY MAZE ========== */

.city-maze {
  text-align: center;
  padding: 20px;
}

.maze-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px auto;
}

.maze-grid {
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.2);
  border: 4px solid var(--border-color);
  background: #000;
}
