/* Reset y base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: 'Segoe UI', 'Roboto', 'SF Pro Display', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* Intro overlay */
.intro-overlay {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #232526 0%, #414345 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  padding: 20px;
}

.intro-card {
  max-width: 500px;
  width: 100%;
  padding: 40px 30px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.intro-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  line-height: 1.2;
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-desc {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 30px;
  opacity: 0.9;
}

.intro-btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 15px 40px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.intro-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.debug-btn {
  background: linear-gradient(45deg, #ff6b6b, #ee5a52);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 30px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
  width: 100%;
  margin-top: 10px;
}

.debug-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

/* Game container */
.game-container {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 15px 25px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffd700;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.audio-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.volume-slider {
  width: 80px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd700;
  cursor: pointer;
}

/* Main game area */
.game-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 25px;
  min-height: 0;
}

/* Scene container */
.scene-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.image-wrapper {
  width: 100%;
  height: 300px;
  overflow: hidden;
  flex-shrink: 0;
}

.scene-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.scene-img:hover {
  transform: scale(1.05);
}

.text-wrapper {
  padding: 25px 30px;
  max-height: 40vh;
  overflow-y: auto;
}

.scene-text {
      font-size: 1.2rem;
      line-height: 1.7;
      text-align: center;
      min-height: 80px;
      /* display: flex; */
      align-items: center;
      justify-content: center;
      word-wrap: break-word;
      overflow-wrap: break-word;
      max-height: 40vh;
      overflow-y: auto;
}

@media (max-width: 767px) {
  .text-wrapper, .scene-text {
    max-height: 32vh;
  }
}
@media (max-width: 480px) {
  .text-wrapper, .scene-text {
    max-height: 28vh;
  }
}

/* Estilos para texto enriquecido */
.scene-text b {
  font-weight: 700;
  color: #ffd700;
}

.scene-text i {
  font-style: italic;
  color: #87ceeb;
}

.scene-text u {
  text-decoration: underline;
  color: #98fb98;
}

.scene-text br {
  line-height: 1.5;
}

/* Options container */
.options-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 25px 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.options-title {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: #ffd700;
  font-weight: 600;
}

.options-grid {
  display: grid;
  gap: 12px;
}

.option {
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 15px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.option::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.option:hover {
  transform: translateY(-2px);
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15));
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.option:hover::before {
  left: 100%;
}

.option:active {
  transform: translateY(0);
}

/* Desktop layout */
@media (min-width: 768px) {
  .game-main {
    grid-template-columns: 2fr 1fr;
    gap: 30px;
  }
  
  .image-wrapper {
    height: 400px;
  }
  
  .scene-text {
    font-size: 1.3rem;
    min-height: 120px;
  }
  
  .options-grid {
    grid-template-columns: 1fr;
  }
  
  .option {
    padding: 18px 25px;
    font-size: 1.1rem;
  }
}

@media (min-width: 1024px) {
  .game-container {
    padding: 30px;
  }
  
  .image-wrapper {
    height: 450px;
  }
  
  .scene-text {
    font-size: 1.4rem;
    min-height: 140px;
  }
  
  .options-grid {
    gap: 15px;
  }
}

/* Mobile optimizations */
@media (max-width: 767px) {
  .game-container {
    padding: 10px;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
  }
  
  .game-header {
    flex-direction: row;
    gap: 10px;
    text-align: left;
    padding: 10px 15px;
    margin-bottom: 10px;
    min-height: auto;
  }
  
  .game-title {
    font-size: 1.2rem;
  }
  
  .game-main {
    gap: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
  }
  
  .scene-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  
  .intro-card {
    padding: 20px 20px;
    margin: 15px;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .intro-title {
    font-size: 1.8rem;
    margin-bottom: 15px;
  }
  
  .intro-desc {
    font-size: 0.95rem;
    margin-bottom: 20px;
    line-height: 1.5;
  }
  
  .image-wrapper {
    height: 180px;
    flex-shrink: 0;
  }
  
  .text-wrapper {
    padding: 15px 20px;
    flex: 1;
    min-height: 0;
  }
  
  .scene-text {
    font-size: 1.15rem;
    line-height: 1.5;
    min-height: 60px;
    max-height: none;
    overflow-y: auto;
    text-align: left;
    padding: 10px 0;
  }
  
  .options-container {
    padding: 15px 20px;
    flex-shrink: 0;
    max-height: 40vh;
    overflow-y: auto;
  }
  
  .options-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }
  
  .option {
    padding: 12px 15px;
    font-size: 1.05rem;
    margin-bottom: 8px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }
  
  /* Ajustes específicos para texto enriquecido */
  .scene-text b {
    font-weight: 700;
    color: #ffd700;
  }
  
  .scene-text i {
    font-style: italic;
    color: #87ceeb;
  }
  
  .scene-text u {
    text-decoration: underline;
    color: #98fb98;
  }
  
  /* Asegurar que el contenido no se desborde */
  .scene-text * {
    max-width: 100%;
    word-wrap: break-word;
  }
}

/* Para pantallas muy pequeñas */
@media (max-width: 480px) {
  .game-container {
    padding: 8px;
  }
  
  .game-header {
    padding: 8px 12px;
    margin-bottom: 8px;
  }
  
  .game-title {
    font-size: 1.1rem;
  }
  
  .image-wrapper {
    height: 150px;
  }
  
  .text-wrapper {
    padding: 12px 15px;
  }
  
  .scene-text {
    font-size: 1.05rem;
    min-height: 50px;
    line-height: 1.4;
  }
  
  .options-container {
    padding: 12px 15px;
    max-height: 45vh;
  }
  
  .options-title {
    font-size: 1rem;
    margin-bottom: 10px;
  }
  
  .option {
    padding: 10px 12px;
    font-size: 1rem;
    margin-bottom: 6px;
  }
  
  .intro-card {
    padding: 15px 18px;
    margin: 10px;
  }
  
  .intro-title {
    font-size: 1.6rem;
  }
  
  .intro-desc {
    font-size: 0.9rem;
  }
}

/* Animaciones adicionales */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scene-container,
.options-container {
  animation: fadeIn 0.5s ease-out;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Game Over Screen Styles */
.gameover-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  overflow-y: auto;
  padding: 20px;
}

.gameover-content {
  max-width: 600px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  padding: 40px 30px;
  text-align: center;
  color: white;
  animation: gameoverSlideIn 1s ease-out;
}

@keyframes gameoverSlideIn {
  from {
    opacity: 0;
    transform: translateY(50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gameover-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: titlePulse 2s ease-in-out infinite;
}

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

.gameover-subtitle {
  font-size: 1.2rem;
  margin-bottom: 30px;
  opacity: 0.9;
}

.gameover-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  min-width: 120px;
  transition: transform 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-5px);
}

.stat-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.stat-text {
  font-size: 0.9rem;
  font-weight: 600;
}

.gameover-thanks {
  margin-bottom: 30px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
}

.gameover-thanks h2 {
  margin-bottom: 15px;
  color: #ffd700;
}

.gameover-thanks p {
  line-height: 1.6;
  opacity: 0.9;
}

.gameover-credits {
  margin-bottom: 30px;
  text-align: left;
}

.gameover-credits h3 {
  text-align: center;
  margin-bottom: 20px;
  color: #87ceeb;
}

.credits-list {
  display: grid;
  gap: 10px;
}

.credit-item {
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border-left: 4px solid #25d366;
}

.credit-item strong {
  color: #ffd700;
}

.gameover-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.restart-btn, .credits-btn {
  padding: 15px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 180px;
}

.restart-btn {
  background: linear-gradient(45deg, #25d366, #20c997);
  color: white;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
}

.credits-btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.credits-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.gameover-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 20px;
  opacity: 0.8;
}

.gameover-footer p {
  margin-bottom: 5px;
}

.version {
  font-size: 0.8rem;
  opacity: 0.6;
  font-family: monospace;
}

/* Mobile optimizations for Game Over */
@media (max-width: 767px) {
  .gameover-content {
    padding: 30px 20px;
    margin: 10px;
    max-height: 95vh;
    overflow-y: auto;
  }
  
  .gameover-title {
    font-size: 2rem;
  }
  
  .gameover-subtitle {
    font-size: 1rem;
  }
  
  .gameover-stats {
    flex-direction: column;
    align-items: center;
  }
  
  .stat-item {
    width: 100%;
    max-width: 200px;
  }
  
  .gameover-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .restart-btn, .credits-btn {
    width: 100%;
    max-width: 250px;
  }
  
  .credits-list {
    gap: 8px;
  }
  
  .credit-item {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

/* WhatsApp Chat Styles */
.whatsapp-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #e5ddd5;
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  z-index: 2000;
}

.whatsapp-header {
  background: #075e54;
  color: white;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #25d366;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.contact-info {
  display: flex;
  flex-direction: column;
}

.contact-name {
  font-weight: 600;
  font-size: 1rem;
}

.contact-status {
  font-size: 0.8rem;
  opacity: 0.8;
}

.back-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.back-btn:hover {
  background: rgba(255,255,255,0.2);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23e5ddd5"/><circle cx="20" cy="20" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="80" cy="20" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="50" cy="50" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="20" cy="80" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="80" cy="80" r="1" fill="%23ffffff" opacity="0.1"/></svg>');
  background-size: 200px 200px;
}

.message {
  margin-bottom: 12px;
  display: flex;
  animation: messageSlideIn 0.3s ease-out;
}

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

.message.bot {
  justify-content: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 18px;
  position: relative;
  word-wrap: break-word;
}

.message.bot .message-bubble {
  background: white;
  color: #303030;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.user .message-bubble {
  background: #dcf8c6;
  color: #303030;
  border-bottom-right-radius: 4px;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.message.bot .message-time {
  text-align: left;
}

.audio-message {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 10px;
  border-radius: 18px;
  min-width: 200px;
}

.audio-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #25d366;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.2s ease;
}

.audio-play-btn:hover {
  background: #1da851;
}

.audio-info {
  flex: 1;
}

.audio-duration {
  font-size: 0.9rem;
  color: #666;
}

.audio-transcript {
  font-size: 0.8rem;
  color: #888;
  margin-top: 4px;
  font-style: italic;
}

.image-message {
  max-width: 250px;
  border-radius: 12px;
  overflow: hidden;
}

.image-message img {
  width: 100%;
  height: auto;
  display: block;
}

.image-caption {
  padding: 8px 12px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.9rem;
}

.user-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px;
  background: white;
  border-top: 1px solid #ddd;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.option-btn {
  background: #f0f0f0;
  border: 2px solid #25d366;
  padding: 15px 20px;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  color: #333;
  font-size: 1rem;
  font-weight: 500;
  min-height: 50px;
  display: flex;
  align-items: center;
}

.option-btn:hover {
  background: #25d366;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.typing-indicator {
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.9);
  border-top: 1px solid #ddd;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.typing-text {
  font-size: 0.9rem;
  color: #666;
}

/* Mobile optimizations for WhatsApp */
@media (max-width: 767px) {
  .whatsapp-header {
    padding: 12px 15px;
  }
  
  .contact-name {
    font-size: 1rem;
  }
  
  .contact-status {
    font-size: 0.8rem;
  }
  
  .message-bubble {
    max-width: 85%;
    padding: 10px 14px;
  }
  
  .audio-message {
    min-width: 180px;
  }
  
  .image-message {
    max-width: 200px;
  }
  
  .back-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  
  .user-options {
    padding: 20px 15px;
    gap: 12px;
  }
  
  .option-btn {
    padding: 18px 20px;
    font-size: 1.1rem;
    min-height: 60px;
    border-radius: 30px;
    font-weight: 600;
  }
  
  .chat-input {
    position: sticky;
    bottom: 0;
    z-index: 100;
  }
  
  .chat-messages {
    padding-bottom: 20px;
  }
}
