/*
 * MMO HUD 風ダークテーマ
 * レイアウト方針: 各領域は固定サイズ。表示の出し入れは visibility / opacity で行い、
 * 数値は tabular-nums にして、詠唱・被弾・撃破で要素の位置が動かないようにする。
 * Web フォントが読めない (オフライン) 場合も下のフォールバックで同じ寸法に収まる。
 */
:root {
  /* 背景・パネル */
  --bg-0: #07090f;
  --bg-1: #0d111c;
  --panel: rgba(16, 21, 34, 0.9);
  --panel-2: rgba(22, 28, 45, 0.92);
  --line: #273049;
  --line-strong: #3a4566;
  /* 文字 */
  --text: #e9edf7;
  --text-dim: #8d97b3;
  --text-faint: #566079;
  /* アクセント */
  --gold: #d8b469;
  --gold-soft: rgba(216, 180, 105, 0.35);
  --typed: #ffd76a;
  --good: #46d58a;
  --bad: #ff5468;
  --warn: #ffb547;
  /* ゲージ */
  --hp: #3fd07f;
  --hp-2: #1f9a58;
  --hp-low: #ffb547;
  --mp: #4f97ff;
  --mp-2: #2c5fd6;
  --boss-hp: #e5484d;
  --boss-hp-2: #9d1f2b;
  /* 攻撃呪文の★帯 */
  --t1: #4fd8c8;
  --t2: #63a8ff;
  --t3: #c08cff;
  /* 支援呪文の種類 */
  --k-heal: #6fe3a0;
  --k-guard: #e2c27a;
  --k-silence: #ff8fc7;
  --k-pure: #7fdcf0;
  --k-buff: #ff9f5a;
  /* ボスの技の種類 */
  --a-auto: #8d97b3;
  --a-raidwide: #ff9f43;
  --a-buster: #ff4d6d;
  --a-interruptible: #ff8fc7;
  --a-dot: #9be15d;
  --a-enrage: #ff2040;
  /* フォント */
  --font-ui: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  --font-display: "Cinzel", "Times New Roman", "Yu Mincho", serif;
  --radius: 10px;
}

html { scrollbar-gutter: stable; }
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(80, 100, 170, 0.22), transparent 70%),
    radial-gradient(800px 400px at 85% 110%, rgba(140, 90, 200, 0.12), transparent 70%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  display: grid;
  place-items: center;
  overflow-x: hidden;
}

/* 1080px 幅の固定レイアウトを JS (fitToScreen) で zoom して画面に収める */
#app {
  position: relative;
  width: 1080px;
  padding: 10px 16px 16px;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #151b2c;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8em;
  line-height: 1.6;
  text-align: center;
}

/* ---------- 共通パネル ---------- */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.panel::before {
  /* 上辺の金のハイライト */
  content: "";
  position: absolute; left: 12px; right: 12px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
}
.panel-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ---------- ヘッダー ---------- */
.topbar { display: flex; align-items: center; gap: 14px; height: 40px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { color: var(--gold); font-size: 1.1rem; text-shadow: 0 0 10px var(--gold-soft); }
.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff6dc, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.chip {
  min-width: 72px;
  padding: 1px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.06em;
}
.stage-label { width: 100px; text-align: right; color: var(--gold); font-size: 0.85rem; letter-spacing: 0.08em; }
.icon-btn {
  width: 34px; height: 30px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); cursor: pointer; font-size: 0.95rem;
}
.diff-easy { color: #6fe3a0; }
.diff-normal { color: #63a8ff; }
.diff-hard { color: #ffb547; }
.diff-savage { color: #ff5468; }

/* ---------- ボス ---------- */
.stage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  margin-top: 6px;
  height: 330px;
}

.boss { padding: 12px 18px 14px; overflow: hidden; display: grid; grid-template-rows: 30px 22px minmax(0, 1fr) 82px; gap: 6px; }
.boss-plate { display: flex; align-items: center; gap: 10px; min-width: 0; }
.boss-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.boss-name {
  font-size: 1.25rem; font-weight: 700; letter-spacing: 0.06em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
.phase-chip {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  color: var(--gold); border: 1px solid var(--gold-soft); border-radius: 4px; padding: 0 6px;
  white-space: nowrap;
}
.enrage {
  margin-left: auto; display: flex; align-items: baseline; gap: 6px;
  padding: 2px 10px; border-radius: 6px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25);
}
.enrage-label { font-family: var(--font-display); font-size: 0.62rem; letter-spacing: 0.16em; color: var(--text-dim); }
.enrage-time { font-size: 1.05rem; font-weight: 700; color: var(--text); width: 3.2em; text-align: right; }
.enrage.danger { border-color: var(--bad); box-shadow: 0 0 12px rgba(255, 84, 104, 0.35); }
.enrage.danger .enrage-time { color: var(--bad); }

/* ゲージ共通 */
.gauge-track {
  position: relative;
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(180deg, #05070c, #10141f);
  border: 1px solid #1e2538;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.gauge-fill {
  position: relative;
  height: 100%;
  transition: width 0.25s ease-out;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 8px currentColor;
}
.gauge-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.boss-hp { height: 20px; }
.boss-hp .gauge-fill { color: rgba(229, 72, 77, 0.6); background: linear-gradient(180deg, #ff6a6f, var(--boss-hp) 55%, var(--boss-hp-2)); }

.boss-body { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.boss-aura {
  position: absolute; width: 180px; height: 120px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(120, 140, 255, 0.22), transparent);
  filter: blur(6px);
}
.sprite {
  position: relative;
  height: 140px;
  display: flex; align-items: center; justify-content: center;
  font-size: 92px; line-height: 1;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.7));
  transition: opacity 0.6s, transform 0.6s;
  user-select: none;
}
.sprite svg { display: block; height: 140px; width: auto; overflow: visible; }
.sprite.dead { animation: defeat 1.1s ease-in forwards; }
.sprite.enter { animation: enter 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
@keyframes defeat {
  0% { opacity: 1; transform: none; filter: brightness(1); }
  20% { opacity: 1; transform: translateX(-6px); filter: brightness(3) saturate(0); }
  35% { transform: translateX(6px); }
  100% { opacity: 0; transform: translateY(16px) scale(0.85); filter: brightness(2) blur(8px) saturate(0); }
}
@keyframes enter {
  0% { opacity: 0; transform: translateY(24px) scale(0.85); filter: brightness(0) blur(4px); }
  60% { opacity: 1; filter: brightness(0.6) blur(0); }
  100% { opacity: 1; transform: none; filter: none; }
}
.sprite.lunge { animation: lunge 0.35s ease-out; }
.sprite.hit { animation: hit 0.4s ease-out; }
/* 敵スプライトの演出は transform / filter のみ (周囲のレイアウトには影響しない) */
@keyframes hit {
  0% { transform: translateX(0); filter: brightness(2.2); }
  30% { transform: translateX(-10px); filter: brightness(1.5) drop-shadow(0 0 24px rgba(255, 215, 106, 0.8)); }
  60% { transform: translateX(6px); }
  100% { transform: translateX(0); filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.7)); }
}
@keyframes lunge {
  0% { transform: scale(1); }
  40% { transform: scale(1.18) translateY(8px); }
  100% { transform: scale(1); }
}

/* ボスの詠唱バー (最重要の視線誘導先) */
.castbar {
  --tc: var(--a-auto);
  padding: 8px 12px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(5, 7, 12, 0.55);
  opacity: 0.5;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.castbar.casting { opacity: 1; border-color: color-mix(in srgb, var(--tc) 70%, transparent); }
.castbar.type-raidwide { --tc: var(--a-raidwide); }
.castbar.type-buster { --tc: var(--a-buster); }
.castbar.type-interruptible { --tc: var(--a-interruptible); }
.castbar.type-dot { --tc: var(--a-dot); }
.castbar.type-enrage { --tc: var(--a-enrage); }
.castbar.type-buster.casting, .castbar.type-interruptible.casting, .castbar.type-enrage.casting {
  animation: cast-pulse 0.9s ease-in-out infinite;
}
@keyframes cast-pulse { 50% { box-shadow: 0 0 18px color-mix(in srgb, var(--tc) 55%, transparent); } }
.castbar-head { display: flex; align-items: center; gap: 8px; height: 24px; white-space: nowrap; overflow: hidden; }
.cast-type {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 3px; background: var(--tc); color: #0b0d14;
}
.cast-name { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; }
.cast-time { margin-left: auto; font-size: 0.85rem; color: var(--text-dim); width: 4em; text-align: right; }
.castbar-track {
  height: 10px; margin-top: 5px; border-radius: 2px; overflow: hidden;
  background: #05070c; border: 1px solid #1e2538;
}
.castbar-fill {
  height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 60%, #000), var(--tc));
  box-shadow: 0 0 10px var(--tc);
}
.cast-hint { height: 18px; margin-top: 4px; font-size: 0.78rem; font-weight: 700; color: var(--tc); white-space: nowrap; overflow: hidden; }

/* ---------- サイドパネル ---------- */
.side { display: grid; grid-template-rows: 150px 58px minmax(0, 1fr); gap: 10px; min-height: 0; }
.timeline-panel { padding: 10px 12px; }
.tl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tl-list li {
  --tc: var(--a-auto);
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 6px;
  height: 24px; padding: 0 6px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.02); border-left: 3px solid var(--tc);
  font-size: 0.8rem; white-space: nowrap;
}
.tl-list li.now { background: color-mix(in srgb, var(--tc) 16%, transparent); }
.tl-list li .tl-marker { color: var(--tc); font-size: 0.65rem; }
.tl-list li .tl-name { overflow: hidden; text-overflow: ellipsis; }
.tl-list li .tl-type { font-size: 0.66rem; color: var(--tc); }
.tl-list li.unknown { color: var(--text-faint); }
.tl-hidden { margin-left: 8px; font-family: var(--font-body, inherit); font-size: 0.62rem; font-weight: 600; letter-spacing: 0.04em; color: var(--text-dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; vertical-align: 1px; }
.tl-hidden[hidden] { display: none; }
.pause-panel .timeline { max-width: 520px; margin-inline: auto; }
.tl-list .type-raidwide, .tl-item.type-raidwide { --tc: var(--a-raidwide); }
.tl-list .type-buster, .tl-item.type-buster { --tc: var(--a-buster); }
.tl-list .type-interruptible, .tl-item.type-interruptible { --tc: var(--a-interruptible); }
.tl-list .type-dot, .tl-item.type-dot { --tc: var(--a-dot); }
.tl-list .type-enrage { --tc: var(--a-enrage); }

.stats-panel { padding: 8px 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; text-align: center; }
.stat-grid dt { font-family: var(--font-display); font-size: 0.58rem; letter-spacing: 0.12em; color: var(--text-dim); }
.stat-grid dd { margin: 0; font-size: 0.95rem; font-weight: 700; }

.log-panel { padding: 6px 12px; overflow: hidden; }
.log { list-style: none; margin: 0; padding: 0; font-size: 0.74rem; color: var(--text-dim); }
.log li { height: 18px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log li.latest { color: var(--text); }

/* ---------- プレイヤー ---------- */
.party {
  position: relative;
  margin-top: 10px;
  height: 58px;
  display: grid;
  grid-template-rows: 24px 26px;
  row-gap: 8px;
}
.party-gauges { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.gauge { display: grid; grid-template-columns: 28px minmax(0, 1fr) 76px; align-items: center; gap: 8px; }
.gauge-label { font-family: var(--font-display); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.1em; }
.gauge .gauge-track { height: 16px; }
.gauge-num { font-size: 0.85rem; font-weight: 700; text-align: right; }
.gauge.hp .gauge-label { color: var(--hp); }
.gauge.hp .gauge-fill { color: rgba(63, 208, 127, 0.5); background: linear-gradient(180deg, #7cf0ac, var(--hp) 50%, var(--hp-2)); }
.gauge.hp .gauge-fill.low { color: rgba(255, 181, 71, 0.6); background: linear-gradient(180deg, #ffd38a, var(--hp-low) 50%, #c47f17); }
.gauge.mp .gauge-label { color: var(--mp); }
.gauge.mp .gauge-fill { color: rgba(79, 151, 255, 0.5); background: linear-gradient(180deg, #8fbcff, var(--mp) 50%, var(--mp-2)); transition: width 0.1s linear; }

.status-row { display: flex; gap: 6px; height: 26px; overflow: hidden; }
.status {
  flex: none;
  width: 98px; height: 24px; line-height: 22px;
  padding: 0 8px; border-radius: 5px;
  font-size: 0.72rem; white-space: nowrap; overflow: hidden;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3);
  visibility: hidden;
}
.status i { font-style: normal; margin-right: 4px; }
.status.on { visibility: visible; }
.status.buff { color: var(--gold); border-color: rgba(216, 180, 105, 0.4); }
.status.debuff { color: var(--bad); border-color: rgba(255, 84, 104, 0.5); background: rgba(80, 10, 20, 0.35); }
.party .fx-layer { top: -26px; }

/* ---------- 詠唱ライン ---------- */
.chant {
  margin-top: 10px;
  height: 66px;
  padding: 6px 16px;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  grid-template-rows: 34px 18px;
  column-gap: 16px;
  align-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(255, 215, 106, 0.06), rgba(10, 13, 22, 0.85) 30%);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chant.active { border-color: rgba(255, 215, 106, 0.55); box-shadow: 0 0 18px rgba(255, 215, 106, 0.12); }
.chant.miss { animation: chant-miss 0.3s; }
@keyframes chant-miss { 0% { border-color: var(--bad); box-shadow: 0 0 16px rgba(255, 84, 104, 0.4); } }
.chant-meta { grid-row: 1 / span 2; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.chant-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 22px; }
.chant-candidates { font-size: 0.7rem; color: var(--text-dim); height: 16px; white-space: nowrap; }
.chant-romaji {
  font-size: 1.7rem; font-weight: 700; letter-spacing: 0.03em;
  white-space: nowrap; overflow: hidden; line-height: 34px; height: 34px;
}
.chant-romaji .typed { color: var(--typed); text-shadow: 0 0 12px rgba(255, 215, 106, 0.45); }
.chant-romaji .rest { color: #f3f5fb; }
.chant:not(.active) .chant-romaji .rest { color: var(--text-faint); font-size: 1rem; letter-spacing: 0.05em; font-family: var(--font-ui); font-weight: 500; }
.chant-kana { font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; line-height: 18px; height: 18px; }
.chant-kana .done { color: var(--typed); }

/* ---------- 手札 ---------- */
.hand { margin-top: 10px; }
.attack-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hotbar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }

.card {
  --c: var(--text-dim);
  position: relative;
  border-radius: 9px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--c) 10%, transparent), transparent 45%),
    linear-gradient(180deg, #161c2d, #0f1320);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  transition: opacity 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.card::before {
  /* 上辺の色帯 */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--c), transparent);
}
.card.attack { height: 118px; padding: 8px 12px; }
.card.skill { height: 110px; padding: 7px 9px; }
.card.tier-1 { --c: var(--t1); }
.card.tier-2 { --c: var(--t2); }
.card.tier-3 { --c: var(--t3); }
.card.kind-heal { --c: var(--k-heal); }
.card.kind-guard { --c: var(--k-guard); }
.card.kind-silence { --c: var(--k-silence); }
.card.kind-pure { --c: var(--k-pure); }
.card.kind-buff { --c: var(--k-buff); }
.card.live {
  border-color: var(--c);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 60%, transparent), 0 0 18px color-mix(in srgb, var(--c) 35%, transparent);
}
.card.out { opacity: 0.28; }

.card-head { display: flex; justify-content: space-between; align-items: center; height: 18px; white-space: nowrap; }
.card-tier { color: var(--c); font-size: 0.78rem; letter-spacing: 1px; }
.card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--c);
  font-size: 0.7rem; font-style: normal;
}
.card-meta { font-size: 0.72rem; color: var(--text-dim); }
.card-meta .mp { color: var(--mp); }
.card-meta .gain { color: var(--good); }
.card-name { margin-top: 3px; height: 21px; font-weight: 700; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-kana { height: 17px; font-size: 0.74rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; }
.card-kana .done { color: var(--typed); }
.card-romaji {
  height: 24px; line-height: 24px; margin-top: 2px;
  font-family: var(--font-mono); font-size: 1rem; font-weight: 500;
  white-space: nowrap; overflow: hidden;
}
.card.skill .card-romaji { font-size: 0.86rem; height: 20px; line-height: 20px; }
.card-romaji .typed { color: var(--typed); font-weight: 700; }
.card-romaji .rest { color: #9aa4c0; }
.card.live .card-romaji .rest { color: #ffffff; }
.card-foot { height: 20px; line-height: 20px; margin-top: 2px; font-size: 0.72rem; color: var(--text-dim); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.card.skill .card-foot { display: block; text-overflow: ellipsis; }
.card.attack .card-romaji { letter-spacing: -0.01em; }
.card.skill .card-foot { font-size: 0.66rem; }
.card-foot strong { color: var(--text); font-size: 0.9rem; font-family: var(--font-mono); }
.tag { font-size: 0.66rem; padding: 0 5px; border-radius: 3px; }
.tag.penalty { background: rgba(255, 84, 104, 0.18); color: var(--bad); }
.tag.boost { background: rgba(255, 159, 90, 0.18); color: var(--k-buff); }

/* リキャスト (FF14 風の時計回りのスイープ) と MP 不足 */
.cd-veil {
  --cd: 0;
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: conic-gradient(rgba(4, 6, 12, 0.78) calc(var(--cd) * 360deg), rgba(4, 6, 12, 0.5) 0);
  visibility: hidden;
}
.card.disabled .cd-veil { visibility: visible; }
.card.disabled { filter: grayscale(0.85) brightness(0.85); }
.cd-text { font-weight: 700; font-size: 1.05rem; text-shadow: 0 1px 3px #000; }

.card.renew { animation: renew 0.7s ease-out; }
@keyframes renew {
  0% { opacity: 0.1; filter: sepia(1) blur(3px); }
  60% { opacity: 1; filter: sepia(0.2) blur(0); }
  100% { opacity: 1; filter: none; }
}

@keyframes deny { 0% { outline-color: var(--bad); } 100% { outline-color: transparent; } }

.help { color: var(--text-faint); font-size: 0.74rem; text-align: center; margin: 10px 0 0; }
.help kbd { color: var(--text-dim); }
.ime-warning {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--bad); color: #fff; padding: 8px 16px; border-radius: 8px; font-weight: 700;
  margin: 0; visibility: hidden; z-index: 20;
}
.ime-warning.show { visibility: visible; }

/* ---------- エフェクト (絶対配置なのでレイアウトに影響しない) ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; }
.float {
  position: absolute; top: 30%;
  transform: translateX(-50%);
  font-family: var(--font-mono); font-weight: 700;
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(0, 0, 0, 0.9);
  animation: float-up 1s ease-out both;
  white-space: nowrap;
}
.float.dmg { font-size: 2.3rem; color: #fff; }
.float.dmg.big { font-size: 3rem; color: var(--typed); }
.float.label { top: 18%; font-size: 1.2rem; font-family: var(--font-ui); }
.float.label.good { color: var(--typed); }
.float.label.phase { color: var(--bad); font-size: 1.5rem; }
.float.hurt { top: 0; color: var(--bad); font-size: 1.5rem; }
.float.hurt.heavy { font-size: 2.1rem; }
.float.heal { top: 0; color: var(--good); font-size: 1.5rem; }
.float.buff { top: 0; color: var(--gold); font-size: 1.05rem; font-family: var(--font-ui); }
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  30% { transform: translate(-50%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50px); }
}

/* 被弾は画面の縁だけを赤く光らせる (手札や入力中の文字は覆わない) */
body.flash::after, body.flash-heavy::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  animation: flash 0.4s ease-out both;
}
body.flash::after { box-shadow: inset 0 0 50px rgba(255, 60, 80, 0.45); }
body.flash-heavy::after { box-shadow: inset 0 0 90px rgba(255, 30, 60, 0.7); }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- オーバーレイ ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(7, 9, 15, 0.7), rgba(7, 9, 15, 0.92));
  backdrop-filter: blur(2px);
}
.overlay-panel {
  position: relative;
  width: 100%; max-width: 680px; max-height: 100%; overflow: auto;
  padding: 22px 30px;
  text-align: center;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(26, 32, 52, 0.97), rgba(13, 17, 28, 0.97));
  box-shadow: 0 0 0 1px rgba(216, 180, 105, 0.15), 0 24px 70px rgba(0, 0, 0, 0.7);
}
.overlay-panel h2 { margin: 0 0 8px; color: var(--gold); letter-spacing: 0.08em; }
.overlay-panel h2.title {
  font-size: 1.8rem; letter-spacing: 0.14em;
  background: linear-gradient(180deg, #fff6dc, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overlay-panel .subtitle { font-family: var(--font-display); color: var(--text-dim); letter-spacing: 0.3em; font-size: 0.72rem; margin: -4px 0 10px; }
.overlay-panel h2.lose { color: var(--bad); }
.rules { text-align: left; line-height: 1.85; font-size: 0.86rem; padding-left: 1.2em; margin: 10px 0; }
.tip { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 0.88rem; }
.stats.result { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; max-width: 280px; margin: 12px auto; }
.stats.result dt { color: var(--text-dim); text-align: left; }
.stats.result dd { margin: 0; text-align: right; font-weight: 700; }
.blink { animation: blink 1.4s ease-in-out infinite; margin-top: 14px; }
@keyframes blink { 50% { opacity: 0.45; } }

.diff-select { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.diff-btn {
  min-width: 124px; height: 58px; padding: 6px 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 8px; border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #182036, #0f1424);
  font-family: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.diff-btn.selected { border-color: currentColor; box-shadow: 0 0 0 1px currentColor, 0 0 16px color-mix(in srgb, currentColor 35%, transparent); }
.diff-name { white-space: nowrap; font-family: var(--font-display); letter-spacing: 0.06em; }
.diff-speed { font-size: 0.68rem; font-weight: 500; color: var(--text-dim); white-space: nowrap; }
.diff-key { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-faint); margin-right: 6px; }
.diff-desc { color: var(--text); font-size: 0.85rem; height: 1.4em; margin: 10px 0 2px; }
.diff-note { color: var(--text-faint); font-size: 0.7rem; margin: 0; height: 2.6em; }

.timeline { text-align: left; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-top: 12px; }
.timeline h3 { font-size: 0.85rem; margin: 0 0 6px; color: var(--gold); }
.tl-row { margin: 4px 0; }
.tl-phase { font-size: 0.7rem; color: var(--text-dim); }
.tl-items { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tl-arrow { color: var(--text-faint); font-size: 0.66rem; }
.tl-item {
  --tc: var(--a-auto);
  font-size: 0.74rem; padding: 0 6px; border-radius: 3px; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--tc) 70%, transparent); color: var(--tc);
}
.note { color: var(--text-dim); font-size: 0.76rem; margin: 4px 0 0; }

/* ---------- 追加の HUD 部品 ---------- */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; transition: border-color 0.15s, background 0.15s; }
.icon-btn:hover { border-color: var(--gold-soft); background: #1c2440; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* HP が減ったぶんを遅れて追いかける帯 (どれだけ削れたかを見せる) */
.gauge-lag {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: rgba(255, 236, 190, 0.75);
  transition: width 0.6s ease-in 0.35s;
}
.gauge.hp .gauge-lag { background: rgba(255, 84, 104, 0.75); }
.gauge-fill.glow { animation: gauge-glow 0.6s ease-out; }
@keyframes gauge-glow { 0% { filter: brightness(1.8); } }

.sprite .emoji { font-size: 92px; }
#enemy-area.phase-shift { animation: phase-shift 0.9s ease-out; }
@keyframes phase-shift {
  0% { box-shadow: inset 0 0 0 2px var(--bad), 0 0 40px rgba(255, 84, 104, 0.5); }
  100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.35); }
}
.castbar.appear { animation: cast-appear 0.5s ease-out; }
@keyframes cast-appear { 0% { transform: scale(1.04); filter: brightness(1.8); } }
.float.label.combo { top: 6%; color: var(--typed); font-family: var(--font-display); font-size: 1.3rem; letter-spacing: 0.08em; }

/* 呪文の着弾: 広がるリングと飛び散る火花 */
.burst {
  --bc: var(--t1);
  position: absolute; left: 50%; top: 52%; width: 0; height: 0;
  animation: burst-life 0.6s linear forwards;
}
.burst.tier-2 { --bc: var(--t2); }
.burst.tier-3 { --bc: var(--t3); }
.burst.empowered { --bc: var(--k-buff); }
.burst.interrupt { --bc: var(--k-silence); }
.burst::before {
  content: ""; position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border-radius: 50%;
  border: 3px solid var(--bc);
  box-shadow: 0 0 24px var(--bc), inset 0 0 24px var(--bc);
  animation: burst-ring 0.5s ease-out forwards;
}
.burst.tier-3::before, .burst.empowered::before { border-width: 5px; }
.burst i {
  position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 8px 2px var(--bc);
  animation: burst-spark 0.55s ease-out forwards;
}
.burst i:nth-child(1) { --a: 0deg; } .burst i:nth-child(2) { --a: 45deg; } .burst i:nth-child(3) { --a: 90deg; }
.burst i:nth-child(4) { --a: 135deg; } .burst i:nth-child(5) { --a: 180deg; } .burst i:nth-child(6) { --a: 225deg; }
.burst i:nth-child(7) { --a: 270deg; } .burst i:nth-child(8) { --a: 315deg; }
@keyframes burst-life { to { opacity: 1; } }
@keyframes burst-ring { 0% { transform: scale(0.2); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
@keyframes burst-spark {
  0% { transform: rotate(var(--a)) translateX(10px) scale(1.2); opacity: 1; }
  100% { transform: rotate(var(--a)) translateX(90px) scale(0.2); opacity: 0; }
}

/* 被弾の画面揺れ */
#app.shake-small { animation: shake-small 0.26s linear; }
#app.shake-big { animation: shake-big 0.42s linear; }
@keyframes shake-small { 25% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 75% { transform: translate(-2px, 0); } }
@keyframes shake-big {
  10% { transform: translate(-8px, 3px); } 25% { transform: translate(7px, -4px); } 40% { transform: translate(-6px, 2px); }
  55% { transform: translate(4px, -2px); } 75% { transform: translate(-2px, 1px); }
}

/* HP 危険域: 画面の縁が脈打つ */
body.danger::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 5;
  box-shadow: inset 0 0 120px rgba(255, 40, 60, 0.45);
  animation: danger-pulse 0.9s ease-in-out infinite;
}
@keyframes danger-pulse { 50% { opacity: 0.35; } }

/* ---------- ステージ開始のバナー ---------- */
.banner {
  position: absolute; left: 0; right: 0; top: 150px; z-index: 6;
  display: flex; justify-content: center; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
}
.banner.show { opacity: 1; visibility: visible; }
.banner-inner {
  width: 100%; padding: 14px 0 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: linear-gradient(90deg, transparent, rgba(7, 9, 15, 0.9) 20%, rgba(7, 9, 15, 0.9) 80%, transparent);
  border-top: 1px solid var(--gold-soft); border-bottom: 1px solid var(--gold-soft);
}
.banner.show .banner-inner { animation: banner-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes banner-in { 0% { transform: scaleY(0); } 100% { transform: scaleY(1); } }
.banner-stage { font-family: var(--font-display); color: var(--gold); letter-spacing: 0.4em; font-size: 0.85rem; font-weight: 700; }
.banner-name { font-size: 2rem; font-weight: 700; letter-spacing: 0.12em; text-shadow: 0 2px 12px #000; }
.banner-call { font-size: 1rem; color: var(--text-dim); letter-spacing: 0.2em; height: 1.5em; }
.banner.go .banner-call { color: var(--typed); font-weight: 700; animation: call-pop 0.4s ease-out; }
@keyframes call-pop { 0% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- オーバーレイの部品 ---------- */
.overlay-panel { zoom: var(--panel-zoom, 1); max-height: calc(100vh / var(--panel-zoom, 1) - 32px); animation: panel-in 0.25s ease-out; }
@keyframes panel-in { 0% { opacity: 0; transform: translateY(8px) scale(0.98); } }
.overlay.hidden { display: none; }
.title-panel { max-width: 720px; }
.title-mark { font-size: 2rem; color: var(--gold); text-shadow: 0 0 24px var(--gold); line-height: 1; animation: mark-spin 8s linear infinite; display: inline-block; }
@keyframes mark-spin { to { transform: rotate(360deg); } }
.lead { font-size: 0.92rem; }
.notice { background: rgba(255, 181, 71, 0.12); border: 1px solid rgba(255, 181, 71, 0.5); color: var(--warn); border-radius: 8px; padding: 6px 10px; font-size: 0.82rem; }
.kicker { margin: 0 0 4px; font-family: var(--font-display); color: var(--text-dim); letter-spacing: 0.25em; font-size: 0.72rem; }
.hint { color: var(--text-faint); font-size: 0.74rem; margin: 10px 0 0; }
.hint kbd { color: var(--text-dim); }

.diff-btn { height: 78px; }
.diff-rec { font-size: 0.64rem; font-family: var(--font-mono); color: var(--text-dim); height: 1.3em; letter-spacing: 0.04em; }
.diff-rec.cleared { color: var(--gold); }
.diff-rec.empty { color: var(--text-faint); }
.diff-rec b { font-family: var(--font-display); font-size: 0.8rem; }
.diff-record { color: var(--text-dim); font-size: 0.74rem; margin: 0 0 2px; height: 1.4em; }
.diff-btn:hover { border-color: currentColor; }

.menu-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.menu-col { display: grid; gap: 8px; max-width: 320px; margin: 16px auto 0; }
.menu-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 140px; height: 42px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1a2238, #10152a);
  color: var(--text); font-family: inherit; font-size: 0.92rem; font-weight: 700; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.menu-col .menu-btn { justify-content: space-between; }
.menu-btn:hover { border-color: var(--gold-soft); box-shadow: 0 0 14px rgba(216, 180, 105, 0.15); }
.menu-btn:active { transform: translateY(1px); }
.menu-btn kbd { font-size: 0.72rem; }
.menu-btn.primary {
  border-color: var(--gold); color: #1a1406;
  background: linear-gradient(180deg, #f3d68e, var(--gold) 55%, #a8843f);
  box-shadow: 0 0 18px rgba(216, 180, 105, 0.3);
}
.menu-btn.primary kbd { background: rgba(0, 0, 0, 0.18); border-color: rgba(0, 0, 0, 0.3); color: #1a1406; }
.menu-btn.attention { border-color: var(--gold); animation: attention 1.6s ease-in-out infinite; }
@keyframes attention { 50% { box-shadow: 0 0 16px rgba(216, 180, 105, 0.45); } }
.menu-btn.danger { color: var(--bad); border-color: rgba(255, 84, 104, 0.5); min-width: 120px; }
.menu-btn.ghost-disabled { opacity: 0.35; pointer-events: none; }

/* 遊び方 */
.howto-panel { max-width: 680px; }
.howto-body { text-align: left; min-height: 260px; }
.howto-body .lead { text-align: center; }
.demo-chant {
  display: flex; align-items: center; gap: 16px; justify-content: center;
  padding: 10px; margin: 8px 0; border-radius: 8px; border: 1px solid rgba(255, 215, 106, 0.55);
  background: rgba(10, 13, 22, 0.85); font-size: 1.4rem; font-weight: 700;
}
.demo-chant .demo-name { font-size: 0.9rem; }
.demo-chant .typed { color: var(--typed); }
.demo-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.demo-card { --c: var(--t1); padding: 8px 10px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--c) 60%, transparent); background: #121828; display: grid; gap: 2px; font-size: 0.78rem; text-align: center; }
.demo-card b { color: var(--c); }
.demo-card.tier-2 { --c: var(--t2); }
.demo-card.tier-3 { --c: var(--t3); }
.howto-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; margin: 8px 0; }
.howto-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.howto-table td:first-child { white-space: nowrap; width: 1%; }
.tl-item.type-enrage { --tc: var(--a-enrage); }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.pager .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.pager .dot.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* 設定 */
.settings-panel { max-width: 520px; }
.settings { display: grid; gap: 4px; margin-top: 10px; text-align: left; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid transparent; }
.setting.focus { border-color: var(--gold-soft); background: rgba(216, 180, 105, 0.06); }
.setting-ctl { display: flex; align-items: center; gap: 10px; }
.setting .val { width: 2.5em; text-align: right; color: var(--text-dim); }
input[type=range] { width: 200px; accent-color: var(--gold); }
.toggle {
  width: 64px; height: 28px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: #10152a; color: var(--text-dim); font-family: var(--font-mono); font-weight: 700; cursor: pointer;
}
.toggle.on { background: color-mix(in srgb, var(--good) 25%, #10152a); border-color: var(--good); color: var(--good); }

/* 結果 */
.result-panel { max-width: 720px; }
.result-grid { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; align-items: center; margin: 10px 0; }
.result-grid .stats.result { max-width: none; margin: 0; }
.rank-badge {
  --rc: var(--text-dim);
  width: 140px; height: 140px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px solid var(--rc);
  background: radial-gradient(circle, color-mix(in srgb, var(--rc) 22%, transparent), transparent 70%);
  box-shadow: 0 0 30px color-mix(in srgb, var(--rc) 40%, transparent), inset 0 0 20px color-mix(in srgb, var(--rc) 30%, transparent);
  animation: stamp 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) 0.15s both;
}
.rank-badge.rank-S { --rc: #ffd76a; }
.rank-badge.rank-A { --rc: #c08cff; }
.rank-badge.rank-B { --rc: #63a8ff; }
.rank-badge.rank-C { --rc: #8d97b3; }
.rank-label { font-family: var(--font-display); font-size: 0.7rem; letter-spacing: 0.3em; color: var(--text-dim); }
.rank-letter { font-family: var(--font-display); font-size: 4.2rem; line-height: 1; font-weight: 700; color: var(--rc); text-shadow: 0 0 20px var(--rc); }
@keyframes stamp { 0% { transform: scale(2.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
b.rank-S { color: #ffd76a; } b.rank-A { color: #c08cff; } b.rank-B { color: #63a8ff; } b.rank-C { color: #8d97b3; }
.stats.result dd.score { color: var(--gold); font-size: 1.1rem; }
.total-score { margin: 0 0 6px; font-size: 1rem; text-align: left; }
.total-score .num { font-size: 2rem; font-weight: 700; color: var(--gold); }
.new-record {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 4px;
  background: var(--bad); color: #fff; font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.1em;
  animation: blink 0.9s ease-in-out infinite;
}
.stage-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.stage-table th { font-weight: 500; color: var(--text-dim); font-size: 0.7rem; text-align: left; padding: 2px 6px; }
.stage-table td { padding: 3px 6px; border-top: 1px solid var(--line); text-align: left; }
.stage-table b { font-family: var(--font-display); }
.defeat-hp { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 0.85rem; margin: 8px 0 10px; }
.defeat-hp .gauge-fill { background: linear-gradient(180deg, #ff6a6f, var(--boss-hp) 55%, var(--boss-hp-2)); }
.timeline-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.timeline-head h3 { margin: 0; }
.mini-sprite { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; }
.mini-sprite svg { width: 40px; height: 40px; }
.mini-sprite svg * { animation: none !important; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg-0); color: var(--text); margin: 0; z-index: 30; }

/* ---------- 演出を控えめにする ---------- */
.reduce-motion .blink, .reduce-motion .title-mark, .reduce-motion .menu-btn.attention,
.reduce-motion .castbar.casting, .reduce-motion .new-record, .reduce-motion .boss-svg,
.reduce-motion .boss-svg * { animation: none !important; }
.reduce-motion body.danger::before, .reduce-motion.danger::before { animation: none; opacity: 0.6; }
.reduce-motion .float { animation-name: float-fade; }
@keyframes float-fade { 0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
.reduce-motion .sprite.hit, .reduce-motion .sprite.lunge { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .blink, .title-mark { animation: none; }
}
