/* =========================================
   1. 基礎佈局與響應式
   ========================================= */
.wrd-wrapper {
	width: 100%;
	padding: 0;
	box-sizing: border-box;
	margin: 0 auto;
	position: relative;
	display: block;
}
.award_img{
	width:40px;
	height:100%;
}
@media screen and (min-width: 200px) {
	#content{
		margin-top: 50px;
	}
	.boss-battle-stage {border-radius: 0px;}
	.award_img{width:30px;height:100%;}
}
@media screen and (min-width: 540px) {
	#content{
		margin-top: 50px;
	}
	.boss-battle-stage {border-radius: 0px;}
	.award_img{width:30px;height:100%;}
}
@media screen and (min-width: 768px) {
	#content{
		margin-top: 60px;
	}
	.boss-battle-stage {border-radius: 12px;}
	.award_img{width:35px;height:100%;}
}
@media screen and (min-width: 1200px) {
	#content { margin-top: 150px; }
	.boss-battle-stage {border-radius: 12px;}
}

/* =========================================
   2. 進度條系統：動畫定義 (修正：動態同步更新寬度與數值變數)
   ========================================= */
@keyframes slideIn {
	from { 
		width: 100%; 
		--current-width: 100%; /* 動態計時器開局為 100% */
	} 
	to { 
		width: var(--target-width); 
		--current-width: var(--target-width); /* 動態計時器結束於目標值 (例如 18%) */
	} 
}

@keyframes fadeInText {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes lineFadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes labelPopIn {
	0% { transform: scale(0); opacity: 0; }
	70% { transform: scale(1.15); opacity: 1; }
	100% { transform: scale(1); opacity: 1; }
}


/* =========================================
   3. Boss 血量條主體樣式 (精準動態變色系統)
   ========================================= */

/* 核心關鍵：必須註冊 --current-width 變數，CSS 才能在動畫播放期間計算出 100% 到 18% 之間的每一步中間值 */
@property --current-width {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 100%;
}

.wrd-bar-bg {
	position: relative;
	width: 100%;
	height: 24px;
	background-color: rgba(30, 30, 30, 0.6); /* 被扣掉的血量背景 */
	border-radius: 6px;
	display: flex;
	align-items: center;
	box-shadow: 
        /* 層 1: 金色外圍實線 */
        0 0 0 1px #cf975a,
        /* 層 2: 外圍深紫色細外緣 */
        0 0 0 2px #cf975a,
        /* 層 3: 金色外框下方的環境光 */
        0 2px 5px 3px rgba(0,0,0,0.4),
        /* 層 4: 內陰影，營造血條內部的凹陷感 */
        inset 0 2px 6px 1px rgba(0,0,0,0.7);
}

.wrd-bar-fill-container {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	border-radius: 5px;
	overflow: hidden;
	z-index: 1;
}

/* 核心邏輯：根據動畫即時進度變色 */
/* 紫色/綠/黃/紅 智能三段變色血量條 */
.wrd-bar-fill {
	height: 100%;
	width: 100%; 
	
	/* =================================================================
	   【三段變色黑科技邏輯解析】
	   1. --is-green  (大於 50% 觸發)：當血量 > 50% 時為 100%，否則為 0%
	   2. --is-yellow (大於 20% 觸發)：當血量 > 20% 時為 100%，否則為 0%
	   
	   ▶ 血量 100% ~ 50%： 綠色=100%、黃色=100% ➔ 顯示綠色
	   ▶ 血量  50% ~ 20%： 綠色=0%、  黃色=100% ➔ 顯示黃色
	   ▶ 血量  20% ~  0%： 綠色=0%、  黃色=0%   ➔ 顯示紅色
	   ================================================================= */
	--is-green: clamp(0%, (var(--current-width) - 50%) * 9999, 100%);
	--is-yellow: clamp(0%, (var(--current-width) - 20%) * 9999, 100%);

	/* 運用 linear-gradient 疊加色標，達成整條流暢切換顏色，且動畫播放到特定比例時才會瞬間變色 */
	background: linear-gradient(90deg, 
		/* 1. 綠色健康色調 */
		rgba(3, 182, 71, 1) 0%, 
		rgba(35, 195, 73, 1) var(--is-green), 
		
		/* 2. 黃色警告色調 */
		rgba(248, 206, 39, 1) var(--is-green), 
		rgba(255, 205, 14, 1) var(--is-yellow), 
		
		/* 3. 紅色危險色調 */
		rgba(231, 76, 60, 1) var(--is-yellow), 
		rgba(192, 41, 43, 1) 100%
	);
	
	/* 內陰影立體光澤 */
	box-shadow: inset 0 3px 5px rgba(255,255,255,0.3), inset 0 -3px 5px rgba(0,0,0,0.3);

	/* 執行血條縮減動畫 (維持你原本設定的 1.5 秒延遲、3秒播放) */
	animation: slideIn 3s cubic-bezier(0.25, 1, 0.5, 1) 1.5s forwards;
}

.wrd-bar-text {
	position: absolute;
	left: 20px;
	z-index: 5;
	color: #fff; 
	font-size: 0.95rem;
	pointer-events: none;
	font-weight: bold;
	text-shadow: 1px 1px 3px rgba(0,0,0,0.8); 
	opacity: 0;
	animation: fadeInText 1s ease forwards 1.8s;
}
/* =========================================
   4. 進度條系統：節點防線設定
   ========================================= */
.wrd-node {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;
}

/* 預設狀態：朝上三角形金屬刻度 */
.wrd-line {
	width: 8px;  /* 稍微加寬，讓三角形底座更穩固 */
	height: 12px; /* 寬高相等 */
	background-color: rgba(255, 255, 255, 0.5); 
	
	/* 關鍵：利用 clip-path 將正方形裁切成朝上的三角形 */
	/* 三個座標分別代表：頂點 (50%, 0%)、右下角 (100%, 100%)、左下角 (0%, 100%) */
	clip-path: polygon(50% 0%, 100% 100%, 0% 100%); 
	
	/* 由於 clip-path 會裁切掉原生 border，我們改用 filter 加上微弱的外發光來營造邊框質感 */
	filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.6));
	
	margin: 0 auto;
	opacity: 0;
	transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
	animation: lineFadeIn 0.8s ease forwards;
}

/* 達成目標時：三角形變成發光的黃綠色寶石箭頭 */
.active .wrd-line:not(.wrd-line-bonus) {
	background-color: #4eff4e;
	
	/* 達成時強化綠色螢光效果，讓三角形看起來像充能亮起 */
	filter: drop-shadow(0 0 4px #4eff4e) drop-shadow(0 0 8px rgba(78, 255, 78, 0.6));
	
	/* 達成時稍微放大 (1.25倍)，並往上微移 1px，讓指向寶箱的視覺感更強烈 */
	transform: scale(1.25) translateY(-1px); 
}
.wrd-line-bonus {
	background-color: transparent !important;
	width: 2px; 
	height: 24px;
	position: relative;
}

/* 擊破大獎時的亮綠色星星 */
.active .wrd-line-bonus::after {
	font-family: "Font Awesome 5 Free";
	content: '\f005';
	font-weight: 900;
	display: block;
	position: absolute; 
	left: 50%;
	top: -5px; 
	opacity: 0; 
	transform: translateX(-50%) rotate(0deg);
	animation: lineFadeIn 0.8s ease forwards;
	animation-delay: 4.5s;
	color: #4eff4e; 
	font-size: 20px;
	text-shadow: 0 0 8px rgba(0,255,0,0.6);
}

/* 懸浮血量文字標籤 */
.wrd-label-bottom {
	position: absolute;
	top: -35px; 
	right: -30px; 
	white-space: nowrap;
	font-size: 0.9rem;
	color: #bbb;
	font-weight: bold;
	opacity: 0;
	transform: scale(0);
	transform-origin: center bottom;
	text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.wrd-line {
	animation: lineFadeIn 0.8s ease forwards;
}

.wrd-label-bottom {
	animation: labelPopIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* 達成受擊目標時，字體亮綠燈代表解鎖成功 */
.active .wrd-label-bottom {
	color: #4eff4e;
}

.active .wrd-line:not(.wrd-line-bonus) {
	background-color: #4eff4e;
}

/* =========================================
   5. 精準進場定時器 (不論是否達成，一律由右往左排隊進場)
   ========================================= */

/* 預設讓所有節點的文字與線條都套用進場動畫 (labelPopIn) */
.wrd-node .wrd-line, 
.wrd-node .wrd-label-bottom {
    animation-fill-mode: forwards !important; 
}

/* -----------------------------------------
   各階段排隊進場時間 (不論 active 與否皆觸發)
   ----------------------------------------- */

/* 階段 1：HP 27,000 (最右邊，最先登場) */
.node-stage-1 .wrd-line, .node-stage-1 .wrd-label-bottom { animation-delay: 1.5s; }
.node-stage-1 .chest-btn { animation: labelPopIn 0.5s 1.5s forwards; }

/* 階段 2：HP 24,000 */
.node-stage-2 .wrd-line, .node-stage-2 .wrd-label-bottom { animation-delay: 2.0s; }
.node-stage-2 .chest-btn { animation: labelPopIn 0.5s 2.0s forwards; }

/* 階段 3：HP 20,000 */
.node-stage-3 .wrd-line, .node-stage-3 .wrd-label-bottom { animation-delay: 2.5s; }
.node-stage-3 .chest-btn { animation: labelPopIn 0.5s 2.5s forwards; }

/* 階段 4：HP 15,000 */
.node-stage-4 .wrd-line, .node-stage-4 .wrd-label-bottom { animation-delay: 3.0s; }
.node-stage-4 .chest-btn { animation: labelPopIn 0.5s 3.0s forwards; }

/* 階段 5：HP 8,000 */
.node-stage-5 .wrd-line, .node-stage-5 .wrd-label-bottom { animation-delay: 3.5s; }
.node-stage-5 .chest-btn { animation: labelPopIn 0.5s 3.5s forwards; }

/* 階段 6：擊破防線！(最左邊，最後登場) */
.node-stage-6 .wrd-line, .node-stage-6 .wrd-label-bottom { animation-delay: 4.0s; }
.node-stage-6 .chest-btn { animation: labelPopIn 0.5s 4.0s forwards; }

/* 針對最左邊大獎字體的邊界修正 */
.node-stage-6 .wrd-label-bottom {
	width:30px;
	left:30px;
}


/* =========================================
   6. 魔王舞台空間區（RWD 1200 * 628 自適應）
   ========================================= */
.boss-battle-stage {
	position: relative;
	width: 100%;       
	aspect-ratio: 1200 / 628; 
	margin: 0 auto;
	overflow: hidden;
}

.boss-bg-layer {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-size: cover !important;
	z-index: 1;
}

.monster-stage {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 10;
}

/* =========================================
   7. 魔王主容器：【安全放大修改】
   ========================================= */
.monster-character {
	position: absolute;
	bottom: 12%;            /* 降低底部位置，讓放大後的魔王穩穩踩在台階上 */
	left: 50%;
	width: 45%;             /* 核心：寬度由 36% 放大到 45%，完美實現大 Boss 氣勢 */
	max-width: 540px;       /* 同步放寬最大上限 */
	height: auto; 
	aspect-ratio: 450 / 400; 
	transform: translateX(-50%);
	animation: bossInPlaceAnimate 12s ease-in-out infinite; /* 保留原本神級流暢的晃動與大跳躍動畫 */
}

/* =========================================
   8. 魔王零件精密組合定位
   ========================================= */
.gacha-boss-container {
	position: relative;
	width: 100%;
	height: 100%;
}

.boss-part {
	position: absolute;
	display: block;
}

.boss-part.cloak {
	/*width: 98%; 
	left: 1%;
	top: 38%;   
	z-index: 2;
	animation: cloakPulse 2s ease-in-out infinite alternate;*/
	width: 100%;
    left: -3%;
    top: 43%;
    z-index: 2;
    animation: cloakPulse 2s ease-in-out infinite alternate;
}

.boss-part.body {
	/*width: 55%; 
	left: 22%;  
	top: 2.5%;  
	z-index: 1;*/
	width: 75%;
    left: 8%;
    top: -13.5%;
    z-index: 1;
}

.boss-part.hand-staff {
	/*width: 53%; 
	left: 0%;  
	top: 15.5%; 
	z-index: 6;
	transform-origin: 50% 60%;
	animation: staffWave 2.5s ease-in-out infinite alternate;*/
	width: 60%;
    left: 0%;
    top: 22%;
    z-index: 6;
    transform-origin: 50% 60%;
    animation: staffWave 2.5s ease-in-out infinite alternate;
}

/* =========================================
   9. 魔王隨機對話氣泡：【基礎樣式與雙位置整合】
   ========================================= */

/* --- 氣泡通用核心樣式 (公用屬性) --- */
.monster-bubble,
.monster-bubble-left {
	position: absolute;
	background: rgba(255, 255, 255, 0.95);
	border: 3px solid #FFF;
	border-radius: 10px;
	padding: 0.4em 0.8em; 
	font-size: 14px;
	font-weight: bold;
	color: #666;
	white-space: nowrap;
	z-index: 50;
	box-shadow: 0 5px 15px rgba(0,0,0,0.3);
	opacity: 0;
	animation: randomBubblePop 48s infinite;	/*75s -> 60s*/
	animation-delay: var(--d);
	pointer-events: none;
}

/* 通用小箭頭基礎設定 */
.monster-bubble::after,
.monster-bubble-left::after {
	content: '';
	position: absolute;
	display: block;
	width: 0;
	height: 0;
}


/* --- 位置 A：右側對話氣泡 (原本的) --- */
.monster-bubble {
	top: 30%;               /* 調整至上方水平高度 */
	left: 80%;              /* 精準移到畫面右側空白區 */
	transform: none !important;
}

/* 右側氣泡小箭頭：在左邊，尖端朝左指向魔王 */
.monster-bubble::after {
	left: -10px;            
	top: 50%;
	transform: translateY(-50%);
	border-width: 6px 10px 6px 0; 
	border-style: solid;
	border-color: transparent #FFF transparent transparent; 
}


/* --- 位置 B：【全新製作】左下角對話氣泡 --- */
.monster-bubble-left {
	/*bottom: 25%;            /* 鎖定在底部往上一點點的位置，避開血條 */
	/*left: -40%;               /* 靠左邊，剛好在魔王斗篷的左下方空白處 */
	bottom: 32%;            /* 鎖定在底部往上一點點的位置，避開血條 */
	left: -14%;               /* 靠左邊，剛好在魔王斗篷的左下方空白處 */
	transform: none !important;
}

/* 左下角氣泡小箭頭：在右邊，尖端朝右指向魔王 */
.monster-bubble-left::after {
	right: -8px;           /* 移至對話框最右邊 */
	top: 20%;
	transform: translateY(-50%) rotate(91deg);
	border-width: 6px 0 6px 10px; /* 關鍵：箭頭尖端朝右 */
	border-style: solid;
	border-color: transparent transparent transparent #FFF; /* 填滿白色 */
}


/* --- 雙氣泡的響應式 Mobile 適配 --- */
@media (max-width: 768px) {
	.monster-bubble,
	.monster-bubble-left { 
		font-size: 11px;
	}
}

@media (max-width: 480px) {
	.monster-bubble,
	.monster-bubble-left { 
		font-size: 11px;
	}
	/* 手機版若左邊空間太擠，可微調左下氣泡位置 */
	.monster-bubble-left {
		left: -45%;
		bottom: 28%;
	}
}
/* =========================================
   10. 嵌入式底部整合面板樣式 (Progress + Button)
   ========================================= */
.boss-bottom-panel {
	position: absolute;
	bottom: 5px;
	left: 0;
	width: 100%;
	height: 7%;
	z-index: 40;
	display: flex;
	align-items: center;
	padding: 0 1.5%;
	box-sizing: border-box;
}

/* 底部左側進度條容器占 100% 寬度 */
.boss-progress-col {
	flex: 0 0 100%;
	width: 100%;
	padding-right: 0px;
	box-sizing: border-box;
}

/* 底部右側按鈕容器占 15% 寬度 */
.boss-btn-col {
	flex: 0 0 15%;
	width: 15%;
	box-sizing: border-box;
}

.boss-btn-col .btn {
	white-space: nowrap;
	display: inline-flex;
	justify-content: center;
	align-items: center;
	height: 34px;
}

/* =========================================
   11. 動畫 Keyframes 核心定義
   ========================================= */
@keyframes bossInPlaceAnimate {
	/* 0% ~ 40%: 優雅緩慢的呼吸與輕微晃動 */
	0%, 100% { 
		transform: translateX(-50%) translateY(0) rotate(0deg) scale(1); 
	}
	15% { 
		transform: translateX(-50.5%) translateY(1px) rotate(-0.3deg) scaleX(1.01); 
	}
	30% { 
		transform: translateX(-49.5%) translateY(-1px) rotate(0.3deg) scaleX(0.99); 
	}

	/* 45% ~ 75%: 輕微且流暢的起伏彈跳 (不激烈的蓄力與回彈) */
	45% { 
		/* 蓄力微蹲：向下沉 2px，身體微微壓扁 */
		transform: translateX(-50%) translateY(2px) scaleX(1.02) scaleY(0.98); 
	}
	55% { 
		/* 輕微彈跳：向上飄 12px，身體稍微拉長 */
		transform: translateX(-50%) translateY(-12px) scaleX(0.98) scaleY(1.02); 
	}
	65% { 
		/* 落地緩衝：回歸地面並帶有極微幅的下壓餘震 */
		transform: translateX(-50%) translateY(1px) scaleX(1.01) scaleY(0.99); 
	}
	75% { 
		/* 恢復原狀，準備進入下一次循環 */
		transform: translateX(-50%) translateY(0) scale(1); 
	}
}

@keyframes staffWave {
	0% { transform: rotate(-5deg) translateY(0); }
	100% { transform: rotate(8deg) translateY(-5px); }
}

@keyframes cloakPulse {
	0% { transform: scale(1); }
	100% { transform: scale(1.03) translateY(-2px); }
}

/* 配合氣泡右移後的全新彈出 Keyframes（移除舊有的 translateX 軸向位移干擾） */
/*75s
@keyframes randomBubblePop {
	0% { opacity: 0; transform: scale(0) translateY(15px); }
	0.3% { opacity: 1; transform: scale(1.1) translateY(0); } 
	0.6%, 1.4%, 2.2% { transform: rotate(-1deg); }
	1.0%, 1.8%, 2.6% { transform: rotate(1deg); }
	3.5% { opacity: 1; transform: scale(1); }
	4% { opacity: 0; transform: scale(0) translateY(-15px); } 
	100% { opacity: 0; } 
}*/
/* 💡 精密計算：8 句話、48秒完美不相撞輪播 Keyframes */
@keyframes randomBubblePop {
    /* -----------------------------------------------
       A. 登場階段 (0% ~ 0.6%)：約 0.3 秒
       從下方微微升起，並帶有 1.15 倍的日系手遊風彈跳阻尼感
       ----------------------------------------------- */
    0% { 
        opacity: 0; 
        transform: scale(0) translateY(15px); 
    }
    0.6% { 
        opacity: 1; 
        transform: scale(1.15) translateY(-2px); 
    } 
    0.8% {
        transform: scale(1) translateY(0);
    }
    
    /* -----------------------------------------------
       B. 停留與手遊風微抖動階段 (0.8% ~ 8.5%)：約 3.7 秒
       在畫面上穩定停留供玩家閱讀，並帶有精緻的微微晃動感
       ----------------------------------------------- */
    1%   { transform: rotate(-1deg) scale(1); opacity: 1; }
    2.5% { transform: rotate(1deg) scale(1); opacity: 1; }
    4%   { transform: rotate(-0.5deg) scale(1); opacity: 1; }
    6%   { transform: rotate(0.5deg) scale(1); opacity: 1; }
    7.5% { transform: rotate(0deg) scale(1); opacity: 1; }
    8.5% { transform: scale(1); opacity: 1; }
    
    /* -----------------------------------------------
       C. 退場階段 (8.5% ~ 9.375%)：約 0.4 秒
       快速縮小並向上飄移淡出，總活躍時間剛好約 4.5 秒
       ----------------------------------------------- */
    9.375% { 
        opacity: 0; 
        transform: scale(0) translateY(-15px); 
    } 
    
    /* -----------------------------------------------
       D. 靜止潛伏階段 (9.375% ~ 100%)：約 43.5 秒
       剩下的時間完全隱藏，大方地把舞台讓給其他 7 句話排隊輪播
       ----------------------------------------------- */
    100% { 
        opacity: 0; 
    }
}
/* =========================================
   12. RWD 斷點全面進化 (Mobile Optimization)
   ========================================= */
@media (max-width: 768px) {
	.wrd-bar-text { font-size: 12px; left: 10px; }
	.wrd-label-bottom { font-size: 11px; top: -30px; }
	.boss-btn-col .btn { font-size: 12px !important; height: 28px; }
	/* 行動裝置上適度調整魔王比例與氣泡位置避免溢出螢幕 */
	.monster-character { width: 50%; bottom: 14%; }
	.monster-bubble { font-size: 11px;}
	.boss-progress-col { flex: 0 0 100%; width: 100%; padding: 0; margin-bottom: 10px;}
	.boss-btn-col { flex: 0 0 24%; width: 24%; }
	.boss-btn-col .btn { font-size: 11px !important; height: 24px; padding: 0 !important; }
	.boss-bottom-panel{padding: 0 1.5%;left:1%;}
	.wrd-bar-bg{border-radius: 6px;}
	.wrd-bar-fill-container{border-radius: 5px;}

}

@media (max-width: 480px) {
	.wrd-bar-text { font-size: 12px; left: 10px; }
	.wrd-label-bottom { font-size: 9px; top: -31px; right: 3px; }
	.monster-bubble { font-size: 11px;}
	/*.boss-progress-col { flex: 0 0 76%; width: 76%; padding-right: 10px; }*/
	.boss-progress-col { flex: 0 0 100%; width: 100%; padding: 0; margin-bottom: 10px;}
	.boss-btn-col { flex: 0 0 24%; width: 24%; }
	.boss-btn-col .btn { font-size: 11px !important; height: 24px; padding: 0 !important; }
	.boss-bottom-panel{padding: 0 1.5%;left:1%;}
	.wrd-bar-bg{border-radius: 6px;}
	.wrd-bar-fill-container{border-radius: 5px;}

	.boss-part.body {
		width: 75%;
		left: 11%;
		top: -5.5%;
		z-index: 1;
	}
	.boss-part.cloak {
		width: 100%;
		left: 1%;
		top: 52%;
		z-index: 2;
		animation: cloakPulse 2s ease-in-out infinite alternate;
	}
}


