/* プレイ中の HUD。矢印・ことばは 48px 以上、ボタンは 88px 以上 */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { position: absolute; }
#hud button { pointer-events: auto; }
#hud-top {
  top: max(10px, env(safe-area-inset-top)); left: var(--gutter); right: var(--gutter); display: flex; align-items: center; gap: 14px;
  padding: 8px 14px; background: var(--panel); border: 2px solid var(--panel-line); border-radius: 18px; font-size: 20px;
}
#hud-mode { flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hud-time { position: relative; flex: 1; height: 28px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; min-width: 80px; }
#hud-timeBar { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--accent2), var(--good)); transition: width 0.2s linear; }
#hud-timeText { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; color: var(--accent-ink); }
.is-free #hud-mode { flex: 1; }
#hud-combo { color: var(--warm); min-width: 5em; text-align: right; }
#hud-done { white-space: nowrap; }
#hud-pause { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--panel-line); background: var(--btn); font-size: 16px; }

/* ボスの HP バー。ひとことカードの上に置き、カードはその分だけ下げる */
#hud-boss { top: 76px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 2 * var(--gutter))); display: flex; align-items: center; gap: 10px;
  padding: 4px 12px; background: var(--panel); border: 2px solid var(--panel-line); border-radius: 999px; font-size: 16px; }
#hud-bossName { flex: 0 0 auto; white-space: nowrap; }
#hud-bossBar { position: relative; flex: 1; height: 18px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
#hud-bossFill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--warm), var(--accent)); transition: width 0.3s ease-out; }
.has-boss #hud-card { top: 122px; }
.has-boss #hud-nextCard { top: 122px; }

#hud-card {
  top: 84px; left: 50%; transform: translateX(-50%); min-width: 300px; max-width: calc(100% - 2 * var(--gutter));
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 28px 10px;
  background: var(--panel); border: 4px solid var(--dir, var(--panel-line)); border-radius: 26px; text-align: center;
}
#hud-next { min-height: 20px; font-size: 16px; color: var(--ink-soft); }
#hud-arrow { font-size: 72px; line-height: 1; color: var(--dir, #fff); text-shadow: 0 0 18px var(--dir, #fff); min-height: 72px; }
#hud-label { font-size: 52px; line-height: 1.15; font-weight: 800; word-break: keep-all; overflow-wrap: anywhere; } /* 「しゃがんで よけて！」を語の途中で折らない（空白で折る） */
#hud-dots { min-height: 22px; font-size: 20px; letter-spacing: 6px; color: var(--warm); }
#hud-seq { font-size: 40px; letter-spacing: 6px; }
#hud-card.is-preview { opacity: 0.88; }
#hud-card.is-go { box-shadow: 0 0 30px var(--dir, #fff); transform: translateX(-50%) scale(1.05); }
#hud-card.good { animation: bb-good 0.42s ease-out; }
#hud-card.hint { animation: bb-hint 0.42s ease-out; }
/* ホールドの輪: --p (0〜100) まで色が伸びる */
#hud-hold { --p: 0; position: relative; width: 104px; height: 104px; margin: 0 auto; border-radius: 50%;
  background: conic-gradient(var(--good) calc(var(--p) * 1%), rgba(255, 255, 255, 0.18) 0); }
#hud-hold::after { content: ''; position: absolute; inset: 14px; border-radius: 50%; background: var(--panel, rgba(20, 14, 52, 0.85)); }
#hud-holdBar { display: none; }
.is-free #hud-next, .is-free #hud-dots { display: none; }

#hud-nextCard {
  top: 84px; right: var(--gutter); display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  background: var(--panel); border: 2px solid var(--panel-line); border-radius: 16px; font-size: 22px; opacity: 0.85;
}
#hud-nextArrow { font-size: 30px; }
#hud-count {
  top: 38%; left: 0; right: 0; text-align: center; font-size: clamp(110px, 22vw, 240px); font-weight: 800; line-height: 1;
  text-shadow: 0 0 30px var(--accent), 0 6px 0 rgba(0, 0, 0, 0.3);
}
#hud-count.pop { animation: bb-pop 0.7s ease-out; }

#hud-buttons {
  left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; justify-content: center; align-items: flex-end; gap: 12px;
}
#hud-buttons button {
  min-width: 96px; min-height: 96px; padding: 0 14px; border-radius: 26px; border: 3px solid #fff; background: rgba(20, 12, 60, 0.78);
  font-size: 34px; font-weight: 800; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}
#hud-buttons button[data-action="S"] { min-width: 180px; font-size: 26px; }
#hud-buttons button.pressed { background: var(--btn-on); transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
#hud-combo.bounce, #hud-arrow.bounce { animation: bb-pop 0.42s ease-out; }

@keyframes bb-pop { 0% { transform: scale(0.5); opacity: 0.2; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes bb-good { 0% { filter: brightness(2); } 100% { filter: none; } }
@keyframes bb-hint { 0% { transform: translateX(-50%) rotate(-3deg); } 50% { transform: translateX(-50%) rotate(3deg); } 100% { transform: translateX(-50%); } }

@media (max-width: 900px) {
  #hud-top { flex-wrap: wrap; row-gap: 6px; font-size: 17px; }
  #hud-nextCard { top: 108px; right: var(--gutter); font-size: 18px; padding: 4px 10px; } /* 課題カードの中に重ねず、右上の隅へ */
  #hud-nextArrow { font-size: 24px; }
  #hud-boss { top: 100px; }
  #hud-card { top: 108px; }
  .has-boss #hud-card { top: 142px; }
  .has-boss #hud-nextCard { top: 142px; }
  #hud-label { font-size: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  #hud * { animation: none !important; transition: none !important; }
}
