/* =========================================
   1. 基本設定（全体・キャンバス）
   ========================================= */
body {
  margin: 0;
  background: #111;
  color: white;
  text-align: center;
  font-family: sans-serif;
  overflow-y: auto;
  line-height: 1.5;
  /* iOSのダブルタップズームを防止しつつスクロールを許可 */
  touch-action: manipulation;
  /* パッドが被らないように下側に余白を確保 */
  padding-bottom: 35vh; 
}

canvas {
  display: block;
  width: 100%;
  height: 200px;
  background: black;
  margin: 0 auto;
  touch-action: manipulation;
}

h2, .title {
  font-size: 18px !important;
  margin: 5px 0 !important;
  padding: 0 !important;
}

/* =========================================
   2. ゲームUI（スコア・コンボ）
   ========================================= */
#score, #combo {
  margin-top: 2px !important;
  font-weight: bold;
  line-height: 1.2;
}
#score { font-size: 18px; }
#combo { font-size: 22px; }

/* =========================================
   3. 判定パッド (#pad)
   ========================================= */
#pad {
  position: fixed;
  bottom: 5vh; 
  left: 50%;
  transform: translateX(-50%);

  /* サイズ設定：画面幅の80%かつ、高さの45%を超えない正円 */
  width: min(80vw, 45vh); 
  aspect-ratio: 1 / 1;
  max-width: 400px; 
  
  border-radius: 50%;
  background: radial-gradient(circle, #e74c3c 0% 40%, #2c3e50 41% 100%);
  border: 6px solid #333;
  box-shadow: 0 8px 0 #1a1a1a;
  box-sizing: border-box;
  z-index: 9999;
  
  /* 操作性：ブラウザのジェスチャーを完全禁止 */
  touch-action: none !important;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  
  /* アニメーション：沈み込みと透明化 */
  transition: transform 0.05s linear, filter 0.05s, background 0.05s, opacity 0.3s ease;
  cursor: pointer;
}

/* センターライン */
#pad::before {
  content: "";
  position: absolute;
  left: 50%; top: 0;
  width: 1px; height: 100%;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.6), transparent);
  opacity: 0.8;
  z-index: 1;
}

/* 左右ガイドテキスト */
#pad::after {
  content: "L  |  R";
  position: absolute;
  top: -25px; left: 50%;
  transform: translateX(-50%);
  color: #aaa;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
}

/* 隠すクラス（スクロール時用） */
#pad.pad-hidden {
  opacity: 0;
  pointer-events: none;
}

/* 押し心地（アクティブ時） */
#pad:active {
  transform: translateX(-50%) translateY(4px);
  box-shadow: 0 4px 0 #1a1a1a;
  filter: brightness(1.1);
}

/* =========================================
   4. ボタン共通設定
   ========================================= */
button, .buttonstart, .buttonstop, .buttonreset, .buttonhojyo, .copied-sample-button {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 5px;
  touch-action: manipulation;
  height: 44px;
  width: fit-content;
  padding: 0 12px;
  white-space: nowrap;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform .1s ease, filter .1s ease, box-shadow .1s ease;
}

/* 個別ボタン色設定 */
.buttonstart {
  border: 1px solid rgb(92, 171, 148);
  background: linear-gradient(135deg, rgb(118, 198, 175) 0%, rgb(92, 169, 146) 100%);
  color: #fff;
  box-shadow: rgba(71, 136, 118, 0.22) 0px 8px 20px;
}
.buttonstop {
  border: 1px solid rgb(234, 211, 187);
  background: linear-gradient(135deg, #fff 0%, rgb(255, 241, 224) 55%, rgb(246, 224, 199) 100%);
  color: rgb(107, 75, 45);
}
.buttonreset {
  border: 1px solid rgb(216, 132, 132);
  background: linear-gradient(135deg, rgb(255, 176, 176) 0%, rgb(234, 134, 134) 52%, rgb(208, 108, 108) 100%);
  color: #fff;
  box-shadow: rgba(179, 92, 92, 0.24) 0px 8px 20px;
}
.buttonhojyo, .copied-sample-button {
  border: 1px solid rgb(189, 210, 224);
  background: linear-gradient(135deg, #fff 0%, rgb(242, 246, 249) 100%);
  color: rgb(36, 52, 71);
}

/* ボタンアクション */
button:active, .buttonstart:active, .buttonstop:active, .buttonreset:active {
  transform: translateY(1px);
  filter: brightness(0.95);
  box-shadow: none;
}

/* =========================================
   5. ランキング表示（ネオン・ゲーミングスタイル）
   ========================================= */
.force-flex-container {
  display: flex !important;
  flex-direction: row !important;
  width: 100% !important;
  margin: 20px 0 !important;
  gap: 12px !important;
  padding: 0 10px !important;
  box-sizing: border-box !important;
}

.ranking-half-box {
  flex: 1 !important;
  background: rgba(20, 20, 25, 0.9) !important;
  padding: 15px 8px !important;
  border-radius: 16px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
  overflow-y: auto !important;
  max-height: 480px !important;
}

/* ランキング項目のコンテナ */
.rank-item {
  display: flex !important;
  align-items: center !important;
  background: rgba(255, 255, 255, 0.03) !important;
  margin-bottom: 8px !important;
  padding: 10px !important;
  border-radius: 10px !important;
  border-left: 4px solid transparent;
  transition: transform 0.2s ease;
  opacity: 0;
  transform: translateX(-10px);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
  backdrop-filter: blur(5px);
}

.rank-item.show {
  opacity: 1 !important;
  transform: translateX(0) !important;
}

/* 順位バッジ */
.rank-number {
  font-family: 'Arial Black', sans-serif;
  font-size: 18px;
  min-width: 35px;
  text-align: center;
  margin-right: 10px;
  color: #888;
}

/* 名前とスコアのブロック */
.rank-info {
  text-align: left !important;
  flex-grow: 1;
}

.rank-name {
  display: block;
  font-size: 14px;
  font-weight: bold;
  color: #eee;
  margin-bottom: 2px;
}

.rank-score {
  display: block;
  font-family: monospace;
  font-size: 13px;
  color: #00ffcc;
  text-shadow: 0 0 5px rgba(0, 255, 204, 0.5);
}

/* 「NO DATA」の表示を寂しくさせない */
.ranking-half-box:empty::after {
  content: "LOADING...";
  display: block;
  text-align: center;
  padding: 50px;
  color: #444;
  font-family: monospace;
  letter-spacing: 3px;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* 特殊ランクの色 */
.rank-1 { border-left-color: #ffd700 !important; background: rgba(255, 215, 0, 0.08) !important; }
.rank-1 .rank-number { color: #ffd700; text-shadow: 0 0 8px #ffd700; }

.rank-2 { border-left-color: #c0c0c0 !important; background: rgba(192, 192, 192, 0.08) !important; }
.rank-2 .rank-number { color: #c0c0c0; }

.rank-3 { border-left-color: #cd7f32 !important; background: rgba(205, 127, 50, 0.08) !important; }
.rank-3 .rank-number { color: #cd7f32; }

/* 自分のランク */
.rank-item.myRank {
  background: rgba(0, 255, 204, 0.15) !important;
  border: 1px solid rgba(0, 255, 204, 0.4) !important;
  border-left: 4px solid #00ffcc !important;
  transform: scale(1.02);
}

/* =========================================
   6. デバイス別調整 (iPad / PC)
   ========================================= */
@media (min-width: 768px) {
  #pad {
    width: min(60vw, 35vh);
  }
  #score { font-size: 24px; }
  #combo { font-size: 32px; }
  canvas { height: 250px; }
  button {
    height: 50px;
    padding: 0 24px;
    font-size: 18px;
  }
}

/* 設定画面を包んでいる大元のDIVのIDが "settingsModal" だとしたら */
/* モーダル全体の背景（親） */
#profileModal {
  display: none; /* 初期状態は非表示 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  
  /* 親要素をスクロール可能にする設定 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 40px 0; /* 上下に余白を作る */
}

/* 入力欄の共通スタイル */
#nameInput, #transferInput {
  background: #333;
  border: 1px solid #555;
  color: white;
  padding: 8px;
  border-radius: 5px;
  width: calc(100% - 80px);
  margin-bottom: 10px;
}

/* ボタンの共通スタイル */
button {
  cursor: pointer;
  transition: opacity 0.2s;
}
button:active {
  opacity: 0.7;
}

/* ランキング内のスクロールバーをカスタマイズ */
.ranking-half-box::-webkit-scrollbar {
  width: 6px;
}
.ranking-half-box::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}
.ranking-half-box::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 10px;
}
.ranking-half-box::-webkit-scrollbar-thumb:hover {
  background: #00ffcc; /* ホバーで光る */
}

.rank-item {
  /* 既存のプロパティに以下を追加・修正 */
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease !important;
}

.rank-item:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: scale(1.02) translateX(5px) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* もしHTMLにヘッダーを追加する場合のスタイル */
.ranking-header {
  display: flex;
  padding: 0 10px 10px 10px;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 10px;
}

.rank-item.myRank {
  animation: my-pulse 2s infinite ease-in-out;
}

@keyframes my-pulse {
  0% { box-shadow: 0 0 0px rgba(0, 255, 204, 0.2); }
  50% { box-shadow: 0 0 15px rgba(0, 255, 204, 0.4); }
  100% { box-shadow: 0 0 0px rgba(0, 255, 204, 0.2); }
}

/* スコアの末尾に pts や total を入れた時のための微調整 */
.rank-score small {
  opacity: 0.6;
  margin-left: 2px;
  font-family: sans-serif;
}

/* 圏外の自分が点線になった時のアニメーション */
.myRank[style*="dashed"] {
  border-width: 2px !important;
  animation: border-flicker 2s infinite alternate;
}

@keyframes border-flicker {
  from { border-color: rgba(0, 255, 204, 0.4); }
  to { border-color: rgba(0, 255, 204, 0.8); }
}