/* css/style.css - OPTIMIZED FOR LOCAL PRINT */

:root {
  --bg-dark: #121212;
  --bg-panel: #1e1e1e;
  --bg-card: #262626;
  --bg-header: #181818;
  --bg-input: #333;
  --text-main: #e0e0e0;
  --text-muted: #888;
  --text-label: #aaa;
  --accent: #4caf50;
  --accent-hover: #43a047;
  --danger: #d32f2f;
  --info: #2196f3;
  --border: #333;
  --border-light: #444;
  --type-estado: #455a64;
  --type-ayuda: #2e7d32;
}

body {
  font-family: "Lato", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  margin: 0;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: "Cinzel", serif;
}

.single-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
}

.ra {
  font-family: "RPGAwesome" !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
}

.sidebar {
  width: 320px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 80px;
}

.main-content {
  flex: 1;
  background-color: #1a1a1a;
  padding: 20px;
  overflow-y: hidden;
}

.sidebar-header {
  padding: 15px;
  background-color: var(--bg-header);
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.header-top h1 {
  font-size: 1rem;
  margin: 0;
  color: var(--accent);
  white-space: nowrap;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-help-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabs {
  display: flex;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 5px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 0.8rem;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.tab-content {
  display: none;
  padding: 15px;
}
.tab-content.active {
  display: block;
}

.card-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-panel h3 {
  margin: 0 0 10px 0;
  font-size: 0.9rem;
  color: #ccc;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 5px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.checkbox-container input {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

/* Store / Armeria Deck Styles */
.deck-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 8px;
  margin: 10px 0;
}
.deck-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #ccc;
  transition: color 0.2s;
}
.deck-option:hover {
  color: #fff;
}
.deck-option input {
  cursor: pointer;
  width: 16px;
  height: 16px;
  margin: 0;
}

.form-group {
  margin-bottom: 5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group.flex-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.flex-grow {
  flex-grow: 1;
}
.full-width {
  width: 100%;
  box-sizing: border-box;
}
select,
input {
  background: var(--bg-input);
  color: #fff;
  border: 1px solid var(--border-light);
  padding: 8px;
  border-radius: 4px;
}

.btn-primary {
  background: #2e7d32;
  color: #fff;
  border: none;
  padding: 8px 12px;
  width: 100%;
  cursor: pointer;
  font-weight: bold;
  border-radius: 6px;
  transition: all 0.2s;
}
.btn-primary:hover:not(:disabled) {
  background: #388e3c;
}
.btn-primary:disabled {
  background: #333;
  color: #666;
}

.btn-secondary {
  background: #1565c0;
  color: #fff;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-weight: bold;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: #1976d2;
}

.btn-danger {
  background: #c62828;
  color: #fff;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  font-weight: bold;
  transition: all 0.2s;
}
.btn-danger:hover {
  background: #d32f2f;
}

.btn-success {
  background: #2e7d32;
  color: #fff;
  border: none;
  padding: 8px 12px;
  width: 100%;
  cursor: pointer;
  font-weight: bold;
  border-radius: 6px;
  transition: all 0.2s;
}
.btn-success:hover {
  background: #388e3c;
}

.btn-action {
  background: var(--info);
  color: #fff;
  border: none;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.7rem;
}

.bag-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  align-items: center;
  padding-top: 5px;
  overflow-y: auto; /* Permitir scroll en pantallas pequeñas */
  padding-bottom: 100px;
}

.bag-intro {
  text-align: center;
  margin-top: 10px;
}

.bag-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.main-bag-img {
  width: 150px;
  height: auto;
  object-fit: contain;
  margin-bottom: 5px;
}

.bag-header {
  width: 100%;
  color: #777; /* Gris bonito */
  text-align: center;
  margin-bottom: 30px;
}
.bag-header h2 {
  font-family: "Cinzel", serif;
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: 4px;
  text-transform: uppercase;
}
#bagCount {
  font-size: 0.8rem;
  color: #555;
  display: block;
  margin-top: 8px;
  font-style: italic;
}

.bag-count-badge {
  background-color: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  vertical-align: middle;
  margin-left: 5px;
  font-family: "Lato", sans-serif;
}

.bag-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, #444, #444, transparent);
  margin: 20px 0;
}

/* Estilos de Bolsa de Selección */
#selectedItems {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 1200px;
  min-height: 50px;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto; /* Scroll interno */
}

/* Ocultar scroll lateral si no hay suficientes tarjetas para llenar las 4 columnas */
#selectedItems:empty {
  overflow-y: hidden;
}

.bag-item {
  background: #2a2a2a; /* Fondo sólido más visible */
  border: 1px solid #444; /* Borde más visible */
  padding: 8px 15px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
  color: #e0e0e0; /* Texto claro */
  min-height: 40px; /* Altura mínima garantizada */
  width: 100%; /* Ancho completo */
  box-sizing: border-box; /* Incluir padding en el ancho */
  flex-shrink: 0; /* Evitar que se encojan */
}
.bag-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #444;
}

.bag-item-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
  min-width: 0; /* Permite que el texto se trunque */
}

.bag-item-title {
  color: #bbb;
  font-size: 0.85rem;
  font-family: "Cinzel", serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
}

.bag-item-type {
  display: none; /* Etiqueta de tipo eliminada a petición */
}

.remove-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 5px;
  transition: color 0.2s;
  flex-shrink: 0;
}
.remove-btn:hover {
  color: var(--danger);
}

/* --- PANTALLAS MODALES --- */
.loading-overlay,
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.loader-content {
  text-align: center;
  color: var(--accent);
}
.d20-spinner img {
  width: 80px;
  height: 80px;
  animation: spin 2s linear infinite;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  position: relative;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}
.close-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}
.help-steps {
  display: grid;
  gap: 15px;
  margin: 20px 0;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}
.step-number {
  background: var(--accent);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}
.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dont-show-again {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* Botón flotante Donación - RESTAURADO Y DISCRETO */
.donation-btn {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: #000;
  color: #ffca28;
  border: 1px solid #ffca28;
  padding: 6px 12px;
  border-radius: 20px;
  text-decoration: none;
  font-family: "Cinzel", serif;
  font-size: 0.65rem;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
  transition: all 0.3s ease;
  z-index: 1000;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.donation-btn:hover {
  background: #111;
  border-color: #ffd54f;
  color: #ffd54f;
  transform: translateY(-2px);
}
.donation-content {
  display: flex;
  align-items: center;
  gap: 6px;
}

.donation-icon {
  display: inline-block;
  font-size: 1.1rem;
  animation: beer-float 2s ease-in-out infinite;
}

@keyframes beer-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* --- DISEÑO DE TARJETAS (PRINT) --- */
.card-face {
  width: 62mm;
  height: 88mm;
  border: 1px solid #000;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: white;
  position: relative;
  padding: 0;
  page-break-inside: avoid;
}

.card-header {
  background-color: #333;
  color: white;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 8mm;
  box-sizing: border-box;
  border-bottom: 1px solid #000;
}

.icon-circle {
  display: none;
}

.card-header h2 {
  font-size: 9pt;
  margin: 0;
  flex-grow: 1;
  font-family: "Cinzel", serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* Modificador específico para el título de tarjetas manuales (Especie, Clase, etc.) */
.manual-card-header {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important; /* Quitar padding para aprovechar el espacio centrado */
}

.manual-card-header h2 {
  font-size: 11pt !important; /* Más grande pero sin desbordar */
  text-align: center !important;
  width: 100%;
  flex-grow: 0 !important;
  line-height: 1 !important; /* Elimina espacio vertical extra que empuja hacia arriba */
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
}

.level-badge {
  background-color: white;
  color: #333;
  padding: 0px 3px;
  border-radius: 2px;
  font-size: 6pt;
  font-weight: bold;
  white-space: nowrap;
}

.level-badge-inline {
  background-color: rgba(255, 255, 255, 0.9);
  color: #333;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 6pt;
  font-weight: bold;
  text-transform: uppercase;
  position: absolute;
  bottom: 2px;
  right: 2px;
  border: 1px solid #ccc;
  pointer-events: none;
}

.card-body {
  padding: 4px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.card-image-container {
  width: 100%;
  height: 28mm;
  border: 1px solid #ccc;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 2px;
  flex-shrink: 0;
}
.card-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Modificador estricto para tarjetas manuales (4x4 cm) */
.manual-card-image {
  width: 40mm !important;
  height: 40mm !important;
  margin: 0 auto 2px auto !important; /* Centrado horizontalmente */
}

/* Estilos para el Modo de Previsualización en Vivo */
#preview-section {
  display: none;
  flex: 1;
  background-color: #1f1f1f;
  border-radius: 8px;
  padding: 20px;
  margin-left: 20px;
  border: 1px dashed var(--border-light);
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
}

#preview-section h2 {
  color: var(--accent);
  margin-top: 0;
  margin-bottom: 20px;
  text-align: center;
  font-size: 1.5rem;
}

.live-preview-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.preview-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.preview-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Ajustes de layout cuando el preview está activo */
.main-content.preview-active {
  display: flex;
  flex-direction: row;
}

.main-content.preview-active #bag-container {
  width: 300px;
  flex: none;
  border-right: 1px solid var(--border);
  padding-right: 20px;
}

.main-content.preview-active #selectedItems {
  grid-template-columns: 1fr; /* Una sola columna para la bolsa si está el preview */
}

.card-description {
  font-size: 9pt;
  line-height: 1.15;
  text-align: left;
  color: #000;
  flex-grow: 1;
}

/* Colores específicos por tipo */
.type-clase {
  background-color: #1a237e;
} /* Azul oscuro */
.card-header.type-clase {
  background-color: #1a237e;
}
.type-especie {
  background-color: #1b5e20;
} /* Verde oscuro */
.card-header.type-especie {
  background-color: #1b5e20;
}
.type-trasfondo {
  background-color: #bf360c;
} /* Naranja quemado */
.card-header.type-trasfondo {
  background-color: #bf360c;
}
.type-dote {
  background-color: #4a148c;
} /* Morado */
.card-header.type-dote {
  background-color: #4a148c;
}
.type-maestria {
  background-color: #3e2723;
} /* Café */
.card-header.type-maestria {
  background-color: #3e2723;
}
.type-arma {
  background-color: #b71c1c;
} /* Rojo */
.card-header.type-arma {
  background-color: #b71c1c;
}
.type-armadura {
  background-color: #263238;
} /* Gris azulado */
.card-header.type-armadura {
  background-color: #263238;
}
.type-escudo {
  background-color: #455a64;
} /* Gris */
.card-header.type-escudo {
  background-color: #455a64;
}
.type-item {
  background-color: #00bcd4;
} /* Celeste */
.card-header.type-item {
  background-color: #00bcd4;
}
.type-pack {
  background-color: #006064;
} /* Cyan oscuro */
.card-header.type-pack {
  background-color: #006064;
}
.type-estado {
  background-color: var(--type-estado);
}
.card-header.type-estado {
  background-color: var(--type-estado);
}
.type-referencia {
  background-color: var(--type-ayuda);
}
.card-header.type-referencia {
  background-color: var(--type-ayuda);
}

/* Listas compactas */
.compact-list {
  margin: 0;
  padding-left: 12px;
}
.compact-list li {
  margin-bottom: 0;
}

/* Bloques de rasgos (Detalles de clase) */
.feature-block {
  margin-bottom: 1mm;
}
.feature-block h4 {
  margin: 0;
  font-size: 8.5pt;
  border-bottom: 1px solid #ddd;
  padding-bottom: 0;
  color: #000;
  line-height: 1.2;
}
.feature-block p {
  margin: 0.5mm 0 0 0;
  font-size: 8pt;
  line-height: 1.1;
  font-family: "Lato", sans-serif;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  padding-bottom: 1px;
  margin-bottom: 1px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1mm;
  border-bottom: 1px solid #eee;
  padding-bottom: 2px;
  margin-bottom: 2px;
  font-size: 7.5pt;
  line-height: 1.1;
}

#printArea {
  display: none;
}

/* --- PNJ / COMPAÑERO CARD STYLES --- */
.card-face.pnj {
  padding: 2mm 3mm;
  display: flex !important;
  flex-direction: column !important;
  background-color: #fdfaf3;
  background-image: url("https://www.transparenttextures.com/patterns/parchment.png");
  border: 1px solid #5d4037;
}

/* FRONT FACE */
.pnj-front-title {
  font-family: "Cinzel", serif;
  font-size: 14pt;
  font-weight: 800;
  color: #3e2723;
  text-align: center;
  margin-bottom: 2mm;
  border-bottom: 2px solid #7b1d1d;
}

.pnj-front-image {
  flex-grow: 1;
  width: 100%;
  aspect-ratio: 3/4; /* User requested 3:4 */
  object-fit: cover;
  border: 1px solid #8d6e63;
  box-shadow: 0 0 2mm rgba(0, 0, 0, 0.2);
}

/* BACK FACE */
.pnj-header-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2mm;
}

.pnj-text-group {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding-top: 1mm;
}

.pnj-squares-group {
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}

.pnj-back-title {
  font-family: "Cinzel", serif;
  font-size: 14pt; /* Mas grande */
  font-weight: 800;
  color: #7b1d1d;
  margin: 0;
  line-height: 1;
}

.pnj-back-info-text {
  font-size: 9pt; /* Mas grande */
  font-style: italic;
  font-family: "Georgia", serif;
  color: #000;
  line-height: 1.1;
  margin-top: 1mm;
}

.pnj-square-stat {
  width: 10mm;
  height: 10mm;
  border: 2px solid #7b1d1d;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pnj-square-label {
  font-size: 5pt;
  font-weight: 900;
  color: #7b1d1d;
  line-height: 1;
}

.pnj-square-val {
  font-size: 9pt;
  font-weight: 900;
  color: #000;
}

.pnj-columns {
  display: grid;
  grid-template-columns: 25% 75%;
  flex-grow: 1;
  gap: 2mm;
  overflow: hidden;
}

.pnj-stats-column {
  display: flex;
  flex-direction: column;
  gap: 1mm;
}

.pnj-stat-row-compact {
  display: flex;
  align-items: center;
  background: rgba(141, 110, 99, 0.1);
  border: 0.5px solid #8d6e63;
  padding: 0.5mm 1mm;
  height: 7.5mm;
}

.pnj-stat-letter {
  font-size: 7pt;
  font-weight: 900;
  color: #7b1d1d;
  width: 5mm;
  border-right: 1px solid #8d6e63;
  margin-right: 1mm;
}

.pnj-stat-number {
  font-size: 8pt;
  font-weight: bold;
  color: #000;
  flex-grow: 1;
  text-align: center;
}

.pnj-desc-column {
  font-size: 8pt;
  line-height: 1.1;
  font-family: "Georgia", serif;
  text-align: justify;
  border: 0.5px solid #8d6e63; /* Marco delgadito */
  padding: 1.5mm;
  background: white;
  min-height: 60mm; /* Asegura que el marco se vea */
}

/* --- ESTILOS FORMULARIO CREADOR --- */
.pnj-stats-input-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 20px;
}

.form-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
}

.form-stat-row label {
  font-weight: bold;
  color: var(--text-label);
  font-size: 0.85rem;
}

.form-stat-row input {
  width: 50px;
  text-align: right;
  padding: 4px;
}

.pnj-header-stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  background: var(--bg-header);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

.pnj-header-stat-item {
  flex: 1;
  margin: 0;
  text-align: center;
}

.pnj-header-stat-item label {
  font-weight: bold;
  font-size: 0.75rem;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.pnj-header-stat-item input {
  text-align: center;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 4px;
  font-weight: bold;
  width: 100%;
}

/* --- IMPRESIÓN --- */
@media print {
  @page {
    size: letter landscape;
    margin: 10mm;
  }

  .vertical-page {
    size: letter landscape !important;
  }
  body {
    background: white !important;
    color: black !important;
    overflow: visible !important;
    display: block !important;
    margin: 0;
    padding: 0;
  }
  body > *:not(#printArea) {
    display: none !important;
  }

  #printArea {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-page {
    display: grid;
    grid-template-columns: repeat(4, 6.2cm);
    gap: 0;
    padding: 0;
    margin: 0 auto;
    page-break-after: auto;
    justify-content: center;
    align-content: start;
  }

  .fold-unit {
    width: 6.2cm;
    height: 17.6cm;
    display: flex;
    flex-direction: column;
    border: 0.1mm solid #eee;
    page-break-inside: avoid;
    box-sizing: border-box;
  }
  .card-face {
    width: 6.2cm;
    height: 8.8cm;
    padding: 2mm 3mm 3mm 3mm;
    border: 1px solid #000;
    border-radius: 2mm;
    position: relative;
    background: white;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    page-break-inside: avoid;
  }
  .card-back {
    transform: rotate(180deg);
  }
  .card-face.pnj.monster-tent {
    transform: rotate(180deg);
  }

  .card-header {
    background-color: #333;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color: white;
    margin: -2mm -3mm 2mm -3mm;
    padding: 2.5mm 3mm 2.5mm 3mm;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: "Cinzel", serif;
    min-height: 7mm;
  }
  .card-header h2 {
    font-size: 10pt;
    margin: 0;
    line-height: 1.2;
    flex-grow: 1;
    text-align: center;
    /* Permitir envolver en 2 filas */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    width: 100%;
    /* Centrado vertical extra por si acaso */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 4mm;
  }
  .card-header .level-badge {
    position: relative;
    top: auto;
    right: auto;
    font-size: 7pt;
    background: white;
    color: black;
    padding: 0.2mm 1mm;
    border-radius: 2px;
    font-weight: bold;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
    z-index: 10;
    margin-left: 2mm;
  }
  .card-header .icon-circle {
    display: none; /* Ahorrar espacio en header */
  }

  .level-badge-inline {
    position: absolute;
    bottom: 1mm;
    right: 1mm;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5mm 1.5mm;
    font-size: 7pt;
    border-radius: 2px;
    font-weight: bold;
    z-index: 5;
    text-transform: uppercase;
  }

  .card-body {
    font-family: "Lato", sans-serif;
    font-size: 9pt;
    flex-grow: 1;
    line-height: 1.25;
    color: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .card-body p {
    margin: 0;
  }
  .feature-block {
    margin-bottom: 1.5mm !important;
  }
  .feature-block h4 {
    margin: 0 !important;
    line-height: 1.1 !important;
    border-bottom: 1px solid #ccc !important;
  }
  .feature-block p {
    margin: 0.2mm 0 0 0 !important;
    line-height: 1.1 !important;
    font-family: "Lato", sans-serif !important;
  }

  .card-image-container {
    width: 100%;
    height: 2.8cm; /* Altura fija contenida */
    margin-bottom: 2mm;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    border: 1px solid #ccc;
    overflow: hidden;
    flex-shrink: 0;
  }

  .card-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Evita zoom excesivo y cortes */
  }

  .card-description {
    flex-grow: 1;
    overflow: hidden;
  }

  .stat-block {
    display: flex;
    justify-content: space-between;
    background: #f0f0f0;
    border: 1px solid #999;
    padding: 1.5mm;
    font-weight: bold;
    font-size: 10pt;
    margin-bottom: 2mm;
    border-radius: 4px;
    color: #000;
  }

  .lined-paper {
    background-image: repeating-linear-gradient(
      white 0px,
      white 24px,
      #00b0ff 25px
    );
    flex-grow: 1;
    margin: -3mm;
    margin-top: 0;
  }
}
