/* ==========================================================================
   白黒ミニマル - インカメラ鏡像（完全一致）トラッキングUI
   ========================================================================== */

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

:root {
  /* テーマカラー：白黒＋ピアノの鍵盤カバー（キーカバー）のような深いワインレッド */
  --wine-deep: #4f0b18;
  --wine: #8e1b30;
  --wine-bright: #c83650;
  --wine-glow: rgba(200, 54, 80, 0.45);
}

html, body {
  background-color: #000000;
  color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000000;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

/* ビデオコンテナ：カメラ映像のアスペクト比を維持したまま、画面領域（幅・高さ）の限界まで最大拡大 */
.video-container {
  --video-ar: 4 / 3;
  --video-ar-num: 1.3333;
  position: relative;
  display: block;
  /* 画面（ビューポート）内に収まる最大サイズをアスペクト比に基づき自動計算 */
  width: min(100vw, calc(100vh * var(--video-aspect, 1.3333)));
  height: min(100vh, calc(100vw / var(--video-aspect, 1.3333)));
  width: min(100dvw, calc(100dvh * var(--video-aspect, 1.3333)));
  height: min(100dvh, calc(100dvw / var(--video-aspect, 1.3333)));
  line-height: 0; /* 下部の隙間を排除 */
}

/* インカメラ映像：コンテナに合わせて100%拡大表示、鏡像（ミラー）反転 */
#webcam {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill; /* コンテナ自体がアスペクト比を完全維持しているためfillで完全重畳 */
  transform: scaleX(-1);
}

/* 骨格描画Canvas：ビデオと完全に同一矩形・同一比率で重畳、同じく鏡像反転 */
#output-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  pointer-events: none;
}

/* デバッグHUD（画面左下・非表示） */
.debug-panel {
  display: none !important;
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  background-color: rgba(0, 0, 0, 0.85);
  border: 1px solid #333333;
  padding: 8px 12px;
  border-radius: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: #cccccc;
  z-index: 100;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

.debug-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.debug-label {
  color: #777777;
  font-weight: bold;
}

.debug-sublabel {
  color: #555555;
  font-size: 10px;
}

.debug-val {
  color: #ffffff;
  font-weight: 600;
}

.debug-separator {
  color: #444444;
  margin: 0 2px;
}

.debug-divider {
  width: 100%;
  height: 1px;
  background-color: #222222;
  margin: 2px 0;
}

/* エラー枠 */
.debug-error {
  color: #ff5555;
  font-weight: bold;
  margin-top: 4px;
  border-top: 1px solid #442222;
  padding-top: 4px;
  max-width: 320px;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

/* CSVアップロードボタン / サウンドテストボタン（白黒ミニマル） */
.csv-upload-btn {
  pointer-events: auto;
  cursor: pointer;
  background-color: transparent;
  color: #888888;
  border: 1px solid #444444;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 9px;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
  user-select: none;
  margin-left: auto;
}

.csv-upload-btn:hover {
  background-color: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

/* 打鍵時の一瞬の白黒反転ハイライト */
.spike-highlight {
  background-color: #ffffff;
  color: #000000 !important;
  padding: 0 4px;
  border-radius: 2px;
  font-weight: bold;
}


/* 初回オーディオ開始バナー */
.audio-start-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 255, 255, 0.95);
  color: #000000;
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: bold;
  z-index: 300;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(255, 255, 255, 0.35);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: auto;
  user-select: none;
}
.audio-start-banner.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-12px);
  pointer-events: none;
}

/* ==========================================================================
   右上固定：コントロール群（トラッキングライン切替ボタン ＆ 楽曲選択ボタン）
   ========================================================================== */
.top-right-controls {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* 右上の切り替えボタン（トラッキングライン ON/OFF） */
.view-mode-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  background-color: rgba(20, 20, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.view-mode-btn:hover {
  background-color: rgba(50, 50, 50, 0.95);
}

.view-mode-btn:active {
  transform: scale(0.95);
}

.view-mode-btn.is-on {
  border-color: var(--wine-bright);
  box-shadow: 0 0 10px var(--wine-glow);
}

.song-select-container {
  position: relative;
  pointer-events: auto;
}

/* ==========================================================================
   ノーツ描画オーバーレイCanvas（画面全体に重畳・クリック透過）
   ========================================================================== */
.notes-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 215;
}

/* ==========================================================================
   右手運指ガイドウィジェット（画面右下に半透明・中サイズで固定配置）
   ========================================================================== */
.hand-guide-widget {
  --hand-guide-size: 200px;
  position: absolute;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(-10px + env(safe-area-inset-bottom, 0px));
  top: auto;
  left: auto;
  width: var(--hand-guide-size, 200px);
  height: var(--hand-guide-size, 200px);
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  pointer-events: none;
  z-index: 210;
  opacity: 0.80;
  transition: opacity 0.2s ease, transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1), filter 0.15s ease;
}

/* 左下のドラッグリサイズつまみ（固定配置のため非表示） */
.hand-guide-resizer {
  display: none;
}

.hand-guide-resizer:hover,
.hand-guide-resizer.active-drag {
  opacity: 1;
  transform: scale(1.15);
}

.hand-guide-resizer .resizer-icon {
  width: 12px;
  height: 12px;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 1.5;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.hand-guide-resizer:hover .resizer-icon,
.hand-guide-resizer.active-drag .resizer-icon {
  stroke: #ffffff;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.9));
}

/* 手のひら・各指のSVGベース（ドロップシャドウで背景から浮かび上がらせる） */
.hand-guide-svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  overflow: visible;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}

/* 手全体の一体型シームレスベース（指定色 #FEDCBD、つなぎ目完全ゼロ） */
.hand-base-unified {
  fill: #FEDCBD;
  stroke: none;
}

/* 各指の固有カラー（指別カラーコーディング用） */
#hand-finger-THUMB  { --finger-color: #FF4D4F; }
#hand-finger-INDEX  { --finger-color: #FFD600; }
#hand-finger-MIDDLE { --finger-color: #00E676; }
#hand-finger-RING   { --finger-color: #29B6F6; }
#hand-finger-PINKY  { --finger-color: #B388FF; }

/* 各指オーバーレイ（通常時は非表示、色コーディングON時は非アクティブ指も薄く着色） */
.hand-finger {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s cubic-bezier(0.2, 0.9, 0.3, 1);
}

body.color-coding-on .hand-finger {
  opacity: 0.42;
}

body.color-coding-on .hand-finger .finger-path {
  fill: var(--finger-color, #00E5FF);
  stroke: none;
}

/* 選択された指（アクティブ：指色またはシアンで鮮やかに発光） */
body.color-coding-on .hand-finger.active,
.hand-finger.active {
  opacity: 1;
}

.hand-finger.active .finger-path {
  /* 光る指はノーツ（レーン）と同じ色。色は main.js の updateHandGuideWidget が --active-finger-color に設定 */
  fill: var(--active-finger-color, #00E5FF);
  stroke: none;
  filter: drop-shadow(0 0 6px var(--active-finger-color, #00E5FF)) drop-shadow(0 0 14px var(--active-finger-color, #00E5FF));
}

/* 指番号ラベル（指番号ガイド表示ONのときのみ表示） */
.finger-num-label {
  display: none;
  font-size: 11px;
  font-weight: 800;
  fill: #ffffff;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.78);
  stroke-width: 2.6px;
  stroke-linejoin: round;
  pointer-events: none;
}

body.finger-number-mode .finger-num-label {
  display: block;
}

body.finger-number-mode .hand-finger {
  opacity: 1;
}

body.finger-number-mode:not(.color-coding-on) .hand-finger:not(.active) .finger-path {
  fill: transparent;
}

/* 打鍵時の一瞬のポップフィードバック */
.hand-guide-widget.hit-pop {
  transform: scale(1.1);
  filter: brightness(1.25);
}

.song-select-container {
  position: relative;
  pointer-events: auto;
}

/* 右上コントロール共通丸ボタン（直径38px・白黒シンプル） */
.ctrl-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: rgba(20, 20, 20, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  outline: none;
  padding: 0;
}

.ctrl-circle-btn:hover {
  background-color: rgba(45, 45, 45, 0.95);
  border-color: #ffffff;
  transform: scale(1.05);
}

.ctrl-circle-btn:active {
  transform: scale(0.92);
}

/* トラッキングライン切替ボタンのアイコンスタイル */
.tracking-line-btn .btn-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.tracking-line-btn .icon-line {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease, opacity 0.2s ease;
}

.tracking-line-btn .icon-dot {
  fill: #ffffff;
  transition: fill 0.2s ease, opacity 0.2s ease;
}

.tracking-line-btn .icon-dot-tip {
  fill: #00E5FF;
  filter: drop-shadow(0 0 3px #00E5FF);
  transition: all 0.2s ease;
}

.tracking-line-btn .slash-line {
  display: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* OFF（トラッキングライン非表示）状態 */
.tracking-line-btn.off {
  border-color: rgba(255, 255, 255, 0.2);
  background-color: rgba(15, 15, 15, 0.7);
}

.tracking-line-btn.off .icon-line,
.tracking-line-btn.off .icon-dot {
  opacity: 0.35;
}

.tracking-line-btn.off .icon-dot-tip {
  fill: rgba(255, 255, 255, 0.35);
  filter: none;
}

.tracking-line-btn.off .slash-line {
  display: block;
  stroke: #ff5252;
  filter: drop-shadow(0 0 2px rgba(255, 82, 82, 0.8));
}

.song-select-btn {
  font-size: 16px;
}

/* 曲選択メニュー（白黒ミニマルポップアップ） */
.song-select-menu {
  position: absolute;
  top: 46px;
  right: 0;
  min-width: 140px;
  background-color: rgba(20, 20, 20, 0.95);
  border: 1px solid #333333;
  border-radius: 6px;
  padding: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.song-menu-header {
  font-size: 10px;
  color: #888888;
  padding: 4px 8px;
  border-bottom: 1px solid #262626;
  margin-bottom: 2px;
  letter-spacing: 0.5px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.song-menu-item {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #cccccc;
  font-size: 12px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: all 0.15s ease;
}

.song-menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.song-menu-item.active {
  background-color: #ffffff;
  color: #000000;
  font-weight: 600;
}

/* ==========================================================================
   カウントダウンオーバーレイ（3・2・1・START!・白黒シンプル）
   ========================================================================== */
.countdown-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.65);
  z-index: 300;
  pointer-events: none;
}

.countdown-text {
  font-size: 76px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 2px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.9), 0 0 32px rgba(255, 255, 255, 0.4);
  user-select: none;
  transition: transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ==========================================================================
   演奏進捗バッジ（画面上部中央・白黒ミニマル）
   ========================================================================== */
.song-progress-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(20, 20, 20, 0.85);
  border: 1px solid #333333;
  color: #eeeeee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  padding: 4px 14px;
  border-radius: 4px;
  z-index: 200;
  pointer-events: none;
  user-select: none;
}

/* ==========================================================================
   完走時クリア通知オーバーレイ（COMPLETE・白黒ミニマル）
   ========================================================================== */
.clear-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.75);
  z-index: 350;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.clear-overlay.show {
  opacity: 1;
}

.clear-title {
  font-size: 56px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
  user-select: none;
}

.clear-subtitle {
  font-size: 13px;
  font-weight: 500;
  color: #888888;
  letter-spacing: 3px;
  margin-top: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
  user-select: none;
}

/* ==========================================================================
   カメラエラー・ガイダンス通知オーバーレイ（白黒ミニマル）
   ========================================================================== */
.camera-error-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 400;
  padding: 20px;
}

.camera-error-modal {
  background-color: #111111;
  border: 1px solid #333333;
  border-radius: 6px;
  max-width: 420px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.camera-error-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #000000;
  background-color: #ffffff;
  padding: 2px 8px;
  border-radius: 2px;
  margin-bottom: 12px;
}

.camera-error-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.camera-error-message {
  font-size: 13px;
  line-height: 1.6;
  color: #cccccc;
  margin-bottom: 24px;
  word-break: break-word;
}

.camera-error-actions {
  display: flex;
  width: 100%;
  gap: 10px;
}

.camera-error-btn {
  flex: 1;
  background-color: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
}

.camera-error-btn:hover {
  background-color: #e0e0e0;
  border-color: #e0e0e0;
}

.camera-error-btn-secondary {
  background-color: transparent;
  color: #888888;
  border: 1px solid #444444;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s ease;
}

.camera-error-btn-secondary:hover {
  background-color: #222222;
  color: #ffffff;
  border-color: #666666;
}

/* ==========================================================================
   タップ起動フォールバック（Autoplay Policy・低電力モード対策・白黒ミニマル）
   ========================================================================== */
.camera-tap-prompt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 380;
  pointer-events: auto;
}

.camera-tap-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  border-radius: 30px;
  padding: 14px 28px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  user-select: none;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.camera-tap-btn:hover,
.camera-tap-btn:active {
  background-color: #000000;
  color: #ffffff;
  border-color: #ffffff;
  transform: scale(1.04);
}

.camera-tap-icon {
  font-size: 13px;
  line-height: 1;
}

/* ==========================================================================
   アプリ内ブラウザ（WebView）誘導モーダル（白黒ミニマル）
   ========================================================================== */
.inapp-browser-modal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 450;
  padding: 20px;
}

.inapp-browser-card {
  background-color: #111111;
  border: 1px solid #333333;
  border-radius: 6px;
  max-width: 440px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.inapp-browser-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #000000;
  background-color: #ffffff;
  padding: 2px 8px;
  border-radius: 2px;
  margin-bottom: 12px;
}

.inapp-browser-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.inapp-browser-desc {
  font-size: 13px;
  line-height: 1.6;
  color: #cccccc;
  margin-bottom: 20px;
  word-break: break-word;
}

.inapp-browser-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 8px;
}

.inapp-btn {
  width: 100%;
  background-color: #222222;
  color: #ffffff;
  border: 1px solid #444444;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.inapp-btn:hover {
  background-color: #333333;
  border-color: #666666;
}

.inapp-btn-primary {
  background-color: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.inapp-btn-primary:hover {
  background-color: #e0e0e0;
  border-color: #e0e0e0;
}

.inapp-btn-secondary {
  background-color: transparent;
  color: #888888;
  border-color: #333333;
}

.inapp-btn-secondary:hover {
  background-color: #1a1a1a;
  color: #cccccc;
  border-color: #555555;
}

.inapp-copy-toast {
  align-self: center;
  margin-top: 12px;
  background-color: #ffffff;
  color: #000000;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   起動スプラッシュ：暗くした背景写真の上にロゴが現れる
   ========================================================================== */
.splash {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  position: absolute;
  inset: 0;
  z-index: 420;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 60%, #141414 0%, #000000 70%);
  cursor: pointer;
  transition: opacity 0.6s var(--ease-out), visibility 0.6s, transform 0.6s var(--ease-out);
}

/* 背景写真（public/images/splash-bg.jpg）。黒を重ねて暗くし、ゆっくりズームさせる。写真がなければ黒のグラデーションのみ */
.splash-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.splash-bg::before {
  content: "";
  position: absolute;
  inset: -4%;
  background: url("./images/splash-bg.jpg") 58% 72% / cover no-repeat; /* 手元（打鍵している手）が中心に来る位置 */
  filter: grayscale(0.35) contrast(1.05);
  animation: bg-drift 14s ease-out both;
}

.splash-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(90% 70% at 50% 50%, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.82) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.75) 100%);
}

.splash-stage {
  position: relative;
}

@keyframes bg-drift {
  from { transform: scale(1.12); opacity: 0; }
  12% { opacity: 1; }
  to { transform: scale(1.0); opacity: 1; }
}

.splash.is-leaving {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.06);
  pointer-events: none;
}

.splash-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-inline: 16px;
  text-align: center;
}

.splash-logo {
  display: flex;
  font-family: "Lobster", "Brush Script MT", "Segoe Script", cursive;
  font-size: clamp(76px, 22vw, 132px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
  color: #ffffff;
}

/* ロゴの「ar」だけ、鍵盤カバーのような重厚なワインレッドに（ベルベットの光沢をグラデーションで表現） */
.logo-accent {
  color: var(--wine-bright);
  background: linear-gradient(180deg, #d75a70 0%, var(--wine-bright) 30%, var(--wine) 65%, var(--wine-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 12px var(--wine-glow));
}

.splash-logo span {
  display: inline-block;
  opacity: 0;
  transform: translateY(18px);
  filter: blur(6px);
}

.splash.is-logo .splash-logo span {
  animation: letter-in 0.6s var(--ease-out) forwards;
  animation-delay: calc(0.05s * var(--l, 0));
}

.splash-logo span:nth-child(1) { --l: 0; }
.splash-logo span:nth-child(2) { --l: 1; }
.splash-logo span:nth-child(3) { --l: 2; }
.splash-logo span:nth-child(4) { --l: 3; }
.splash-logo span:nth-child(5) { --l: 4; }
.splash-logo span:nth-child(6) { --l: 5; }

.splash-tagline {
  font-size: clamp(12px, 3.4vw, 15px);
  color: #9a9a9a;
  letter-spacing: 0.18em;
  opacity: 0;
  transform: translateY(8px);
}

.splash.is-logo .splash-tagline {
  animation: fade-up 0.7s var(--ease-out) 0.35s forwards;
}

@keyframes letter-in {
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* 「ar」は登場後にワインレッドの光彩を残す */
.splash.is-logo .splash-logo .logo-accent {
  animation-name: letter-in-accent;
}

@keyframes letter-in-accent {
  to { opacity: 1; transform: translateY(0); filter: drop-shadow(0 0 12px var(--wine-glow)); }
}

@keyframes fade-up {
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   起動時：楽曲選択＆スタートモーダル（モーション付き・白黒ミニマル）
   ========================================================================== */
.start-modal {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 390;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.45s var(--ease-out), visibility 0.45s;
}

/* スプラッシュ表示中は待機（カードはまだ出さない） */
.start-modal.is-waiting {
  opacity: 0;
  visibility: hidden;
}

.start-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  background-color: #111111;
  border: 1px solid #333333;
  border-radius: 12px;
  max-width: 320px;
  width: 100%;
  padding: 24px 20px 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: card-in 0.6s var(--ease-out) both;
  transition: transform 0.45s var(--ease-out), opacity 0.45s var(--ease-out), filter 0.45s;
}

.start-modal.is-waiting .start-card,
.start-modal.is-waiting .start-song-item,
.start-modal.is-waiting .start-play-btn,
.start-modal.is-waiting .start-title {
  animation-play-state: paused;
}

/* スタート押下後：カードが奥へ沈んで消える */
.start-modal.hidden .start-card {
  animation: card-out 0.4s var(--ease-out) forwards;
}

.start-title {
  font-size: 15px;
  font-weight: 700;
  color: #dddddd;
  letter-spacing: 2px;
  margin-bottom: 16px;
  animation: fade-up-in 0.5s var(--ease-out) 0.1s both;
}

.start-song-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 18px;
}

.start-song-item {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background-color: #181818;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px 14px;
  color: #aaaaaa;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  user-select: none;
  width: 100%;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.25s var(--ease-out);
  animation: item-in 0.55s var(--ease-out) both;
  animation-delay: calc(0.24s + 0.07s * var(--i, 0));
}

/* 選択中の曲：左端の光るバーが伸びる */
.start-song-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--wine-bright);
  box-shadow: 0 0 12px var(--wine-glow);
  transform: scaleY(0);
  transition: transform 0.35s var(--ease-out);
}

.start-song-item:hover {
  background-color: #222222;
  color: #ffffff;
  border-color: #444444;
  transform: translateX(3px);
}

.start-song-item:active {
  transform: scale(0.98);
}

.start-song-item.selected {
  background-color: #241417;
  border-color: var(--wine);
  color: #ffffff;
  font-weight: 600;
}

.start-song-item.selected::before {
  transform: scaleY(1);
}

/* 登場アニメーション後は固定し、選んだ瞬間だけ小さくはずませる */
.start-song-item.is-in {
  animation: none;
}

.start-song-item.is-in.is-picked {
  animation: item-pick 0.35s var(--ease-out);
}

.start-song-name {
  letter-spacing: 0.5px;
}

.start-song-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: #666666;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.start-song-item.selected .start-song-meta {
  color: #aaaaaa;
}

.start-song-level {
  font-size: 7px;
  letter-spacing: 2px;
}

.start-play-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  border-radius: 8px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  user-select: none;
  transition: background-color 0.15s ease, transform 0.2s var(--ease-out), box-shadow 0.3s ease;
  animation: item-in 0.55s var(--ease-out) 0.5s both, btn-glow 2.4s ease-in-out 1.2s infinite;
}

/* 光が横切るシマー */
.start-play-btn::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.9), transparent);
  transform: skewX(-20deg);
  animation: shimmer 2.4s ease-in-out 1.2s infinite;
  pointer-events: none;
}

.start-play-btn:hover {
  background-color: #e8e8e8;
  border-color: #e8e8e8;
  transform: translateY(-1px);
}

.start-play-btn:active {
  transform: scale(0.97);
  background-color: #cccccc;
}

.start-play-btn:disabled {
  opacity: 0.75;
  cursor: progress;
  transform: none;
  animation: none;
}

.start-play-btn:disabled::after {
  animation: shimmer 1s linear infinite;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes card-out {
  from { opacity: 1; transform: scale(1); filter: blur(0); }
  to { opacity: 0; transform: scale(0.92) translateY(10px); filter: blur(4px); }
}

@keyframes fade-up-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes item-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes item-pick {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes shimmer {
  0% { left: -40%; }
  60%, 100% { left: 120%; }
}

@keyframes btn-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 26px var(--wine-glow); }
}

/* 動きを減らす設定の端末ではアニメーションを止め、すぐ表示する */
@media (prefers-reduced-motion: reduce) {
  .splash *, .splash, .start-modal *, .start-modal {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* iPadセンターステージ等の注意書き（白黒ミニマル・控えめな注記） */
.start-hint {
  margin-top: 14px;
  font-size: 10px;
  line-height: 1.5;
  color: #666666;
  text-align: center;
  letter-spacing: 0.3px;
  word-break: break-word;
}



/* ==========================================================================
   演奏画面：手のガイドとノーツを大きく、カメラは左下の小窓（body.play-mode）
   ========================================================================== */
body.play-mode .video-container {
  position: fixed;
  left: var(--pip-left, 12px);
  top: var(--pip-top, 12px);
  width: var(--pip-w, 200px) !important;
  height: var(--pip-h, 150px) !important;
  z-index: 230;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--pip-border, rgba(255, 255, 255, 0.35));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  transition: border-color 0.2s ease;
}

body.play-mode .hand-guide-widget {
  opacity: 1;
}

.pip-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  background: rgba(200, 50, 60, 0.85);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  z-index: 6;
}

.pip-status[hidden] {
  display: none;
}

/* 手の位置合わせ中：カメラを大きく表示し、手のガイドは隠す */
body.positioning .hand-guide-widget {
  display: none;
}

/* 狭い画面では進捗バッジを左上に寄せ、右上のボタン群と重ならないようにする */
@media (max-width: 560px) {
  .song-progress-badge {
    left: calc(16px + env(safe-area-inset-left, 0px));
    transform: none;
    top: calc(22px + env(safe-area-inset-top, 0px));
  }
}

/* 演奏中の小窓：最初に合わせた手の位置（点線＋手のイラスト）と今の手の位置 */
.pip-guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.pip-guide .pip-ref {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.5px;
  stroke-dasharray: 5 3;
  vector-effect: non-scaling-stroke;
}
.pip-guide .pip-ref-hand rect {
  fill: rgba(254, 220, 189, 0.38);
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
.pip-guide .pip-now {
  fill: none;
  stroke: #3ddc84;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}
.pip-guide.bad .pip-now {
  stroke: #f0626c;
}

/* 進捗バッジ：曲名（とセクション）を小さく添える */
.song-progress-badge .badge-song {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #aaaaaa;
  margin-right: 8px;
}

/* 演奏中、手がずれたときに画面中央に出す大きな矢印 */
.drift-badge {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  z-index: 260;
  padding: 14px 22px 16px;
  border-radius: 20px;
  background: rgba(10, 12, 16, 0.82);
  border: 2px solid #ffd23f;
  animation: drift-blink 1s ease-in-out infinite;
}
/* 位置合わせ側の .dir-badge（クリック透過）より優先させてタップで消せるようにする */
.dir-badge.drift-badge {
  pointer-events: auto;
  cursor: pointer;
}
.drift-badge .drift-dismiss {
  font-size: 11px;
  color: #9aa4b4;
}
.drift-badge .dir-icon {
  width: clamp(120px, 32vmin, 230px) !important;
  height: clamp(120px, 32vmin, 230px) !important;
}
.drift-badge[hidden] {
  display: none;
}
@keyframes drift-blink {
  50% { transform: translate(-50%, -50%) scale(0.94); }
}
@media (prefers-reduced-motion: reduce) {
  .drift-badge { animation: none; }
}

/* ノーツのレーン背景（5本の縞）。動かないので canvas で毎フレーム描かずに CSS で表示 */
.lane-bg {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 214;
  background: repeating-linear-gradient(90deg,
    rgba(255, 255, 255, 0.012) 0 20%,
    rgba(255, 255, 255, 0.025) 20% 40%);
}
body.play-mode .lane-bg {
  display: block;
}
body.positioning .lane-bg {
  display: none;
}
.lane-bg .lane-active {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20%;
  display: none;
}

/* ==========================================================================
   右上の設定（⚙）ボタンとパネル
   ========================================================================== */
.settings-btn {
  position: relative;
}
.settings-btn .btn-icon {
  width: 22px;
  height: 22px;
}
.settings-btn .gear {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.settings-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.18);
}
.settings-rec-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f0626c;
  display: none;
}
body.is-recording .settings-rec-dot,
body.is-rec-armed .settings-rec-dot {
  display: block;
}
body.is-recording .settings-rec-dot {
  animation: rec-pulse 1s ease-in-out infinite;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  background: rgba(16, 18, 24, 0.97);
  border: 1px solid #2c3440;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  padding: 10px 12px 14px;
  display: grid;
  gap: 12px;
  color: #e8ecf2;
  z-index: 400;
}
.settings-panel.hidden {
  display: none;
}
.sp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  padding: 2px 2px 0;
}
.sp-close {
  font: inherit;
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #9aa4b4;
  cursor: pointer;
}
.sp-section {
  display: grid;
  gap: 4px;
}
.sp-title {
  font-size: 11.5px;
  color: #9aa4b4;
  letter-spacing: 0.04em;
  padding: 0 4px 2px;
}
.settings-panel .sp-row {
  font: inherit;
  font-size: 14px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: #e8ecf2;
  cursor: pointer;
}
.settings-panel .sp-row:hover {
  background: rgba(255, 255, 255, 0.1);
}
.settings-panel .sp-row:focus-visible,
.sp-close:focus-visible,
.settings-btn:focus-visible {
  outline: 2px solid #56b4e9;
  outline-offset: 2px;
}
/* 選んでいる曲 */
.settings-panel .song-menu-item.active {
  border-color: #56b4e9;
  background: rgba(86, 180, 233, 0.14);
}
.settings-panel .song-menu-item.active::after {
  content: "✓";
  color: #56b4e9;
  font-weight: 700;
}
/* 記録の行（赤い丸＋文字） */
.settings-panel .rec-btn {
  justify-content: flex-start;
}
.settings-panel .rec-btn .rec-dot {
  flex: none;
}
/* オン／オフのスイッチ */
.sp-switch {
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: #3a4352;
  position: relative;
  transition: background 0.15s;
}
.sp-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.15s;
}
.sp-toggle[aria-pressed="true"] .sp-switch {
  background: #00b386;
}
.sp-toggle[aria-pressed="true"] .sp-switch::after {
  transform: translateX(16px);
}
/* 2 つから選ぶボタン（新宝島の音） */
.sp-choice {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.sp-choice-label {
  font-size: 14px;
  color: #e8ecf2;
}
.sp-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
}
.sp-seg button {
  font: inherit;
  font-size: 13px;
  min-height: 36px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #c3cad6;
  cursor: pointer;
}
.sp-seg button small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
}
.sp-seg button[aria-checked="true"] {
  background: #56b4e9;
  color: #0b1220;
  font-weight: 700;
}
.sp-seg button:focus-visible {
  outline: 2px solid #56b4e9;
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .sp-switch, .sp-switch::after { transition: none; }
}

/* 設定パネルが、ノーツ（215）・カメラ小窓（230）・ずれの矢印（260）より手前に出るように */
.top-right-controls {
  z-index: 450;
}

/* ==========================================================================
   画面の一番上の進捗バー（曲全体の長さのうちどこまで進んだか。文字なし）
   ========================================================================== */
.song-progress-bar {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 460;
  pointer-events: none;
  display: none;
}
body.play-mode .song-progress-bar {
  display: block;
}
body.free-mode .song-progress-bar,
body.positioning .song-progress-bar {
  display: none;
}
.song-progress-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: rgba(255, 255, 255, 0.85);
  transition: width 0.35s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .song-progress-bar > span { transition: none; }
}
/* 進捗バッジは曲名だけになったので、文字を少し読みやすく */
.song-progress-badge .badge-song {
  margin-right: 0;
}

/* ==========================================================================
   遅れの測定（latency.js）：画面上部の結果パネル
   ========================================================================== */
.latency-hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 24px));
  background: rgba(16, 18, 24, 0.95);
  border: 1px solid #2c3440;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  padding: 10px 14px 12px;
  color: #e8ecf2;
  display: grid;
  gap: 6px;
  z-index: 470;
}
.latency-hud[hidden] {
  display: none;
}
.lh-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lh-title {
  font-size: 12px;
  color: #9aa4b4;
  letter-spacing: 0.04em;
}
.lh-close {
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid #3a4352;
  background: transparent;
  color: #e8ecf2;
  cursor: pointer;
}
.lh-close:focus-visible {
  outline: 2px solid #56b4e9;
  outline-offset: 2px;
}
.lh-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.lh-label {
  font-size: 12px;
  color: #9aa4b4;
}
.lh-value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lh-sub {
  font-size: 12px;
  color: #9aa4b4;
}
.lh-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 13px;
  color: #9aa4b4;
  font-variant-numeric: tabular-nums;
}
.lh-list .latest {
  color: #e8ecf2;
  font-weight: 700;
}
.lh-msg {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #9aa4b4;
}

/* データ記録（datalog.js）の表示：遅れの測定と重ならないよう左上に置く */
.datalog-hud {
  left: max(12px, env(safe-area-inset-left, 0px));
  transform: none;
  width: min(320px, calc(100vw - 24px));
}
.dl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dl-actions[hidden],
.datalog-hud .lh-close[hidden] {
  display: none;
}

/* ==========================================================================
   起動画面：画面の高さが足りなくても（スマホの横向きなど）スタートボタンが必ず見えるように
   曲の一覧だけをスクロールさせ、ボタンは常にカードの下に表示する
   ========================================================================== */
.start-card {
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
.start-song-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.start-play-btn {
  flex: none;
}
/* 横向き・高さの低い画面：曲を2〜3列に並べ、注意書きは隠して高さを節約 */
@media (max-height: 520px) {
  .start-modal {
    padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  }
  .start-card {
    max-width: min(640px, 100%);
    padding: 12px 14px;
  }
  .start-title {
    margin-bottom: 8px;
  }
  .start-song-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 6px;
    margin-bottom: 10px;
  }
  .start-song-item {
    padding: 8px 10px;
  }
  .start-hint {
    display: none;
  }
}
