* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1b1024;
  color: #fff;
  font-family: "Press Start 2P", monospace;
}

#juego {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* 1em = 8 píxeles lógicos del juego; main.js fija --escala. */
#marco {
  --escala: 1;
  position: relative;
  font-size: calc(8px * var(--escala));
}

#lienzo {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#capa {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.6;
  text-align: center;
}

h1, h2, p { margin: 0; font-size: 1em; font-weight: normal; }
h1, h2 { color: #ffd84d; text-shadow: .125em .125em 0 #1b1024; }

.icono { image-rendering: pixelated; vertical-align: middle; }

.fila {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5em;
}

button {
  font: inherit;
  color: #1b1024;
  background: #ffd84d;
  border: .125em solid #1b1024;
  box-shadow: 0 .25em 0 #b8860b;
  padding: .6em .8em;
  cursor: pointer;
}
button.chico { font-size: .75em; background: #fff; box-shadow: 0 .25em 0 #8d8d9c; }
button:focus-visible { outline: .125em solid #fff; outline-offset: .125em; }
button:disabled { background: #7d7d8c; color: #3c3c4a; box-shadow: none; cursor: default; }

/* Botones pequeños en la esquina inferior derecha (salir del mundo, sonido) */
button.esquina { position: absolute; right: .5em; bottom: .5em; padding: .4em .6em; opacity: .8; }

/* Mapa de mundos */
.mapa {
  width: 100%;
  padding: 1em .5em 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75em;
}
.total { text-shadow: .125em .125em 0 #1b1024; }
.total .icono { margin: 0 .125em; }
.mundos {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .4em;
}
.mundo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4em;
  padding: .5em .1em;
  min-height: 4.5em;
}
.mundo .nombre { font-size: .5625em; line-height: 1.4; }
.mundo.superado { background: #7be08a; box-shadow: 0 .25em 0 #2c7a43; }
.aviso { font-size: .75em; min-height: 1.6em; text-shadow: .125em .125em 0 #1b1024; }

/* Paneles de instrucciones y diálogos */
.panel {
  margin: auto;
  width: 29em;
  padding: 1em;
  display: flex;
  flex-direction: column;
  gap: .9em;
  background: #1b1024f2;
  border: .25em solid #fff;
}
.panel p { font-size: .75em; }
.grupo { display: flex; flex-direction: column; gap: .5em; padding: .5em; border: .125em dashed; }
.grupo { border-color: #6a5a8a; }
.grupo.bueno { border-color: #7be08a; }
.grupo.malo { border-color: #ff6b6b; }

.dialogo { display: flex; align-items: flex-end; gap: 1em; text-align: left; }
.dialogo .icono { flex: none; }
/* Dos íconos del mismo tamaño que se alternan (animación de dos cuadros) */
.alterna { position: relative; flex: none; line-height: 0; }
.alterna > :last-child { position: absolute; left: 0; top: 0; animation: alternar .7s step-end infinite; }
@keyframes alternar { 0% { opacity: 0; } 50% { opacity: 1; } }
.globo {
  flex: 1;
  min-height: 6em;
  padding: .75em;
  background: #fff;
  color: #1b1024;
  border: .125em solid #1b1024;
}
.globo strong { display: block; font-weight: normal; font-size: .75em; color: #2c7a43; margin-bottom: .5em; }
.panel .globo .frase { font-size: 1em; }

/* Barra de avance de la pantalla de carga */
.barra { height: 1.25em; padding: .125em; border: .125em solid #fff; }
.barra .relleno { width: 0; height: 100%; background: #ffd84d; }

/* Vitrina de premios */
.premios { display: grid; grid-template-columns: 1fr 1fr; gap: .4em; }
.premio {
  display: flex;
  align-items: center;
  gap: .5em;
  min-height: 3em;
  padding: .1em .4em;
  text-align: left;
  border: .125em solid #4a4266;
  color: #7d7d8c;
}
.premio.ganado { border-color: #ffd84d; color: #fff; }
.premio .dibujo { flex: none; width: 3em; text-align: center; line-height: 0; }
.premio:not(.ganado) .dibujo { line-height: 1; }
.panel .premio p { font-size: .5625em; line-height: 1.5; }

/* Controles táctiles */
#controles {
  display: none;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
}
#controles button {
  flex: 1;
  max-width: 96px;
  height: 72px;
  padding: 0;
  font-size: 28px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
@media (pointer: coarse) {
  #controles { display: flex; }
}
