Bootstrap

Category: Game

Bookmarks 0 Views 20
#Game
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>1972DIFM: Revolution v2.3</title>
<style>
:root {
--bg-main: #12121c;
--bg-panel: #1e1e2e;
--primary: #8be9fd;
--danger: #ff5555;
--success: #50fa7b;
--warning: #f1fa8c;
--text: #f8f8f2;
--border: #44475a;
--duo-blue: #1cb0f6;
}

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

body {
font-family: 'Pretendard', -apple-system, sans-serif;
background-color: #000;
display: flex; justify-content: center; align-items: center;
height: 100vh; overflow: hidden; color: var(--text);
}

#app {
width: 100%; max-width: 480px; height: 100vh; max-height: 850px;
background: var(--bg-main); display: flex; flex-direction: column;
position: relative;
}

header {
background: #191a21; padding: 12px 16px;
border-bottom: 2px solid var(--border); z-index: 10;
}
.top-stats { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 8px; font-size: 1.1rem;}
.resource-stats { display: flex; gap: 12px; font-size: 0.95rem; color: #ffb86c; }
.resource-stats span { display: flex; align-items: center; gap: 4px; }

.nav-tabs {
display: flex; background: var(--bg-panel); border-bottom: 2px solid var(--border);
}
.tab-btn {
flex: 1; padding: 12px; text-align: center; color: var(--text); font-weight: bold;
background: transparent; border: none; cursor: pointer; transition: 0.2s;
}
.tab-btn.active { background: var(--border); color: var(--primary); border-bottom: 3px solid var(--primary); }

.view-container { flex: 1; overflow-y: auto; display: none; flex-direction: column; }
.view-container.active { display: flex; }

#battle-arena {
display: flex; flex-direction: column; align-items: center; padding: 20px 15px;
background: linear-gradient(180deg, #282a36 0%, #12121c 100%);
border-bottom: 2px solid var(--border);
}
.stage-info { color: var(--warning); font-weight: bold; font-size: 1.2rem; margin-bottom: 10px; }
#monster-emoji { font-size: 4rem; margin-bottom: 10px; transition: transform 0.1s; }
.hp-bar-box { width: 80%; height: 18px; background: #333; border-radius: 9px; overflow: hidden; border: 1px solid #555; }
#monster-hp-bar { height: 100%; width: 100%; background: var(--danger); transition: width 0.2s; }
#monster-name { margin-top: 6px; font-size: 0.95rem; font-weight: bold; }

#chat-container { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 1rem; line-height: 1.4; animation: popIn 0.3s; }
@keyframes popIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg.sys { align-self: center; background: transparent; color: var(--warning); font-size: 0.9rem; text-align: center; font-weight: bold; }
.msg.bot { align-self: flex-start; background: var(--border); }
.msg.user { align-self: flex-end; background: #6272a4; }

.battle-controls { padding: 16px; background: var(--bg-panel); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; min-height: 150px; justify-content: center; }

.touch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.btn { background: #44475a; border: 2px solid #6272a4; border-radius: 8px; padding: 16px 10px; color: white; font-weight: bold; cursor: pointer; font-size: 1.05rem; }
.btn:active { transform: scale(0.96); background: #6272a4; }

.voice-ui { display: none; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.big-mic-btn {
background: var(--duo-blue); border: none; border-radius: 30px; padding: 12px 20px; color: white;
font-weight: bold; font-size: 1.1rem; display: flex; justify-content: center; align-items: center; gap: 8px;
box-shadow: 0 4px 0 #1899d6; cursor: pointer; width: 100%;
}
.big-mic-btn.listening { background: var(--danger); box-shadow: 0 4px 0 #cc0000; animation: pulse 1s infinite; }
.voice-text-input {
width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--border);
background: #12121c; color: white; font-size: 1rem; outline: none; text-align: center;
}

@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }

.panel-content { padding: 20px; display: flex; flex-direction: column; gap: 15px; }
.market-notice { background: #282a36; padding: 10px; border-radius: 8px; text-align: center; color: var(--warning); font-size: 0.9rem; font-weight: bold; border: 1px dashed var(--warning); }
.item-card { background: var(--border); border-radius: 10px; padding: 15px; display: flex; justify-content: space-between; align-items: center; }
.item-info h4 { margin-bottom: 4px; color: var(--primary); }
.item-info p { font-size: 0.85rem; color: #ccc; }
.buy-btn, .craft-btn, .equip-btn { border: none; padding: 8px 16px; border-radius: 6px; font-weight: bold; cursor: pointer; color: #000; }
.buy-btn { background: var(--success); } .craft-btn { background: #bd93f9; } .equip-btn { background: var(--warning); }
.buy-btn:disabled, .craft-btn:disabled { background: #555; color: #888; }

.shake { animation: shake 0.4s; }
.flash-red { animation: flashRed 0.3s; }
.flash-white { animation: flashWhite 0.2s; }
@keyframes shake { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-5px);} 75%{transform:translateX(5px);} }
@keyframes flashRed { 50% { background-color: #500; } }
@keyframes flashWhite { 50% { filter: brightness(2); } }
</style>
</head>
<body>

<div id="app">
<header>
<div class="top-stats">
<span>❤️ HP: <span id="ui-hp">10</span>/<span id="ui-maxhp">10</span></span>
<span>⚔️ 공격력: <span id="ui-atk">1</span></span>
</div>
<div class="resource-stats">
<span>🪙 <span id="ui-gold">0</span> G</span>
<span>🪨 철광석 <span id="ui-ore">0</span>개</span>
</div>
</header>

<div class="nav-tabs">
<button class="tab-btn active" onclick="switchTab('battle')">⚔️ 전투</button>
<button class="tab-btn" onclick="switchTab('shop')">🏪 상점 & 훈련</button>
<button class="tab-btn" onclick="switchTab('inv')">🎒 가방</button>
</div>

<div id="view-battle" class="view-container active">
<div id="battle-arena">
<div class="stage-info">스테이지 <span id="ui-stage">1-1</span></div>
<div id="monster-emoji">👾</div>
<div class="hp-bar-box"><div id="monster-hp-bar"></div></div>
<div id="monster-name">슬라임 (HP: 2)</div>
</div>
<div id="chat-container"></div>
<div class="battle-controls">
<div id="touch-ui" class="touch-grid"></div>
<div id="voice-ui" class="voice-ui">
<button id="big-mic-btn" class="big-mic-btn" onclick="toggleVoice()">🎙️ 음성 인식 시작</button>
<input type="text" id="voice-text-input" class="voice-text-input" placeholder="영단어 또는 뜻 입력 후 Enter" onkeypress="handleVoiceInputKey(event)">
</div>
</div>
</div>

<div id="view-shop" class="view-container">
<div class="panel-content">
<div id="market-notice" class="market-notice">📊 상점 시세 변동 중 (물가: 100%)</div>

<h3 style="color:var(--warning)">전투력 강화</h3>
<div class="item-card">
<div class="item-info"><h4>💪 기본 공격력 훈련 (ATK +1)</h4><p>비용: <span id="train-cost">50</span> G</p></div>
<button class="buy-btn" onclick="trainAttack()">훈련하기</button>
</div>
<div class="item-card">
<div class="item-info"><h4>❤️ 체력 물약</h4><p>HP 5 회복 (비용: <span id="potion-cost">30</span> G)</p></div>
<button class="buy-btn" onclick="buyPotion()">구매</button>
</div>

<h3 style="color:var(--warning); margin-top:10px;">무기 상점 및 제작 (25종)</h3>
<div id="weapon-shop-list" style="display:flex; flex-direction:column; gap:10px;"></div>
</div>
</div>

<div id="view-inv" class="view-container">
<div class="panel-content">
<h3 style="color:var(--warning)">장착 중인 무기</h3>
<div class="item-card" style="background:#282a36; border:1px solid var(--primary);">
<div class="item-info"><h4 id="equipped-weapon">주먹 (ATK 1)</h4></div>
</div>
<h3 style="color:var(--warning); margin-top:10px;">보유 무기</h3>
<div id="inventory-list" style="display:flex; flex-direction:column; gap:10px;">
<p style="color:#888; font-size:0.9rem;">보유한 무기가 없습니다.</p>
</div>
</div>
</div>
</div>

<script>
// --- 영단어 DB ---
const wordDB = [
{ en: "apple", ko: "사과", level: 1 }, { en: "boy", ko: "소년", level: 1 }, { en: "cat", ko: "고양이", level: 1 },
{ en: "dog", ko: "개", level: 1 }, { en: "egg", ko: "계란", level: 1 }, { en: "fire", ko: "불", level: 1 },
{ en: "girl", ko: "소녀", level: 1 }, { en: "house", ko: "집", level: 1 }, { en: "ice", ko: "얼음", level: 1 },
{ en: "jump", ko: "점프하다", level: 1 }, { en: "king", ko: "왕", level: 1 }, { en: "love", ko: "사랑", level: 1 },
{ en: "moon", ko: "달", level: 1 }, { en: "name", ko: "이름", level: 1 }, { en: "orange", ko: "오렌지", level: 1 },
{ en: "abandon", ko: "포기하다", level: 2 }, { en: "benefit", ko: "이익", level: 2 }, { en: "calculate", ko: "계산하다", level: 2 },
{ en: "determine", ko: "결정하다", level: 2 }, { en: "environment", ko: "환경", level: 2 }, { en: "frequent", ko: "빈번한", level: 2 },
{ en: "generate", ko: "발생시키다", level: 2 }, { en: "hesitate", ko: "주저하다", level: 2 }, { en: "identify", ko: "식별하다", level: 2 },
{ en: "justify", ko: "정당화하다", level: 2 }
];

// --- 무기 25종 리스트 ---
const weaponDB = [
{ name: "나무검", atk: 2, gold: 50, ore: 0 },
{ name: "돌검", atk: 4, gold: 120, ore: 0 },
{ name: "구리검", atk: 7, gold: 200, ore: 2 },
{ name: "철검", atk: 10, gold: 350, ore: 5 },
{ name: "강철검", atk: 15, gold: 600, ore: 10 },
{ name: "은검", atk: 20, gold: 900, ore: 15 },
{ name: "금검", atk: 28, gold: 1400, ore: 20 },
{ name: "백금검", atk: 38, gold: 2000, ore: 28 },
{ name: "미스릴검", atk: 50, gold: 3000, ore: 40 },
{ name: "아다만티움검", atk: 65, gold: 4500, ore: 55 },
{ name: "화염의 검", atk: 85, gold: 6500, ore: 75 },
{ name: "얼음의 검", atk: 110, gold: 9000, ore: 100 },
{ name: "번개의 검", atk: 140, gold: 12500, ore: 130 },
{ name: "암흑의 검", atk: 180, gold: 17000, ore: 170 },
{ name: "성스러운 검", atk: 230, gold: 23000, ore: 220 },
{ name: "드래곤 슬레이어", atk: 300, gold: 31000, ore: 300 },
{ name: "타이탄의 대검", atk: 390, gold: 41000, ore: 400 },
{ name: "이모탈 블레이드", atk: 500, gold: 54000, ore: 520 },
{ name: "이클립스", atk: 650, gold: 70000, ore: 670 },
{ name: "솔라 스워드", atk: 850, gold: 90000, ore: 850 },
{ name: "게이볼그", atk: 1100, gold: 120000, ore: 1100 },
{ name: "엑스칼리버", atk: 1450, gold: 160000, ore: 1450 },
{ name: "무라마사", atk: 1900, gold: 210000, ore: 1900 },
{ name: "칼라드볼그", atk: 2500, gold: 280000, ore: 2500 },
{ name: "제네시스", atk: 3500, gold: 400000, ore: 3500 }
];

let wordPools = { lv1: [], lv2: [], review: [] };
function shuffleArray(array) { return [...array].sort(() => Math.random() - 0.5); }
function getWordFromPool(level) {
let pool = level === 1 ? wordPools.lv1 : wordPools.lv2;
if (pool.length === 0) { pool.push(...shuffleArray(wordDB.filter(w => w.level === level))); }
return pool.pop();
}
function getReviewWord() {
if (wordPools.review.length === 0) { wordPools.review = shuffleArray(battle.stageReviewWords); }
if (wordPools.review.length === 0) return getWordFromPool(1);
return wordPools.review.pop();
}

let player = { hp: 10, maxHp: 10, baseAtk: 1, gold: 0, ore: 0 };
let inventory = { weapons: [], equipped: { name: "주먹", atk: 0 } };
let stage = { major: 1, sub: 1 };
let battle = { monsterMaxHp: 2, monsterHp: 2, currentWord: null, isWaiting: false, stageReviewWords: [], isVoiceQ: false };
let priceMultiplier = 1.0;
let trainCost = 50;

const ui = {
hp: document.getElementById('ui-hp'), maxHp: document.getElementById('ui-maxhp'),
atk: document.getElementById('ui-atk'), gold: document.getElementById('ui-gold'), ore: document.getElementById('ui-ore'),
stage: document.getElementById('ui-stage'), mEmoji: document.getElementById('monster-emoji'),
mHpBar: document.getElementById('monster-hp-bar'), mName: document.getElementById('monster-name'),
chat: document.getElementById('chat-container'), touchUI: document.getElementById('touch-ui'),
voiceUI: document.getElementById('voice-ui'), bigMicBtn: document.getElementById('big-mic-btn'),
voiceInput: document.getElementById('voice-text-input'),
invList: document.getElementById('inventory-list'), eqWeapon: document.getElementById('equipped-weapon'),
weaponShopList: document.getElementById('weapon-shop-list'), marketNotice: document.getElementById('market-notice')
};

function getAtk() { return player.baseAtk + inventory.equipped.atk; }
function updateUI() {
ui.hp.innerText = player.hp; ui.maxHp.innerText = player.maxHp;
ui.atk.innerText = getAtk(); ui.gold.innerText = player.gold; ui.ore.innerText = player.ore;
ui.stage.innerText = `${stage.major}-${stage.sub}`;
document.getElementById('train-cost').innerText = Math.round(trainCost * priceMultiplier);
document.getElementById('potion-cost').innerText = Math.round(30 * priceMultiplier);
const hpPct = Math.max(0, (battle.monsterHp / battle.monsterMaxHp) * 100);
ui.mHpBar.style.width = `${hpPct}%`;
}
function msg(text, type="sys") {
const d = document.createElement('div'); d.className = `msg ${type}`; d.innerHTML = text;
ui.chat.appendChild(d); setTimeout(() => ui.chat.scrollTop = ui.chat.scrollHeight, 50); return d;
}
function switchTab(tabId) {
document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.view-container').forEach(v => v.classList.remove('active'));
event.target.classList.add('active');
document.getElementById(`view-${tabId}`).classList.add('active');
if(tabId === 'shop') renderShop();
}

// --- 20초마다 시세 변동 시스템 ---
function fluctuatePrices() {
priceMultiplier = +(0.7 + Math.random() * 0.8).toFixed(2);
ui.marketNotice.innerText = `📊 상점 시세 변동됨! (현재 물가: ${Math.round(priceMultiplier * 100)}%)`;
updateUI();
renderShop();
}
setInterval(fluctuatePrices, 20000);

// --- 상점 & 훈련 로직 ---
function trainAttack() {
let cost = Math.round(trainCost * priceMultiplier);
if (player.gold < cost) { alert("골드가 부족합니다."); return; }
player.gold -= cost;
player.baseAtk += 1;
trainCost = Math.floor(trainCost * 1.2);
updateUI();
alert("기본 공격력이 1 증가했습니다!");
}

function buyPotion() {
let cost = Math.round(30 * priceMultiplier);
if (player.gold < cost) { alert("골드가 부족합니다."); return; }
if (player.hp >= player.maxHp) { alert("체력이 가득 찼습니다."); return; }
player.gold -= cost;
player.hp = Math.min(player.maxHp, player.hp + 5);
updateUI();
alert("체력을 5 회복했습니다!");
}

function renderShop() {
ui.weaponShopList.innerHTML = '';
weaponDB.forEach(w => {
let finalGold = Math.round(w.gold * priceMultiplier);
let hasIt = inventory.weapons.find(item => item.name === w.name);
ui.weaponShopList.innerHTML += `
<div class="item-card">
<div class="item-info">
<h4>${w.name} (ATK +${w.atk})</h4>
<p>비용: ${finalGold}G ${w.ore > 0 ? `+ 철광석 ${w.ore}개` : ''}</p>
</div>
<button class="buy-btn" ${hasIt ? 'disabled' : ''} onclick="buyWeapon('${w.name}', ${w.atk}, ${finalGold}, ${w.ore})">
${hasIt ? '보유중' : '구매/제작'}
</button>
</div>`;
});
}

function buyWeapon(name, atk, goldCost, oreCost) {
if (player.gold < goldCost || player.ore < oreCost) { alert("골드나 철광석이 부족합니다."); return; }
player.gold -= goldCost; player.ore -= oreCost;
inventory.weapons.push({ name, atk });
updateUI(); renderShop(); renderInventory();
alert(`${name} 획득 완료! 가방에서 장착하세요.`);
}

function renderInventory() {
if (inventory.weapons.length === 0) {
ui.invList.innerHTML = `<p style="color:#888; font-size:0.9rem;">보유한 무기가 없습니다.</p>`; return;
}
ui.invList.innerHTML = '';
inventory.weapons.forEach(w => {
const isEq = (inventory.equipped.name === w.name);
ui.invList.innerHTML += `
<div class="item-card">
<div class="item-info"><h4>${w.name} (ATK +${w.atk})</h4></div>
<button class="equip-btn" ${isEq?'disabled':''} onclick="equipWeapon('${w.name}', ${w.atk})">
${isEq ? '장착 중' : '장착하기'}
</button>
</div>`;
});
}

function equipWeapon(name, atk) {
inventory.equipped = { name, atk };
ui.eqWeapon.innerText = `${name} (ATK +${atk})`;
updateUI(); renderInventory(); alert(`${name} 장착 완료!`);
}

// --- 음성 인식 및 백업 입력 ---
let recognition = null;
let isListening = false;
let speechSupported = ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window);

if (speechSupported) {
const SpeechRec = window.SpeechRecognition || window.webkitSpeechRecognition;
recognition = new SpeechRec();
recognition.lang = 'en-US';
recognition.interimResults = false;

recognition.onresult = (event) => {
if(!battle.isWaiting) return;
const transcript = event.results[0][0].transcript.trim().toLowerCase();
ui.voiceInput.value = transcript;
checkAnswerVoice(transcript);
stopVoice();
};
recognition.onerror = () => { stopVoice(); };
recognition.onend = () => { stopVoice(); };
}

function toggleVoice() {
if(!speechSupported) { alert("이 브라우저는 음성 인식을 지원하지 않습니다. 아래 입력창을 사용해주세요."); return; }
if(!battle.isWaiting) return;
if(isListening) { recognition.stop(); stopVoice(); }
else { recognition.start(); isListening = true; ui.bigMicBtn.classList.add('listening'); ui.bigMicBtn.innerText = "듣는 중..."; }
}
function stopVoice() {
isListening = false; ui.bigMicBtn.classList.remove('listening'); ui.bigMicBtn.innerText = "🎙️ 음성 인식 시작";
}

function handleVoiceInputKey(e) {
if(e.key === 'Enter' && battle.isWaiting) {
const val = ui.voiceInput.value.trim().toLowerCase();
ui.voiceInput.value = '';
checkAnswerVoice(val);
}
}

// --- 전투 로직 ---
function initStage() {
const isBoss = (stage.sub === 13);
battle.monsterMaxHp = isBoss ? stage.major * 30 : (stage.major * 3) + (stage.sub * 2);
battle.monsterHp = battle.monsterMaxHp;

ui.mEmoji.innerText = isBoss ? "👿" : "👾";
ui.mName.innerText = isBoss ? `👿 보스 몬스터 (HP: ${battle.monsterHp})` : `👾 야생의 몬스터 (HP: ${battle.monsterHp})`;
updateUI();

if(isBoss) msg(`⚠️ <strong>보스 출현!</strong> 복습 스테이지입니다!`, 'sys');
else msg(`스테이지 ${stage.major}-${stage.sub} 전투 시작!`, 'sys');

setTimeout(askQuestion, 1000);
}

function askQuestion() {
if(player.hp <= 0) return;

const isBoss = (stage.sub === 13);
if (isBoss) battle.currentWord = getReviewWord();
else battle.currentWord = stage.major === 1 ? getWordFromPool(1) : getWordFromPool(2);

if (!isBoss && !battle.stageReviewWords.includes(battle.currentWord)) {
battle.stageReviewWords.push(battle.currentWord);
}

battle.isVoiceQ = Math.random() < 0.3;

if (battle.isVoiceQ) {
// 💡 [수정] 음성 문제 출제 시 정답(뜻)이 미리 보이지 않도록 제거함
msg(`다음 단어를 소리 내어 말하거나 뜻/단어를 입력하세요:<br><strong style="font-size:1.6rem; color:var(--duo-blue);">${battle.currentWord.en}</strong>`, 'bot');
ui.touchUI.style.display = 'none';
ui.voiceUI.style.display = 'flex';
ui.voiceInput.focus();
} else {
renderTouchQuestion(battle.currentWord);
}
battle.isWaiting = true;
}

function renderTouchQuestion(wordObj) {
msg(`공격할 단어의 뜻은?<br><strong style="font-size:1.5rem; color:var(--primary);">${wordObj.en}</strong>`, 'bot');
ui.voiceUI.style.display = 'none';
ui.touchUI.style.display = 'grid';

let opts = wordDB.filter(w => w.en !== wordObj.en);
opts = shuffleArray(opts).slice(0, 3).map(w => w.ko);
opts.push(wordObj.ko);
opts = shuffleArray(opts);

ui.touchUI.innerHTML = '';
opts.forEach(opt => {
const b = document.createElement('button');
b.className = 'btn'; b.innerText = opt;
b.onclick = () => { if(battle.isWaiting){ msg(`"${opt}"`, 'user'); processAnswer(opt === wordObj.ko); } };
ui.touchUI.appendChild(b);
});
}

function checkAnswerVoice(transcript) {
const cleanInput = transcript.trim().toLowerCase();
const targetEn = battle.currentWord.en.trim().toLowerCase();
const targetKo = battle.currentWord.ko.trim().toLowerCase();

const isCorrect = cleanInput.length > 0 && (
cleanInput === targetEn ||
cleanInput === targetKo ||
cleanInput.includes(targetEn) ||
cleanInput.includes(targetKo) ||
targetEn.includes(cleanInput)
);

msg(`🎙️ "${transcript}"`, 'user');
processAnswer(isCorrect);
}

function processAnswer(isCorrect) {
battle.isWaiting = false;
ui.touchUI.innerHTML = ''; ui.voiceUI.style.display = 'none';

setTimeout(() => {
if (isCorrect) {
const dmg = getAtk();
battle.monsterHp -= dmg;
ui.mEmoji.classList.add('flash-white'); setTimeout(() => ui.mEmoji.classList.remove('flash-white'), 200);
ui.mName.innerText = `몬스터 (HP: ${Math.max(0, battle.monsterHp)})`;
// 정답을 맞혔을 때 정답과 뜻을 함께 표시
msg(`⚔️ 정답! (${battle.currentWord.en} = ${battle.currentWord.ko})<br>${dmg}의 데미지를 입혔습니다.`, 'sys');
updateUI();

if (battle.monsterHp <= 0) winBattle();
else setTimeout(askQuestion, 1200);
} else {
player.hp--;
document.getElementById('app').classList.add('shake', 'flash-red');
setTimeout(() => document.getElementById('app').classList.remove('shake', 'flash-red'), 300);
// 틀렸을 때 정답과 뜻을 표시
msg(`🩸 오답! 몬스터의 반격!<br>정답: <strong>${battle.currentWord.en} (${battle.currentWord.ko})</strong>`, 'bot');
updateUI();

if (player.hp <= 0) setTimeout(die, 1000);
else setTimeout(askQuestion, 1500);
}
}, 400);
}

function winBattle() {
const isBoss = (stage.sub === 13);
const earnGold = isBoss ? 600 : (stage.major * 80) + 100;
const earnOre = isBoss ? 5 : (Math.random() < 0.4 ? 1 : 0);

player.gold += earnGold; player.ore += earnOre;
msg(`🏆 승리! 🪙 ${earnGold}G${earnOre>0 ? `, 🪨 철광석 ${earnOre}개` : ''} 획득!`, 'sys');
updateUI();

setTimeout(() => {
if (isBoss) {
msg(`🎉 보스 격파 완료! 다음 월드로 진입합니다!`, 'sys');
stage.major++; stage.sub = 1;
battle.stageReviewWords = []; wordPools.review = [];
} else {
stage.sub++;
}
initStage();
}, 2000);
}

function die() {
msg(`💀 체력이 모두 소진되었습니다...<br>스테이지 <strong>${stage.major}-1</strong> 처음으로 돌아갑니다.`, 'sys');
player.hp = player.maxHp;
stage.sub = 1;
battle.stageReviewWords = []; wordPools.review = [];
updateUI();
setTimeout(() => { ui.chat.innerHTML = ''; initStage(); }, 3000);
}

window.onload = () => { initStage(); };
</script>
</body>
</html>