* {
  font-family: monospace;
  letter-spacing: 0.05em;
}

.game-container {
  max-width: 35%;
  padding: 15px;
  margin: 0 auto;
}

#game-output {
  margin: 1rem auto;
  height: clamp(150px, 30vh, 300px);
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: clamp(0.875rem, 2vw, 1rem);
}

.battle-stats {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  height: 36px;
  padding-top: 12px;
}

#stage-display {
  text-align: center;
  font-size: 1.5rem;
}

.button-container {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 5px 0;
}

button {
  min-width: 120px;
  padding: 0.75rem 1rem;
  font-size: clamp(0.875rem, 2vw, 1rem);
  margin: 0.25rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #4a5568;
  color: white;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  background-color: #718096 !important;
}

#loot-choice {
  margin-top: 10px;
}

.critical-hit {
  color: #ff4444;
  font-weight: bold;
}

.defeat-message {
  color: #ff0000;
  font-weight: bold;
  font-size: 1.2em;
}

.normal-message {
  color: #333;
}

#game-output p {
  margin: 5px 0;
  line-height: 1.4;
}

.player-stats {
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 15px;
  margin: 10px 0;
  text-align: left;
}

.player-stats h3 {
  margin: 0 0 10px 0;
  color: #333;
}

.player-stats div {
  margin: 5px 0;
  font-family: monospace;
}

.flee-button {
  background-color: #e53e3e !important;
}

.flee-button:hover:not(:disabled) {
  background-color: #c53030 !important;
}

.stats-container {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1rem 0;
}

.stats-box {
  flex: 1;
  width: 300px;
  padding: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.stats-box h3 {
  margin: 0 0 10px 0;
  color: #333;
  text-align: center;
}

.stats-box div {
  margin: 0.5rem 0;
  font-family: monospace;
  font-size: clamp(0.875rem, 2vw, 1rem);
}

.health-display {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.health-bar {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  display: inline-block;
  font-family: monospace;
  white-space: pre;
  font-size: 16px;
  line-height: 1;
  margin-left: -40px;
  margin-bottom: -20px;
  margin-top: -60px;
}

.bar-container {
  position: relative;
  display: inline-block;
  height: 16px;
  vertical-align: middle;
}

.bar-container .filled,
.bar-container .empty {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  line-height: 1;
}

.bar-container .filled {
  z-index: 2;
}

.bar-container .empty {
  z-index: 1;
}

#hero-stats,
#enemy-stats {
  white-space: pre-wrap;
}

#enemy-stats {
  margin-right: 28px
}

#auto-attack {
  transition: background-color 0.3s;
}

#auto-attack:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#auto-attack.active {
  background-color: #e53e3e;
}

#auto-attack.active:hover {
  background-color: #c53030;
}

.button-container-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1rem 0;
}

.battle-buttons,
.loot-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.loot-buttons button:disabled {
  background-color: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
}

.loot-buttons button:not(:disabled) {
  background-color: #48bb78;
}

.loot-buttons button:not(:disabled):hover {
  background-color: #38a169;
  transform: translateY(-1px);
}

#decline-loot {
  background-color: #e53e3e;
}

#decline-loot:hover:not(:disabled) {
  background-color: #c53030;
}

@media screen and (max-width: 414px) {
  body {
    height: 796px;
    width: 414px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .game-container {
    padding: 10px;
    max-width: 100%;
    min-height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
  }

  #game-output {
    width: 90%;
    margin: 0.5rem auto;
    height: 15vh;
    font-size: 12px;
  }

  .stats-container {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.5rem 0;
  }

  .battle-stats {
    width: 90%;
    margin: 0.5rem auto;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0;
    margin-left: 0;
    height: 60px;
  }

  .button-container-wrapper {
    margin-top: -10px;
    gap: 0;
    width: 106%;
  }

  .battle-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    width: 90%;
    gap: 4px;
    margin: 0.5rem auto;
  }

  .loot-buttons {
    display: flex;
    flex-direction: row;
    width: 90%;
    gap: 4px;
    margin: 0.5rem auto;
  }

  button {
    flex: 1;
    padding: 8px 4px;
    margin: 0;
    min-height: 40px;
    font-size: 14px;
    min-width: unset;
  }

  .health-bar {
    margin-left: -70px;
    text-align: center;
    font-size: 12px;
  }

  .health-display {
    align-items: center;
    text-align: center;
    width: 100%;
  }

  #hero-stats,
  #enemy-stats {
    text-align: center;
    margin: 5px auto;
    width: 100%;
    padding: 5px;
  }

  #enemy-stats {
    margin-right: 0;
  }

  h1 {
    margin: 0.5rem 0;
    font-size: 24px;
  }

  .stats-box {
    font-size: 14px;
    padding: 4px;
    width: 95%;
  }

  .player-stats {
    padding: 5px;
  }

}

@media screen and (max-width: 320px) {
  .health-bar {
    font-size: 12px;
  }

  button {
    font-size: 14px;
  }
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  text-align: center;
}