* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --header-bg: #1a2b4a;
  --header-text: #ffffff;
  --footer-bg: #2c3e50;
  --footer-text: #ffffff;
  --rojo: #c0392b;
  --rojo-borde: #922b21;
  --azul: #2980b9;
  --azul-borde: #1a5276;
  --amarillo: #f1c40f;
  --amarillo-borde: #d4ac0d;
  --blanco: #ffffff;
  --gris-fondo: #eef1f5;
  --texto-oscuro: #1c2833;
  --modal-bg: rgba(0, 0, 0, 0.75);
}

html, body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--gris-fondo);
  color: var(--texto-oscuro);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 10px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 4px solid #f1c40f;
}

.header-eleccion {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  line-height: 1.35;
}

.eleccion-nombre {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
}

.header-titulo {
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: right;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

/* ===== MAIN ===== */
.app-main {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.pantalla {
  animation: aparecer 0.25s ease;
}

.oculta {
  display: none !important;
}

@keyframes aparecer {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== GRIDS ===== */
.grid {
  display: grid;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.grid-2x2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-4x2 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-4x3 {
  grid-template-columns: repeat(4, 1fr);
}

/* ===== TARJETAS ===== */
.tarjeta-voto,
.tarjeta-lista {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border: 3px solid;
  border-radius: 8px;
  background: var(--blanco);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  font-family: inherit;
  text-align: center;
}

.tarjeta-voto img,
.tarjeta-lista img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  pointer-events: none;
}

.tarjeta-voto:hover,
.tarjeta-lista:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}

.tarjeta-voto:focus-visible,
.tarjeta-lista:focus-visible,
.boton-accion:focus-visible,
.btn-footer:focus-visible,
.modal-boton:focus-visible {
  outline: 4px solid #27ae60;
  outline-offset: 2px;
}

.tarjeta-blanca:hover {
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}

.tarjeta-roja { border-color: var(--rojo); background: #fdecea; }
.tarjeta-azul { border-color: var(--azul); background: #eaf2f8; }
.tarjeta-amarilla { border-color: var(--amarillo-borde); background: #fef9e7; }
.tarjeta-blanca { border-color: #b0b0b0; background: var(--blanco); }

.tarjeta-texto {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.indicador-bloque {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.55;
}

#pantalla-1 .indicador-bloque,
#pantalla-1 .tarjeta-texto {
  display: none;
}

#pantalla-2 .tarjeta-texto {
  display: none;
}

#pantalla-3 .tarjeta-texto {
  display: none;
}

/* ===== FRANJA LISTA (PANTALLA 3) ===== */
.franja-lista {
  background: var(--rojo);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 16px;
  border-radius: 6px;
  max-width: 1100px;
  margin: 0 auto 18px;
  width: 100%;
  border-bottom: 4px solid var(--rojo-borde);
}

/* ===== RESUMEN (PANTALLA 4) ===== */
.resumen-paneles {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.panel-resumen {
  background: var(--blanco);
  border: 3px solid var(--azul);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  min-height: 320px;
}

.panel-resumen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

.panel-resumen-titulo,
.panel-resumen-texto {
  display: none;
}

.panel-acciones {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.boton-accion {
  width: 60%;
  background: var(--blanco);
  border: 3px solid var(--footer-bg);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.boton-accion:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
}

.boton-accion img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  pointer-events: none;
}

/* ===== FOOTER ===== */
.app-footer {
  background: var(--footer-bg);
  padding: 10px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  border-top: 4px solid #f1c40f;
}

.btn-footer {
  background: transparent;
  color: var(--footer-text);
  border: 2px solid var(--footer-text);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-footer:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: aparecer 0.2s ease;
}

.modal-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 26px 30px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  border-top: 8px solid var(--rojo);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.modal-titulo {
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--rojo);
  margin-bottom: 10px;
}

.modal-mensaje {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.modal-boton {
  background: var(--rojo);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal-boton:hover {
  background: var(--rojo-borde);
}

/* ===== ALTO CONTRASTE ===== */
body.alto-contraste {
  background: #000000;
  color: #ffffff;
}

.alto-contraste .app-header {
  background: #000000;
  border-bottom: 4px solid #ffff00;
}

.alto-contraste .header-titulo {
  background: #ffff00;
  color: #000000;
}

.alto-contraste .app-footer {
  background: #000000;
  border-top: 4px solid #ffff00;
}

.alto-contraste .btn-footer {
  color: #ffff00;
  border-color: #ffff00;
}

.alto-contraste .tarjeta-voto,
.alto-contraste .tarjeta-lista,
.alto-contraste .panel-resumen {
  background: #000000;
  border-color: #ffffff;
  color: #ffffff;
}

.alto-contraste .tarjeta-texto,
.alto-contraste .panel-resumen-texto,
.alto-contraste .panel-resumen-titulo {
  color: #ffffff;
}

.alto-contraste .franja-lista {
  background: #ffffff;
  color: #000000;
  border-bottom: 4px solid #000000;
}

.alto-contraste .modal-box {
  background: #000000;
  color: #ffffff;
  border-top: 8px solid #ffff00;
}

.alto-contraste .modal-titulo {
  color: #ffff00;
}

.alto-contraste .indicador-bloque {
  color: #ffffff;
}

/* ===== MODAL EXITO ===== */
#modalExito {
  background: rgba(10, 22, 40, 0.75);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.modal-exito-box {
  background: linear-gradient(160deg, #ffffff 0%, #f3f7ff 100%);
  border-radius: 20px;
  padding: 34px 36px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
}

.modal-exito-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, #27ae60, #2ecc71, #1abc9c, #27ae60);
  background-size: 200% 100%;
  animation: barraBrillo 2.5s linear infinite;
}

@keyframes barraBrillo {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}

.modal-exito-icono {
  width: 74px;
  height: 74px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #27ae60, #1abc9c);
  color: #ffffff;
  font-size: 40px;
  font-weight: 800;
  line-height: 74px;
  box-shadow: 0 10px 24px rgba(39, 174, 96, 0.4);
  animation: latido 1.6s ease-in-out infinite;
}

@keyframes latido {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.modal-exito-titulo {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(90deg, #1e8449, #16a085);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #1e8449;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-exito-mensaje {
  font-size: 15px;
  line-height: 1.6;
  color: #44546a;
  margin-bottom: 22px;
}

.modal-exito-boton {
  background: linear-gradient(135deg, #27ae60, #1abc9c);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 13px 40px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 8px 20px rgba(39, 174, 96, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.modal-exito-boton:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(39, 174, 96, 0.45);
}

.modal-exito-boton:focus-visible {
  outline: 4px solid #1abc9c;
  outline-offset: 2px;
}

.alto-contraste .modal-exito-box {
  background: #000000;
  color: #ffffff;
}

.alto-contraste .modal-exito-mensaje {
  color: #ffffff;
}

.alto-contraste .modal-exito-titulo {
  -webkit-text-fill-color: #ffff00;
  color: #ffff00;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .app-main {
    padding: 8px;
  }

  .grid {
    gap: 8px;
  }

  .tarjeta-voto,
  .tarjeta-lista {
    padding: 6px;
    gap: 6px;
    border-width: 2px;
  }

  .resumen-paneles {
    gap: 8px;
  }

  .panel-acciones {
    flex-direction: row;
  }

  .panel-resumen {
    min-height: auto;
  }

  .header-titulo {
    font-size: 16px;
    text-align: left;
  }
}

@media (max-width: 520px) {
  .app-main {
    padding: 6px;
  }

  .grid {
    gap: 5px;
  }

  .tarjeta-voto,
  .tarjeta-lista {
    padding: 3px;
    gap: 3px;
    border-radius: 4px;
  }

  .grid-2x2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-4x2,
  .grid-4x3 {
    grid-template-columns: repeat(4, 1fr);
  }

  .tarjeta-voto img,
  .tarjeta-lista img {
    width: 100%;
    height: auto;
    object-fit: contain;
  }

  .tarjeta-texto {
    font-size: 8px;
    line-height: 1.2;
  }

  .franja-lista {
    font-size: 11px;
    padding: 5px 8px;
    margin-bottom: 6px;
    letter-spacing: 0;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 12px;
  }

  .header-eleccion {
    font-size: 10px;
  }

  .header-titulo {
    font-size: 12px;
    padding: 4px 8px;
  }

  .app-footer {
    justify-content: center;
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .btn-footer {
    font-size: 12px;
    padding: 6px 12px;
  }

  .panel-resumen {
    min-height: 0;
    height: 150px;
    border-width: 2px;
  }

  .panel-resumen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .panel-acciones {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    height: 150px;
    width: 60%;
    justify-self: center;
  }

  .boton-accion {
    flex: 1;
    width: 100%;
    min-height: 0;
    max-width: none;
    padding: 0;
    border-width: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .boton-accion img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}