:root {
  --ink-dark: #070a0f;
  --ink-panel: rgba(10, 14, 22, 0.78);
  --gold-main: #e6c17a;
  --gold-bright: #ffd97d;
  --jade-cyan: #38e8d6;
  --jade-deep: #0d9488;
  --crimson: #c82829;
  --crimson-bright: #ff4444;
  --font-brush: "Ma Shan Zheng", "Zhi Mang Xing", "STKaiti", "KaiTi", "DFKai-SB", serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink-dark);
  color: #f4efe6;
  font-family: var(--font-serif);
  touch-action: none;
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* 全螢幕濾鏡與暗角 */
#vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 58%, rgba(3, 5, 10, 0.72) 100%);
  z-index: 4;
}

#screen-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.18s ease;
}

#screen-fx.fx-dodge {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(56, 232, 214, 0.08) 35%, rgba(16, 185, 175, 0.36) 100%);
  box-shadow: inset 0 0 90px rgba(56, 232, 214, 0.45);
}

#screen-fx.fx-parry {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(255, 225, 130, 0.24) 10%, rgba(230, 193, 122, 0.05) 70%);
}

#screen-fx.fx-hurt {
  opacity: 1;
  background: radial-gradient(circle at center, transparent 35%, rgba(200, 20, 20, 0.55) 100%);
}

#screen-fx.fx-ult {
  opacity: 1;
  background: radial-gradient(circle at center, rgba(56, 232, 214, 0.15) 20%, rgba(4, 9, 20, 0.75) 100%);
}

/* 標題畫面 */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 5vw 7vw;
  pointer-events: auto;
}

.title-ink-backdrop {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(5, 8, 14, 0.85) 0%, rgba(5, 8, 14, 0.42) 48%, rgba(5, 8, 14, 0.08) 100%);
  pointer-events: none;
}

.title-content {
  position: relative;
  z-index: 2;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 54px;
}

/* 首頁底部即時同步水墨金字歌詞列 */
.title-lyrics-bar {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 18px));
  transform: translateX(-50%);
  z-index: 6;
  width: min(860px, 92vw);
  padding: 10px 26px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(6, 10, 18, 0.08) 0%, rgba(6, 10, 18, 0.78) 22%, rgba(6, 10, 18, 0.78) 78%, rgba(6, 10, 18, 0.08) 100%);
  border-top: 1px solid rgba(230, 193, 122, 0.28);
  border-bottom: 1px solid rgba(230, 193, 122, 0.18);
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.lyrics-meta {
  font-size: 0.76rem;
  letter-spacing: 0.28em;
  color: rgba(230, 193, 122, 0.72);
  margin-bottom: 3px;
}

.lyrics-current {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(1.02rem, 2.1vw, 1.38rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #fff8e7;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.95), 0 0 18px rgba(230, 193, 122, 0.48);
  min-height: 1.55em;
  animation: lyricFadeIn 0.35s ease;
}

.lyrics-next {
  font-size: clamp(0.76rem, 1.25vw, 0.88rem);
  letter-spacing: 0.12em;
  color: rgba(226, 232, 240, 0.48);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  min-height: 1.2em;
  margin-top: 2px;
}

@keyframes lyricFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.title-seal, .ending-seal, .stage-card-seal {
  display: inline-block;
  padding: 4px 12px;
  border: 2px solid #c9332b;
  color: #ff6b61;
  background: rgba(145, 24, 24, 0.25);
  font-family: var(--font-brush);
  font-size: 1.15rem;
  letter-spacing: 4px;
  transform: rotate(-3deg);
  box-shadow: 0 0 18px rgba(201, 51, 43, 0.35);
}

.game-logo {
  font-family: var(--font-brush);
  font-size: clamp(3.6rem, 8vw, 6.4rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fffdf7 0%, #ebd094 55%, #b5893d 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.92)) drop-shadow(0 0 28px rgba(230, 193, 122, 0.25));
}

.game-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  letter-spacing: 0.28em;
  color: rgba(232, 224, 208, 0.88);
  text-shadow: 0 2px 10px #000;
  margin-bottom: 10px;
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 82vw);
}

.wuxia-btn {
  position: relative;
  padding: 13px 26px;
  background: linear-gradient(90deg, rgba(16, 22, 33, 0.92), rgba(28, 36, 52, 0.78));
  border: 1px solid rgba(230, 193, 122, 0.45);
  border-left: 4px solid var(--gold-main);
  color: #f4efe6;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.wuxia-btn:hover {
  transform: translateX(6px);
  border-color: var(--jade-cyan);
  border-left-color: var(--jade-cyan);
  box-shadow: 0 0 24px rgba(56, 232, 214, 0.3);
}

.wuxia-btn.primary-btn {
  background: linear-gradient(90deg, rgba(145, 28, 28, 0.92), rgba(75, 16, 22, 0.85));
  border-color: var(--gold-main);
  border-left: 5px solid var(--gold-bright);
  font-size: 1.3rem;
}

.btn-brush {
  font-family: var(--font-brush);
  font-size: 1.65rem;
  letter-spacing: 0.22em;
}

.controls-preview {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.82rem;
  color: rgba(226, 218, 200, 0.78);
  background: rgba(8, 12, 20, 0.65);
  padding: 10px 14px;
  border-left: 2px solid rgba(56, 232, 214, 0.55);
}

.controls-preview b {
  color: var(--jade-cyan);
  margin-left: 3px;
}

/* PWA 與每關開局空地說明卷軸彈窗 */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(3, 6, 12, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.briefing-backdrop {
  background: linear-gradient(90deg, rgba(4, 8, 15, 0.88) 0%, rgba(4, 8, 15, 0.55) 55%, rgba(4, 8, 15, 0.25) 100%);
  justify-content: flex-start;
  padding-left: 6vw;
}

.briefing-scroll {
  max-width: 560px;
  background: linear-gradient(180deg, rgba(12, 19, 31, 0.94), rgba(7, 11, 18, 0.96));
  border: 1px solid rgba(230, 193, 122, 0.6);
  border-left: 5px solid var(--gold-bright);
  padding: 26px 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  animation: cardBrushIn 0.35s ease-out;
}

.briefing-title {
  font-family: var(--font-brush);
  font-size: clamp(1.85rem, 3.6vw, 2.55rem);
  color: var(--gold-bright);
  letter-spacing: 0.12em;
  margin: 10px 0 12px;
}

.briefing-desc {
  line-height: 1.75;
  color: #e6dfd1;
  font-size: 0.98rem;
  margin-bottom: 14px;
}

.briefing-tip {
  padding: 10px 14px;
  background: rgba(13, 148, 136, 0.16);
  border-left: 3px solid var(--jade-cyan);
  color: #ccfbf1;
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

.briefing-keys {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px 14px;
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-bottom: 20px;
  background: rgba(5, 8, 14, 0.65);
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.briefing-keys b {
  color: var(--gold-bright);
  margin-right: 4px;
}

.briefing-start-btn {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.briefing-start-btn small {
  font-size: 0.8rem;
  color: #fde68a;
  font-weight: 500;
}

/* 闖關推進目標指引列與 560m 路程進度條 */
.objective-hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(540px, 52vw);
  padding: 9px 22px 10px;
  background: linear-gradient(90deg, transparent, rgba(8, 15, 26, 0.88) 12%, rgba(8, 15, 26, 0.88) 88%, transparent);
  border-top: 1px solid rgba(230, 193, 122, 0.45);
  border-bottom: 1px solid rgba(226, 232, 240, 0.35);
  text-align: center;
}

.objective-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.objective-sub {
  font-size: 0.76rem;
  color: var(--gold-main);
  letter-spacing: 0.12em;
}

.objective-pct {
  font-size: 0.75rem;
  color: #e2e8f0;
  font-weight: 700;
}

.stage-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(230, 193, 122, 0.35);
  margin-bottom: 6px;
  overflow: hidden;
}

.stage-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #b45309, #fbbf24, #fef08a);
  transition: width 0.2s ease;
}

.objective-main {
  font-size: clamp(0.88rem, 1.4vw, 1.02rem);
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 8px #000;
}

.modal-box {
  max-width: 480px;
  background: linear-gradient(180deg, #111827, #090d16);
  border: 1px solid var(--gold-main);
  padding: 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.85);
}

.modal-box h2 {
  font-family: var(--font-brush);
  font-size: 2rem;
  color: var(--gold-bright);
  margin-bottom: 14px;
}

.pwa-steps p {
  line-height: 1.7;
  margin-bottom: 12px;
  color: #d8d4cb;
  font-size: 0.95rem;
}

/* 電影過場動畫黑邊 (12%) 與直排書法字卡 */
#cinematic-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

.letterbox {
  position: absolute;
  left: 0;
  right: 0;
  height: 12vh;
  background: #020306;
  display: flex;
  align-items: center;
  padding: 0 4vw;
  z-index: 2;
}

.letterbox-top {
  top: 0;
  justify-content: flex-end;
  border-bottom: 1px solid rgba(230, 193, 122, 0.22);
}

.letterbox-bottom {
  bottom: 0;
  justify-content: center;
  border-top: 1px solid rgba(230, 193, 122, 0.22);
}

.skip-btn {
  pointer-events: auto;
  padding: 8px 18px;
  background: rgba(25, 32, 46, 0.82);
  border: 1px solid rgba(230, 193, 122, 0.55);
  color: var(--gold-main);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.skip-btn:hover {
  background: rgba(230, 193, 122, 0.2);
  color: #fff;
}

.cinematic-subtitle {
  font-size: clamp(1rem, 2.2vw, 1.38rem);
  letter-spacing: 0.14em;
  color: #f6efe0;
  text-align: center;
  text-shadow: 0 2px 12px #000;
}

.stage-card {
  position: absolute;
  right: 9vw;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 18px;
  padding: 26px 24px;
  background: linear-gradient(180deg, rgba(6, 9, 15, 0.88), rgba(16, 10, 12, 0.78));
  border-right: 4px solid var(--gold-main);
  border-left: 1px solid rgba(230, 193, 122, 0.35);
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.9);
  animation: cardBrushIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.stage-card.crimson-card {
  border-right-color: #ff3b3b;
  box-shadow: 0 0 45px rgba(200, 20, 20, 0.55);
}

.stage-card-main {
  writing-mode: vertical-rl;
  font-family: var(--font-brush);
  font-size: clamp(2.8rem, 5vw, 4.3rem);
  letter-spacing: 0.22em;
  color: #fff9eb;
  text-shadow: 0 0 22px rgba(230, 193, 122, 0.55);
}

.stage-card-sub {
  writing-mode: vertical-rl;
  font-size: 1.15rem;
  letter-spacing: 0.3em;
  color: var(--gold-main);
  padding-top: 8px;
}

@keyframes cardBrushIn {
  from { opacity: 0; transform: translateY(-50%) scale(1.12) translateX(25px); }
  to { opacity: 1; transform: translateY(-50%) scale(1) translateX(0); }
}

/* 戰鬥 HUD */
#combat-hud {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

.player-hud {
  position: absolute;
  top: 18px;
  left: 20px;
  width: min(330px, 44vw);
  background: linear-gradient(90deg, rgba(6, 10, 18, 0.82), rgba(6, 10, 18, 0.25));
  padding: 10px 14px;
  border-left: 3px solid var(--jade-cyan);
}

.sword-emblem {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sword-emblem-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--jade-cyan);
  background: radial-gradient(circle, rgba(56, 232, 214, 0.28), rgba(8, 16, 26, 0.95));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-brush);
  font-size: 1.35rem;
  color: var(--jade-cyan);
  box-shadow: 0 0 14px rgba(56, 232, 214, 0.4);
}

.player-name {
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.12em;
}

.weapon-tag {
  font-size: 0.78rem;
  color: var(--jade-cyan);
  font-weight: 600;
  margin-left: 6px;
}

.buff-tag {
  font-size: 0.74rem;
  color: var(--gold-bright);
  letter-spacing: 0.08em;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.bar-label {
  font-size: 0.75rem;
  color: #cbd5e1;
  width: 32px;
}

.bar-track {
  position: relative;
  flex: 1;
  height: 10px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.bar-trail {
  position: absolute;
  inset: 0 auto 0 0;
  background: #fde68a;
  transition: width 0.45s ease;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  transition: width 0.1s linear;
}

.hp-fill {
  background: linear-gradient(90deg, #881313, #dc2626, #f87171);
}

.qi-fill {
  background: linear-gradient(90deg, #0d9488, #2dd4bf, #7dd3fc);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.65);
}

.bar-num {
  font-size: 0.74rem;
  width: 38px;
  text-align: right;
  color: #e2e8f0;
}

/* Boss 頂部魂系血條與金色架勢條 */
.boss-hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 52vw);
  text-align: center;
}

.boss-header {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 5px;
  text-shadow: 0 2px 10px #000;
}

.boss-stage-tag {
  font-size: 0.8rem;
  color: var(--gold-main);
  letter-spacing: 0.14em;
}

.boss-name {
  font-family: var(--font-brush);
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  letter-spacing: 0.18em;
  color: #fff8eb;
}

.boss-phase {
  padding: 2px 8px;
  background: rgba(185, 28, 28, 0.85);
  border: 1px solid #fca5a5;
  font-size: 0.72rem;
  color: #fff;
  letter-spacing: 0.1em;
}

.boss-hp-container {
  position: relative;
  height: 13px;
  background: rgba(10, 12, 18, 0.9);
  border: 1px solid rgba(230, 193, 122, 0.5);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.75);
  overflow: hidden;
}

.boss-hp-trail {
  position: absolute;
  inset: 0 auto 0 0;
  background: #fef08a;
  transition: width 0.5s ease;
}

.boss-hp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #5c0a0a, #b91c1c, #ef4444);
  transition: width 0.1s linear;
}

.boss-posture-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.posture-label {
  font-size: 0.7rem;
  color: var(--gold-main);
  letter-spacing: 0.08em;
}

.boss-posture-track {
  flex: 1;
  height: 6px;
  background: rgba(15, 18, 26, 0.88);
  border: 1px solid rgba(230, 193, 122, 0.35);
  overflow: hidden;
}

.boss-posture-fill {
  height: 100%;
  background: linear-gradient(90deg, #b45309, #f59e0b, #fef08a);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.75);
  transition: width 0.12s ease;
}

/* 右上角工具鈕 */
.top-right-tools {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.tool-btn {
  padding: 6px 12px;
  background: rgba(10, 15, 25, 0.78);
  border: 1px solid rgba(230, 193, 122, 0.42);
  color: #e5e0d5;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  cursor: pointer;
}

.tool-btn:hover {
  border-color: var(--jade-cyan);
  color: var(--jade-cyan);
}

/* 金光／紅光預警與招式書法橫幅 */
.telegraph-banner {
  position: absolute;
  top: 21%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 22px;
  font-family: var(--font-brush);
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  letter-spacing: 0.18em;
  border-radius: 4px;
  text-shadow: 0 2px 14px #000;
}

.telegraph-gold {
  color: #fff7cc;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.52), transparent 75%);
  text-shadow: 0 0 20px #fbbf24, 0 0 40px #f59e0b;
}

.telegraph-red {
  color: #ffe4e6;
  background: radial-gradient(circle, rgba(225, 29, 72, 0.58), transparent 75%);
  text-shadow: 0 0 20px #ef4444, 0 0 40px #dc2626;
}

.skill-banner {
  position: absolute;
  left: 5vw;
  top: 38%;
  padding: 8px 34px 8px 20px;
  background: linear-gradient(90deg, rgba(8, 22, 30, 0.9), rgba(8, 22, 30, 0));
  border-left: 5px solid var(--jade-cyan);
  font-family: var(--font-brush);
  font-size: clamp(2rem, 4.2vw, 3.2rem);
  letter-spacing: 0.22em;
  color: #e6fffb;
  text-shadow: 0 0 20px rgba(56, 232, 214, 0.85), 0 4px 14px #000;
  animation: bannerSlash 0.28s ease-out;
}

@keyframes bannerSlash {
  from { opacity: 0; transform: translateX(-40px) skewX(-12deg); }
  to { opacity: 1; transform: translateX(0) skewX(-6deg); }
}

.stamp-banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stamp-box {
  padding: 18px 42px;
  border: 6px solid #dc2626;
  background: rgba(127, 29, 29, 0.35);
  color: #fecaca;
  font-family: var(--font-brush);
  font-size: clamp(4.2rem, 10vw, 7.5rem);
  letter-spacing: 0.25em;
  transform: rotate(-8deg);
  box-shadow: 0 0 60px rgba(220, 38, 38, 0.75), inset 0 0 30px rgba(220, 38, 38, 0.45);
  animation: stampSlam 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes stampSlam {
  from { opacity: 0; transform: scale(2.4) rotate(-18deg); }
  to { opacity: 1; transform: scale(1) rotate(-8deg); }
}

/* 連擊面板 */
.combo-panel {
  position: absolute;
  right: 26px;
  top: 32%;
  text-align: right;
}

.combo-count {
  font-family: var(--font-brush);
  font-size: clamp(2.4rem, 4.5vw, 3.8rem);
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(255, 217, 125, 0.65), 0 4px 12px #000;
}

.combo-count small {
  font-size: 1.2rem;
  color: #f3e8d2;
}

.combo-rank {
  display: inline-block;
  padding: 2px 12px;
  background: linear-gradient(90deg, transparent, rgba(56, 232, 214, 0.32));
  border-right: 3px solid var(--jade-cyan);
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  color: #ccfbf1;
}

/* 敗北面板 */
.defeat-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(7, 10, 16, 0.92);
  border: 1px solid #b91c1c;
  padding: 30px 44px;
  text-align: center;
  pointer-events: auto;
  box-shadow: 0 20px 60px #000;
}

.defeat-title {
  font-family: var(--font-brush);
  font-size: 3.2rem;
  color: #f87171;
  margin-bottom: 8px;
}

.defeat-sub {
  color: #cbd5e1;
  margin-bottom: 20px;
}

/* 左下角水墨虛擬搖桿 */
.joystick-zone {
  position: absolute;
  left: 22px;
  bottom: 22px;
  width: 150px;
  height: 150px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.joystick-base {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.35), rgba(8, 12, 20, 0.65));
  border: 1.5px solid rgba(230, 193, 122, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.65);
}

.joystick-stick {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230, 193, 122, 0.85), rgba(146, 108, 45, 0.72));
  border: 1px solid #fff7d6;
  box-shadow: 0 0 16px rgba(230, 193, 122, 0.55);
  transition: transform 0.04s linear;
}

/* 右下角劍道技能按鍵弧群 */
.action-cluster {
  position: absolute;
  right: 20px;
  bottom: 18px;
  width: 290px;
  height: 245px;
  pointer-events: none;
}

.skill-btn {
  position: absolute;
  pointer-events: auto;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(24, 36, 54, 0.92), rgba(8, 12, 20, 0.94));
  border: 1.5px solid rgba(230, 193, 122, 0.55);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.75);
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.skill-btn:active {
  transform: scale(0.92);
}

.skill-title {
  position: relative;
  z-index: 2;
  font-family: var(--font-serif);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.15;
}

.skill-key {
  position: relative;
  z-index: 2;
  font-size: 0.62rem;
  color: var(--gold-main);
  margin-top: 2px;
}

.cd-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: rgba(2, 6, 14, 0.78);
  z-index: 1;
  transition: height 0.08s linear;
}

.attack-btn {
  right: 6px;
  bottom: 6px;
  width: 92px;
  height: 92px;
  border: 2px solid var(--jade-cyan);
  background: radial-gradient(circle, rgba(15, 118, 110, 0.85), rgba(8, 22, 32, 0.95));
  box-shadow: 0 0 26px rgba(56, 232, 214, 0.42);
}

.attack-main {
  font-family: var(--font-brush);
  font-size: 1.85rem;
  color: #e6fffb;
}

.dodge-btn {
  right: 112px;
  bottom: 4px;
  width: 64px;
  height: 64px;
}

.parry-btn {
  right: 102px;
  bottom: 78px;
  width: 66px;
  height: 66px;
  border-color: var(--gold-bright);
}

.s1-btn {
  right: 14px;
  bottom: 110px;
  width: 64px;
  height: 64px;
  border-color: #38bdf8;
}

.s2-btn {
  right: 84px;
  bottom: 152px;
  width: 64px;
  height: 64px;
  border-color: #2dd4bf;
}

.s3-btn {
  right: 162px;
  bottom: 124px;
  width: 64px;
  height: 64px;
  border-color: #a78bfa;
}

.ult-btn {
  right: 184px;
  bottom: 42px;
  width: 74px;
  height: 74px;
  border: 2px solid rgba(230, 193, 122, 0.4);
  opacity: 0.65;
}

.ult-btn.ult-ready {
  opacity: 1;
  border-color: var(--gold-bright);
  background: radial-gradient(circle, rgba(217, 119, 6, 0.85), rgba(69, 26, 3, 0.95));
  box-shadow: 0 0 28px rgba(251, 191, 36, 0.85), 0 0 55px rgba(56, 232, 214, 0.5);
  animation: ultPulse 1.1s infinite alternate;
}

@keyframes ultPulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* 結局畫面 */
#ending-screen {
  justify-content: flex-end;
  background: linear-gradient(270deg, rgba(6, 10, 18, 0.88) 0%, rgba(6, 10, 18, 0.35) 58%, transparent 100%);
}

.ending-card {
  max-width: 520px;
  padding: 32px;
  background: rgba(8, 12, 20, 0.82);
  border: 1px solid rgba(230, 193, 122, 0.55);
  border-top: 4px solid var(--gold-bright);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
}

.ending-title {
  font-family: var(--font-brush);
  font-size: clamp(2.2rem, 4.5vw, 3.3rem);
  color: var(--gold-bright);
  margin: 12px 0;
}

.ending-poem {
  line-height: 1.8;
  color: #e2dac9;
  margin-bottom: 22px;
  letter-spacing: 0.08em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-item {
  padding: 12px;
  background: rgba(17, 24, 39, 0.8);
  border-left: 3px solid var(--jade-cyan);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 0.78rem;
  color: #94a3b8;
}

.stat-val {
  font-family: var(--font-brush);
  font-size: 1.9rem;
  color: #fff;
}

@media (max-width: 768px) {
  .controls-preview { display: none; }
  .boss-hud { width: 46vw; top: 10px; }
  .player-hud { top: 10px; left: 10px; width: 40vw; padding: 7px 10px; }
  .sword-emblem-icon { width: 28px; height: 28px; font-size: 1rem; }
  .action-cluster { transform: scale(0.88); transform-origin: bottom right; right: 10px; bottom: 10px; }
  .joystick-zone { left: 10px; bottom: 10px; transform: scale(0.9); transform-origin: bottom left; }
}
