/* ================================
   トップページ用
   ================================ */

#top-wrapper {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 12px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#top-title-image {
  width: min(80vw, 320px);
  height: auto;
  margin-bottom: 12px;
  image-rendering: pixelated;    /* ドット感をくっきり */
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
}

#top-main-title {
  font-size: 26px;
  margin-bottom: 12px;
}

.play-button {
  display: inline-block;
  padding: 12px 32px;
  margin: 12px 0 20px;
  background: #ffcc00;
  color: #222;
  font-weight: bold;
  font-size: 18px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 4px 0 #b58a00;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.play-button:hover {
  background: #ffe066;
}

.play-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #b58a00;
}

.play-button-bottom {
  margin-top: 24px;
}

/* 説明ブロック */
.top-section {
  width: 100%;
  max-width: 640px;
  background: #222;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 12px;
  text-align: left;
}

.top-section h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

.top-section ul {
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
}

.top-section li + li {
  margin-top: 4px;
}

.top-note {
  margin-top: 6px;
  font-size: 13px;
  color: #ccc;
}

/* スマホで少し文字を小さく */
@media (max-width: 768px) {
  #top-main-title {
    font-size: 22px;
  }
  .play-button {
    width: 80%;
    max-width: 320px;
    font-size: 16px;
  }
  .top-section {
    padding: 10px 12px;
  }
}


* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #111;
  color: #fff;
  font-family: sans-serif;

  /* ここを追加 */
  touch-action: manipulation;
  -ms-touch-action: manipulation;
}

#game-wrapper {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 4px 8px 8px; /* 上を少し詰める */
  display: flex;
  flex-direction: column;
  align-items: center;
}

#level-title {
  font-size: 24px;
  font-weight: bold;
  line-height: 1.1;
  margin: 0;
}

#hp-box {
  font-size: 20px;
  line-height: 1.1;
  margin: 0;
}

/* ★ 高さ固定メッセージ欄 */
#message-box {
  width: 100%;
  max-width: 520px;
  height: 18px;           /* 固定高さ */
  line-height: 18px;      /* 1行テキスト */
  font-size: 14px;
  color: #ff6666;
  text-align: center;
  margin: 2px 0 0;
  overflow: hidden;       /* 長文でも高さを変えない */
}

/* フィールドエリア（正方形） */
#board-container {
  margin-top: 2px;        /* 上側の余白をギリギリまで詰める */
  position: relative;
  width: min(95vw, 520px);
  aspect-ratio: 1 / 1;
  background: #000;
  overflow: hidden;
}

/* Three.js 描画領域 */
#three-container {
  width: 100%;
  height: 100%;
}

/* STAGE CLEAR ボックス：デフォルト非表示 */
#clear-box {
  position: absolute;
  inset: 0;
  display: none !important;  /* 最初は完全に非表示 */
  opacity: 0;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

#clear-box.show {
  display: flex !important;
  opacity: 1;
}

#clear-text {
  font-size: 40px;
  font-weight: bold;
  color: #ffcc00;
  text-shadow: 0 0 18px #fff;
}

/* コントローラー */
#controller {
  margin-top: 10px;
}

.pad-row {
  display: flex;
  justify-content: center;
  margin: 4px 0;
}

.pad-btn {
  width: 72px;
  height: 72px;
  margin: 0 8px;
  background: #444;
  color: #fff;
  font-size: 30px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.pad-btn:active {
  background: #666;
}

/* スマホ調整 */
@media (max-width: 768px) {
  #board-container {
    width: 92vw;
  }
  .pad-btn {
    width: 58px;
    height: 58px;
    font-size: 24px;
    margin: 4px;
  }
}

/* ================================
   タイムアタック用表示
   ================================ */

#time-box {
  font-size: 18px;
  margin-top: 2px;
}

#score-box {
  margin-top: 12px;        /* 矢印のすぐ下 */
  font-size: 20px;
  text-align: center;
}

/* COMBO 表示用（JSから使用） */
.combo-text {
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 34px;
  font-weight: bold;
  color: #ff99ff;
  text-shadow: 0 0 10px #fff;
  opacity: 0;
  transition: opacity 0.3s;
}

/* タイムアタック用表示 */

#time-box {
  font-size: 18px;
  margin-top: 2px;
}

/* ★ コンボカウント表示（フィールドの上あたり） */
#combo-count-box {
  width: 100%;
  max-width: 520px;
  height: 18px;
  line-height: 18px;
  font-size: 14px;
  color: #ffcc00;
  text-align: center;
  margin: 2px 0 0;
  overflow: hidden;
}

#score-box {
  margin-top: 12px;
  font-size: 20px;
  text-align: center;
}

/* COMBO テキスト（画面中央用） */
.combo-text {
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 34px;
  font-weight: bold;
  color: #ff99ff;
  text-shadow: 0 0 10px #fff;
  opacity: 0;
  transition: opacity 0.3s;
}

/* PLUS10 表示用（フィールド上に出す小さめの文字） */
.plus10-text {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 26px;
  font-weight: bold;
  color: #ffcc00;
  text-shadow: 0 0 10px #000;
  opacity: 0;
  transition: opacity 0.2s;
}

/* タイムアタック：トップに戻るボタン */
#back-top-wrapper {
  margin-top: 12px;
  text-align: center;
}

.back-top-button {
  display: inline-block;
  padding: 8px 24px;
  background: #444;
  color: #fff;
  font-size: 14px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid #888;
}

.back-top-button:hover {
  background: #666;
}

/* PLUS3 表示用（フィールド上に出す小さめの文字） */
.plus10-text {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 26px;
  font-weight: bold;
  color: #ffcc00;
  text-shadow: 0 0 10px #000;
  opacity: 0;
  transition: opacity 0.2s;
}

/* play.html：トップに戻るボタン */
#back-top-wrapper {
  margin-top: 12px;
  text-align: center;
  padding-bottom: 10px;
}

.back-top-button {
  display: inline-block;
  padding: 10px 30px;
  background: #444;
  color: #fff;
  font-size: 16px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid #888;
}

.back-top-button:hover {
  background: #666;
}

/* ▼ TIME 表示色（通常は青） */
#time-value {
  color: #1e90ff;  /* 青 */
  font-weight: bold;
}

/* ▼ 残り10秒以下になったら赤色 */
.time-warning {
  color: #ff3333 !important;
}

/* back-top 内でボタンを横並び・間隔 */
#back-top-wrapper .back-top-button + .back-top-button {
  margin-left: 8px;
}

/* ================================
   ステージセレクト用
   ================================ */

/* ================================
   ステージセレクト用
   ================================ */

#select-wrapper {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 12px 40px;
  text-align: center;
  min-height: 100vh;
}

.select-title {
  font-size: 32px;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.select-status {
  font-size: 14px;
  margin-bottom: 18px;
  line-height: 1.6;
  color: #ddd;
}

#stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* カード型ステージボタン */
.stage-select-button {
  position: relative;
  width: 100%;
  height: 110px;
  border-radius: 6px;
  border: 2px solid #5a5a5a;
  background: #2c7a3f;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  padding: 84px 4px 4px;
  text-align: center;
  overflow: hidden;
  box-shadow: 0 0 0 1px #000;
}

/* 上半分：フィールドっぽいエリア */
.stage-select-button::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 4px;
  bottom: 28px;
  border-radius: 4px;
  background:
    linear-gradient(135deg, #4caf50 0%, #2e7d32 40%, #33691e 100%);
}

/* クリア済み／解放済みアイコン（旗っぽい） */
.stage-select-button:not(.locked)::after {
  content: "🚩";
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 26px;
}

/* ロック中：色を暗く＋鍵アイコン */
.stage-select-button.locked {
  background: #4a1942;
  border-color: #7b325e;
  color: #aaaaaa;
  cursor: default;
}

.stage-select-button.locked::before {
  background: linear-gradient(135deg, #3b1434 0%, #290c24 40%, #1d0719 100%);
}

.stage-select-button.locked::after {
  content: "🔒";
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 28px;
}

/* ホバー時 */
.stage-select-button:hover:not(.locked) {
  filter: brightness(1.15);
}

/* セーブしたステージは枠を光らせる */
.stage-select-button.last-saved {
  border-color: #ffeb3b;
  box-shadow: 0 0 10px rgba(255, 235, 59, 0.8);
}

/* フッター */
.select-footer {
  margin-top: 24px;
}

/* 小さいボタン（初期化） */
.back-top-button.small {
  padding: 8px 18px;
  font-size: 14px;
  margin-left: 8px;
}

/* スマホ調整 */
@media (max-width: 768px) {
  #select-wrapper {
    padding-top: 16px;
  }
  .select-title {
    font-size: 24px;
  }
  #stage-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
