/* =========================================
   VARIABLES Y ESTILOS BASE
   ========================================= */
:root {
  --sketch-font: 'Gloria Hallelujah', cursive, sans-serif;
  --bg-color: #f0f0f0;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%; 
}

body {
  font-family: sans-serif;
  background: var(--bg-color);
  background-image: radial-gradient(#d7d7d7 1px, transparent 1px);
  background-size: 20px 20px;
  padding: 20px;
  display: flex; 
  justify-content: center;
  box-sizing: border-box;
}

.main-container { 
  max-width: 950px; 
  width: 100%; 
}

h1 { 
  text-align: center; 
  font-family: var(--sketch-font);
  margin-top: 0;
  font-size: 1.8rem;
}

.generator-layout { 
  display: flex; 
  gap: 40px; 
  flex-wrap: wrap; 
  justify-content: center; 
  align-items: flex-start;
}

/* =========================================
   FORMULARIO (Panel Izquierdo)
   ========================================= */
.form-panel {
  flex: 1; 
  min-width: 300px; 
  max-width: 400px;
  background: #fff; 
  padding: 25px;
  border: 4px solid #000; 
  box-shadow: 8px 8px 0 #000;
  border-radius: 4px;
}

.input-group { margin-bottom: 20px; }
label { display: block; font-weight: bold; margin-bottom: 8px; font-family: var(--sketch-font); }

input[type="text"] {
  width: 100%; 
  padding: 10px; 
  border: 2px solid #000;
  font-family: var(--sketch-font); 
  font-size: 1.1rem; 
  box-sizing: border-box; 
  background: #fafafa;
}

.radio-options { display: flex; gap: 15px; flex-wrap: wrap; }
.radio-btn { cursor: pointer; display: flex; align-items: center; gap: 5px; }

.action-btn {
  width: 100%; 
  padding: 15px; 
  background: #000; 
  color: #fff; 
  border: none;
  font-family: var(--sketch-font); 
  font-size: 1.2rem; 
  cursor: pointer;
  transition: transform 0.1s;
}
.action-btn:active { transform: scale(0.98); }

/* =========================================
   EL CARNET (Panel Derecho - Preview)
   ========================================= */
.preview-panel { 
  display: flex; 
  justify-content: center; 
  align-items: flex-start;
  padding: 10px; 
}

.sketch-carnet {
  width: 450px; 
  height: 315px; 
  position: relative;
  background: #fff; 
  overflow: hidden;
  border: 4px solid #000; 
  box-shadow: 10px 10px 0 rgba(0,0,0,0.15); 
  flex-shrink: 0; 
}

.bg-layer { width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 0; }

.sketch-text {
  position: absolute;
  font-family: var(--sketch-font);
  color: #000;
  line-height: 0.9;
  text-transform: uppercase;
  z-index: 10;
}

/* Posiciones */
.text-carnet { top: 55px; left: 20px; font-size: 2.7rem; transform: rotate(-2deg); }
.text-de { top: 100px; left: 110px; font-size: 2.5rem; transform: rotate(1deg); }
.text-ofendido {
  top: 145px; 
  left: 15px;
  font-size: 2.2rem; 
  font-weight: bold;
  transform: rotate(-1deg);
  white-space: nowrap;
}

/* Datos Usuario (Posición absoluta) */
.data-nick {
  position: absolute; 
  top: 210px;         
  left: 15px; 
  right: 25px;        
  text-align: right;  
  font-size: 1.4rem; 
  color: #000;
  white-space: nowrap; 
  overflow: hidden;    
  text-overflow: ellipsis; 
  transform: rotate(-1deg);
  text-shadow: 2px 2px 0px #fff; 
  z-index: 15;
}

.data-num-row {
  position: absolute; 
  top: 255px;         
  right: 25px;        
  left: 15px;         
  text-align: right;
  font-family: var(--sketch-font);
  font-size: 1rem;
  font-weight: bold;
  transform: rotate(1deg); 
  z-index: 15;
}

/* Avatar y Fecha */
.avatar-area {
  position: absolute;
  top: 25px; right: 25px;
  width: 140px;
  z-index: 5;
}

.avatar-sketch-container {
  width: 135px; 
  height: 135px;
  position: relative;
  overflow: visible; /* Dejamos que respire */
  background: transparent;
}

/* Clase genérica para las capas (cara y pelo) */
.layer {
  width: 100%; 
  height: 100%; 
  position: absolute; 
  top: 0; 
  left: 0;
  /* LA MAGIA: Esto obliga a la imagen a entrar en el cuadro perfectamente */
  background-size: contain; 
  background-repeat: no-repeat;
  background-position: center bottom; /* Alineado abajo al centro */
}

/* Acá definimos las imágenes */
.face-bg {
  background-image: url('assets/carnet/cara-sketch.svg');
}

.hair-bg {
  background-image: url('assets/carnet/pelo-extra.svg');
}

.hidden { display: none; }
.avatar-layer { width: 100%; height: 100%; position: absolute; object-fit: contain; }
.hidden { display: none; }

.date-text {
  position: absolute;
  top: 115px; right: -10px;
  z-index: 20;
  font-size: 0.85rem;
  font-weight: bold;
  font-family: sans-serif;
  letter-spacing: 1px;
  color: #000;
  transform: rotate(-15deg);
  border: 2px solid #000;
  padding: 3px 6px;
  background: rgba(255,255,255,0.95);
}

/* =========================================
   RESPONSIVE (CELULARES)
   ========================================= */
@media (max-width: 600px) {
  
  body {
    padding: 10px 0; /* Sin padding lateral en body */
    display: block; 
  }

  h1 { font-size: 1.5rem; margin-bottom: 20px; }

  .generator-layout {
    gap: 30px;
    width: 100%;
  }

  /* --- EL CAMBIO QUE NECESITÁS --- */
  .form-panel {
    width: 90% !important; /* Forzamos el 90% */
    max-width: 90% !important;
    margin: 0 auto 30px auto !important; /* Centrado */
    min-width: 0; /* Permite achicarse */
    box-sizing: border-box;
    box-shadow: 5px 5px 0 #000;
  }
  /* ------------------------------- */

  .preview-panel {
    width: 100%;
    padding: 0;
    margin-bottom: 40px; 
    overflow: visible; 
  }

  .sketch-carnet {
    transform: scale(0.68); 
    transform-origin: top center; 
    margin-bottom: -100px; 
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 380px) {
  .sketch-carnet {
    transform: scale(0.63); 
    margin-bottom: -110px;
  }
}