/* 🌌 Estilo general */
body {
  background: radial-gradient(circle at center, #011314, #001820);
  color: #00ffcc;
  font-family: 'Share Tech Mono', monospace;
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.wrap {
  width: 90%;
  max-width: 800px;
  background: rgba(10, 10, 10, 0.9);
  border: 2px solid #00ffcc;
  border-radius: 12px;
  box-shadow: 0 0 25px #00ffcc55;
  overflow: hidden;
  animation: flicker 3s infinite alternate;
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: scale(0.7);
  animation:
    zoomInWrap 0.7s ease-out forwards 2.5s, /* empieza tras el viaje */
    flicker 2s infinite alternate 3.2s; /* flicker tras zoom */
}

@keyframes flicker {
  from { box-shadow: 0 0 20px #00ffcc66; }
  to { box-shadow: 0 0 40px #00ffccaa; }
}

@keyframes zoomInWrap {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

header {
  background: linear-gradient(90deg, #00ffcc44, #0066ff44);
  border-bottom: 1px solid #00ffcc;
  padding: 15px;
  text-align: center;
  text-shadow: 0 0 8px #00ffff;
}

header h1 {
  font-size: 1.6em;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #00ffff;
}

#server {
  font-size: 0.9em;
  color: #aaffff;
  margin-top: 5px;
  opacity: 0.8;
}

#chat {
  padding: 20px;
  height: 400px;
  overflow-y: auto;
  background: rgba(0, 20, 20, 0.6);
  border-top: 1px solid #00ffcc44;
  border-bottom: 1px solid #00ffcc44;
  scrollbar-width: thin;
  scrollbar-color: #00ffcc66 transparent;
}

#chat::-webkit-scrollbar {
  width: 8px;
}

#chat::-webkit-scrollbar-track {
  background: transparent;
}

#chat::-webkit-scrollbar-thumb {
  background-color: #00ffcc66;
  border-radius: 4px;
  border: 2px solid transparent;
}

.msg {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 8px;
  max-width: 98%;
  width: fit-content;
  line-height: 1.4em;
  word-wrap: break-word;
  box-sizing: border-box;
  font-size: 1rem;
  user-select: text;
  white-space: pre-wrap; /* Mantener saltos de línea */
}

.msg.user {
  background: #00ffcc22;
  border: 1px solid #00ffcc;
  align-self: flex-end;
  text-align: right;
  color: #00ffcc;
}

.msg.ai {
  background: #003333;
  border: 1px solid #00ffff66;
  text-align: left;
  color: #aaffff;
  box-shadow: 0 0 10px #00ffff33;
}

#inputBox {
  display: flex;
  border-top: 1px solid #00ffcc44;
  background: rgba(0, 20, 20, 0.7);
}

#texto {
  flex: 1;
  padding: 12px;
  background: #001111;
  color: #00ffff;
  border: none;
  font-family: inherit;
  font-size: 1em;
  outline: none;
  transition: background-color 0.3s;
}

#texto::placeholder {
  color: #00ffcc88;
}

#texto:focus {
  background-color: #004444;
}

button {
  background: linear-gradient(90deg, #00ffff55, #00ffcc);
  border: none;
  padding: 12px 18px;
  color: #001010;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 0 0 5px #00ffff;
  transition: all 0.2s;
}

button:hover {
  background: #00ffff;
  color: #000;
  transform: scale(1.05);
}

/* Animación campo de estrellas */
.starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: black;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.starfield::before, .starfield::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  background: #00ffcc;
  box-shadow:
    100px 200px #00ffcc,
    -150px -100px #00ffcc,
    200px -150px #00ffcc,
    -250px 150px #00ffcc,
    300px 100px #00ffcc,
    150px 250px #00ffcc,
    -200px -180px #00ffcc,
    250px -230px #00ffcc,
    -300px 210px #00ffcc,
    350px 140px #00ffcc;
  animation: starsMove 2.5s linear forwards;
  transform-origin: center;
  width: 2px;
  height: 2px;
}

.starfield::after {
  width: 1px;
  height: 1px;
  background: #0066ff;
  box-shadow:
    80px 160px #0066ff,
    -120px -80px #0066ff,
    160px -120px #0066ff,
    -200px 120px #0066ff,
    240px 80px #0066ff,
    180px 300px #0066ff,
    -210px -160px #0066ff,
    270px -200px #0066ff,
    -320px 180px #0066ff,
    370px 120px #0066ff;
  animation-delay: 1.25s;
  animation-duration: 2.5s;
}

@keyframes starsMove {
  to {
    transform: translate3d(0, 0, 50vw) scale(15);
    opacity: 0;
  }
}
