* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #111418; color: #eee;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}
body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; overflow: hidden;
}

/* phone-shaped viewport so a PC browser still previews it like a real device */
#app {
  position: relative;
  width: min(92vw, 480px);
  aspect-ratio: 557 / 1024;
  background: #000;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 6px #05070a;
}

.scene { position: absolute; inset: 0; }
.hidden { display: none !important; }
.scene-bg { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ================= TITLE ================= */
.scene-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.1) 45%, rgba(0,0,0,0) 68%);
}
.title-content {
  position: absolute; left: 0; right: 0; bottom: 9%;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.game-title {
  margin: 0; color: #fff; font-size: clamp(24px, 7.5vw, 34px); letter-spacing: 5px;
  text-shadow: 0 0 14px rgba(255,20,40,0.85), 0 2px 4px rgba(0,0,0,0.85);
}
.blink-btn {
  background: #ff2b4e; color: #fff; border: none;
  padding: 12px 46px; font-size: 18px; font-weight: 800; letter-spacing: 3px;
  border-radius: 30px; box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
  animation: blink 1.1s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.32; } }

/* ================= 汎用カットシーン ================= */
#scene-cutscene { background: #000; }
.cutscene-lines {
  position: absolute; inset: 0; padding: 0 9%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.cutscene-line {
  opacity: 0; color: #fff; font-size: clamp(14px, 4.6vw, 19px); line-height: 2;
  margin: 0 0 26px; transition: opacity 1.1s ease-out;
}
.cutscene-line.show { opacity: 1; }
.red-text { color: #ff3b3b; font-weight: 700; }

#cutsceneFlash {
  position: absolute; inset: 0; opacity: 0;
  transition: opacity 0.45s ease-in;
  background: #fff;
}
#cutsceneFlash.show { opacity: 1; }
#cutsceneFlash.flash-black { background: #000; }

#cutsceneEpilogue { position: absolute; inset: 0; }
#cutsceneEpilogue #epilogueImage {
  opacity: 0; transition: opacity 1.4s ease-in;
}
#cutsceneEpilogue.show #epilogueImage { opacity: 1; }
.epilogue-restart {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%);
}

/* ================= バトル共通 ================= */
#scene-battle { background: #000; }

#battleHud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  padding: 10px 14px 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.78), rgba(0,0,0,0));
}
.gauge-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.gauge-label {
  width: 54px; color: #fff; font-size: 11px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.gauge-track {
  flex: 1; height: 12px; background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3); border-radius: 6px; overflow: hidden;
}
.gauge-fill { height: 100%; width: 100%; transition: width 0.1s linear; }
.time-fill { background: linear-gradient(90deg, #ffd35c, #ff9d2b); }
.hp-fill { background: linear-gradient(90deg, #ff5d5d, #ff2b4e); }
.hp-fill.urgent { animation: hpUrgent 0.4s ease-in-out infinite; }
@keyframes hpUrgent { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.7); } }

#battleMain { position: absolute; inset: 0; cursor: pointer; overflow: hidden; }
#battleMain #battleImage { transition: none; }
#battleMain.punch #battleImage { animation: punch 0.22s cubic-bezier(.36,.07,.19,.97); }
@keyframes punch {
  0% { transform: scale(1); }
  35% { transform: scale(0.965); }
  65% { transform: scale(1.025); }
  100% { transform: scale(1); }
}
/* 画像エリアだけを揺らす（上段ゲージ・下段メッセージは固定のまま） */
#battleMain.shake { animation: hitShake 0.22s cubic-bezier(.36,.07,.19,.97); }
@keyframes hitShake {
  0% { transform: translate(0,0); }
  20% { transform: translate(-6px,3px); }
  40% { transform: translate(5px,-3px); }
  60% { transform: translate(-4px,2px); }
  80% { transform: translate(3px,-2px); }
  100% { transform: translate(0,0); }
}

#tapFxLayer { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.tap-flash {
  position: absolute; width: 74px; height: 74px; margin-left: -37px; margin-top: -37px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,30,30,0.85) 0%, rgba(255,30,30,0.35) 55%, rgba(255,30,30,0) 75%);
  animation: tapFlashAnim 0.35s ease-out forwards;
}
@keyframes tapFlashAnim {
  from { opacity: 1; transform: scale(0.4); }
  to { opacity: 0; transform: scale(1.7); }
}
.tap-ring {
  position: absolute; width: 20px; height: 20px; margin-left: -10px; margin-top: -10px;
  border-radius: 50%; border: 3px solid rgba(255,255,255,0.85);
  animation: tapRingAnim 0.4s ease-out forwards;
}
@keyframes tapRingAnim {
  from { opacity: 0.9; transform: scale(0.3); }
  to { opacity: 0; transform: scale(3.2); }
}
.tap-spark {
  position: absolute; width: 7px; height: 7px; margin-left: -3.5px; margin-top: -3.5px;
  border-radius: 50%; background: #fff5b8;
  animation: sparkAnim 0.45s ease-out forwards;
}
@keyframes sparkAnim {
  from { opacity: 1; transform: translate(0,0) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

#comboDisplay {
  position: absolute; top: 32%; left: 50%; transform: translate(-50%, -50%) scale(1);
  color: #ffe066; font-size: 26px; font-weight: 900; letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.75), 0 0 14px rgba(255,180,0,0.6);
  pointer-events: none; z-index: 7;
}
#comboDisplay.pop { animation: comboPop 0.28s ease-out; }
@keyframes comboPop {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.4; }
  55% { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#stageFlash {
  position: absolute; inset: 0; z-index: 20; opacity: 0; pointer-events: none;
  transition: opacity 0.12s ease-in;
}
#stageFlash.show { opacity: 0.92; }
#stageFlash.flash-up { background: #ffe066; }
#stageFlash.flash-down { background: #ff2b3d; }

#battleMessage {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 14px 16px 18px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), rgba(0,0,0,0));
  color: #fff; text-align: center; font-size: 15px; font-weight: 700; letter-spacing: 1px;
}

#choicePanel {
  position: absolute; left: 0; right: 0; bottom: 22%; z-index: 15;
  display: flex; flex-direction: column; gap: 10px; padding: 0 8%;
}
.choice-btn {
  background: rgba(15,18,24,0.92); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 14px; padding: 12px 14px; font-size: 14px; font-weight: 700;
  animation: choiceIn 0.3s ease-out;
}
.choice-btn:active { background: rgba(50,55,65,0.95); }
@keyframes choiceIn { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: translateY(0);} }

.action-btn {
  position: absolute; left: 50%; bottom: 20%; transform: translateX(-50%); z-index: 15;
}

#devBackBtn {
  position: absolute; top: 10px; right: 10px; z-index: 25;
  background: rgba(0,0,0,0.55); color: #ffd35c;
  border: 1px solid rgba(255,255,255,0.35); border-radius: 14px;
  padding: 6px 10px; font-size: 11px;
}
