/* 结印对决 —— 水墨暗黑 × 金/朱 东方案术风 */

:root {
  --bg: #0d0f14;
  --panel: rgba(18, 21, 30, 0.85);
  --ink: #e8e2d4;
  --dim: #8b8778;
  --gold: #d4af6a;
  --vermilion: #c0392b;
  --jade: #4caf7d;
  --thunder: #7d6bd9;
  --kanji-font: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", "Songti SC", serif;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  user-select: none;
}

#app { width: 100vw; height: 100vh; position: relative; }

/* ---------- 屏幕切换 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.screen.active { display: flex; }

/* ---------- 开始界面 ---------- */
.title {
  font-family: var(--kanji-font);
  font-size: 84px;
  letter-spacing: 18px;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(212, 175, 106, 0.35);
}
.subtitle { color: var(--dim); letter-spacing: 8px; margin-top: -10px; }

.seal-intro { display: flex; gap: 14px; margin: 18px 0 6px; }
.seal-card {
  width: 108px; padding: 14px 8px 10px;
  background: var(--panel);
  border: 1px solid rgba(212, 175, 106, 0.25);
  border-radius: 10px;
  text-align: center;
}
.seal-card .icon { font-size: 34px; display: block; line-height: 1.3; }
.seal-card .glyph { font-family: var(--kanji-font); font-size: 26px; color: var(--gold); display: block; margin-top: 2px; }
.seal-card .hint { font-size: 11px; color: var(--dim); display: block; margin-top: 6px; line-height: 1.5; }

.btn-primary {
  padding: 14px 64px;
  font-size: 22px; font-family: var(--kanji-font); letter-spacing: 8px;
  color: var(--ink); background: linear-gradient(160deg, #8e2f23, var(--vermilion));
  border: 1px solid rgba(212, 175, 106, 0.5); border-radius: 8px;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 30px rgba(192, 57, 43, 0.45); }
.btn-ghost {
  padding: 8px 28px; color: var(--dim); background: transparent;
  border: 1px solid #3a3f4d; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--gold); }
.tip { color: var(--dim); font-size: 13px; }
.tip b { color: var(--gold); }

/* ---------- 匹配界面 ---------- */
.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 3px solid rgba(212, 175, 106, 0.2); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#match-text { letter-spacing: 4px; color: var(--ink); }

/* ---------- 战斗界面 ---------- */
#screen-battle { justify-content: flex-start; gap: 0; padding: 14px 22px; }
#screen-battle.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-7px, 4px); }
  50% { transform: translate(6px, -5px); }
  75% { transform: translate(-4px, -3px); }
}

#battle-top { width: 100%; display: flex; align-items: center; gap: 18px; }
.hp-side { flex: 1; display: flex; align-items: center; gap: 10px; }
.hp-side.right { flex-direction: row-reverse; }
.pname { font-family: var(--kanji-font); font-size: 20px; color: var(--gold); white-space: nowrap; }
.hp-bar {
  position: relative; flex: 1; height: 22px;
  background: #1a1d26; border: 1px solid #3a3f4d; border-radius: 11px; overflow: hidden;
}
.hp-fill {
  height: 100%; width: 100%; border-radius: 10px;
  background: linear-gradient(90deg, #3d8b5f, var(--jade));
  transition: width 0.3s ease;
}
.hp-fill.foe { background: linear-gradient(90deg, #a03024, var(--vermilion)); margin-left: auto; }
.hp-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; text-shadow: 0 1px 2px #000;
}
#timer {
  font-family: var(--kanji-font); font-size: 34px; color: var(--ink); min-width: 72px; text-align: center;
}
#timer.urgent { color: var(--vermilion); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
.shield-tag {
  font-size: 12px; color: #9fc6ff; border: 1px solid #4a6b9e;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  animation: pulse 1.2s infinite;
}
.hidden { display: none !important; }

#banner {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  z-index: 30; padding: 12px 42px;
  font-family: var(--kanji-font); font-size: 44px; letter-spacing: 10px; white-space: nowrap;
  border-radius: 8px; border: 1px solid rgba(212, 175, 106, 0.6);
  background: rgba(13, 15, 20, 0.9);
  animation: bannerIn 1.1s ease forwards;
  pointer-events: none;
}
#banner.fire { color: #ff9a5c; box-shadow: 0 0 60px rgba(255, 110, 40, 0.35); }
#banner.thunder { color: #b9a8ff; box-shadow: 0 0 60px rgba(125, 107, 217, 0.4); }
#banner.wood { color: #8fe0b0; box-shadow: 0 0 60px rgba(76, 175, 125, 0.35); }
#banner.metal { color: #9fc6ff; box-shadow: 0 0 60px rgba(120, 160, 220, 0.3); }
#banner.rock, #banner.wind { color: var(--gold); box-shadow: 0 0 40px rgba(212, 175, 106, 0.25); }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateX(-50%) scale(1.5); }
  15% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#battle-main { width: 100%; flex: 1; display: flex; gap: 18px; margin-top: 14px; min-height: 0; }

#cam-wrap {
  flex: 1.2; position: relative; border-radius: 12px; overflow: hidden;
  background: #000; border: 1px solid #2a2e3a;
  display: flex; align-items: center; justify-content: center;
}
#cam-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
#cam-off, #cam-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 15px; letter-spacing: 2px; text-align: center; padding: 20px;
  background: #101218;
}
#recog-label {
  position: absolute; left: 12px; top: 12px;
  padding: 6px 14px; border-radius: 6px;
  background: rgba(13, 15, 20, 0.75); border: 1px solid #3a3f4d;
  font-family: var(--kanji-font); font-size: 22px; color: var(--gold);
}
#recog-label.confirm { border-color: var(--jade); color: var(--jade); }

#seq-display {
  position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center;
}
.seq-chip {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--kanji-font); font-size: 24px;
  background: rgba(13, 15, 20, 0.8); border: 2px solid #3a3f4d; color: var(--dim);
}
.seq-chip.done { border-color: var(--jade); color: var(--jade); }
.seq-chip.next { border-color: var(--gold); color: var(--gold); animation: pulse 1s infinite; }

#opp-wrap {
  flex: 1; position: relative; border-radius: 12px;
  background: radial-gradient(ellipse at 50% 70%, #171a24 0%, #0b0d12 75%);
  border: 1px solid #2a2e3a;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
#opp-avatar {
  position: relative; width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, #1d2130 0%, #0d0f14 70%);
  border: 2px solid rgba(212, 175, 106, 0.3);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
#opp-glyph {
  font-family: var(--kanji-font); font-size: 96px; color: #3d4358;
  text-shadow: 0 0 30px rgba(125, 107, 217, 0.3);
  transition: color 0.2s;
}
#opp-aura {
  position: absolute; inset: -14px; border-radius: 50%; opacity: 0;
  border: 2px solid var(--thunder);
}
#opp-avatar.sealing #opp-aura { opacity: 1; animation: auraSpin 1.1s linear infinite; }
#opp-avatar.sealing #opp-glyph { color: var(--thunder); }
#opp-avatar.hit { animation: oppHit 0.4s; }
#opp-avatar.cast #opp-glyph { color: var(--vermilion); }
@keyframes auraSpin {
  0% { transform: rotate(0); border-top-color: transparent; }
  100% { transform: rotate(360deg); border-top-color: transparent; }
}
@keyframes oppHit {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-12px); filter: brightness(2); }
  60% { transform: translateX(8px); }
}
#opp-name { color: var(--dim); letter-spacing: 3px; font-size: 14px; }
#opp-action {
  min-height: 52px; font-family: var(--kanji-font); font-size: 38px; color: var(--thunder);
  text-shadow: 0 0 20px rgba(125, 107, 217, 0.5);
}

#battle-bottom { width: 100%; display: flex; gap: 18px; margin-top: 14px; }
#skill-bar { flex: 1.2; display: flex; gap: 10px; flex-wrap: wrap; }
.skill-chip {
  position: relative; width: 118px; padding: 8px 6px 6px;
  background: var(--panel); border: 1px solid #2a2e3a; border-radius: 8px;
  text-align: center; overflow: hidden;
}
.skill-chip .s-glyphs { font-family: var(--kanji-font); font-size: 20px; color: var(--gold); letter-spacing: 2px; }
.skill-chip .s-name { font-size: 11px; color: var(--ink); margin-top: 3px; }
.skill-chip .s-desc { font-size: 10px; color: var(--dim); margin-top: 2px; }
.skill-chip .cd-mask {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 0%;
  background: rgba(13, 15, 20, 0.82);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--ink); pointer-events: none;
}
#log {
  flex: 1; height: 96px; overflow: hidden;
  background: var(--panel); border: 1px solid #2a2e3a; border-radius: 8px;
  padding: 8px 12px; font-size: 12px; color: var(--dim); line-height: 1.7;
}
#log .me { color: var(--jade); }
#log .foe { color: #e07b6d; }

#fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.float-num {
  position: absolute; font-family: var(--kanji-font); font-size: 42px; font-weight: 700;
  animation: floatUp 1s ease-out forwards; text-shadow: 0 2px 8px #000;
}
.float-num.dmg { color: #ff7b63; }
.float-num.heal { color: var(--jade); }
.float-num.block { color: #9fc6ff; font-size: 30px; }
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.6); }
  20% { opacity: 1; transform: translateY(0) scale(1.15); }
  100% { opacity: 0; transform: translateY(-70px) scale(1); }
}
.seal-pop {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--kanji-font); font-size: 110px; color: var(--gold);
  animation: sealPop 0.55s ease-out forwards; text-shadow: 0 0 40px rgba(212, 175, 106, 0.6);
}
@keyframes sealPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(0.95); }
}
.flash { position: absolute; inset: 0; animation: flashFade 0.3s ease-out forwards; }
@keyframes flashFade { from { opacity: 0.55; } to { opacity: 0; } }

/* ---------- 结算界面 ---------- */
#result-title { font-family: var(--kanji-font); font-size: 96px; letter-spacing: 24px; }
#result-title.win { color: var(--gold); text-shadow: 0 0 50px rgba(212, 175, 106, 0.5); }
#result-title.lose { color: var(--vermilion); }
#result-title.draw { color: var(--dim); }
#result-detail { color: var(--dim); letter-spacing: 3px; }
.result-buttons { display: flex; gap: 16px; margin-top: 10px; }

/* ---------- 手势舞台视图（默认）：只看识别结果，不看摄像头画面 ---------- */
#stage {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 62%, #151824 0%, #0b0d12 78%);
  overflow: hidden;
}
#stage::before { /* 舞台中央的法阵底纹 */
  content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%;
  border: 1px solid rgba(212, 175, 106, 0.14);
  box-shadow: 0 0 0 24px rgba(212, 175, 106, 0.04), 0 0 0 60px rgba(212, 175, 106, 0.02);
}
#stage-glyph {
  position: relative; z-index: 2;
  font-family: var(--kanji-font); font-size: 148px; line-height: 1;
  color: transparent; transition: color 0.15s, text-shadow 0.15s, transform 0.15s;
}
#stage-glyph.live { color: rgba(212, 175, 106, 0.45); }
#stage-glyph.confirm {
  color: var(--gold);
  text-shadow: 0 0 55px rgba(212, 175, 106, 0.75);
  transform: scale(1.08);
}
#stage-icon { position: relative; z-index: 2; font-size: 42px; margin-top: 14px; opacity: 0.85; }
#cam-video.cam-hidden { visibility: hidden; }

.btn-view {
  position: absolute; right: 10px; top: 10px; z-index: 6;
  padding: 4px 12px; font-size: 12px; color: var(--dim);
  background: rgba(13, 15, 20, 0.7); border: 1px solid #3a3f4d; border-radius: 6px; cursor: pointer;
}
.btn-view:hover { color: var(--ink); border-color: var(--gold); }

#recog-label, #seq-display { z-index: 6; }

/* 技能释放时的属性冲击特效（覆盖舞台） */
.stage-burst { position: absolute; inset: 0; z-index: 1; animation: burstFade 0.7s ease-out forwards; }
.stage-burst.fire    { background: radial-gradient(circle, rgba(255, 110, 40, 0.55) 0%, transparent 70%); }
.stage-burst.thunder { background: radial-gradient(circle, rgba(125, 107, 217, 0.6) 0%, transparent 70%); animation: burstFade 0.45s ease-out 2; }
.stage-burst.wood    { background: radial-gradient(circle, rgba(76, 175, 125, 0.5) 0%, transparent 70%); }
.stage-burst.metal   { background: radial-gradient(circle, rgba(120, 160, 220, 0.45) 0%, transparent 70%); }
.stage-burst.rock, .stage-burst.wind { background: radial-gradient(circle, rgba(212, 175, 106, 0.4) 0%, transparent 70%); }
@keyframes burstFade {
  0% { opacity: 0; transform: scale(0.55); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.45); }
}

/* ---------- 手部骨架（舞台视图实时显示手的位置） ---------- */
#hand-canvas { position: absolute; inset: 0; z-index: 1; }
#stage-nohand {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 3;
  font-size: 13px; color: var(--dim); letter-spacing: 2px; white-space: nowrap;
  animation: pulse 1.6s infinite;
}

/* ---------- SVG 图标尺寸 ---------- */
.seal-card .icon svg { width: 46px; height: 46px; color: var(--gold); display: block; margin: 0 auto; }
.s-glyphs { display: flex; gap: 5px; justify-content: center; align-items: center; min-height: 24px; }
.s-glyphs svg { width: 21px; height: 21px; color: var(--gold); }
#stage-icon svg { width: 44px; height: 44px; color: var(--gold); opacity: 0.9; }

/* ---------- 粒子引擎画布 ---------- */
#fx-canvas { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* 序列进度图标 */
.seq-chip { flex-direction: column; gap: 2px; }
.seq-chip svg { width: 22px; height: 22px; }
.seq-chip b { font-size: 10px; font-weight: 400; line-height: 1; }

/* ---------- 金钟罩 ---------- */
#opp-wrap { position: relative; }
.bell {
  position: absolute; left: 50%; top: 47%; width: 250px; height: 250px; z-index: 4;
  transform: translate(-50%, -50%); pointer-events: none;
  mix-blend-mode: screen; /* 半透明能量罩：透出舞台内容 */
  filter: drop-shadow(0 0 26px rgba(212, 175, 106, 0.35));
}
.bell svg { width: 100%; height: 100%; display: block; }
.bell.mini { width: 118px; height: 118px; top: 36%; }
.bell.drop { animation: bellDrop 0.5s cubic-bezier(0.2, 1.35, 0.4, 1); }
@keyframes bellDrop {
  from { transform: translate(-50%, -170%); }
  to { transform: translate(-50%, -50%); }
}
.bell.fade { animation: bellFade 0.5s ease forwards; }
@keyframes bellFade { to { opacity: 0; transform: translate(-50%, -50%) scale(0.92); } }
.bell.shatter { animation: bellShatter 0.45s ease-out forwards; }
@keyframes bellShatter {
  20% { filter: brightness(2.4) drop-shadow(0 0 46px rgba(255, 230, 150, 0.9)); }
  100% { opacity: 0; transform: translate(-50%, -32%) rotate(9deg) scale(1.18); }
}
