/* =====================
   共通
===================== */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Rounded Mplus 1c", sans-serif;
  background: #fef6e4;
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* =====================
   キャラ選択
===================== */
#characterSelect {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.char-list {
  display: flex;
  gap: 20px;
}

.char-btn {
  width: 140px;
  min-height: 160px;
  background: #fff;
  border: 3px solid #ffd166;
  border-radius: 20px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.char-btn img {
  width: 90px;
  height: 90px;
}

.char-btn:active {
  transform: scale(0.95);
}

/* =====================
   モード切替
===================== */
#modeSelect {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.mode {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  background: #ddd;
  font-size: 16px;
}

.mode.active {
  background: #ffcc66;
}

/* =====================
   ゲーム画面
===================== */
#gameScreen {
  position: fixed;
  inset: 0;
  background: linear-gradient(#bde0fe, #ffffff);
  overflow: hidden;

  border: 10px solid #ffd166;
  border-radius: 20px;
  box-shadow: inset 0 0 0 4px #fff;
}


#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;

  display: flex;
  justify-content: space-between;
  font-size: 20px;
  z-index: 10;
}

/* スコアバウンド */
#score.bump {
  animation: bump 0.2s ease;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

/* 残り10秒警告 */
#timer.danger {
  color: #ff3b3b;
  animation: dangerBlink 0.6s ease-in-out infinite;
}

@keyframes dangerBlink {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

/* プレイヤー */
#player {
  position: absolute;
  bottom: 20px;
  width: 80px;
  height: 80px;

  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* =====================
   プレイヤーヒット演出
===================== */
#player.hit {
  animation: playerHit 0.25s ease;
}

@keyframes playerHit {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.25);
  }

  100% {
    transform: scale(1);
  }
}


/* =====================
   星 共通
===================== */
.star {
  position: absolute;
  pointer-events: none;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* 通常星 */
.star.normal {
  background-image: url("images/star.png");
}

/* 当たり星 */
.star.hit {
  background-image: url("images/star_hit.png");
}

/* 🌈 レインボースター */
.star.rainbow {
  background-image: url("images/star_rainbow.png");
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
  animation: rainbowSpin 1.4s linear infinite;
}

/* 🌈 オーラ演出 */
.star.rainbow::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(rgba(255, 255, 255, 0.9),
      rgba(255, 255, 255, 0));
  animation: aura 1s ease-in-out infinite;
}

/* =====================
   レインボー取得時 強調
===================== */
#hud {
  transition: filter 0.2s;
}

/* =====================
   スコア枠
===================== */
#score {
  padding: 8px 14px;
  background: #ffffffcc;
  border: 3px solid #ffcc66;
  border-radius: 14px;

  font-weight: bold;
  color: #333;
  box-shadow: 0 4px 0 #f4b942;
}

#score.gold {
  color: gold;
  text-shadow: 0 0 12px gold;
}

#score.rainbow {
  background: linear-gradient(
    90deg,
    red, orange, yellow, green, cyan, blue, violet
  );
  background-size: 400%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowText 2s linear infinite;
}

@keyframes rainbowText {
  0% { background-position: 0%; }
  100% { background-position: 400%; }
}



/* =====================
   タイマー枠
===================== */
#timer {
  padding: 8px 14px;
  background: #ffffffcc;
  border: 3px solid #8ecae6;
  border-radius: 14px;

  font-weight: bold;
  color: #333;
  box-shadow: 0 4px 0 #6fb3d2;
}

/* =====================
   長押し終了UI
===================== */
#holdExit {
  position: absolute;
  bottom: 12px;
  right: 12px;

  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;

  border-radius: 20px;
  font-size: 14px;
  z-index: 20;

  user-select: none;
}

/* =====================
   終了画面
===================== */
#endScreen {
  text-align: center;
}

#endScreen h2 {
  font-size: 32px;
}

#resultMsg {
  font-size: 20px;
  margin: 12px 0 20px;
}

/* =====================
   将来拡張用HUD余白
===================== */
#hud>div {
  min-width: 90px;
  text-align: center;
}



@keyframes aura {
  0% {
    transform: scale(0.9);
    opacity: 0.6;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }

  100% {
    transform: scale(0.9);
    opacity: 0.6;
  }
}

@keyframes rainbowSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* =====================
   +5 ポップ
===================== */
.score-pop {
  position: absolute;
  font-size: 28px;
  font-weight: bold;
  color: gold;
  pointer-events: none;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
  animation: popUp 0.8s ease-out forwards;
}

@keyframes popUp {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }

  30% {
    opacity: 1;
    transform: translateY(-10px) scale(1.2);
  }

  100% {
    opacity: 0;
    transform: translateY(-40px) scale(1);
  }
}

/* =====================
   キラキラ粒子
===================== */
.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: radial-gradient(white, rgba(255, 255, 255, 0));
  border-radius: 50%;
  pointer-events: none;
  animation: sparkleMove 0.6s ease-out forwards;
}

@keyframes sparkleMove {
  to {
    transform: translate(var(--dx), var(--dy));
    opacity: 0;
  }
}

/* =====================
   フラッシュ演出
===================== */
.flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
  animation: flash 0.25s ease-out forwards;
  z-index: 999;
}

@keyframes flash {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

#gameScreen {
  background: linear-gradient(#bde0fe, #ffffff);
  background-size: 100% 200%;
  animation: bgFlow 20s linear infinite;
}

#gameScreen.combo {
  animation-duration: 8s;
  /* コンボ中は速く */
}

@keyframes bgFlow {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 0 100%;
  }
}

/* =====================
   COMBO 表示（最終・競合解消版）
===================== */
#comboPop {
  position: fixed;              /* ← HUDから独立 */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 44px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  text-align: center;

  text-shadow:
    0 4px 0 #fff,
    0 10px 20px rgba(0,0,0,0.3);
}

/* 表示トリガー */
#comboPop.show {
  animation: comboPop 0.8s ease-out forwards;
}

/* 最大コンボ・フルコンボ用 */
#comboPop.full,
#comboPop.record {
  color: gold;
  text-shadow:
    0 0 12px gold,
    0 0 24px white;
}

/* 虹（中〜高コンボ） */
#comboPop.rainbow {
  background: linear-gradient(
    90deg,
    red, orange, yellow, green, cyan, blue, violet
  );
  background-size: 400%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowText 2s linear infinite;
}

/* ★999999 到達（金・最終） */
#comboPop.full {
  color: gold;
  background: none;
  -webkit-text-fill-color: initial;
  text-shadow:
    0 0 12px gold,
    0 0 24px white,
    0 0 48px gold;
}


/* =====================
   COMBO アニメ（統一）
===================== */
@keyframes comboPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.4);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80%) scale(0.8);
  }
}



/* 最大コンボ更新 */
#comboPop.record {
  color: gold;
  text-shadow: 0 0 12px gold;
}

/* タイムアップ演出 */
.game.slow {
  filter: brightness(1.1);
}


#comboPop.show {
  animation: comboPop 0.8s ease-out forwards;
}

@keyframes comboPop {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 1;
  }
  60% {
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80%) scale(0.8);
  }
}


.star.trail::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 40px;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0.8),
    rgba(255,255,255,0)
  );
  transform: translate(-50%, -10px);
  filter: blur(2px);
}


@keyframes trail {
  from { opacity: 0.8; }
  to { opacity: 0.2; }
}

.game-screen.fever {
  animation: feverFlash 0.5s alternate infinite;
}

@keyframes feverFlash {
  0% {
    filter: brightness(1) saturate(1.2);
  }
  100% {
    filter: brightness(1.3) saturate(1.8);
  }
}

.game-screen.combo {
  background-position-y: 0;
  animation: bgScrollFast 6s linear infinite;
}

@keyframes bgScrollFast {
  from { background-position-y: 0; }
  to   { background-position-y: 1000px; }
}

