/* CANDIL — estilos. Paleta: azules noche, violetas de tinta, ámbar/dorado. */
:root {
  --noche: #0b0e1f; --noche2: #141a33; --noche3: #1f2a4d; --azul: #46598f;
  --tinta: #4a2366; --violeta: #9b5cc4; --lila: #c99be6;
  --ambar: #ffc04a; --ambar2: #ffe08a; --crema: #fff6d9; --rosa: #ff5c8a; --hielo: #9ff0ff; --verde: #6fb24f;
  --t: 1; /* escala de texto (ajustes) */
  --k: 1; /* escala del lienzo: px CSS por px lógico */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #05060f; color: var(--crema); overflow: hidden;
  font-family: "Trebuchet MS", system-ui, -apple-system, "Segoe UI", sans-serif; overscroll-behavior: none; }
body { display: flex; align-items: center; justify-content: center; touch-action: auto; user-select: none; -webkit-user-select: none; }

#juego { position: relative; width: 360px; height: 640px; overflow: hidden; background: var(--noche); }
#lienzo { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; }

.oculto { display: none !important; }

/* Botones fijos: silencio siempre visible, pausa durante la Noche */
#botones-fijos { position: absolute; top: calc(8px * var(--k)); right: calc(8px * var(--k)); display: flex; gap: 8px; z-index: 30; }
.redondo { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--ambar); background: rgba(11,14,31,0.85);
  color: var(--ambar2); font-size: 18px; font-weight: bold; cursor: pointer; padding: 0; line-height: 1; }
.redondo[aria-pressed="true"] { border-color: #6b6f85; color: #6b6f85; text-decoration: line-through; }

/* Pantallas de menú y capas superpuestas */
.pantalla, .capa { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center;
  padding: 56px 16px 16px; overflow-y: auto; gap: 10px; font-size: calc(16px * var(--t)); }
.pantalla { background: linear-gradient(rgba(11,14,31,0.35), rgba(11,14,31,0.8)); }
.capa { background: rgba(6,8,20,0.82); justify-content: center; }
h1, h2, h3 { margin: 0; text-align: center; }
h1 { font-size: 56px; letter-spacing: 6px; color: var(--ambar); text-shadow: 0 0 18px rgba(255,192,74,0.7), 3px 3px 0 var(--tinta); }
h2 { font-size: calc(22px * var(--t)); color: var(--ambar2); }
h3 { font-size: calc(16px * var(--t)); color: var(--lila); margin-top: 4px; }
.sub { margin: 0; color: var(--lila); font-size: calc(16px * var(--t)); letter-spacing: 1px; }
.logo { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
.logo-candil img { width: 96px; height: 96px; image-rendering: pixelated; animation: flotar 2.4s ease-in-out infinite; filter: drop-shadow(0 0 14px rgba(255,192,74,0.8)); }
@keyframes flotar { 50% { transform: translateY(-8px); } }
.pabilos-linea { margin: 4px 0; font-weight: bold; color: var(--ambar2); }
.ico-pabilo { display: inline-block; width: 10px; height: 14px; background: var(--crema); border-top: 4px solid var(--ambar); vertical-align: -2px; }
.menu-botones { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 280px; margin-top: 8px; }
.pie { margin-top: auto; font-size: 14px; color: #8a8fa3; text-align: center; }

.btn { font: inherit; font-weight: bold; font-size: calc(16px * var(--t)); color: var(--crema); background: var(--noche3);
  border: 2px solid var(--azul); border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; box-shadow: 0 3px 0 #0b0e1f; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.pri { background: var(--ambar); color: #2a1740; border-color: var(--ambar2); }
.btn.grande { font-size: calc(20px * var(--t)); padding: 14px 18px; letter-spacing: 2px; }
.btn.peligro { background: #5a1a2e; border-color: var(--rosa); }
.btn:disabled { opacity: 0.45; cursor: default; }
.fila-botones { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: 8px; width: 100%; }
.fila-botones .btn.grande { flex: 1; max-width: 220px; }

/* Selección de personaje */
.lista-pj { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.pj { background: var(--noche2); border: 2px solid var(--noche3); border-radius: 10px; padding: 6px 4px; color: var(--crema);
  font: inherit; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-height: 96px; }
.pj img { width: 48px; height: 48px; image-rendering: pixelated; }
.pj.sel { border-color: var(--ambar); box-shadow: 0 0 10px rgba(255,192,74,0.5); }
.pj.bloq { opacity: 0.75; }
.detalle { min-height: 48px; text-align: center; margin: 0; font-size: calc(14px * var(--t)); color: #d9dcf0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 18px; border: 2px solid var(--azul); background: var(--noche2); color: var(--crema); cursor: pointer; min-height: 40px; }
.chip.sel { border-color: var(--ambar); background: #3a2a12; }
.chip:disabled { opacity: 0.4; }
.interruptor { display: flex; align-items: center; gap: 10px; font-size: calc(15px * var(--t)); }
.interruptor input { width: 22px; height: 22px; accent-color: var(--ambar); }
small { color: #8a8fa3; }

/* Taller */
.lista-taller { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.mejora { background: var(--noche2); border: 2px solid var(--noche3); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.mejora b { color: var(--ambar2); font-size: 15px; }
.mejora .pts { letter-spacing: 2px; color: var(--ambar); }
.mejora .btn { padding: 6px 8px; min-height: 38px; font-size: 14px; }

/* Cuaderno */
.pestanas { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.pestana { flex: 1 1 auto; font: inherit; font-size: 14px; font-weight: bold; padding: 8px 2px; border: 2px solid var(--noche3); background: var(--noche2); color: var(--crema); border-radius: 8px; cursor: pointer; min-height: 40px; }
.pestana.activa { border-color: var(--ambar); color: var(--ambar2); }
.cuaderno { width: 100%; display: flex; flex-direction: column; gap: 8px; font-size: calc(14px * var(--t)); }
.fila { display: flex; gap: 10px; align-items: center; background: var(--noche2); border-radius: 10px; padding: 8px; border: 1px solid var(--noche3); }
.fila img { width: 40px; height: 40px; image-rendering: pixelated; flex: none; }
.fila p { margin: 2px 0 0; color: #c8cbe0; }
.fila.no { opacity: 0.7; }
.fila b { color: var(--ambar2); }
.contador { text-align: center; color: var(--lila); margin: 0; }

/* Cartas de subida de nivel */
.cartas { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 330px; }
.carta { position: relative; display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; color: var(--crema);
  background: var(--noche2); border: 3px solid var(--fam, var(--azul)); border-radius: 12px; padding: 10px 12px; cursor: pointer;
  min-height: 84px; box-shadow: 0 4px 0 #05060f; animation: entra 0.25s ease-out both; }
.carta:nth-child(2) { animation-delay: 0.05s; } .carta:nth-child(3) { animation-delay: 0.1s; } .carta:nth-child(4) { animation-delay: 0.15s; }
@keyframes entra { from { transform: translateY(20px) scale(0.95); opacity: 0; } }
.carta:active { transform: scale(0.98); }
.carta img { width: 48px; height: 48px; image-rendering: pixelated; flex: none; background: rgba(0,0,0,0.3); border-radius: 8px; padding: 4px; }
.carta .nom { font-weight: bold; font-size: calc(17px * var(--t)); color: var(--fam, var(--crema)); }
.carta .nv { font-size: 14px; color: var(--ambar2); }
.carta .efe { font-size: calc(14px * var(--t)); color: #d9dcf0; }
.carta .forma { position: absolute; left: 6px; top: 4px; font-size: 12px; color: var(--fam); }
.sinergia { position: absolute; right: 8px; top: 6px; color: var(--ambar2); font-size: 20px; animation: brilla 0.8s ease-in-out infinite alternate; }
.sinergia small { font-size: 11px; color: var(--ambar2); display: block; text-align: right; }
@keyframes brilla { from { transform: scale(1) rotate(0); text-shadow: 0 0 2px var(--ambar); } to { transform: scale(1.25) rotate(15deg); text-shadow: 0 0 12px var(--ambar); } }

/* Cofre */
.cofre { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.cofre img { width: 96px; height: 96px; image-rendering: pixelated; }
.cofre.fusion img { animation: giro 1.2s ease-out both; filter: drop-shadow(0 0 20px var(--ambar)); }
.cofre .rayos { width: 220px; height: 220px; position: absolute; border-radius: 50%; background: repeating-conic-gradient(rgba(255,224,138,0.25) 0 10deg, transparent 10deg 20deg); animation: rota 6s linear infinite; z-index: -1; }
@keyframes giro { from { transform: scale(0.2) rotate(-360deg); opacity: 0; } }
@keyframes rota { to { transform: rotate(360deg); } }

/* Pausa y fin */
.pausa, .fin { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px; font-size: calc(14px * var(--t)); }
.inventario { display: flex; flex-wrap: wrap; gap: 6px; }
.inv { display: flex; align-items: center; gap: 4px; background: var(--noche2); border-radius: 8px; padding: 4px 6px; font-size: 14px; }
.inv img { width: 24px; height: 24px; image-rendering: pixelated; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px dotted #2e3d6b; padding: 2px 0; }
.stats b { color: var(--ambar2); }
.barra { display: grid; grid-template-columns: 24px 92px 1fr 48px; align-items: center; gap: 6px; font-size: 14px; }
.barra img { width: 20px; height: 20px; image-rendering: pixelated; }
.barra .b { height: 10px; background: var(--ambar); border-radius: 3px; }
.falto { background: #2a1740; border: 2px solid var(--violeta); border-radius: 10px; padding: 8px 10px; }
.falto b { color: var(--lila); display: block; margin-bottom: 2px; }
.novedad { background: #3a2a12; border: 2px solid var(--ambar); border-radius: 10px; padding: 6px 10px; color: var(--ambar2); }

/* Avisos flotantes (logros, recordatorio) */
#avisos { position: absolute; left: 0; right: 0; bottom: 110px; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.aviso { display: flex; gap: 8px; align-items: center; background: rgba(20,26,51,0.95); border: 2px solid var(--ambar); border-radius: 10px; padding: 6px 10px; max-width: 320px; font-size: 14px; animation: entra 0.3s ease-out both; }
.aviso img { width: 32px; height: 32px; image-rendering: pixelated; }
.aviso b { color: var(--ambar2); display: block; }

.ajustes { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.ajustes label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: calc(15px * var(--t)); }
.ajustes input[type="range"] { width: 160px; accent-color: var(--ambar); }
.ajustes select { font: inherit; font-size: 15px; background: var(--noche2); color: var(--crema); border: 2px solid var(--azul); border-radius: 8px; padding: 6px; }

/* Capas largas (fin, pausa): empiezan arriba y los botones quedan siempre visibles abajo */
#capa-fin, #capa-pausa { justify-content: flex-start; padding-top: 60px; padding-bottom: 0; }
#capa-fin .fila-botones, #capa-pausa .fila-botones { position: sticky; bottom: 0; background: linear-gradient(rgba(6,8,20,0), rgba(6,8,20,0.95) 30%); padding: 18px 0 14px; }

/* PC apaisado: el lienzo ocupa toda la pantalla y los menús quedan en una columna centrada */
body.panoramico .pantalla, body.panoramico .capa { padding-left: max(16px, calc(50% - 230px)); padding-right: max(16px, calc(50% - 230px)); }
#btn-completa { font-size: 20px; }
/* en móvil vertical, durante la Noche, el botón ⛶ se esconde para no tapar el reloj */
body:not(.panoramico) #btn-pausa:not(.oculto) ~ #btn-completa { display: none; }

/* PC (ratón y teclado): ayudas sólo visibles en ordenador */
.solo-pc { display: none; }
body.pc .solo-pc { display: block; }
.controles-pc { margin: 4px 0; max-width: 340px; text-align: center; font-size: calc(14px * var(--t)); color: var(--lila); line-height: 1.7; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--azul); border-bottom-width: 2px; border-radius: 4px; background: var(--noche2);
  color: var(--crema); font: bold 14px "Trebuchet MS", system-ui, sans-serif; line-height: 18px; }
#btn-menu-completa, #btn-pausa-completa { width: 100%; max-width: 280px; }
#btn-menu-completa small { font-size: 14px; opacity: 0.8; }
body.pc .redondo { cursor: pointer; }
body.pc #lienzo { cursor: crosshair; }
/* PC: menú algo más compacto para que quepan el botón de pantalla completa y la chuleta de teclas */
body.pc #pantalla-menu { gap: 6px; padding-top: 40px; }
body.pc .logo { margin-top: 0; }
body.pc .logo-candil img { width: 72px; height: 72px; }
body.pc h1 { font-size: 46px; }
body.pc .menu-botones { gap: 8px; margin-top: 2px; }
body.pc .menu-botones .btn.grande { min-height: 48px; padding-top: 8px; padding-bottom: 8px; }
body.pc #pantalla-menu .pie { margin: 0; }

/* ---- v1.3.1 Gran aviso de desbloqueo (poderes automáticos) ---- */
#anuncio-poder { position: absolute; left: 50%; top: 34%; z-index: 45; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; max-width: min(92%, 560px);
  background: radial-gradient(circle at 25% 50%, #5a3a2a, #1a1240 70%);
  border: 3px solid #ffe08a; border-radius: 16px; color: #fff6d9; pointer-events: none;
  box-shadow: 0 0 30px rgba(255, 192, 74, 0.8);
  will-change: transform, opacity; animation: anuncio-boom 1.9s cubic-bezier(.2, 1.6, .4, 1) both; }
#anuncio-poder.oculto { display: none; }
#anuncio-poder.grande { border-color: #ff4d94; box-shadow: 0 0 36px rgba(255, 77, 148, 0.9); }
#anuncio-poder img { width: 56px; height: 56px; image-rendering: pixelated; animation: anuncio-giro 0.6s ease-out both; }
#anuncio-poder small { display: block; font-size: calc(15px * var(--t, 1)); font-weight: 900; letter-spacing: 1px; color: #ffe08a; text-shadow: 0 0 10px #ff7a1f; }
#anuncio-poder.grande small { color: #ff9ac4; font-size: calc(18px * var(--t, 1)); }
#anuncio-poder b { display: block; font-size: calc(24px * var(--t, 1)); line-height: 1.1; text-shadow: 0 2px 0 #000, 0 0 14px #ffc04a; }
#anuncio-poder span { display: block; font-size: calc(14px * var(--t, 1)); opacity: 0.95; }
@keyframes anuncio-boom {
  0% { transform: translate(-50%, -50%) scale(0.1) rotate(-8deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.3) rotate(3deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(0.95) rotate(-1deg); }
  32% { transform: translate(-50%, -50%) scale(1.04); }
  38%, 80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -62%) scale(0.9); opacity: 0; }
}
@keyframes anuncio-giro { from { transform: scale(2.5) rotate(-180deg); } to { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { #anuncio-poder, #anuncio-poder img { animation-duration: 0.01s; animation-fill-mode: both; } #anuncio-poder { animation: none; } }

/* v1.4 — Preparación y ruta. El escenario conserva el arte y los efectos originales. */
.ceja { margin: 0; color: var(--hielo); letter-spacing: 2px; font-size: calc(12px * var(--t)); font-weight: bold; }
#pantalla-menu { gap: 7px; padding-top: 40px; }
#pantalla-menu .logo { margin-top: 0; }
#pantalla-menu .logo-candil img { width: 70px; height: 70px; }
#pantalla-menu h1 { font-size: 48px; }
#pantalla-menu .menu-botones { gap: 7px; margin-top: 2px; max-width: 320px; }
#pantalla-menu .menu-botones .btn.grande { padding: 9px 10px; font-size: calc(17px * var(--t)); letter-spacing: 1px; }
.menu-botones .pri small { display: block; color: #4b381b; font-size: calc(12px * var(--t)); font-weight: normal; letter-spacing: 0; margin-top: 4px; }
.mapa-ruta { display: flex; width: 100%; max-width: 320px; margin: 2px 0; }
.parada { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.parada:not(:last-child)::after { content: ''; height: 1px; width: 55%; position: absolute; top: 15px; left: 72%; background: #657092; }
.parada i { font: bold 13px system-ui; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--ruta-color); border-radius: 50%; background: #131c30; color: var(--ruta-color); }
.parada span { font-size: 12px; color: #cad0e2; }
.parada small { min-height: 14px; font-size: 12px; color: var(--ambar); }
.parada.superada i { box-shadow: 0 0 12px #ffc04a60; background: #373023; }
#pantalla-seleccion { gap: 12px; justify-content: flex-start; padding-top: 55px; padding-bottom: 0; touch-action: pan-y; }
#pantalla-seleccion > * { flex-shrink: 0; }
.modos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.modo, .amuleto { font: inherit; color: var(--crema); background: #111d34; border: 1px solid #4b557b; border-radius: 12px; padding: 12px 8px; cursor: pointer; text-align: left; }
.modo { display: flex; flex-direction: column; gap: 6px; min-height: 90px; }
.modo b { font-size: calc(14px * var(--t)); letter-spacing: 1px; }
.modo span { font-size: calc(13px * var(--t)); line-height: 1.4; color: #c9d1e7; }
.modo.sel, .amuleto.sel { border-color: var(--ambar); background: linear-gradient(125deg, #41301c, #1d2034); box-shadow: inset 0 0 0 1px #ffc04a; }
#config-amuleto { width: 100%; }
.amuletos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.amuleto { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 10px 6px; }
.amuleto i { font: bold 26px system-ui; }
.amuleto b { font-size: calc(13px * var(--t)); }
.amuleto span { font-size: calc(12px * var(--t)); line-height: 1.4; color: #cbd6e5; }
.nota-amuleto { font-size: calc(12px * var(--t)); color: #aeb6ce; text-align: center; margin: 6px 0 0; }
.guia-ruta { width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid #4b6a78; border-radius: 10px; background: #12283a; font-size: calc(14px * var(--t)); line-height: 1.4; }
.guia-ruta b { color: var(--hielo); }
.guia-ruta strong { color: var(--ambar2); font-size: calc(13px * var(--t)); margin-top: 3px; }
#pantalla-seleccion .lista-pj { grid-template-columns: repeat(4, 1fr); gap: 5px; }
#pantalla-seleccion .pj { min-height: 78px; padding: 5px 2px; }
#pantalla-seleccion .pj img { width: 36px; height: 36px; }
#pantalla-seleccion .fila-botones { position: sticky; bottom: 0; z-index: 3; padding: 14px 0; background: #0b0e1ff5; }
#pantalla-seleccion .fila-botones .btn.grande { max-width: none; font-size: calc(16px * var(--t)); letter-spacing: 0; }
.ruta-resumen { display: flex; flex-direction: column; gap: 8px; padding: 18px; text-align: center; background: linear-gradient(135deg, #343021, #142638); border: 1px solid var(--ambar); border-radius: 14px; }
.ruta-resumen b { font-size: calc(22px * var(--t)); color: var(--ambar2); }
.numero-etapa { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border: 1px solid var(--ambar); border-radius: 50%; }
#capa-fin .fila-botones { flex-wrap: wrap; }
#capa-fin .fila-botones #btn-otra { flex: 1 0 100%; max-width: none; }
body.en-travesia #anuncio-poder { top: 73%; max-width: min(90%, 390px); padding: 8px 12px; gap: 8px; border-width: 2px; }
body.en-travesia #anuncio-poder img { width: 34px; height: 34px; }
body.en-travesia #anuncio-poder small, body.en-travesia #anuncio-poder.grande small { font-size: calc(12px * var(--t)); }
body.en-travesia #anuncio-poder b { font-size: calc(18px * var(--t)); }
body.en-travesia #anuncio-poder span { font-size: calc(12px * var(--t)); }
button:focus-visible { outline: 3px solid var(--hielo); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
