/* ===== style.css — クレぷよ スタイル ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100svh;
  overflow: hidden;
  background: #CCFFFF;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
  color: #333;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- BGMボタン --- */
.bgm-btn {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 200;
  background: rgba(255,255,255,0.85);
  color: #1a4a6e;
  border: 1px solid rgba(26,74,110,0.25);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  padding: 0;
}
.bgm-btn:active {
  background: rgba(255,255,255,1);
  transform: scale(0.92);
}

/* --- オーバーレイ画面共通 --- */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #CCFFFF;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 100;
  padding: 20px;
  overflow-x: hidden;
  overflow-y: auto;
}

.overlay h1 {
  font-size: 26px;
  margin-bottom: 10px;
  color: #FFD700;
}

.overlay h2 {
  font-size: 18px;
  margin-bottom: 10px;
  color: #ccc;
}

/* --- ボタン --- */
.btn {
  display: inline-block;
  padding: 14px 28px;
  font-size: 17px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin: 6px;
  transition: transform 0.1s;
  color: #fff;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
}

#startScreen .btn-primary,
#rankingScreen > .btn-primary {
  width: 90%;
  max-width: 380px;
  padding: 14px 0;
}

.btn-secondary {
  background: linear-gradient(135deg, #f093fb, #f5576c);
}

.btn-ranking {
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  color: #1a1a2e;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- スタート画面 --- */
.title-area {
  text-align: center;
  margin-bottom: 15px;
}

.title {
  font-size: 52px;
  font-weight: bold;
  color: #FFD700;
  text-shadow: 3px 3px 8px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.1em;
}

.title-img {
  width: 90%;
  max-width: 380px;
  height: auto;
  cursor: pointer;
}

.subtitle {
  font-size: 15px;
  color: #333;
  margin-top: 2px;
}

/* --- ゲームオーバー画面 --- */
.batankyu-img {
  width: 70%;
  max-width: 280px;
  margin-bottom: 10px;
}

.go-score-area {
  text-align: center;
  margin-bottom: 10px;
}

.score-label {
  font-size: 14px;
  color: #aaa;
}

.score-display {
  font-size: 40px;
  font-weight: bold;
  color: #FFD700;
}

.chain-display {
  font-size: 16px;
  color: #aaa;
}

/* --- 名前変更エリア --- */
.name-area {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}

.name-area input {
  width: 140px;
  padding: 8px 12px;
  font-size: 14px;
  border: 2px solid #555;
  border-radius: 8px;
  background: #2a2a4a;
  color: #fff;
  text-align: center;
  outline: none;
}

.name-area input:focus {
  border-color: #667eea;
}

.btn-small {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  background: #555;
  color: #fff;
  cursor: pointer;
}

.btn-small:active {
  background: #777;
}

/* --- ランキング --- */
.ranking-box {
  width: 100%;
  max-width: 340px;
  margin: 4px 0;
}

/* --- TOP3 固定表示 --- */
.ranking-top3 {
  list-style: none;
  padding: 0;
  width: 100%;
  max-width: 340px;
  margin: 0 auto 4px;
}

.ranking-top3 li {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 8px;
  margin-bottom: 3px;
  font-size: 15px;
  font-weight: bold;
}

.ranking-top3 li .rank { width: 30px; text-align: center; }
.ranking-top3 li .rname { flex: 1; margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-top3 li .rscore { color: #FFD700; margin-left: 8px; min-width: 55px; text-align: right; }
.ranking-top3 li .rchain { font-size: 12px; color: #aaa; margin-left: 6px; min-width: 48px; text-align: right; font-weight: normal; }

.ranking-top3 li.my-score {
  background: rgba(255, 210, 0, 0.25);
  border: 1px solid #FFD700;
}

.ranking-box ul {
  list-style: none;
  padding: 0;
}

.ranking-box li {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  margin-bottom: 3px;
  font-size: 14px;
}

.ranking-box li.empty {
  justify-content: center;
  color: #888;
}

.ranking-box li.my-score {
  background: rgba(255, 210, 0, 0.25);
  border: 1px solid #FFD700;
}

.ranking-box li.rank-separator {
  justify-content: center;
  color: #666;
  font-size: 12px;
  padding: 2px;
  background: none;
}

.ranking-box li .rank {
  width: 30px;
  text-align: center;
  font-weight: bold;
}

.ranking-box li .rname {
  flex: 1;
  margin-left: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-box li .rscore {
  font-weight: bold;
  color: #FFD700;
  margin-left: 8px;
  min-width: 55px;
  text-align: right;
}

.ranking-box li .rchain {
  font-size: 12px;
  color: #aaa;
  margin-left: 6px;
  min-width: 48px;
  text-align: right;
}

/* --- SNSアイコン --- */
.sns-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0;
  flex-wrap: nowrap;
}

.sns-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sns-row a img {
  width: 56px;
  height: 56px;
  max-width: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.1s;
}

.sns-row a:active img {
  transform: scale(0.92);
}

/* --- 遊び方 / シェアする セクション共通 --- */
.howto-section,
.share-section {
  width: 90%;
  max-width: 380px;
  margin: 16px auto 8px;
  text-align: center;
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Segoe UI', 'Hiragino Sans', 'Meiryo', sans-serif;
}

.section-title {
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: clamp(15px, 4.5vw, 18px);
  margin: 0 auto 12px;
}

/* --- 遊び方 タイトル（ピンクのピル型） --- */
.howto-title {
  display: inline-block;
  background: #EC407A;
  color: #fff;
  padding: 8px clamp(40px, 12vw, 64px);
  border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.howto-desc {
  color: #1a4a6e;
  font-size: clamp(13px, 3.7vw, 14px);
  line-height: 1.7;
  margin-bottom: 12px;
}

/* --- 操作ガイド（howto-section 内）--- */
.howto-section .controls-guide {
  font-size: clamp(14px, 3.9vw, 15px);
  color: #1a4a6e;
  margin-top: 8px;
  text-align: center;
  line-height: 1.7;
}

/* --- シェアする タイトル（ダーク化したティール）--- */
.share-title {
  color: #1a8a87;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vw, 12px);
}

.share-title .slash {
  color: #1a8a87;
  font-weight: 700;
  display: inline-block;
}

/* --- キャラクターサイトリンク --- */
.chara-link {
  display: block;
  width: 100%;
  margin: 24px 0 8px;
  text-align: center;
  line-height: 0;
}

.chara-link img {
  display: inline-block;
  width: 95%;
  max-width: 95%;
  height: auto;
  vertical-align: top;
  transition: transform 0.1s;
}

.chara-link:active img {
  transform: scale(0.97);
}

/* 横長画面では高さ基準で表示 */
@media (orientation: landscape) {
  .chara-link img {
    width: auto;
    height: 90vh;
    max-width: 95%;
    max-height: 90vh;
  }
}

/* --- 再挑戦ボタン (BATANKYU画面) --- */
.btn-retry {
  margin-top: 16px;
  padding: 16px 40px;
  font-size: 19px;
}

/* --- ビルド時刻 --- */
.build-time {
  font-size: 10px;
  color: #444;
  margin-top: 10px;
  text-align: center;
}

/* --- 消去アニメーション（CSS fallback） --- */
@keyframes erase {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.2); }
}

/* --- デバッグメニュー --- */
.debug-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.debug-panel {
  background: #2a1a1a;
  border: 2px solid #8b2252;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  min-width: 240px;
}

.debug-panel h2 {
  color: #8b2252;
  font-size: 20px;
  margin-bottom: 16px;
  letter-spacing: 0.2em;
}

.debug-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  background: #444;
}

.debug-btn:active {
  transform: scale(0.96);
}

.debug-close {
  background: #8b2252;
  margin-top: 6px;
}
