/* === 基本リセット === */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #87ceeb;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  color: #fff;
  touch-action: none;
}
canvas { display: block; }

/* === HP HUD（左上最上段） === */
#hp-hud {
  position: fixed;
  top: 18px; left: 20px;
  display: flex;
  gap: 3px;
  pointer-events: none;
  z-index: 10;
}
#hp-hud .heart {
  font-size: 24px;
  line-height: 1;
  color: #ff5566;
  text-shadow: 0 2px 4px rgba(0,0,0,.6), 0 0 8px rgba(255, 80, 100, 0.4);
  transition: color 0.3s, transform 0.2s;
}
#hp-hud .heart.lost {
  color: rgba(255, 255, 255, 0.18);
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}
#hp-hud .heart.dmg {
  animation: heart-shake 0.5s;
}
@keyframes heart-shake {
  0%, 100% { transform: translateX(0) scale(1); }
  20% { transform: translateX(-3px) scale(1.4); }
  40% { transform: translateX(3px)  scale(1.2); }
  60% { transform: translateX(-2px) scale(1.1); }
}

/* === 操作ヒント === */
#hint {
  position: fixed; top: 70px; left: 20px;
  background: rgba(20, 24, 35, 0.78);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  pointer-events: none;
  transition: opacity 1s;
  border: 1px solid rgba(255,255,255,0.08);
  max-width: 240px;
  line-height: 1.6;
}
#hint.fade { opacity: 0; }
#hint .hint-title { font-weight: 700; margin-bottom: 6px; color: #ffe18a; }
#hint .hint-row { color: #cdd5e1; }

/* === 星のかけらHUD（HP HUDの右隣、左上） === */
#shard-hud {
  position: fixed;
  top: 22px; left: 162px;
  background: rgba(20, 24, 35, 0.78);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #ffe18a;
  letter-spacing: .04em;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 7;
}
#shard-hud .shard-icon {
  font-size: 18px;
  color: #ffe066;
  text-shadow: 0 0 8px rgba(255, 220, 80, 0.7);
}
#shard-hud.bump #shard-count {
  animation: shard-bump 0.5s;
}
@keyframes shard-bump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.5); color: #fff8c0; }
}

/* === スタミナ/MPバー（HP HUDの真下） === */
#status-bars {
  position: fixed;
  top: 50px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  z-index: 9;
}
#status-bars .bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
#status-bars .bar-label {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  width: 18px;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  letter-spacing: 0.04em;
}
#status-bars .bar-fill {
  width: 130px;
  height: 8px;
  background: rgba(20, 24, 35, 0.7);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
#status-bars .bar-fill > div {
  height: 100%;
  width: 100%;
  transition: width 0.15s;
}
#stamina-fill { background: linear-gradient(90deg, #5fc97e, #a8e560); }
#mp-fill      { background: linear-gradient(90deg, #5cb0f0, #8de0ff); }

/* === コンボHUD（右上、ヒット時に出現） === */
#combo-hud {
  position: fixed;
  top: 70px; right: 20px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  pointer-events: none;
  z-index: 9;
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0,0,0,.7), 0 0 14px rgba(255, 90, 200, 0.6);
  animation: combo-pulse 0.4s;
}
#combo-hud.hidden { display: none; }
#combo-hud #combo-count {
  font-size: 38px;
  color: #ffe066;
}
#combo-hud .combo-label {
  font-size: 16px;
  color: #ff8acb;
  letter-spacing: 0.05em;
}
@keyframes combo-pulse {
  0%   { transform: scale(1.5); opacity: 0.4; }
  100% { transform: scale(1.0); opacity: 1.0; }
}

/* === 白フラッシュ（撃破・被弾の一瞬） === */
#flash-overlay {
  position: fixed;
  inset: 0;
  background: #ffffff;
  pointer-events: none;
  opacity: 0;
  z-index: 50;
  mix-blend-mode: screen;
}

/* === ボス進入バナー === */
#boss-banner {
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  pointer-events: none;
  text-align: center;
  z-index: 11;
  animation: boss-slide-in 0.5s;
}
#boss-banner.hidden { display: none; }
#boss-banner .boss-warn {
  font-size: 28px;
  font-weight: 900;
  color: #ff5566;
  letter-spacing: 0.18em;
  text-shadow: 0 2px 8px rgba(0,0,0,.8), 0 0 16px rgba(255, 80, 100, 0.7);
  margin-bottom: 6px;
}
#boss-banner #boss-name {
  font-size: 48px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 10px rgba(0,0,0,.85);
}
#boss-banner .boss-sub {
  font-size: 16px;
  font-weight: 700;
  color: #ffd25c;
  margin-top: 4px;
  letter-spacing: 0.08em;
}
@keyframes boss-slide-in {
  0%   { transform: translateX(-50%) translateY(-40px); opacity: 0; }
  60%  { transform: translateX(-50%) translateY(8px);  opacity: 1; }
  100% { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

/* === チャージゲージ（プレイヤー下、長押し中） === */
#charge-bar {
  position: fixed;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  width: 140px;
  height: 8px;
  background: rgba(20, 24, 35, 0.7);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  z-index: 8;
}
#charge-bar.hidden { display: none; }
#charge-bar #charge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffaa30, #ffe066);
  transition: none;
  box-shadow: 0 0 8px rgba(255, 220, 100, 0.8);
}
#charge-bar.full #charge-fill {
  background: linear-gradient(90deg, #ff5566, #ffe066);
  animation: charge-full 0.4s infinite alternate;
}
@keyframes charge-full {
  0%   { box-shadow: 0 0 4px rgba(255, 80, 100, 0.5); }
  100% { box-shadow: 0 0 14px rgba(255, 220, 100, 1.0); }
}

/* === ボスHPバー（画面下中央） === */
#boss-hp {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  width: 50%;
  max-width: 540px;
  pointer-events: none;
  z-index: 9;
  text-align: center;
}
#boss-hp.hidden { display: none; }
#boss-hp #boss-hp-name {
  font-size: 14px;
  font-weight: 800;
  color: #ff8acb;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0,0,0,.7);
}
#boss-hp #boss-hp-bar {
  width: 100%;
  height: 12px;
  background: rgba(20, 24, 35, 0.85);
  border: 2px solid #ff5566;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(255, 80, 100, 0.6);
}
#boss-hp #boss-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff3344, #ffaaaa);
  transition: width 0.18s;
}

/* === 鍵HUD（星の右隣） === */
#key-hud {
  position: fixed;
  top: 22px; left: 232px;
  background: rgba(20, 24, 35, 0.78);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #ffe18a;
  letter-spacing: .04em;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 7;
}
#key-hud.hidden { display: none; }
#key-hud .key-icon {
  font-size: 18px;
  text-shadow: 0 0 6px rgba(255, 220, 80, 0.5);
}
#key-hud.bump #key-count {
  animation: shard-bump 0.5s;
}

/* === エリア出口ヒント（中央寄せ） === */
#exit-hint {
  position: fixed;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  background: rgba(20, 24, 35, 0.88);
  border: 2px solid #ffd25c;
  border-radius: 12px;
  padding: 10px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  transition: opacity 0.2s;
}
#exit-hint.hidden { display: none; }
#exit-hint .exit-key {
  font-size: 11px;
  font-weight: 500;
  color: #ffd25c;
  letter-spacing: .04em;
  animation: blink 1.2s infinite;
}

/* === エリア名タグ（左上、操作ヒントの下） === */
#area-tag {
  position: fixed;
  top: 178px;
  left: 20px;
  background: rgba(20, 24, 35, 0.78);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #cdd5e1;
  letter-spacing: .04em;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.08);
  z-index: 7;
  transition: background 0.6s, color 0.6s;
}
#area-tag.forest { color: #b8d6a0; border-color: rgba(120, 200, 120, 0.25); }

/* === 時間帯HUD === */
#time-hud {
  position: fixed;
  top: 20px; right: 20px;
  background: rgba(20, 24, 35, 0.78);
  padding: 8px 14px 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: #ffe18a;
  font-weight: 700;
  letter-spacing: .04em;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 8;
  transition: background 0.6s;
}
#time-hud #time-icon { font-size: 18px; line-height: 1; }

/* === 会話ウィンドウ === */
#dialog {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  background: rgba(15, 20, 32, 0.92);
  border: 2px solid #ffe18a;
  border-radius: 14px;
  padding: 16px 20px 14px;
  box-shadow: 0 12px 36px rgba(0,0,0,.5);
  z-index: 10;
  cursor: pointer;
}
#dialog.hidden { display: none; }
#dialog-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffd25c;
  margin-bottom: 8px;
  letter-spacing: .04em;
}
#dialog-text {
  font-size: 16px;
  line-height: 1.7;
  color: #f3f5fa;
  min-height: 1.7em;
}
#dialog-hint {
  font-size: 11px;
  color: #8a93a3;
  text-align: right;
  margin-top: 10px;
  animation: blink 1.2s infinite;
}
@keyframes blink { 0%,60%{opacity:1} 80%{opacity:.2} 100%{opacity:1} }

/* === スマホ用バーチャルパッド === */
#touch-ui.hidden { display: none; }
#stick-base {
  position: fixed; left: 28px; bottom: 28px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.10);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  z-index: 9;
  touch-action: none;
}
#stick-knob {
  position: absolute; top: 50%; left: 50%;
  width: 54px; height: 54px;
  margin: -27px 0 0 -27px;
  background: rgba(255,255,255,0.55);
  border-radius: 50%;
  pointer-events: none;
}
#action-btn, #magic-btn, #dash-btn {
  position: fixed;
  border-radius: 50%;
  border: 2px solid;
  font-weight: 800;
  z-index: 9;
  touch-action: none;
  cursor: pointer;
  text-align: center;
}
#action-btn {
  right: 28px; bottom: 40px;
  width: 86px; height: 86px;
  border-color: #ffe18a;
  background: rgba(255, 200, 80, 0.7);
  color: #1a1409;
  font-size: 28px;
}
#magic-btn {
  right: 130px; bottom: 70px;
  width: 64px; height: 64px;
  border-color: #8de0ff;
  background: rgba(110, 180, 240, 0.7);
  color: #fff;
  font-size: 22px;
}
#dash-btn {
  right: 28px; bottom: 140px;
  width: 64px; height: 64px;
  border-color: #a8e560;
  background: rgba(150, 220, 110, 0.7);
  color: #2a3a18;
  font-size: 16px;
}
#action-btn:active { background: rgba(255, 220, 130, 0.95); }
#magic-btn:active  { background: rgba(150, 210, 250, 0.95); }
#dash-btn:active   { background: rgba(180, 240, 150, 0.95); }

/* =====================================================================
 * タイトル画面
 * ===================================================================== */
#title-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(120, 200, 255, 0.25), transparent 60%),
    linear-gradient(180deg, #08203a 0%, #061528 60%, #02080f 100%);
  color: #fff;
  font-family: 'Hiragino Maru Gothic ProN', 'Noto Sans JP', sans-serif;
  user-select: none;
  animation: title-fade-in 0.6s ease-out;
}
#title-screen.hidden { display: none; }

@keyframes title-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.title-inner {
  text-align: center;
  padding: 40px 60px;
  max-width: 90vw;
}
.title-main {
  font-size: clamp(48px, 9vw, 96px);
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #ffe97a 0%, #ffb84a 60%, #d97a2a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 18px rgba(255, 184, 74, 0.35);
}
.title-sub {
  font-size: clamp(14px, 1.6vw, 20px);
  color: #cdd5e1;
  margin-bottom: 36px;
  letter-spacing: 0.2em;
}
.title-btn {
  font-size: clamp(20px, 2.5vw, 30px);
  font-weight: 700;
  padding: 18px 56px;
  border-radius: 40px;
  border: 3px solid #ffd25c;
  background: linear-gradient(180deg, #ffe066, #ff9f30);
  color: #2a1a08;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 6px 20px rgba(255, 159, 48, 0.45);
  animation: title-btn-pulse 1.6s ease-in-out infinite;
  font-family: inherit;
}
.title-btn:hover  { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(255, 159, 48, 0.6); }
.title-btn:active { transform: translateY(2px); box-shadow: 0 2px 10px rgba(255, 159, 48, 0.4); }

@keyframes title-btn-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

.title-controls {
  margin-top: 36px;
  font-size: 14px;
  color: #d8e2f0;
  line-height: 1.8;
  background: rgba(0, 0, 0, 0.3);
  padding: 16px 28px;
  border-radius: 12px;
  display: inline-block;
}
.title-controls-title {
  font-weight: 700;
  color: #ffe18a;
  margin-bottom: 6px;
}
.title-credit {
  margin-top: 28px;
  font-size: 13px;
  color: #98a4b8;
  letter-spacing: 0.1em;
}

/* =====================================================================
 * リセットボタン（右上、ゲーム中のみ）
 * ===================================================================== */
#reset-btn {
  position: fixed;
  top: 14px;
  right: 90px;
  z-index: 12;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: rgba(60, 30, 30, 0.7);
  border: 1.5px solid rgba(255, 130, 130, 0.6);
  border-radius: 16px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
#reset-btn:hover  { background: rgba(120, 50, 50, 0.85); }
#reset-btn:active { transform: translateY(1px); }
#reset-btn.hidden { display: none; }

/* =====================================================================
 * リセット確認ダイアログ
 * ===================================================================== */
#reset-confirm {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Hiragino Maru Gothic ProN', 'Noto Sans JP', sans-serif;
  animation: title-fade-in 0.2s ease-out;
}
#reset-confirm.hidden { display: none; }
.reset-confirm-inner {
  background: linear-gradient(180deg, #1a2030 0%, #0f1622 100%);
  border: 2px solid rgba(255, 200, 130, 0.4);
  border-radius: 16px;
  padding: 28px 36px;
  color: #fff;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.reset-confirm-text {
  font-size: 15px;
  line-height: 1.7;
  color: #e0e8f0;
  margin-bottom: 22px;
}
.reset-confirm-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.reset-btn-yes, .reset-btn-no {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s;
}
.reset-btn-yes {
  background: linear-gradient(180deg, #ff7855, #c8423a);
  color: #fff;
}
.reset-btn-no {
  background: linear-gradient(180deg, #6c7990, #4a5566);
  color: #fff;
}
.reset-btn-yes:hover, .reset-btn-no:hover { opacity: 0.88; }
.reset-btn-yes:active, .reset-btn-no:active { transform: translateY(1px); }

/* =====================================================================
 * ゲームオーバー画面
 * ===================================================================== */
#game-over {
  position: fixed;
  inset: 0;
  z-index: 98;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(40, 0, 0, 0.85), rgba(0, 0, 0, 0.95));
  font-family: 'Hiragino Maru Gothic ProN', 'Noto Sans JP', sans-serif;
  animation: gameover-fade-in 0.5s ease-out;
}
#game-over.hidden { display: none; }
@keyframes gameover-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.game-over-inner {
  text-align: center;
  color: #fff;
}
.game-over-title {
  font-size: clamp(56px, 9vw, 112px);
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #ff6655 0%, #c8242a 60%, #800010 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 18px rgba(255, 100, 80, 0.55);
  margin-bottom: 12px;
  animation: gameover-shake 0.6s ease-out;
}
@keyframes gameover-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-8px); }
  40%  { transform: translateX( 8px); }
  60%  { transform: translateX(-5px); }
  80%  { transform: translateX( 5px); }
  100% { transform: translateX(0); }
}
.game-over-sub {
  font-size: 22px;
  color: #ddc6c6;
  margin-bottom: 24px;
}
.game-over-hint {
  font-size: 14px;
  color: #98a4b8;
  letter-spacing: 0.15em;
}

/* =====================================================================
 * 学長カットイン（HP=0で借金HP半分以下＋学長加入時に発動）
 * ===================================================================== */
#gakucho-cutin {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  overflow: hidden;
  font-family: 'Hiragino Maru Gothic ProN', 'Noto Sans JP', sans-serif;
}
#gakucho-cutin.hidden { display: none; }

/* 黒帯（上下） */
.cutin-bar {
  position: absolute;
  left: 0; right: 0;
  height: 22vh;
  background: linear-gradient(180deg, #000 0%, #1a0a1a 100%);
  border: 3px solid #ffd700;
}
.cutin-bar-top    { top: 0;    transform: translateY(-110%); animation: bar-slide-down 0.35s 0.05s ease-out forwards; }
.cutin-bar-bottom { bottom: 0; transform: translateY( 110%); animation: bar-slide-up   0.35s 0.05s ease-out forwards; }
@keyframes bar-slide-down { to { transform: translateY(0); } }
@keyframes bar-slide-up   { to { transform: translateY(0); } }

/* スピードライン（背景に流れる斜め線） */
.cutin-speedlines {
  position: absolute;
  inset: 22vh 0;
  background:
    repeating-linear-gradient(
      105deg,
      rgba(255, 215, 0, 0.0) 0px,
      rgba(255, 215, 0, 0.0) 24px,
      rgba(255, 215, 0, 0.4) 24px,
      rgba(255, 215, 0, 0.4) 28px,
      rgba(255, 215, 0, 0.0) 28px,
      rgba(255, 215, 0, 0.0) 60px
    );
  animation: speed-scroll 0.8s linear infinite;
  opacity: 0;
  animation-delay: 0.4s;
  animation-fill-mode: forwards;
}
#gakucho-cutin .cutin-speedlines { animation: speed-scroll 0.6s linear infinite, fade-in 0.3s 0.4s ease-out forwards; }
@keyframes speed-scroll {
  from { background-position: 0 0; }
  to   { background-position: 120px 0; }
}
@keyframes fade-in { to { opacity: 1; } }

/* ポートレート（左から飛び込み） */
.cutin-portrait {
  position: absolute;
  left: 8vw;
  top: 50%;
  width: 30vw;
  max-width: 360px;
  height: 30vw;
  max-height: 360px;
  transform: translate(-150%, -50%) rotate(-15deg);
  animation: portrait-fly-in 0.55s 0.4s cubic-bezier(0.18, 1.4, 0.7, 1.1) forwards,
             portrait-bob 1.4s 1.0s ease-in-out infinite alternate;
}
@keyframes portrait-fly-in {
  to { transform: translate(0, -50%) rotate(-6deg); }
}
@keyframes portrait-bob {
  to { transform: translate(0, -50%) rotate(-3deg) scale(1.04); }
}
.portrait-frame {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff5b8 0%, #ffb84a 45%, #c84020 100%);
  border: 6px solid #ffd700;
  box-shadow: 0 0 60px rgba(255, 184, 74, 0.95),
              0 0 120px rgba(255, 100, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.portrait-burst {
  position: absolute;
  inset: -20%;
  background:
    conic-gradient(
      from 0deg,
      rgba(255, 215, 0, 0.0) 0deg,
      rgba(255, 215, 0, 0.85) 8deg,
      rgba(255, 215, 0, 0.0) 16deg,
      rgba(255, 215, 0, 0.0) 30deg,
      rgba(255, 215, 0, 0.85) 38deg,
      rgba(255, 215, 0, 0.0) 46deg,
      rgba(255, 215, 0, 0.0) 60deg,
      rgba(255, 215, 0, 0.85) 68deg,
      rgba(255, 215, 0, 0.0) 76deg,
      rgba(255, 215, 0, 0.0) 90deg,
      rgba(255, 215, 0, 0.85) 98deg,
      rgba(255, 215, 0, 0.0) 106deg,
      rgba(255, 215, 0, 0.0) 360deg
    );
  animation: burst-spin 4s linear infinite;
  border-radius: 50%;
  mix-blend-mode: screen;
}
@keyframes burst-spin { to { transform: rotate(360deg); } }
.portrait-icon {
  position: relative;
  font-size: clamp(80px, 14vw, 220px);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6));
  animation: icon-roar 0.45s 0.55s ease-out 1 forwards;
  transform: scale(0);
}
@keyframes icon-roar {
  0%   { transform: scale(0)   rotate(-30deg); }
  60%  { transform: scale(1.4) rotate(8deg); }
  100% { transform: scale(1.0) rotate(0deg); }
}

/* テキスト（右から飛び込み） */
.cutin-text {
  position: absolute;
  right: 6vw;
  top: 50%;
  transform: translate(150%, -50%);
  text-align: right;
  color: #fff;
  animation: text-fly-in 0.5s 0.6s cubic-bezier(0.18, 1.3, 0.6, 1.05) forwards;
}
@keyframes text-fly-in {
  to { transform: translate(0, -50%); }
}
.cutin-skill-label {
  font-size: clamp(18px, 2vw, 26px);
  letter-spacing: 0.5em;
  color: #ffd700;
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
  margin-bottom: 4px;
}
.cutin-name {
  font-size: clamp(72px, 11vw, 168px);
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #fff8b0 0%, #ffd24a 50%, #c8420a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 6px 24px rgba(255, 100, 30, 0.7);
  line-height: 1;
}
.cutin-jp {
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 184, 74, 1.0),
               0 4px 8px rgba(0, 0, 0, 0.6);
  margin-top: 8px;
  letter-spacing: 0.1em;
  animation: jp-pulse 0.5s 1.0s ease-out infinite alternate;
}
@keyframes jp-pulse {
  from { transform: scale(1.0); }
  to   { transform: scale(1.06); }
}

/* 全画面フラッシュ */
.cutin-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 1);
  opacity: 0;
  animation: cutin-flash 0.6s 0.0s ease-out forwards,
             cutin-flash 0.4s 1.6s ease-out forwards;
}
@keyframes cutin-flash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* =====================================================================
 * 借金 halfBlown 演出
 * ===================================================================== */
#saikin-halfblown {
  position: fixed;
  inset: 0;
  z-index: 199;
  pointer-events: none;
  overflow: hidden;
  font-family: 'Hiragino Maru Gothic ProN', 'Noto Sans JP', sans-serif;
}
#saikin-halfblown.hidden { display: none; }

/* 金色フラッシュ */
.hb-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 215, 0, 0.95) 0%, rgba(255, 80, 30, 0.7) 35%, rgba(0, 0, 0, 0.0) 70%);
  animation: hb-flash 1.4s ease-out forwards;
}
@keyframes hb-flash {
  0%   { opacity: 0; transform: scale(0.4); }
  20%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* 金色の集中線 */
.hb-rays {
  position: absolute;
  inset: -10%;
  background:
    repeating-conic-gradient(
      from 0deg,
      rgba(255, 215, 0, 0.0)  0deg,
      rgba(255, 215, 0, 0.55) 4deg,
      rgba(255, 215, 0, 0.0)  10deg
    );
  animation: hb-rays 1.4s linear forwards;
  mix-blend-mode: screen;
}
@keyframes hb-rays {
  0%   { transform: rotate(0deg)   scale(0.3); opacity: 0; }
  20%  { transform: rotate(60deg)  scale(1.0); opacity: 1; }
  100% { transform: rotate(180deg) scale(1.4); opacity: 0; }
}

.hb-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(48px, 8vw, 110px);
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #ffe97a 0%, #ff8230 60%, #c8242a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 6px 18px rgba(255, 100, 30, 0.9);
  animation: hb-text 1.4s ease-out forwards;
}
@keyframes hb-text {
  0%   { transform: scale(0.3) rotate(-6deg); opacity: 0; }
  25%  { transform: scale(1.15) rotate(2deg); opacity: 1; }
  60%  { transform: scale(1.0) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.0) rotate(0deg); opacity: 0; }
}
.hb-sub {
  position: absolute;
  bottom: 28%;
  left: 0; right: 0;
  text-align: center;
  font-size: clamp(20px, 2.4vw, 32px);
  color: #fff5b8;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  animation: hb-sub 1.4s ease-out forwards;
  opacity: 0;
}
@keyframes hb-sub {
  0%, 30% { opacity: 0; transform: translateY(20px); }
  50%     { opacity: 1; transform: translateY(0); }
  100%    { opacity: 0; transform: translateY(0); }
}

/* スマホでヒント位置調整 */
@media (max-width: 720px) {
  #hint { font-size: 12px; max-width: 200px; padding: 10px 12px; }
  #dialog { font-size: 14px; }
  #reset-btn { right: 70px; top: 10px; padding: 4px 10px; font-size: 11px; }
  .title-main { font-size: 48px; }
  .title-controls { font-size: 12px; padding: 12px 18px; }
  .game-over-title { font-size: 64px; }
}
