@font-face {
  font-family: 'VT323';
  src: url('assets/vt323.ttf') format('truetype');
  font-display: swap;
}

:root {
  --tinta: #1b1a2e;
  --noche: #26213f;
  --violeta: #3d2c5c;
  --crema: #f1e4c8;
  --rojo: #d12c24;
  --coral: #f27a62;
  --oro: #ffe690;
  --gris: #a9a4c4;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--tinta);
  color: var(--crema);
  font: 20px/1.3 'VT323', monospace;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

main { flex: 1; display: flex; flex-direction: column; }

/* Cabecera común (como Batalla de Socas) */
.cabecera {
  width: min(100%, 680px); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 8px; border-bottom: 2px solid var(--rojo);
}
.marca { display: flex; flex-direction: column; min-height: 44px; justify-content: center; min-width: 0; color: var(--oro); text-decoration: none; }
.marca-nombre { font-size: 24px; line-height: 1; }
.marca-firma { font: 11px/1.3 system-ui, sans-serif; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marca:hover .marca-nombre { text-decoration: underline; text-underline-offset: 3px; }
.cabecera-acciones { display: flex; gap: 4px; flex-shrink: 0; }
@media (max-width: 420px) { .marca-pre { display: none; } .marca-nombre { font-size: 22px; } }
.icono {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 2px solid var(--tinta); border-radius: 4px; background: rgb(61 44 92 / 0.55); color: var(--oro); cursor: pointer;
}
.icono svg { width: 22px; height: 22px; fill: currentColor; shape-rendering: crispEdges; }
.icono[aria-pressed="false"] { color: var(--gris); }
.icono .tachado { display: none; }
.icono[aria-pressed="false"] .ondas { display: none; }
.icono[aria-pressed="false"] .tachado { display: inline; }

/* Diálogos */
dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; background: var(--noche); color: var(--crema); border: 3px solid var(--oro); border-radius: 12px; padding: 16px 18px; font: 18px/1.35 'VT323', monospace; }
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
dialog h2 { font-size: 30px; margin: 0 30px 8px 0; color: var(--oro); font-weight: normal; }
dialog h3 { font-size: 22px; margin: 14px 0 4px; color: var(--oro); font-weight: normal; }
dialog p { margin: 6px 0; }
.dialogo-cerrar { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; background: none; border: 0; color: var(--crema); font-size: 22px; cursor: pointer; }
.dialogo-pie { margin-top: 14px; text-align: center; }
.hall-lista { padding-left: 1.6em; font-size: 22px; }
.hall-lista li { margin: 4px 0; }
.hall-lista .fecha { color: var(--gris); font-size: 16px; }
.hall-mios { list-style: none; padding: 0; }
.hall-mios li { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin: 4px 0; }
.boton-texto { background: none; border: 0; color: var(--oro); font: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.publicar { max-width: 340px; margin: 10px auto; padding: 10px 12px; border: 2px solid var(--oro); border-radius: 10px; text-align: left; }
.publicar label { display: block; margin: 6px 0 2px; }
.publicar input[type="text"], .publicar input:not([type]) { box-sizing: border-box; width: 100%; min-height: 44px; font: 20px 'VT323', monospace; padding: 4px 8px; }
.publicar .casilla { display: flex; gap: 8px; align-items: flex-start; font-size: 17px; }
.publicar .casilla input { width: 22px; height: 22px; margin-top: 2px; }
.publicar .boton { width: 100%; margin-top: 8px; }
.aviso { color: var(--gris); font-size: 16px; }
#btn-estadisticas[aria-pressed="true"] { background: var(--violeta); border-color: var(--oro); }

/* Portada */
.portada, .final {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  text-align: center;
}
.portada-arte { position: relative; height: 190px; margin: 0 auto; width: 260px; }
.portada-arte img { height: 180px; width: auto; image-rendering: pixelated; position: relative; z-index: 1; }
.pompa {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff 0 12%, var(--coral) 13% 45%, var(--rojo) 46% 78%, #4a1116 79%);
  animation: bote 1.6s ease-in infinite alternate;
}
.p1 { width: 56px; height: 56px; left: 0; top: 20px; }
.p2 { width: 34px; height: 34px; right: 10px; top: 0; animation-duration: 1.2s; background: radial-gradient(circle at 32% 30%, #fff 0 12%, #9acdf5 13% 45%, #3b82d6 46% 78%, #141f45 79%); }
.p3 { width: 22px; height: 22px; right: 30px; top: 110px; animation-duration: 0.9s; background: radial-gradient(circle at 32% 30%, #fff 0 12%, #ffe690 13% 45%, #f0b429 46% 78%, #4d300a 79%); }
@keyframes bote { from { transform: translateY(0); } to { transform: translateY(40px); } }
@media (prefers-reduced-motion: reduce) { .pompa { animation: none; } }

h1 { font-size: 44px; line-height: 1; margin: 8px 0; color: var(--oro); text-shadow: 3px 3px 0 var(--rojo); font-weight: normal; }
h2 { font-size: 38px; line-height: 1; margin: 8px 0; color: var(--oro); font-weight: normal; }
.entradilla { margin: 8px auto 16px; max-width: 30em; }

.boton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 6px 20px;
  font: inherit; font-size: 22px; color: var(--crema); text-decoration: none;
  background: var(--violeta); border: 2px solid var(--crema); border-radius: 10px;
  box-shadow: 0 4px 0 #000; cursor: pointer;
}
.boton:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.boton.principal { background: var(--rojo); font-size: 30px; min-width: 220px; min-height: 60px; }
.boton:focus-visible, .icono:focus-visible, a:focus-visible, .personaje:focus-visible { outline: 3px solid var(--oro); outline-offset: 3px; }

.pasos { text-align: left; max-width: 26em; margin: 20px auto; padding-left: 1.4em; }
.pasos li { margin: 6px 0; }
.pasos b { color: var(--oro); font-weight: normal; }

.personajes { display: flex; justify-content: center; gap: 10px; margin: 12px 0; }
.personaje {
  width: 86px; min-height: 96px; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
  font: inherit; font-size: 17px; color: var(--crema);
  background: var(--noche); border: 2px solid var(--violeta); border-radius: 10px;
}
.personaje img { height: 60px; width: auto; image-rendering: pixelated; }
.personaje.elegido { border-color: var(--oro); background: var(--violeta); }
.personaje.bloqueado { opacity: 0.5; }
.silueta { font-size: 40px; line-height: 60px; color: var(--gris); }
.record { color: var(--oro); }

.control { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.opcion {
  min-height: 44px; padding: 4px 12px; font: inherit; font-size: 18px; color: var(--crema);
  background: var(--noche); border: 2px solid var(--violeta); border-radius: 8px; cursor: pointer;
}
.opcion[aria-pressed='true'] { border-color: var(--oro); background: var(--violeta); }
.creditos { font: 12px/1.3 system-ui, sans-serif; color: var(--gris); margin-top: 16px; }
.creditos .boton-texto { font-size: 12px; }
.creditos-lista p { font: 13px/1.4 system-ui, sans-serif; margin: 0 0 8px; }
#btn-continuar { background: var(--violeta); font-size: 24px; margin-bottom: 10px; }

/* Selector de fases para revisar (regla común: ?revision) */
.revision { margin: 20px auto 0; padding: 12px; border: 2px dashed var(--oro); border-radius: 10px; max-width: 520px; }
.revision h2 { font-size: 26px; margin: 0 0 4px; }
.revision p { font: 13px/1.3 system-ui, sans-serif; color: var(--gris); margin: 0 0 10px; }
.fases { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.fases .boton { font-size: 18px; min-height: 44px; padding: 4px 8px; }

/* Partida: el lienzo ocupa todo el alto disponible */

.partida { flex: 1; display: flex; position: relative; }
.lienzo { flex: 1; width: 100%; height: calc(100dvh - 56px); touch-action: none; user-select: none; -webkit-user-select: none; }
.lienzo canvas { image-rendering: pixelated; }

/* Final */
.final img { height: 170px; width: auto; image-rendering: pixelated; }
.final-puntos { font-size: 34px; margin: 4px 0; }
.final-puntos span { color: var(--oro); }
.reto { margin: 20px 0 8px; }
.compartir { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.aviso { min-height: 1.3em; color: var(--oro); }

/* Pie común (contrato de la base común, 16/09/2026) */
footer { width: min(100%, 680px); margin: 0 auto; color: var(--gris); }
body[data-pantalla='partida'] footer { display: none; }
.pm-network-links{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:4px 16px;font:400 13px/1.4 system-ui,-apple-system,sans-serif;letter-spacing:normal;text-transform:none;width:100%;margin:8px auto 0}
.pm-network-links a{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:6px 4px;color:inherit;text-decoration:underline;text-underline-offset:3px;touch-action:manipulation}
.pm-network-links a:hover{text-decoration-thickness:2px}
.pm-network-links a:focus-visible{outline:2px solid currentColor;outline-offset:3px;border-radius:3px}

/* Ordenador frente a móvil (mismo criterio que Trompi Not Dead). */
.solo-ordenador { display: none; }
@media (hover: hover) and (pointer: fine) {
  .solo-ordenador { display: inline; }
  .solo-movil { display: none !important; }
}

/* Recreativa en pantallas anchas de ordenador: laterales decorativos alrededor
   del lienzo, sin cambiar su tamaño ni su proporción. */
.ala { display: none; }
@media (min-width: 1000px) and (hover: hover) and (pointer: fine) {
  .partida { justify-content: center; align-items: stretch; gap: 14px; padding: 12px 0; }
  .lienzo { flex: 0 0 auto; width: min(calc((100dvh - 80px) * 320 / 540), 60vw); height: calc(100dvh - 80px);
    box-shadow: 0 0 0 8px #08070a, 0 0 0 12px var(--violeta), 0 0 60px #d12c2433; }
  .ala {
    display: flex; flex-direction: column; gap: 14px; width: clamp(170px, 17vw, 240px); padding: 16px;
    background: linear-gradient(110deg, #382443, #17101e 45%, #291a32);
    border: 5px solid var(--violeta); border-top-color: var(--coral); border-radius: 28px 6px 6px 14px;
    box-shadow: inset 0 0 0 3px #130d1a, inset 0 0 35px #0009, 0 18px 40px #000;
    pointer-events: none; user-select: none;
  }
  .ala-izq { transform: perspective(1300px) rotateY(-7deg); transform-origin: right; border-left: 9px solid var(--rojo); }
  .ala-der { transform: perspective(1300px) rotateY(7deg); transform-origin: left; border-right: 9px solid var(--oro); border-radius: 6px 28px 14px 6px; }
  .rotulo { padding: 12px 4px; text-align: center; background: #100b17; border: 2px solid var(--oro); }
  .rotulo small { font-size: 14px; color: var(--gris); }
  .rotulo b { display: block; margin-top: 6px; font-size: clamp(30px, 3vw, 44px); line-height: .95; color: var(--oro); text-shadow: 3px 3px var(--rojo); font-weight: normal; }
  .rotulo b em { color: var(--crema); font-style: normal; }
  .rotulo .teclas { font-size: 26px; line-height: 1.25; }
  .altavoz { height: 26px; border-radius: 6px; border: 2px solid #4f3d54; background: repeating-linear-gradient(0deg, #08070b 0 3px, #2b2230 3px 5px); }
  .ala img { flex: 1; min-height: 0; object-fit: contain; image-rendering: pixelated; }
  .ala p { flex: 1; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--crema); font-size: 22px; }
}

[hidden] { display: none !important; }

/* Vídeo al final de una fase (0.3.3): encima del juego, sin tapar el botón de saltar. */
.video-fase { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgb(10 9 22 / 0.94); }
.video-fase[hidden] { display: none; }
.video-fase video { max-width: 100vw; max-height: 100dvh; aspect-ratio: 9 / 16; background: #000; }
.video-saltar { position: absolute; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); min-height: 48px; }
.video-sonido { position: absolute; left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); min-height: 48px; }

/* Enlace a la historia del lugar al superar la fase (0.3.6): tarjeta arriba, sin tapar el juego. */
.historia { position: absolute; top: 104px; left: 50%; transform: translateX(-50%); z-index: 20; width: min(340px, calc(100% - 24px)); box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgb(27 26 46 / 0.94); border: 2px solid var(--oro); border-radius: 10px; color: var(--crema); text-decoration: none; font: 17px/1.2 'VT323', monospace; animation: historia-entra 0.25s ease-out; }
.historia[hidden] { display: none; }
.historia img { image-rendering: pixelated; object-fit: contain; flex: none; }
.historia b { display: block; color: #ffe690; font-weight: normal; font-size: 19px; }
.historia small { display: block; color: var(--gris); font-size: 14px; }
.historia-play { margin-left: auto; flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #d12c24; color: #fff; font-size: 16px; }
@keyframes historia-entra { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Molómetro (0.3.7): tu línea resaltada y la lista en la pantalla final. */
.hall-lista .mia { color: #ffe690; background: rgb(240 180 41 / 0.16); border-radius: 4px; }
.molometro-final { max-width: 360px; margin: 6px auto 10px; text-align: left; }
.molometro-final .hall-lista { font-size: 19px; margin: 4px 0; }

/* Pie común: botones secundarios con las mismas zonas táctiles que los enlaces. */
.pm-network-links .boton-texto{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:6px 4px;font:inherit;color:inherit;text-decoration:underline;text-underline-offset:3px;touch-action:manipulation}
.pm-network-links .boton-texto:focus-visible{outline:2px solid currentColor;outline-offset:3px;border-radius:3px}

#instalar-enlace{width:100%;max-width:100%;font:14px system-ui,sans-serif;padding:8px}

/* Derrota definitiva: una escena breve con BigOsa, sin ocultar el resultado. */
.final[data-resultado='derrota'] #final-titulo{color:var(--coral);font-size:clamp(32px,8vw,48px);margin:8px 0;text-transform:uppercase}
.final-aviso{max-width:32em;margin:8px auto 18px;font:17px/1.5 system-ui,sans-serif}
.final[data-resultado='derrota'] #final-img{animation:bigosa-derrota 650ms ease-out both;filter:drop-shadow(0 0 12px rgba(255,100,90,.3))}
@keyframes bigosa-derrota{0%{opacity:0;transform:translateY(-18px) rotate(-9deg)}45%{opacity:1;transform:translateY(4px) rotate(7deg)}75%{transform:translateY(-2px) rotate(-3deg)}100%{opacity:1;transform:translateY(0) rotate(0)}}
@media(prefers-reduced-motion:reduce){.final[data-resultado='derrota'] #final-img{animation:none}}

/* Eslogan oficial, decisión del propietario 02/10/2026. */
.eslogan{margin:0 0 12px;font-weight:800;color:#f1d59a;font-size:clamp(.95rem,3.6vw,1.2rem);text-align:center}
