Paso 1 de 5
Tres pantallas en HTML
El juego tiene tres pantallas (inicio, partida y resultado), cada una en una <section>. Las que no se ven llevan el atributo hidden; JavaScript lo quitará o lo pondrá para pasar de una a otra.
Los estilos ya incluyen los colores de las respuestas acertadas y falladas que usarás más adelante.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>¿Cuánto sabes de informática?</title>
<link rel="stylesheet" href="estilos.css">
</head>
<body>
<main class="juego">
<section id="inicio">
<h1>¿Cuánto sabes de informática?</h1>
<p>Seis preguntas. Elige la respuesta correcta antes de que se acabe el tiempo.</p>
<button type="button" id="empezar">Empezar</button>
</section>
<section id="partida" hidden>
<div class="cabecera">
<span id="numero">Pregunta 1 de 6</span>
<span id="reloj" class="reloj"></span>
</div>
<div class="progreso"><span id="progreso"></span></div>
<h2 id="pregunta"></h2>
<div id="opciones" class="opciones"></div>
<p id="aviso" class="aviso" aria-live="polite"></p>
<button type="button" id="siguiente" hidden>Siguiente</button>
</section>
<section id="final" hidden>
<h2>Resultado</h2>
<p id="puntuacion" class="puntuacion"></p>
<button type="button" id="otra">Jugar otra vez</button>
</section>
</main>
<script src="app.js"></script>
</body>
</html>
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
padding: 16px;
background: #faf5ff;
color: #3b0764;
font-family: system-ui, sans-serif;
}
.juego {
width: min(100%, 520px);
padding: 28px;
border-radius: 20px;
background: #ffffff;
box-shadow: 0 12px 32px rgb(59 7 100 / 0.12);
}
h1, h2 { margin-top: 0; }
button {
padding: 12px 18px;
border: 0;
border-radius: 12px;
background: #7e22ce;
color: #ffffff;
font: inherit;
font-weight: 700;
cursor: pointer;
}
button:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
.cabecera { display: flex; justify-content: space-between; font-weight: 600; }
.reloj { font-variant-numeric: tabular-nums; }
.progreso { height: 6px; margin: 10px 0 20px; border-radius: 999px; background: #f3e8ff; overflow: hidden; }
.progreso span { display: block; height: 100%; width: 0; background: #a855f7; transition: width 300ms ease; }
.opciones { display: grid; gap: 10px; }
.opciones button {
padding: 14px;
border: 2px solid #e9d5ff;
background: #ffffff;
color: inherit;
text-align: left;
font-weight: 500;
}
.opciones button:hover:not(:disabled) { border-color: #a855f7; }
.opciones button.correcta { border-color: #16a34a; background: #dcfce7; }
.opciones button.incorrecta { border-color: #dc2626; background: #fee2e2; }
.aviso { min-height: 1.5em; font-weight: 600; }
.puntuacion { font-size: 1.4rem; }
// El JavaScript llega en el paso 2