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

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #25253a;
  --bg-card: #2d2d44;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b8;
  --primary: #a855f7;
  --primary-hover: #9333ea;
  --accent: #ec4899;
  --success: #10b981;
  --error: #ef4444;
  --border: #3d3d54;
  --shadow: rgba(0, 0, 0, 0.3);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 2rem 1rem;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 3rem;
}

.title {
  font-size: 4rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

/* Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .game-grid {
    grid-template-columns: 2fr 1fr;
  }
}

/* Game Card */
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 10px 40px var(--shadow);
}

/* Hint */
.hint-container {
  text-align: center;
  margin-bottom: 2rem;
}

.hint-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(168, 85, 247, 0.1);
  color: var(--primary);
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid rgba(168, 85, 247, 0.2);
}

/* Canvas / Hangman Images */
/* Reemplazado estilos de canvas por contenedor de imágenes */
.hangman-container {
  position: relative;
  width: 400px;
  height: 400px;
  margin: 0 auto 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-image {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}

.hangman-part {
  position: absolute;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 2;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.hangman-part.visible {
  opacity: 1;
  animation: dropIn 0.5s ease;
}

@keyframes dropIn {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.8);
  }
  60% {
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hangman-part.head {
    top: 85px;
    right: 107px;
    width: 65px;
    height: 69px;
}

.hangman-part.body {
    top: 151px;
    right: 98px;
    width: 79px;
    height: 104px;
}

.hangman-part.left-arm {
    top: 158px;
    right: 79px;
    width: 26px;
    height: 136px;
    transform-origin: top right;
}

.hangman-part.right-arm {
    top: 158px;
    right: 170px;
    width: 26px;
    height: 136px;
    transform-origin: top left;
}

.hangman-part.left-leg {
    top: 227px;
    right: 80px;
    width: 44px;
    height: 135px;
}

.hangman-part.right-leg {
    top: 228px;
    right: 153px;
    width: 44px;
    height: 135px;
}

/* Word Display */
.word-display {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  min-height: 4rem;
}

.letter-box {
  width: 3rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  transition: all 0.3s ease;
}

.letter-box.revealed {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: var(--primary);
  transform: scale(1.05);
  animation: revealLetter 0.4s ease;
}

@keyframes revealLetter {
  0% {
    transform: scale(0.8) rotateY(90deg);
    opacity: 0;
  }
  100% {
    transform: scale(1.05) rotateY(0deg);
    opacity: 1;
  }
}

/* Stats */
.stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-value.error {
  color: var(--error);
}

.stat-value.success {
  color: var(--success);
}

.stat-value.time {
  color: var(--primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-divider {
  width: 1px;
  height: 3rem;
  background: var(--border);
}

/* Game Status */
.game-status {
  text-align: center;
  padding: 2rem 0;
  animation: fadeInScale 0.4s ease;
}

@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.status-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.status-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.status-title.won {
  color: var(--success);
}

.status-title.lost {
  color: var(--error);
}

.status-message {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--text-primary);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(168, 85, 247, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  background: rgba(168, 85, 247, 0.1);
}

/* Keyboard */
.keyboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(2.5rem, 1fr));
  gap: 0.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.key {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.key:hover:not(.disabled) {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: rgba(168, 85, 247, 0.2);
}

.key.correct {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.key.incorrect {
  background: var(--error);
  border-color: var(--error);
  color: white;
}

.key.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* New Word Container */
.new-word-container {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Leaderboard */
.leaderboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 40px var(--shadow);
  position: sticky;
  top: 2rem;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.leaderboard-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.leaderboard-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.leaderboard-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
}

.rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--bg-primary);
  border-radius: 0.375rem;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.rank.top-1 {
  background: linear-gradient(135deg, #ffd700, #ffa500);
  color: #000;
}

.rank.top-2 {
  background: linear-gradient(135deg, #c0c0c0, #808080);
  color: #000;
}

.rank.top-3 {
  background: linear-gradient(135deg, #cd7f32, #8b4513);
  color: #fff;
}

.leaderboard-info {
  flex: 1;
  min-width: 0;
}

.leaderboard-word {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-details {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.leaderboard-time {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  .title {
    font-size: 2.5rem;
  }

  .game-card {
    padding: 1.5rem;
  }

  /* Ajuste de tamaño del contenedor para móviles */
  .hangman-container {
    width: 300px;
    height: 300px;
  }

  .hangman-part.head {
    top: 40px;
    right: 70px;
    width: 55px;
    height: 55px;
  }

  .hangman-part.body {
    top: 90px;
    right: 78px;
    width: 40px;
    height: 85px;
  }

  .hangman-part.left-arm {
    top: 100px;
    right: 118px;
    width: 55px;
    height: 60px;
  }

  .hangman-part.right-arm {
    top: 100px;
    right: 33px;
    width: 55px;
    height: 60px;
  }

  .hangman-part.left-leg {
    top: 170px;
    right: 105px;
    width: 40px;
    height: 70px;
  }

  .hangman-part.right-leg {
    top: 170px;
    right: 65px;
    width: 40px;
    height: 70px;
  }

  .letter-box {
    width: 2.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
  }

  .stats {
    gap: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 1rem 0.5rem;
  }

  .title {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 0.875rem;
  }

  .game-card {
    padding: 1rem;
  }

  /* Ajuste adicional para pantallas muy pequeñas */
  .hangman-container {
    width: 250px;
    height: 250px;
  }

  .hangman-part.head {
        top: 39px;
        right: 59px;
        width: 53px;
        height: 55px;
    }

  .hangman-part.body {
        top: 87px;
        right: 54px;
        width: 59px;
        height: 87px;
    }

  .hangman-part.left-arm {
        top: 93px;
        right: 37px;
        width: 21px;
        height: 81px;
    }

  .hangman-part.right-arm {
        top: 95px;
        right: 106px;
        width: 21px;
        height: 81px;
    }

  .hangman-part.left-leg {
        top: 150px;
        right: 37px;
        width: 32px;
        height: 92px;
    }

  .hangman-part.right-leg {
        top: 150px;
        right: 100px;
        width: 32px;
        height: 92px;
    }

  .letter-box {
    width: 2rem;
    height: 3rem;
    font-size: 1rem;
    gap: 0.25rem;
  }

  .keyboard {
    gap: 0.375rem;
  }

  .key {
    font-size: 0.875rem;
  }
}
