/* --- TOKENS RESPONSIVOS --- */
:root {
  --lpad: 20px;
  --card-w: 500px;
  --card-pad: 28px 24px;
  --card-top: 5vh;
  --title-sz: 2.1rem;
  --title-ls: 3px;
  --instr-sz: 1.2rem;
  --hint-h: 140px;
  --label-sz: 0.85rem;
  --nav-sz: 1.05rem;
  --btn-pad: 0 20px;
  --btn-sz: 1.12rem;
}
@media (min-width: 768px) {
  :root {
    --lpad: 40px 60px;
    --card-w: 620px;
    --card-pad: 44px 52px;
    --card-top: 8vh;
    --title-sz: 2.3rem;
    --title-ls: 4px;
    --instr-sz: 1.05rem;
    --hint-h: 200px;
    --label-sz: 0.68rem;
    --nav-sz: 0.9rem;
    --btn-pad: 0 28px;
    --btn-sz: 0.92rem;
  }
}

/* --- BASE --- */
body, html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #000;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
}

/* --- FONDO DOBLE CAPA (fixed) --- */
.bg-wrap {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.42s ease;
}
.bg-fill {
  position: absolute;
  top: -12%; left: -12%; right: -12%; bottom: -12%;
  background-size: cover;
  background-position: center;
  filter: blur(32px) brightness(0.55) saturate(0.8);
}
.bg-clear {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* --- OVERLAYS (fixed) --- */
.overlay-radial {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.35) 100%);
}
.overlay-linear {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0,0,0,0.28) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.32) 100%);
}
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0px, transparent 3px, rgba(0,0,0,0.07) 3px, rgba(0,0,0,0.07) 4px);
}

/* --- BARRA DE PROGRESO (sticky arriba) --- */
.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: rgba(0,0,0,0.4);
  z-index: 20;
}
.progress-bar {
  height: 2px;
  background: linear-gradient(90deg, #008800, #00ff00);
  box-shadow: 0 0 8px rgba(0,255,0,0.5);
  border-radius: 0 1px 1px 0;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
}

/* --- LAYOUT PRINCIPAL --- */
.main-container {
  position: relative;
  z-index: 5;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--lpad) 80px;
  box-sizing: border-box;
}

/* --- TARJETA SUPERIOR --- */
.card {
  width: 100%;
  max-width: var(--card-w);
  text-align: center;
  margin-top: var(--card-top);
  background: rgba(0,0,0,0.22);
  padding: var(--card-pad);
  border-radius: 14px;
  backdrop-filter: blur(22px) saturate(1.4) brightness(0.85);
  -webkit-backdrop-filter: blur(22px) saturate(1.4) brightness(0.85);
  border: 1px solid rgba(255,255,255,0.1);
  box-sizing: border-box;
  box-shadow: 0 8px 48px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08);
}

.fase-lbl {
  font-size: var(--label-sz);
  letter-spacing: 5px;
  color: #888;
  margin-bottom: 14px;
  text-transform: uppercase;
  background: rgba(0,0,0,0.55);
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
}

.title {
  font-size: var(--title-sz);
  text-transform: uppercase;
  letter-spacing: var(--title-ls);
  margin: 0 0 20px 0;
  text-shadow: 0 0 20px rgba(255,255,255,0.4);
  font-weight: normal;
  font-family: inherit;
  line-height: 1.2;
}

.instructions {
  font-size: var(--instr-sz);
  line-height: 1.75;
  opacity: 0.8;
  font-family: inherit;
  margin: 0;
}

.instructions-locked {
  filter: blur(6px);
  opacity: 0.25;
  user-select: none;
  pointer-events: none;
  letter-spacing: -1px;
  word-break: break-all;
}

/* Imagen pista */
.hint-wrap-locked .hint-img-locked {
  position: relative;
  width: 100%;
  padding-top: 56%; /* fallback si PHP no obtiene dimensiones */
  background: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,0.04) 0px,
    rgba(255,255,255,0.04) 2px,
    rgba(0,0,0,0.3) 2px,
    rgba(0,0,0,0.3) 8px
  );
  filter: blur(3px);
}

.hint-wrap {
  margin-top: 18px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.hint-img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.85;
}
.hint-label {
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: #aaa;
  padding: 6px;
  text-align: center;
  background: rgba(0,0,0,0.75);
}

/* Error */
.error-msg {
  margin: 0 0 10px 0;
  font-size: 1.05rem;
  color: #ff8080;
  background: rgba(100,15,15,0.5);
  border: 1px solid rgba(255,110,110,0.2);
  border-radius: 6px;
  padding: 8px 12px;
  animation: fadeIn 0.3s ease;
  font-family: inherit;
  letter-spacing: 0.5px;
}

/* Formulario */
.code-form,
.form-placeholder {
  display: flex;
  width: 100%;
  gap: 8px;
  box-sizing: border-box;
}

.code-form-nocod {
  justify-content: center;
}
.code-form-nocod .submit-btn {
  padding: 11px 36px;
  letter-spacing: 3px;
}

.input-field {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #fff;
  font-size: 0.95rem;
  font-family: 'Courier New', Courier, monospace;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 3px;
  transition: all 0.25s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  outline: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.input-field::placeholder {
  color: #444;
  text-transform: none;
  letter-spacing: normal;
  font-size: 1.05rem;
}
.input-field:focus {
  border-color: rgba(0,255,0,0.5);
  box-shadow: 0 0 18px rgba(0,255,0,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
  background: rgba(10,20,10,0.7);
}
.input-field:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.input-field.input-error {
  border-color: rgba(255,68,68,0.7);
  box-shadow: 0 0 14px rgba(255,68,68,0.3), inset 0 1px 0 rgba(255,255,255,0.04);
  animation: shake 0.4s ease;
}

.submit-btn {
  padding: var(--btn-pad);
  background: rgba(0,60,0,0.4);
  border: 1px solid rgba(0,255,0,0.2);
  border-radius: 8px;
  color: rgba(0,255,0,0.6);
  font-family: 'Courier New', Courier, monospace;
  font-size: var(--btn-sz);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  backdrop-filter: blur(8px);
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(0,255,0,0.3);
}
.submit-btn:hover,
.submit-btn:active {
  background: rgba(0,255,0,0.15);
  border-color: rgba(0,255,0,0.6);
  color: #00ff00;
  box-shadow: 0 0 20px rgba(0,255,0,0.2);
  text-shadow: 0 0 8px rgba(0,255,0,0.5);
}
.submit-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --- MULTI-CÓDIGO: progreso de puntos --- */
.multi-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 12px;
}
.multi-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,255,0,0.3);
  background: transparent;
  transition: all 0.3s ease;
}
.multi-dot-on {
  background: rgba(0,255,0,0.7);
  border-color: rgba(0,255,0,0.8);
  box-shadow: 0 0 6px rgba(0,255,0,0.4);
}
.multi-count {
  font-size: 0.92rem;
  letter-spacing: 2px;
  color: rgba(0,255,0,0.45);
  margin-left: 4px;
}

/* Mensaje de código encontrado (verde) */
.found-msg {
  margin: 0 0 10px 0;
  font-size: 1.05rem;
  color: #80ff80;
  background: rgba(0,60,0,0.5);
  border: 1px solid rgba(0,200,0,0.2);
  border-radius: 6px;
  padding: 8px 12px;
  animation: fadeIn 0.3s ease;
  font-family: inherit;
  letter-spacing: 0.5px;
}

/* Input verde al acertar en modo secuencial */
.input-found {
  border-color: rgba(0,255,0,0.5);
  box-shadow: 0 0 14px rgba(0,255,0,0.2);
}

/* --- CONTADOR DE TIEMPO --- */
.countdown-wrap {
  text-align: center;
  padding: 12px 0 14px;
}
.countdown-desc {
  font-size: var(--instr-sz);
  line-height: 1.6;
  color: rgba(255,255,255,0.65);
  margin: 0 0 14px 0;
  font-family: inherit;
}

.countdown-label {
  font-size: 0.82rem;
  letter-spacing: 4px;
  color: #aaa;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.6);
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
}
.countdown-timer {
  font-size: 1.8rem;
  letter-spacing: 4px;
  color: rgba(0,255,0,0.5);
  text-shadow: 0 0 12px rgba(0,255,0,0.2);
  font-variant-numeric: tabular-nums;
}

/* --- NAVEGACIÓN (fixed abajo) --- */
.nav-area {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--card-w);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 20px 22px;
  box-sizing: border-box;
  background: linear-gradient(to top, rgba(0,0,0,0.95) 60%, transparent);
  z-index: 10;
}
.nav-btn {
  color: rgba(0,255,0,0.35);
  font-size: var(--nav-sz);
  text-decoration: none;
  font-family: inherit;
  display: inline-block;
  letter-spacing: 1px;
  transition: color 0.2s;
}
.nav-btn:hover { color: rgba(0,255,0,0.8); }
.nav-btn-right { text-align: right; }

.finished-msg {
  font-size: 1.2rem;
  color: #00ff00;
  text-shadow: 0 0 20px rgba(0,255,0,0.8);
  margin: 0;
  font-family: inherit;
  letter-spacing: 2px;
}

/* --- ANIMACIONES --- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
