:root {
  --note-width: 75px;
  --note-border-width: 10px;
  --target-indicator-left: 125px;
}

body {
  font-family: sans-serif;
  text-align: center;
  background-color: #023;
  color: #9aa;
  font-family: "Kosugi Maru", sans-serif;
  font-size: 20px;
}

h1 {
  font-family: "WDXL Lubrifont JP N", sans-serif;
  font-size: 4.5em;
  margin: 10px 0;
}

.title-sprint,
.title-aiko {
  /* 3Dテキスト効果 */
  text-shadow:
    1px 1px 0px #000,
    2px 2px 0px #000,
    3px 3px 0px #000,
    4px 4px 0px #000,
    8px 8px 15px rgba(0, 0, 0, 0.5);
}

.title-sprint {
  color: #f84828;
}
.title-aiko {
  color: #68c0c0;
  margin-left: -0.08em; /* Tとaの間を詰める */
}

.title-t {
  margin-left: -0.08em; /* nとTの間を詰める */
}

#progress-container {
  width: 80%;
  max-width: 800px;
  height: 25px;
  background-color: #1a1a2e;
  border: 3px solid #444;
  border-radius: 20px;
  margin: 0px auto;
  padding: 3px;
  box-sizing: border-box;
}

#progress-bar {
  width: 0%; /* 初期状態は0% */
  height: 100%;
  background: linear-gradient(
    to right,
    #ffc107,
    #f84828
  ); /* 黄色から赤へのグラデーション */
  border-radius: 15px;
  transition: width 0.2s ease-out; /* 幅の変化を滑らかに */
}
#game-container {
  position: relative;
  width: 1420px;
  height: 240px;
  margin: 20px auto;
  border: 10px solid #000;
  background-color: #2c2c2c;
}

#target-note-indicator {
  position: absolute;
  top: 50%; /* 親要素の垂直中央に配置 */
  left: var(--target-indicator-left); /* 左端からの位置 */
  width: 160px;
  height: 160px;
  background-color: #2c2c2c;
  border: 5px solid #666; /* 明るい灰色の枠線 */
  border-radius: 50%; /* 正円にする */
  transform: translate(-50%, -50%); /* 要素自身の中心に位置を調整 */
  box-sizing: border-box; /* borderをwidth/heightに含める */
  /* ▼の文字が不要になるため非表示にする */
  font-size: 0;
}

#target-note-indicator2 {
  position: absolute;
  top: 50%; /* 親要素の垂直中央に配置 */
  left: var(--target-indicator-left); /* 左端からの位置 */
  width: 90px;
  height: 90px;
  background-color: #555; /* 灰色の背景 */
  border: 10px solid #2c2c2c; /* 明るい灰色の枠線 */
  box-shadow: 0 0 0 5px #999; /* 外側の黒ボーダー + ドロップシャドウ */
  border-radius: 50%; /* 正円にする */
  transform: translate(-50%, -50%); /* 要素自身の中心に位置を調整 */
  box-sizing: border-box; /* borderをwidth/heightに含める */
}

/* 正解時のグロー（発光）アニメーション */
@keyframes glow {
  from {
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.7);
    border-color: #fff;
  }
  to {
    box-shadow: none;
    border-color: #ccc;
  }
}
.hit-effect {
  animation: glow 0.2s ease-out;
}
#notes-display-wrapper {
  width: 100%;
  height: 100%;
  overflow: hidden; /* はみ出た音符を隠す */
}

#notes-display {
  display: block; /* Flexboxをやめてブロック要素にする */
  height: 100%;
  position: relative;
  left: var(--notes-display-left);
}

.note {
  position: absolute; /* 絶対配置に変更 */
  top: 50%; /* 親要素の垂直中央 */
  transform: translateY(-50%); /* 垂直中央揃えの補正 */
  width: var(--note-width);
  height: var(--note-width);
  border-radius: 50%;
  border: var(--note-border-width) solid #f7efe0; /* 内側の白いボーダー */
  box-shadow:
    0 0 0 5px #000000,
    10px 10px 20px rgba(0, 0, 0, 0.5); /* 外側の黒ボーダー + ドロップシャドウ */
  flex-shrink: 0; /* 音符が縮まないようにする */
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: white;
}

.note.hit {
  /* 叩かれた音符は非表示にする */
  visibility: hidden;
}

/* 小節線 */
.bar-line {
  position: absolute;
  top: 0;
  height: 100%;
  width: 4px; /* 線の太さ */
  background-color: #b4b4b4; /* 線の色 */
  z-index: 0; /* 音符(z-index: 1以上)より背後に表示 */
}

.don {
  background-color: #f84828; /* 赤 */
}

.ka {
  background-color: #68c0c0; /* 青 */
}

#info-display {
  /* レイアウト */
  display: flex;
  align-items: center; /* ボタンと高さを合わせる */
  gap: 20px;
  margin: 20px auto;
  padding: 0 20px;
  width: 1420px; /* 譜面表示エリアの幅に合わせる */
  box-sizing: border-box; /* paddingを含めて幅を計算 */
}

.info-box {
  /* デザイン */
  background-color: #1a1a2e; /* リザルト画面と共通の背景色 */
  border: 2px solid #444;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  width: 160px;
  padding: 10px 15px;
  box-sizing: border-box;
  text-align: center;
}

.info-label {
  display: block;
  font-family: "WDXL Lubrifont JP N", sans-serif;
  font-size: 1em;
  color: #9aa; /* 元の文字色 */
  margin-bottom: 5px;
}

.info-value {
  display: block;
  font-size: 2em;
  font-weight: bold;
  color: #f0f0f0;
}

.speed-control,
.setting-control {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.setting-input {
  background-color: #0d0d1a;
  border: 2px solid #444;
  border-radius: 5px;
  color: #f0f0f0;
  font-family: "Kosugi Maru", sans-serif;
  font-size: 1.8em;
  font-weight: bold;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  padding: 2px 0;
}

.speed-control button,
.setting-control button {
  background: #4a4e69;
  border: none;
  color: white;
  font-family: "Kosugi Maru", sans-serif;
  font-size: 1em;
  font-weight: bold;
  border-radius: 50%;
  width: 25px;
  height: 25px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.speed-control button:hover,
.setting-control button:hover {
  background: #6a6e89;
}
#start-button {
  /* デザインを一新 */
  background: linear-gradient(
    to bottom,
    #f85838,
    #f04020
  ); /* テーマカラーの赤系グラデーション */
  color: white;
  font-size: 1.5em; /* 少し大きく */
  font-weight: bold;
  font-family: "WDXL Lubrifont JP N", sans-serif;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
  padding: 15px 30px;
  border: none;
  border-radius: 10px;
  border-bottom: 5px solid #c03010; /* 下に濃い色のボーダーで立体感 */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  margin-left: auto; /* ★これを追加して右端に寄せる */
  white-space: nowrap; /* "Retry"で改行されないように */
  transition: all 0.1s ease-out; /* アニメーションを滑らかに */
}

#start-button:hover {
  /* ホバー時: 少し明るく */
  background: linear-gradient(to bottom, #fa6848, #f25030);
}

#start-button:active {
  /* クリック時: 沈み込む表現 */
  background: #d03010; /* 暗い赤色に変更 */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* 影を少し控えめにする */
  transition-duration: 0.05s; /* クリック感を出すために一瞬で変化 */
}

/* ゲーム中など、ボタンが無効化されている時のスタイル */
#start-button:disabled {
  background: #555; /* 暗いグレー */
  border-bottom-color: #444; /* さらに暗いグレー */
  color: #999;
  cursor: not-allowed; /* クリック不可カーソル */
  box-shadow: none; /* 影をなくす */
  text-shadow: none; /* テキストの影も消す */
}

/* 設定パネル */
#settings-panel,
#help-panel,
#advanced-settings-panel,
#key-config-panel {
  display: none; /* 初期状態は非表示 */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 500px; /* モーダルの横幅を広げる */
  background: #1a1a2e;
  color: #f0f0f0;
  border: 2px solid #68c0c0;
  border-radius: 15px;
  padding: 25px 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 2000; /* 最前面に表示 */
}

#settings-panel h3,
#help-panel h3 {
  font-family: "WDXL Lubrifont JP N", sans-serif;
  font-size: 2em;
  margin: 0 0 20px 0;
  text-align: center;
}
/* advanced-settings-panel にも同じスタイルを適用 */
#advanced-settings-panel h3,
#key-config-panel h3 {
  font-family: "WDXL Lubrifont JP N", sans-serif;
  font-size: 2em;
  margin: 0 0 20px 0;
  text-align: center;
  color: #ffc107; /* マニアックな設定なので色を変える */
}

.key-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 30px;
  margin: 20px 0;
}

.key-config-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.key-config-item label {
  font-size: 1.1em;
  color: #9aa;
}

.key-config-btn {
  background: #333;
  border: 2px solid #666;
  color: white;
  font-family: monospace;
  font-size: 2em;
  font-weight: bold;
  width: 100%;
  padding: 15px 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 15px;
}

#volume-slider {
  flex-grow: 1;
}

#volume-display {
  font-size: 1.2em;
  font-weight: bold;
  min-width: 35px; /* 桁数が変わってもレイアウトが崩れないように */
  text-align: right;
}

.setting-divider {
  border: none;
  border-top: 1px solid #444;
  margin: 25px 0;
}

.setting-item {
  display: flex;
  flex-direction: column; /* アイテムを縦に並べる */
  align-items: stretch; /* 子要素の幅をコンテナに合わせる */
  margin-bottom: 20px; /* 各項目の下のマージンを調整 */
  gap: 8px; /* ラベルと入力欄の間の隙間 */
}
.reset-single-sound-btn:hover {
  background: #f84828;
}

.setting-item label {
  font-size: 1.2em;
  display: flex; /* Flexboxを有効化 */
  justify-content: space-between; /* ラベルテキストとボタンを両端揃え */
  align-items: center; /* 垂直方向の中央揃え */
  width: 100%; /* 幅を100%に */
}
.setting-description {
  font-size: 0.8em;
  color: #9aa;
  margin-top: 5px;
  text-align: left;
}

.label-text-group {
  display: flex;
  align-items: baseline; /* テキストのベースラインを揃える */
}

.sound-status {
  font-size: 0.7em; /* (Custom)の文字を小さくする */
  color: #ffc107; /* ゴールド */
  margin-left: 8px;
}
.reset-single-sound-btn {
  background: #666;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 24px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0; /* ボタンが縮まないようにする */
  transition: background-color 0.2s;
}

.sound-file-input {
  font-family: "Kosugi Maru", sans-serif;
  font-size: 0.9em;
}

.setting-actions {
  display: flex;
  justify-content: flex-end; /* ボタンを右端に寄せる */
  gap: 10px; /* ボタン間の隙間を設定 */
  margin-top: 30px;
}

.setting-actions button {
  background: #4a4e69;
  border: none;
  color: white;
  font-family: "Kosugi Maru", sans-serif;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;

  transition: background-color 0.2s;
}

.setting-actions button:hover {
  background: #6a6e89;
}

/* 設定ボタン */
.settings-toggle-btn,
.help-toggle-btn,
.advanced-settings-toggle-btn {
  position: absolute;
  top: 20px;
  width: 50px;
  height: 50px;
  background: #1a1a2e;
  border: 2px solid #444;
  border-radius: 50%; /* 円形にする */
  color: #9aa; /* 通常時の色 */
  font-family: "Kosugi Maru", sans-serif;
  font-size: 1.5em;
  display: flex; /* Flexboxを有効化 */
  justify-content: center; /* 水平中央揃え */
  align-items: center; /* 垂直中央揃え */
  cursor: pointer;
  transition: all 0.2s;
  z-index: 1500; /* 他の要素より手前に */
}
.settings-toggle-btn:hover,
.help-toggle-btn:hover,
.advanced-settings-toggle-btn:hover {
  background: #4a4e69;
  color: white;
}
.settings-toggle-btn {
  right: 20px;
}
.advanced-settings-toggle-btn {
  right: 85px;
}
.help-toggle-btn {
  right: 150px;
}

#help-panel p {
  font-size: 1.1em;
  line-height: 1.6;
  text-align: left;
}

.key-guide {
  list-style-type: none;
  padding: 0;
  text-align: left;
}

.key-icon {
  display: inline-block;
  padding: 2px 8px;
  border: 2px solid #999;
  border-radius: 4px;
  background-color: #333;
  font-family: monospace;
  margin: 0 5px;
}

.key-guide-divider {
  border: none;
  border-top: 1px solid #444;
  margin: 15px 0;
}

#countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10em;
  font-weight: bold;
  color: white;
  text-shadow:
    0 0 20px rgba(255, 255, 255, 0.7),
    0 0 40px rgba(0, 0, 0, 0.5);
  z-index: 1000; /* 音符より手前に表示 */
  pointer-events: none; /* クリックを背後に透過させる */
  transition: opacity 0.2s ease-out;
  opacity: 1;
}
.hidden#countdown {
  opacity: 0;
}

#bottom-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 30px;
  margin: 20px auto;
}

#result-display {
  /* デザインを一新し、モーダル風に */
  width: 90%;
  max-width: 450px;
  margin: 20px auto;
  background: #1a1a2e; /* 深い紺色 */
  color: #f0f0f0;
  border: 2px solid #68c0c0; /* 「カッ」の色でアクセント */
  border-radius: 15px;
  padding: 25px 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;

  /* 表示/非表示のアニメーション */
  transition:
    opacity 0.3s ease-out,
    transform 0.3s ease-out;
  opacity: 1;
  transform: scale(1);
  margin: 0; /* bottom-wrapperで管理するためリセット */
}

#ranking-display {
  /* result-displayとデザインを合わせる */
  position: relative; /* 子要素の絶対位置指定の基準にする */
  width: 90%;
  max-width: 350px;
  background: #1a1a2e;
  color: #f0f0f0;
  border: 2px solid #444;
  border-radius: 15px;
  padding: 25px 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

/* ランキング注釈が非表示の時は、レイアウトから完全に取り除く */
#ranking-info.hidden {
  display: none;
}

#ranking-display h2 {
  font-family: "WDXL Lubrifont JP N", sans-serif;
  font-size: 2.5em;
  margin: 0 0 20px 0;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

#ranking-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

#ranking-list li {
  display: flex;
  align-items: baseline; /* テキストのベースラインを揃える */
  font-size: 1.2em;
  padding: 8px 5px;
  border-bottom: 1px solid #333;
}

.rank {
  flex-basis: 15%;
  text-align: left;
}
.score {
  flex-basis: 50%;
  text-align: right;
  font-weight: bold;
}
.miss {
  flex-basis: 35%;
  text-align: right;
  font-size: 0.8em;
  color: #9aa;
}

#reset-ranking-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 40px; /* 少し小さめに設定 */
  height: 40px;
  background: #1a1a2e;
  border: 2px solid #444;
  border-radius: 50%;
  color: #9aa; /* 通常時の色 */
  font-size: 1.2em;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition:
    color 0.2s,
    transform 0.2s;
}

#reset-ranking-btn:hover {
  color: #ffc107; /* ゴールド */
  transform: rotate(-90deg);
}
#ranking-list li:last-child {
  border-bottom: none;
}

/* ランクインしたスコアを強調 */
.new-record {
  color: #ffc107; /* ゴールド */
  font-weight: bold;
  animation: glow 1s ease-in-out;
}

/* .hidden クラスが付いている時のスタイル */
.hidden#bottom-wrapper {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none; /* 非表示中はクリックなどを無効化 */
}

#result-display h2 {
  font-family: "WDXL Lubrifont JP N", sans-serif;
  font-size: 2.5em;
  color: #f84828; /* 「ドン」の色 */
  margin: 0 0 20px 0;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
}

/* リザルトの最終スコアを目立たせる */
#result-display .final-score-p {
  font-size: 2em;
  font-weight: bold;
  color: #ffc107; /* ゴールド */
  border-bottom-width: 2px;
}

/* スコア計算式のツールチップ用スタイル */
.score-label-tooltip {
  text-decoration: underline;
  text-decoration-style: dashed;
  cursor: help;
}

#result-display p {
  font-size: 1.2em;
  margin: 15px 0;
  display: flex;
  justify-content: space-between; /* ラベルと値を両端揃え */
  border-bottom: 1px solid #444; /* 区切り線 */
  padding-bottom: 10px;
}

.result-actions {
  display: flex;
  justify-content: flex-end; /* ボタンを右端に寄せる */
  margin-top: 20px;
  padding-top: 15px;
}

.result-actions button {
  background: #1da1f2; /* Xのブランドカラー */
  color: white;
  font-family: "Kosugi Maru", sans-serif;
  padding: 8px 16px;
  border: none;
  border-radius: 20px; /* 角を丸くする */
  cursor: pointer;
  transition: background-color 0.2s;
}

/* 汎用的な非表示クラス */
.hidden {
  opacity: 0;
  pointer-events: none; /* 非表示中はクリックなどを無効化 */
  transition: opacity 0.3s ease-out;
}

/* display:none を使いたい場合は、より詳細なセレクタで指定する */
.note.hit {
  visibility: hidden; /* display:noneから変更 */
}

.page-footer {
  padding: 10px;
  font-size: 0.5em;
  color: #666;
  text-align: center;
}
.page-footer a {
  color: #999;
  text-decoration: none;
}
.page-footer a:hover {
  text-decoration: underline;
}
