/* -------------------------------------------------------------
   ぐにゃぐにゃ だいぼうけん スタイルシート
   ------------------------------------------------------------- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background: #0f172a;
  color: #f8fafc;
  font-family: 'M PLUS Rounded 1c', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100dvh;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100dvh;
  max-width: 450px; /* 横幅を Galaxy S25 Ultra 相当に制限 */
  margin: 0 auto;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.5);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* -------------------------------------------------------------
   上部 HUD
   ------------------------------------------------------------- */
.hud-container {
  height: 75px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  z-index: 10;
  display: none; /* プレイ中のみ active 時に JS で表示 */
}

.hud-container.active {
  display: flex;
}

.hud-center-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* 進捗バーのスタイル */
.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-lbl {
  font-size: 10px;
  font-weight: 900;
  color: #64748b;
}

.progress-track {
  width: 110px;
  height: 8px;
  background: #1e293b;
  border-radius: 9999px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: visible;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  border-radius: 9999px;
  width: 0%;
}

.progress-player-icon {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  background: #ffffff;
  border: 2px solid #0284c7;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent; /* 中身は白丸にする */
  box-shadow: 0 0 4px rgba(56, 189, 248, 0.6);
}

.hud-btn {
  background: #334155;
  color: #f1f5f9;
  border: none;
  font-size: 13px;
  font-weight: 900;
  padding: 8px 12px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1e293b;
  transition: all 0.1s ease;
  font-family: inherit;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.hud-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.hud-btn-icon {
  font-size: 20px;
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-stage-name {
  font-size: 14px;
  font-weight: 900;
  color: #38bdf8;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* -------------------------------------------------------------
   Phaser Canvas コンテナ
   ------------------------------------------------------------- */
#phaser-container {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: #38bdf8; /* 空色 */
  display: flex;
  justify-content: center;
  align-items: center;
}

#phaser-container canvas {
  display: block;
}

/* -------------------------------------------------------------
   下部コントローラー
   ------------------------------------------------------------- */
.controller-container {
  height: 160px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border-top: 2px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  z-index: 10;
  display: none; /* プレイ中のみ active */
}

.controller-container.active {
  display: flex;
}

/* バーチャルジョイスティックのスタイル */
.joystick-zone {
  width: 140px;
  height: 140px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  user-select: none;
}

.joystick-base {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 4px solid rgba(255, 255, 255, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.6);
}

.joystick-stick {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  position: absolute;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  touch-action: none;
}

#joystick-left .joystick-stick {
  background: radial-gradient(circle at 30% 30%, #38bdf8, #0284c7);
}

.action-buttons-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  align-items: center;
  width: 140px;
  height: 140px;
}

.action-btn {
  font-family: inherit;
  font-weight: 900;
  font-size: 16px;
  color: #0f172a;
  border: none;
  border-radius: 24px;
  min-height: 48px;
  width: 120px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}

.action-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.btn-jump {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: white;
  box-shadow: 0 4px 0 #0369a1;
}

.btn-jump:active {
  box-shadow: none;
}

.btn-grab {
  background: linear-gradient(135deg, #facc15, #eab308);
  box-shadow: 0 4px 0 #ca8a04;
}

.btn-grab.pressed {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: white;
  box-shadow: 0 2px 0 #b91c1c;
  transform: translateY(2px);
}

/* 画面高さが小さいスマホ向けのメディアクエリ */
@media (max-height: 820px) {
  .controller-container {
    height: 135px;
    padding: 0 12px;
  }
  .joystick-zone {
    width: 120px;
    height: 120px;
  }
  .joystick-base {
    width: 118px;
    height: 118px;
    border-width: 3px;
  }
  .joystick-stick {
    width: 64px;
    height: 64px;
  }
  .action-buttons-container {
    width: 120px;
    height: 120px;
    gap: 8px;
  }
  .action-btn {
    width: 110px;
    min-height: 48px;
    font-size: 14px;
  }
}

/* -------------------------------------------------------------
   共通ボタン & アニメーション
   ------------------------------------------------------------- */
.btn {
  font-family: inherit;
  border: none;
  cursor: pointer;
  border-radius: 9999px;
  font-weight: 900;
  transition: all 0.1s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #0f172a;
  box-shadow: 0 6px 0 #ca8a04;
  font-size: 22px;
  padding: 14px 44px;
}

.btn-primary:active {
  transform: translateY(6px);
  box-shadow: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.animate-pulse {
  animation: pulse 1.5s infinite ease-in-out;
}

/* -------------------------------------------------------------
   オーバーレイスクリーン（タイトル、クリア画面など）
   ------------------------------------------------------------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #0f172a, #1e1b4b);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 24px;
  display: none;
}

.overlay-screen.active {
  display: flex;
}

/* タイトルロゴ */
.title-logo-container {
  text-align: center;
  margin-bottom: 8px;
}

.title-main {
  font-size: 48px;
  font-weight: 900;
  color: #38bdf8;
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.4), 0 4px 0 #0284c7;
  letter-spacing: -2px;
}

.title-sub {
  font-size: 40px;
  font-weight: 900;
  color: #facc15;
  text-shadow: 0 0 16px rgba(250, 204, 21, 0.4), 0 4px 0 #ca8a04;
  margin-top: -8px;
}

.title-desc {
  font-size: 14px;
  color: #cbd5e1;
  margin-bottom: 16px;
  font-weight: bold;
}

/* ステージ選択ボックス */
.stage-select-box {
  width: 100%;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 12px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.select-label {
  font-size: 13px;
  font-weight: 900;
  color: #94a3b8;
  text-align: center;
}

.stage-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-stage {
  background: #334155;
  color: #94a3b8;
  font-size: 14px;
  padding: 12px;
  border-radius: 16px;
  border: 2px solid transparent;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
}

.btn-stage.active {
  background: #1e1b4b;
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.btn-mute-title {
  position: absolute;
  bottom: 12px;
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 14px;
  font-weight: 900;
  padding: 8px 16px;
  cursor: pointer;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* クリア画面 */
.clear-overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.clear-overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.clear-card {
  background: linear-gradient(135deg, #1e1b4b, #311042);
  border: 4px solid #facc15;
  border-radius: 32px;
  padding: 32px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.clear-overlay-screen.active .clear-card {
  transform: scale(1);
}

.clear-title {
  font-size: 32px;
  font-weight: 900;
  color: #facc15;
  text-shadow: 0 4px 0 #ca8a04;
  margin-bottom: 12px;
}

.font-all-clear {
  font-size: 36px;
  color: #f43f5e;
  text-shadow: 0 4px 0 #be123c;
}

.clear-stars {
  font-size: 40px;
  margin-bottom: 16px;
  letter-spacing: 4px;
  animation: pulse 1.0s infinite ease-in-out;
}

.clear-text {
  font-size: 16px;
  color: #e2e8f0;
  line-height: 1.6;
  margin-bottom: 24px;
  font-weight: bold;
}
