[html]<h3>⚔️ Бой с монстром</h3>
<div id="fightArea">
  <p>Ваше HP: <span id="playerHP">100</span> ❤️</p>
  <p>Монстр HP: <span id="monsterHP">100</span> 💀</p>
  <button id="attackBtn">Атаковать</button>
  <button id="defendBtn">Защититься</button>
  <button id="runBtn">Бежать</button>
  <pre id="log" style="background:#111; color:#0f0; padding:10px; max-height:200px; overflow:auto; font-family:monospace;"></pre>
</div>

<script>
(function(){
  let playerHP = 100;
  let monsterHP = 100;
  const log = document.getElementById('log');

  function writeLog(text) {
    log.textContent += text + "\n";
    log.scrollTop = log.scrollHeight;
  }

  function updateHP() {
    document.getElementById('playerHP').textContent = playerHP;
    document.getElementById('monsterHP').textContent = monsterHP;
  }

  function monsterAttack() {
    if (monsterHP <= 0) return;
    const dmg = Math.floor(Math.random() * 15) + 5;
    playerHP -= dmg;
    writeLog(`👹 Монстр атакует! Вы теряете ${dmg} HP.`);
    updateHP();
    if (playerHP <= 0) writeLog("💀 Вы погибли! Монстр победил.");
  }

  document.getElementById('attackBtn').onclick = () => {
    if (playerHP <= 0 || monsterHP <= 0) return;
    const dmg = Math.floor(Math.random() * 20) + 5;
    monsterHP -= dmg;
    writeLog(`⚔️ Вы нанесли ${dmg} урона!`);
    updateHP();
    if (monsterHP <= 0) {
      writeLog("🏆 Победа! Монстр повержен.");
    } else {
      setTimeout(monsterAttack, 800);
    }
  };

  document.getElementById('defendBtn').onclick = () => {
    if (playerHP <= 0 || monsterHP <= 0) return;
    const reduced = Math.floor(Math.random() * 10);
    writeLog(`🛡 Вы защищаетесь и уменьшаете урон на ${reduced}!`);
    const dmg = Math.max(0, Math.floor(Math.random() * 15) - reduced);
    playerHP -= dmg;
    writeLog(`👹 Монстр атакует, вы получаете ${dmg} HP урона.`);
    updateHP();
    if (playerHP <= 0) writeLog("💀 Вы проиграли!");
  };

  document.getElementById('runBtn').onclick = () => {
    writeLog("🏃‍♀️ Вы сбежали с поля боя!");
  };

  writeLog("Бой начался!");
})();
</script>[/html]