:root {
  --oro: #f4c430;
  --texto: #fff;
  --gris: #a9bdb2;
  --panel: rgba(10, 30, 22, .9);
  --radio: 16px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #0b241b; color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
[hidden] { display: none !important; }

/* Capas */
#stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: #0b241b; }
#hud { position: fixed; inset: 0; z-index: 15; pointer-events: none; display: flex; flex-direction: column; }
#hud-global { position: fixed; top: 0; left: 0; right: 0; z-index: 20; pointer-events: none; }
.interactivo { pointer-events: auto; }
#app { position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: radial-gradient(circle at 50% -10%, #1e6b4a 0%, #0b241b 60%); }

/* Menús */
.pantalla { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.pantalla.centro { text-align: center; justify-content: center; min-height: 100%; }
h1 { font-size: 2rem; margin: .1em 0; }
h2 { margin: 0; font-size: 1.35rem; }
h3 { margin: .6em 0 0; }
.logo { font-size: 4.5rem; line-height: 1; }
.sub { color: var(--gris); margin: 0; }
.nota { color: var(--gris); font-size: .8rem; }
.estado { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.06); }
.estado.ok { border: 1px solid #2bb24c66; }
.estado.pend { border: 1px solid #f4c43066; }
.barra { display: flex; align-items: center; gap: 12px; }

.btn {
  font: inherit; color: var(--texto); background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18); border-radius: var(--radio); padding: 12px 16px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-align: center; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.grande { width: 100%; min-height: 56px; font-size: 1.1rem; font-weight: 600; }
.btn.chico { padding: 8px 12px; font-size: .9rem; border-radius: 12px; }
.btn.primario { background: linear-gradient(180deg, #e63946, #b5121b); border-color: #ff8a8a55; box-shadow: 0 4px 0 #6d0a10; }
.btn.peligro { background: rgba(193,18,31,.3); }

label { display: flex; flex-direction: column; gap: 6px; font-size: .95rem; color: #dfe9e3; }
input, select {
  font: inherit; font-size: 1.05rem; padding: 12px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(0,0,0,.3); color: #fff; width: 100%;
}
select option { color: #000; }
label.check { flex-direction: row; align-items: center; gap: 10px; }
label.check input { width: 22px; height: 22px; }
.fila { display: flex; gap: 10px; }
.fila > label { flex: 1; }
.fila > label.corto { flex: 0 0 100px; }
.ayuda { font-size: .88rem; color: var(--gris); margin: 0; }
.ayuda.ok { color: #8be59c; }
.ayuda.aviso { color: #ffd166; }

.lista { display: flex; flex-direction: column; gap: 10px; }
.tarjeta-est { display: grid; grid-template-columns: 72px 1fr; gap: 10px; background: rgba(255,255,255,.06); border-radius: 14px; padding: 10px; align-items: center; }
.tarjeta-est img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.tarjeta-est .info { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; min-width: 0; }
.tarjeta-est .info span { color: var(--gris); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tarjeta-est .info .letra { color: var(--oro); }
.tarjeta-est .acciones { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.vacio { color: var(--gris); text-align: center; padding: 16px; border: 1px dashed rgba(255,255,255,.2); border-radius: 14px; }
.caja-compilar { background: rgba(244,196,48,.08); border: 1px solid rgba(244,196,48,.3); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.caja-compilar.ok { background: rgba(43,178,76,.08); border-color: rgba(43,178,76,.35); }
.caja-compilar p { margin: 0; }
.consejos { background: rgba(255,255,255,.05); border-radius: 14px; padding: 10px 14px; }
.consejos summary { cursor: pointer; font-weight: 600; }
.consejos li { margin: 6px 0; color: #dfe9e3; }
.foto-box { aspect-ratio: 4 / 3; border-radius: 14px; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--gris); }
.foto-box img { width: 100%; height: 100%; object-fit: contain; }
.progreso { height: 14px; background: rgba(255,255,255,.1); border-radius: 99px; overflow: hidden; }
#barra { height: 100%; width: 0; background: linear-gradient(90deg, var(--oro), #2bb24c); transition: width .3s; }
.error { color: #ff8a8a; }
.reglas { background: rgba(255,255,255,.05); border-radius: 14px; padding: 4px 14px; }
.reglas li { margin: 6px 0; }

/* HUD general */
.hud-bar {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  margin: max(8px, env(safe-area-inset-top)) 8px 0; padding: 8px 10px;
  background: var(--panel); border-radius: 14px; font-weight: 600;
}
.hud-bar .pareja { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42%; }
.g-reloj { font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.urgente { color: #ff6b6b; animation: latido 1s infinite; }
@keyframes latido { 50% { transform: scale(1.12); } }
.ayuda-mini { font-weight: 400; font-size: .8rem; color: var(--gris); }
.cargando { margin: auto; background: var(--panel); padding: 16px 20px; border-radius: 14px; }

/* Búsqueda de estación */
.busqueda { margin: 70px 12px 0; padding: 14px; background: var(--panel); border-radius: 18px; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.busqueda h3 { margin: 0; }
.paso { font-size: .85rem; color: var(--oro); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.recorte { height: 140px; border-radius: 12px; background-color: #000; background-repeat: no-repeat; border: 2px solid rgba(244,196,48,.5); }
.pista-txt { margin: 0; font-style: italic; color: #ffe9a8; }
.fila-btn { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ayuda-scan { margin: 0; font-size: .9rem; color: var(--gris); }

/* Tarjetas de intro y resultado */
.tarjeta-centro {
  margin: auto; padding: 22px 18px; background: var(--panel); border-radius: 22px; text-align: center;
  display: flex; flex-direction: column; gap: 10px; width: calc(100% - 24px); max-width: 520px;
  border: 1px solid rgba(244,196,48,.3);
}
.tarjeta-centro p { margin: 0; line-height: 1.4; }
.encontrada { color: var(--oro); font-weight: 700; }
.icono-reto { font-size: 3.2rem; line-height: 1; }
.chips { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.chips span { background: rgba(255,255,255,.1); padding: 4px 10px; border-radius: 99px; font-size: .85rem; }
.pts { font-size: 1.4rem; font-weight: 800; color: var(--oro); }
.letra-grande { font-size: 3rem; font-weight: 900; color: var(--oro); background: rgba(244,196,48,.12); border: 2px dashed var(--oro); border-radius: 14px; width: 80px; height: 80px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.botones { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* HUD del reto */
.reto-top { display: flex; justify-content: space-between; align-items: center; margin: 66px 12px 0; gap: 8px; }
.reto-nombre { background: var(--panel); padding: 8px 12px; border-radius: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reto-top .btn { background: var(--panel); flex: 0 0 auto; }
.reto-reloj { background: var(--panel); min-width: 62px; text-align: center; padding: 6px 10px; border-radius: 12px; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.reto-status { align-self: center; margin-top: 8px; background: rgba(0,0,0,.6); padding: 6px 14px; border-radius: 99px; font-weight: 700; font-size: 1.1rem; }
.reto-status:empty { display: none; }
.reto-perdido { align-self: center; margin-top: 8px; background: #b5121b; padding: 6px 14px; border-radius: 99px; }
.mira { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px #0008; }
.mira::after { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; background: #ff4d4d; border-radius: 50%; }
.reto-panel { margin-top: auto; padding: 0 12px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.reto-panel:empty { display: none; }
.msg { background: var(--panel); padding: 12px 14px; border-radius: 14px; font-size: 1.1rem; text-align: center; line-height: 1.35; }
.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn.opcion { background: var(--panel); min-height: 54px; font-size: 1rem; font-weight: 600; }
.btn.opcion i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: 0 0 14px; border: 1px solid #0006; }
.btn.opcion.bien { background: #1f8f3a; border-color: #8be59c; opacity: 1; }
.btn.opcion.mal { background: #a4161a; opacity: 1; }
.teclado { background: var(--panel); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pantallita { text-align: center; font-size: 2rem; font-weight: 800; letter-spacing: .2em; background: rgba(0,0,0,.4); border-radius: 10px; padding: 2px; }
.teclas { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.btn.tecla { padding: 10px 0; font-size: 1.2rem; font-weight: 700; }
.sacudir { animation: sacudir .4s; }
@keyframes sacudir { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.libre { display: flex; gap: 8px; }
.libre input { flex: 1; background: rgba(0,0,0,.6); }

/* Final y marcador */
.fichas { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.ficha { width: 52px; height: 60px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 900; background: linear-gradient(180deg, #fff3c4, #f4c430); color: #5a3d00; border-radius: 10px; box-shadow: 0 4px 0 #a07800; }
.ficha.vacia { background: rgba(255,255,255,.1); color: var(--gris); box-shadow: none; }
#f-final { display: flex; flex-direction: column; gap: 10px; }
#f-pal { text-align: center; font-size: 1.4rem; text-transform: uppercase; letter-spacing: .1em; }
.total { font-size: 2.4rem; font-weight: 900; color: var(--oro); }
.marcador { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.marcador li { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.06); padding: 12px; border-radius: 14px; }
.marcador .pos { font-size: 1.5rem; width: 36px; text-align: center; }
.marcador .nom { flex: 1; display: flex; flex-direction: column; }
.marcador small { color: var(--gris); }
.marcador b { font-size: 1.3rem; color: var(--oro); }

.qr-caja { background: #fff; padding: 16px; border-radius: 16px; align-self: center; line-height: 0; }
.qr-caja img, .qr-caja canvas { display: block; }
.url-qr { font-family: ui-monospace, Consolas, monospace; color: var(--oro); word-break: break-all; margin: 0; }

#toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, 10px); opacity: 0; z-index: 50;
  background: rgba(17,17,17,.88); color: #fff; padding: 12px 18px; border-radius: 14px; max-width: 90vw;
  text-align: center; transition: .25s; pointer-events: none; font-weight: 600;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confeti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: caer linear forwards; }
@keyframes caer { to { transform: translateY(110vh) rotate(720deg); } }
