:root {
  --bg-dark: #0a0b10;
  --bg-card: rgba(18, 20, 32, 0.82);
  --border-neon: rgba(0, 243, 255, 0.3);
  --cyan: #00f3ff;
  --magenta: #ff007f;
  --purple: #8b5cf6;
  --yellow: #facc15;
  --green: #22c55e;
  --red: #ef4444;
  --lane-1: #00f3ff;
  --lane-2: #3b82f6;
  --lane-3: #ec4899;
  --lane-4: #f59e0b;
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --font-hud: 'Orbitron', monospace;
  --font-sub: 'Rajdhani', sans-serif;
  --font-base: 'Noto Sans JP', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-base);
}

/* 背景YouTube & グリッド */
#bg-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#yt-player-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw;
  min-height: 100vh;
  min-width: 177.77vh;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* スマホ縦画面 (または16:9より縦長画面): 動画の両端が見切れないよう、画面幅100vwに16:9比率で完全収容 */
@media (max-aspect-ratio: 16/9), (max-width: 768px) {
  #yt-player-wrapper {
    width: 100vw !important;
    height: 56.25vw !important; /* 16:9 ぴったり */
    min-width: 0 !important;
    min-height: 0 !important;
    top: 42% !important; /* 画面中央〜レーン背景として最適な位置 */
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
  }
}

#yt-player-wrapper iframe, #yt-player {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.video-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(10, 11, 16, 0.25) 0%, rgba(10, 11, 16, 0.55) 85%);
  backdrop-filter: blur(0px);
  transition: backdrop-filter 0.3s ease, background 0.3s ease;
}

.cyber-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(0, 243, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  perspective: 500px;
  transform: rotateX(30deg);
  transform-origin: bottom center;
}

/* アプリメイン */
#app {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* ヘッダー */
#game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(10, 11, 20, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 243, 255, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo-title {
  font-family: var(--font-hud);
  font-size: 1.5rem;
  letter-spacing: 2px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.6);
}

.logo-title .highlight {
  color: var(--cyan);
  text-shadow: 0 0 15px var(--cyan);
}

.song-meta {
  display: flex;
  flex-direction: column;
}

.song-title {
  font-family: var(--font-sub);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-time {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* サイバーボタンスタイル */
.cyber-btn {
  background: rgba(18, 24, 42, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.4);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--font-sub);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.1);
}

.cyber-btn:hover {
  background: rgba(0, 243, 255, 0.15);
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 243, 255, 0.4);
  transform: translateY(-1px);
}

.cyber-btn:active {
  transform: translateY(1px);
}

.cyber-btn.highlight {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.3), rgba(236, 72, 153, 0.3));
  border-color: var(--cyan);
}

.cyber-btn.icon-only {
  padding: 8px 12px;
}

/* メインゲームコンテナ */
#game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* RECツールバー */
#rec-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  background: rgba(15, 17, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--magenta);
  border-radius: 30px;
  box-shadow: 0 0 20px rgba(255, 0, 127, 0.3);
  animation: slideDown 0.3s ease;
}

.rec-badge {
  font-family: var(--font-hud);
  font-size: 0.8rem;
  color: var(--magenta);
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 6px;
}

.blink-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 10px var(--magenta);
  animation: blink 1s infinite alternate;
}

.rec-instructions {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.rec-actions {
  display: flex;
  gap: 8px;
}

.rec-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.rec-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.rec-action-btn.highlight {
  border-color: var(--cyan);
  color: var(--cyan);
}

.rec-action-btn.danger {
  border-color: var(--red);
  color: var(--red);
}

/* ゲームHUD */
#game-hud {
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 20;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 840px;
  margin: 0 auto;
  padding: 0 20px;
}

.score-box, .accuracy-box {
  display: flex;
  flex-direction: column;
}

.score-box .label, .accuracy-box .label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.score-box .value {
  font-family: var(--font-hud);
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

.accuracy-box .value {
  font-family: var(--font-hud);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

.gauge-container {
  flex: 1;
  max-width: 320px;
  margin: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.gauge-bar-outer {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 243, 255, 0.4);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.gauge-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #00f3ff, #ec4899);
  box-shadow: 0 0 15px var(--cyan);
  transition: width 0.1s linear;
}

/* コンボ表示 */
.combo-area {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.combo-area.active {
  opacity: 1;
}

.combo-count {
  font-family: var(--font-hud);
  font-size: 3.8rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 0%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(0, 243, 255, 0.8));
  animation: comboPop 0.12s ease-out;
}

.combo-label {
  font-family: var(--font-hud);
  font-size: 0.9rem;
  letter-spacing: 4px;
  color: var(--cyan);
  font-weight: 700;
}

/* 判定テキスト */
.judgment-display {
  position: absolute;
  top: 230px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-hud);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  min-height: 40px;
}

.judge-perfect {
  color: #fff;
  text-shadow: 0 0 15px #facc15, 0 0 30px #facc15;
  animation: judgePop 0.2s ease-out;
}

.judge-great {
  color: #22c55e;
  text-shadow: 0 0 15px #22c55e, 0 0 30px #22c55e;
  animation: judgePop 0.2s ease-out;
}

.judge-good {
  color: #00f3ff;
  text-shadow: 0 0 15px #00f3ff;
  animation: judgePop 0.2s ease-out;
}

.judge-miss {
  color: #ef4444;
  text-shadow: 0 0 15px #ef4444;
  animation: judgeShake 0.2s ease-out;
}

/* 4レーンステージ */
#stage-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 540px;
  position: relative;
  z-index: 10;
}

/* スタート/ポーズ オーバーレイ */
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 40;
  cursor: pointer;
  transition: opacity 0.25s ease, visibility 0.25s;
}

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

.start-card {
  background: rgba(15, 20, 35, 0.94);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 35px rgba(0, 243, 255, 0.4), inset 0 0 20px rgba(0, 243, 255, 0.2);
  border-radius: 16px;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-card:not(:focus-within) {
  animation: pulseCard 2.4s infinite ease-in-out;
}

.start-icon, .start-title, .start-sub {
  pointer-events: none;
}

.start-icon {
  font-size: 2.6rem;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan);
  margin-left: 4px;
}

.start-title {
  font-family: var(--font-hud);
  font-size: 1.45rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
}

.start-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* 一時停止時アクションボタン (最初に戻る / 曲を選び直す / 最初からやり直す) */
.start-pause-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 2px;
  justify-content: center;
  align-items: stretch;
  cursor: default;
}

.start-pause-actions.hidden {
  display: none !important;
}

.start-pause-btn {
  flex: 1 1 0;
  padding: 10px 8px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 8px;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.start-pause-btn .icon {
  font-size: 1.05rem;
}

.start-pause-btn.home-btn {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.35), rgba(6, 182, 212, 0.2));
  border: 1.5px solid var(--cyan);
  color: #fff;
  box-shadow: 0 0 16px rgba(0, 243, 255, 0.35);
}

.start-pause-btn.home-btn:hover {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.55), rgba(6, 182, 212, 0.4));
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.6);
}

.start-pause-btn.song-btn {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(139, 92, 246, 0.15));
  border: 1.5px solid rgba(192, 132, 252, 0.65);
  color: #fff;
}

.start-pause-btn.song-btn:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.45), rgba(139, 92, 246, 0.3));
  border-color: #c084fc;
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(192, 132, 252, 0.5);
}

.start-pause-btn.retry-btn {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.25), rgba(225, 29, 72, 0.15));
  border: 1.5px solid rgba(251, 113, 133, 0.65);
  color: #fff;
}

.start-pause-btn.retry-btn:hover {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.45), rgba(225, 29, 72, 0.3));
  border-color: #fb7185;
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(251, 113, 133, 0.5);
}

@media (max-width: 480px) {
  .start-pause-actions {
    gap: 6px;
  }
  .start-pause-btn {
    padding: 8px 4px;
    font-size: 0.78rem;
  }
  .start-pause-btn .btn-text {
    font-size: 0.78rem;
  }
}

/* YouTube URL 直接入力セクション */
.start-yt-section {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  background: rgba(10, 14, 28, 0.85);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 12px;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}

.start-yt-input-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.start-yt-input {
  flex: 1;
  min-width: 0;
  background: rgba(18, 24, 42, 0.95);
  border: 1px solid rgba(0, 243, 255, 0.35);
  border-radius: 6px;
  padding: 8px 12px;
  color: #fff;
  font-size: 0.88rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.start-yt-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.4);
}

.start-yt-btn {
  padding: 8px 14px;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.start-yt-preset-btn {
  background: transparent;
  border: 1px dashed rgba(0, 243, 255, 0.4);
  color: var(--cyan);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.start-yt-preset-btn:hover {
  background: rgba(0, 243, 255, 0.15);
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

@keyframes pulseCard {
  0%, 100% { transform: scale(1); box-shadow: 0 0 25px rgba(0, 243, 255, 0.3); }
  50% { transform: scale(1.02); box-shadow: 0 0 45px rgba(0, 243, 255, 0.55); }
}

/* タッチ操作ボタン */
#touch-controls {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 540px;
  height: 130px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 30;
  box-sizing: border-box;
  touch-action: none;
}

.touch-btn {
  position: relative;
  background: rgba(18, 22, 38, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.06s, border-color 0.06s, transform 0.04s, box-shadow 0.06s;
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.05), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.touch-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px 12px 0 0;
}

#touch-0::before { background: var(--lane-1); box-shadow: 0 0 8px var(--lane-1); }
#touch-1::before { background: var(--lane-2); box-shadow: 0 0 8px var(--lane-2); }
#touch-2::before { background: var(--lane-3); box-shadow: 0 0 8px var(--lane-3); }
#touch-3::before { background: var(--lane-4); box-shadow: 0 0 8px var(--lane-4); }

.touch-btn .lane-num {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  color: var(--text-dim);
  pointer-events: none;
  opacity: 0.7;
}

.touch-btn .key-label {
  font-family: var(--font-hud);
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.touch-btn:active, .touch-btn.active {
  transform: translateY(3px) scale(0.97);
}

#touch-0:active, #touch-0.active {
  background: rgba(0, 243, 255, 0.45);
  border-color: var(--lane-1);
  box-shadow: 0 0 30px var(--lane-1), inset 0 0 15px var(--lane-1);
}
#touch-1:active, #touch-1.active {
  background: rgba(59, 130, 246, 0.45);
  border-color: var(--lane-2);
  box-shadow: 0 0 30px var(--lane-2), inset 0 0 15px var(--lane-2);
}
#touch-2:active, #touch-2.active {
  background: rgba(236, 72, 153, 0.45);
  border-color: var(--lane-3);
  box-shadow: 0 0 30px var(--lane-3), inset 0 0 15px var(--lane-3);
}
#touch-3:active, #touch-3.active {
  background: rgba(245, 158, 11, 0.45);
  border-color: var(--lane-4);
  box-shadow: 0 0 30px var(--lane-4), inset 0 0 15px var(--lane-4);
}

/* フッターコントロールバー */
#playback-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  background: rgba(10, 11, 20, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0, 243, 255, 0.15);
  z-index: 20;
}
  z-index: 20;
}

.control-btn {
  background: rgba(0, 243, 255, 0.1);
  border: 1px solid rgba(0, 243, 255, 0.4);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.control-btn:hover {
  background: rgba(0, 243, 255, 0.3);
  box-shadow: 0 0 15px var(--cyan);
}

.seek-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.seek-container span {
  font-family: var(--font-hud);
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 40px;
}

#seek-bar {
  flex: 1;
  accent-color: var(--cyan);
  cursor: pointer;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.speed-indicator {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.speed-indicator #current-speed-label {
  color: var(--cyan);
  font-weight: 700;
}

/* モーダルスタイル */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 6, 12, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden, .hidden {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border-neon);
  border-radius: 14px;
  box-shadow: 0 0 40px rgba(0, 243, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  font-family: var(--font-sub);
  font-size: 1.3rem;
  color: #fff;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-section h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--cyan);
}

.url-input-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.url-input-group input {
  min-width: 0;
}

.import-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.url-input-group input, .import-section textarea, #chart-export-text {
  flex: 1;
  background: rgba(10, 12, 20, 0.9);
  border: 1px solid rgba(0, 243, 255, 0.3);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  box-sizing: border-box;
}

.url-input-group input:focus, .import-section textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.hint-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.4;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 6px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
  padding: 0 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-hud);
}

/* プリセット曲リスト */
.preset-song-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.song-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.song-card:hover {
  background: rgba(0, 243, 255, 0.1);
  border-color: var(--cyan);
  transform: translateX(4px);
}

.song-card-info {
  display: flex;
  flex-direction: column;
}

.song-card-title {
  font-family: var(--font-sub);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.song-card-artist {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.song-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.difficulty-badge {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.diff-easy { background: rgba(34, 197, 94, 0.2); color: #22c55e; border: 1px solid #22c55e; }
.diff-normal { background: rgba(59, 130, 246, 0.2); color: #3b82f6; border: 1px solid #3b82f6; }
.diff-hard { background: rgba(236, 72, 153, 0.2); color: #ec4899; border: 1px solid #ec4899; }

.import-section textarea, #chart-export-text {
  width: 100%;
  height: 90px;
  resize: vertical;
  font-family: monospace;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

/* 設定項目 */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.setting-item input[type="range"] {
  accent-color: var(--cyan);
  cursor: pointer;
}

.offset-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.offset-control input[type="range"] {
  flex: 1;
}

.mini-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.mini-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.slider-row input {
  flex: 1;
  max-width: 250px;
}

.keybind-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.key-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.k-lane {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.k-val {
  font-family: var(--font-hud);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--cyan);
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* リザルトカード */
.result-card {
  text-align: center;
  padding: 30px;
  border-color: var(--yellow);
  box-shadow: 0 0 50px rgba(250, 204, 21, 0.25);
}

.clear-badge {
  font-family: var(--font-hud);
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--yellow);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

#res-song-title {
  font-family: var(--font-sub);
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 16px;
}

.result-rank {
  font-family: var(--font-hud);
  font-size: 5rem;
  font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 25px rgba(250, 204, 21, 0.8);
  line-height: 1;
  margin-bottom: 12px;
  animation: rankPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-score-block {
  margin-bottom: 20px;
}

.res-score-label {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 2px;
}

.res-score-val {
  font-family: var(--font-hud);
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
}

.result-stats {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: 700;
}

.stat-row.perfect { color: #facc15; }
.stat-row.great { color: #22c55e; }
.stat-row.good { color: #00f3ff; }
.stat-row.miss { color: #ef4444; }
.stat-row.max-combo { color: #fff; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 6px; margin-top: 4px; }

.result-buttons {
  display: flex;
  justify-content: center;
  gap: 14px;
}

/* 自動譜面生成モーダル */
.auto-card {
  max-width: 680px;
}

.section-desc {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.auto-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(0, 243, 255, 0.2);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auto-box h3 {
  font-family: var(--font-sub);
  font-size: 1.05rem;
  color: var(--cyan);
  font-weight: 700;
}

.tap-bpm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tap-counter-badge {
  font-family: var(--font-hud);
  font-size: 0.75rem;
  color: var(--yellow);
  background: rgba(250, 204, 21, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--yellow);
}

.tap-action-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.tap-beat-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(0, 243, 255, 0.25));
  border: 2px solid var(--cyan);
  border-radius: 12px;
  padding: 18px 14px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
  transition: all 0.1s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.tap-beat-btn:hover {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.4), rgba(0, 243, 255, 0.4));
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.4);
}

.tap-beat-btn:active, .tap-beat-btn.tapping {
  transform: scale(0.96);
  border-color: var(--yellow);
  box-shadow: 0 0 35px var(--yellow);
}

.tap-icon {
  font-size: 1.8rem;
}

.tap-text {
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.tap-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.bpm-display-box {
  width: 140px;
  background: rgba(10, 12, 22, 0.9);
  border: 1px solid rgba(0, 243, 255, 0.4);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.bpm-sub-label {
  font-family: var(--font-hud);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.bpm-number {
  font-family: var(--font-hud);
  font-size: 2.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 15px var(--cyan);
}

.setting-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.num-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.num-control-group input {
  flex: 1;
  background: rgba(10, 12, 20, 0.9);
  border: 1px solid rgba(0, 243, 255, 0.3);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-hud);
  font-size: 1.1rem;
  text-align: center;
  width: 70px;
}

.diff-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.diff-btn {
  background: rgba(20, 24, 38, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn:hover {
  border-color: rgba(0, 243, 255, 0.6);
  background: rgba(0, 243, 255, 0.1);
}

.diff-btn.selected {
  border-color: var(--cyan);
  background: rgba(0, 243, 255, 0.2);
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.diff-name {
  font-family: var(--font-hud);
  font-size: 0.95rem;
  font-weight: 900;
}

.diff-name.easy { color: #22c55e; }
.diff-name.normal { color: #3b82f6; }
.diff-name.hard { color: #ec4899; }
.diff-name.master { color: #f59e0b; }

.diff-info {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
}

.generate-action-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.mega-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 1.2rem;
  justify-content: center;
  border-radius: 8px;
}

.text-center {
  text-align: center;
}

/* アニメーションキーフレーム */
@keyframes comboPop {
  0% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

@keyframes judgePop {
  0% { transform: translateX(-50%) scale(0.6); opacity: 0; }
  50% { transform: translateX(-50%) scale(1.2); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes judgeShake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 6px)); }
  75% { transform: translateX(calc(-50% + 6px)); }
}

@keyframes blink {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

@keyframes slideDown {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes modalScale {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 中画面・itch.io埋め込みサイズ最適化 (幅1180px以下) */
@media (max-width: 1180px) {
  .song-title {
    max-width: 220px;
  }
  .header-left {
    gap: 12px;
  }
  #btn-select-song .btn-text,
  #btn-auto-chart .btn-text,
  #btn-rec-mode .btn-text {
    display: none; /* ボタンをアイコン表示にしてスリム化 */
  }
}

@media (max-width: 980px) {
  .header-left .logo-title {
    font-size: 1.25rem;
  }
  .song-title {
    max-width: 150px;
    font-size: 0.95rem;
  }
  #btn-mobile-connect .btn-text {
    display: none;
  }
  #assist-badge-text {
    font-size: 0.78rem;
  }
}

/* タブレット・小画面 (幅768px以下) */
@media (max-width: 768px) {
  /* スマホ・小画面ではスタートカード内と設定モーダルに難易度・アシストがあるため、ヘッダー内は非表示にしてスペースを確保 */
  .header-difficulty-group {
    display: none !important;
  }
  #btn-mobile-connect {
    display: none !important; /* スマホ自身でプレイ中は不要 */
  }
  #btn-rec-mode {
    display: none !important; /* スマホでは手動RECモードは使わないため非表示でボタンをスッキリ */
  }
}

/* スマホ向けレスポンシブ最適化 (幅600px以下) */
@media (max-width: 600px) {
  #game-header {
    padding: max(6px, env(safe-area-inset-top)) 10px 6px 10px;
    gap: 6px;
    height: auto;
    min-height: 48px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .header-left {
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  .logo-title {
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    flex-shrink: 0;
  }
  .song-meta {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  .song-title {
    max-width: 100%;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .song-time {
    font-size: 0.62rem;
  }
  .header-right {
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
  }
  .header-right .cyber-btn {
    padding: 4px 7px;
    font-size: 0.72rem;
    height: 32px;
    gap: 2px;
    white-space: nowrap;
  }
  .header-right .cyber-btn .icon {
    font-size: 0.85rem;
  }
  .header-right .cyber-btn.icon-only {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hud-top {
    padding: 0 8px;
  }
  .score-box .value {
    font-size: 1.1rem;
  }
  .accuracy-box .value {
    font-size: 1.0rem;
  }
  .gauge-container {
    margin: 0 6px;
  }
  .combo-count {
    font-size: 2.4rem;
  }
  .judgment-display {
    font-size: 1.5rem;
    top: 180px;
  }

  /* スマホでのタッチボタン最適化 */
  #touch-controls {
    height: 125px;
    padding: 6px;
    gap: 5px;
  }
  .touch-btn .key-label {
    font-size: 1.5rem;
  }
  .touch-btn .lane-num {
    font-size: 0.7rem;
  }

  /* 下部コントロールバー */
  #playback-bar {
    padding: 6px 12px;
    gap: 10px;
  }
  .control-btn {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }
  .seek-container span {
    font-size: 0.7rem;
    min-width: 32px;
  }
  .speed-indicator {
    font-size: 0.75rem;
  }

  /* スタートカード */
  .start-card {
    padding: 20px 24px;
    width: 85%;
    max-width: 320px;
  }
  .start-title {
    font-size: 1.25rem;
  }
  .start-sub {
    font-size: 0.75rem;
  }

  /* モーダル */
  .modal-overlay {
    padding: 12px;
  }
  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    padding: 0;
    border-radius: 12px;
    box-sizing: border-box;
  }
  .modal-header {
    padding: 12px 16px;
  }
  .modal-header h2 {
    font-size: 1.05rem;
  }
  .modal-body {
    padding: 14px;
    gap: 14px;
    box-sizing: border-box;
  }
  .diff-selector {
    grid-template-columns: repeat(2, 1fr);
  }

  /* モーダル内のURL読み込みグループ（スマホでは2行にして枠内に収容） */
  .url-input-group {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .url-input-group input {
    width: 100%;
    box-sizing: border-box;
    font-size: 0.85rem;
  }
  #btn-load-custom-yt {
    width: 100%;
    height: 38px;
    padding: 8px 12px;
    font-size: 0.88rem;
    justify-content: center;
    box-sizing: border-box;
  }

  /* モーダル内のJSONインポート（スマホでは2行にして枠内に収容） */
  .import-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .import-section textarea {
    width: 100%;
    box-sizing: border-box;
    font-size: 0.8rem;
    height: 75px;
    margin-bottom: 0;
  }
  #btn-import-chart {
    width: 100%;
    height: 38px;
    padding: 8px 12px;
    font-size: 0.88rem;
    justify-content: center;
    box-sizing: border-box;
  }

  /* プリセット曲カードのモバイル最適化 */
  .song-card {
    padding: 10px 12px;
  }
  .song-card-title {
    font-size: 0.95rem;
  }
  .song-card-meta {
    gap: 6px;
  }
  .song-card-meta .cyber-btn {
    padding: 4px 10px !important;
    height: 28px !important;
    font-size: 0.75rem !important;
    width: auto !important;
    display: inline-flex !important;
  }
}

/* 小型スマホ (幅440px以下: iPhone等の縦持ち) */
@media (max-width: 440px) {
  #game-header {
    padding-left: 6px;
    padding-right: 6px;
  }
  .logo-title {
    font-size: 0.82rem;
  }
  /* アイコンのみにしてヘッダー右側をスマートに1行収容 */
  .header-right .cyber-btn .btn-text {
    display: none !important;
  }
  .header-right .cyber-btn {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    justify-content: center;
    border-radius: 6px;
  }
  .header-right .cyber-btn .icon {
    margin: 0;
    font-size: 0.95rem;
  }
}

/* カウントダウン・ワンクッション演出 */
.countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 11, 16, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.countdown-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: none !important;
}

.countdown-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.countdown-num {
  font-family: var(--font-hud);
  font-size: 6.5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 
    0 0 20px var(--cyan),
    0 0 40px var(--cyan),
    0 0 80px rgba(0, 243, 255, 0.6);
  letter-spacing: 2px;
  line-height: 1;
  transform: scale(1);
}

.countdown-num.pop-anim {
  animation: countdownPop 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.countdown-sub {
  font-family: var(--font-hud);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--cyan);
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(0, 243, 255, 0.5);
  opacity: 0.9;
}

@keyframes countdownPop {
  0% {
    transform: scale(1.6);
    opacity: 0;
    filter: blur(10px);
  }
  30% {
    transform: scale(1.05);
    opacity: 1;
    filter: blur(0px);
  }
  75% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

/* file:// 警告バナー */
#file-protocol-warning {
  position: relative;
  z-index: 100;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.95));
  color: #fff;
  padding: 12px 20px;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
  border-bottom: 2px solid #f87171;
}

#file-protocol-warning.hidden {
  display: none !important;
}

.warning-banner-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.warning-icon {
  font-size: 1.8rem;
}

.warning-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
  flex: 1;
}

.warning-text strong {
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.pulse-btn {
  animation: pulseGlow 1.8s infinite;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 24px rgba(0, 243, 255, 0.9);
  }
}

/* ========================================================
   🤖 AI 楽曲BPM解析 & 譜面生成モーダル スタイリング
   ======================================================== */
.analyzer-card {
  max-width: 540px;
  background: rgba(13, 17, 28, 0.96);
  border: 1px solid var(--border-neon);
  box-shadow: 0 0 35px rgba(0, 243, 255, 0.25), inset 0 0 20px rgba(0, 243, 255, 0.08);
}

.analyzer-scanning-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 10px;
}

.cyber-radar-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* オーディオスペクトラムアニメーション */
.audio-spectrum-anim {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 52px;
  padding: 4px;
}

.audio-spectrum-anim .bar {
  width: 8px;
  background: linear-gradient(180deg, var(--neon-pink) 0%, var(--cyan) 100%);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.6);
  animation: spectrumJump 0.8s ease-in-out infinite alternate;
}

.audio-spectrum-anim .b1 { height: 30%; animation-delay: 0.1s; }
.audio-spectrum-anim .b2 { height: 60%; animation-delay: 0.25s; }
.audio-spectrum-anim .b3 { height: 95%; animation-delay: 0.05s; }
.audio-spectrum-anim .b4 { height: 45%; animation-delay: 0.4s; }
.audio-spectrum-anim .b5 { height: 80%; animation-delay: 0.15s; }
.audio-spectrum-anim .b6 { height: 100%; animation-delay: 0.3s; }
.audio-spectrum-anim .b7 { height: 50%; animation-delay: 0.5s; }
.audio-spectrum-anim .b8 { height: 35%; animation-delay: 0.2s; }

@keyframes spectrumJump {
  0% { transform: scaleY(0.2); }
  50% { transform: scaleY(0.7); }
  100% { transform: scaleY(1.0); }
}

.radar-text {
  font-family: var(--font-cyber);
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.7);
}

.analyzer-progress-wrapper {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(0, 243, 255, 0.3);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

.analyzer-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--neon-pink));
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.8);
  transition: width 0.3s ease;
}

.analyzer-status-text {
  font-size: 0.9rem;
  color: #e2e8f0;
  text-align: center;
  font-family: monospace;
  min-height: 24px;
}

/* 解析結果ビュー */
.analyzer-result-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeIn 0.4s ease;
}

.analyzer-success-badge {
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(0, 243, 255, 0.6);
  padding: 8px 12px;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 8px;
}

.analyzer-info-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analyzer-info-card .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  gap: 10px;
}

.analyzer-info-card .info-row.highlight-row {
  background: rgba(0, 243, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
}

.analyzer-info-card .info-label {
  color: #94a3b8;
  font-weight: 600;
  white-space: nowrap;
}

.analyzer-info-card .info-val {
  color: #fff;
  font-weight: 600;
  text-align: right;
}

.song-title-clamp {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bpm-badge {
  font-family: var(--font-cyber);
  font-size: 1.15rem;
  color: var(--cyan) !important;
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.8);
}

.notes-badge {
  color: var(--yellow) !important;
  font-family: var(--font-cyber);
}

.analyzer-diff-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analyzer-diff-select label {
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 600;
}

.diff-btn-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.analyzer-diff-btn {
  padding: 8px 6px;
  font-size: 0.8rem;
  font-family: var(--font-cyber);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.analyzer-diff-btn:hover {
  background: rgba(0, 243, 255, 0.15);
  color: #fff;
}

.analyzer-diff-btn.selected {
  background: var(--cyan);
  color: #050811;
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.7);
}

.analyzer-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* BPMクイック微調整ツールバー */
.bpm-direct-input {
  width: 70px;
  padding: 4px 6px;
  font-family: var(--font-cyber);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-neon);
  border-radius: 6px;
  text-align: center;
}

.bpm-quick-tuner {
  background: rgba(0, 243, 255, 0.04);
  border: 1px solid rgba(0, 243, 255, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
}

.tuner-buttons {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  align-items: center;
}

.tuner-btn {
  flex: 1;
  padding: 6px 4px;
  font-family: var(--font-cyber);
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tuner-btn:hover {
  background: rgba(0, 243, 255, 0.25);
  border-color: var(--cyan);
  color: #fff;
  transform: translateY(-1px);
}

.tuner-btn.tuner-scale {
  background: rgba(255, 0, 85, 0.15);
  border-color: rgba(255, 0, 85, 0.4);
  color: #ffb3c6;
}

.tuner-btn.tuner-scale:hover {
  background: rgba(255, 0, 85, 0.35);
  border-color: var(--neon-pink);
  color: #fff;
}

/* ========================================================
   初心者サポート・難易度セレクター UI
   ======================================================== */
.header-difficulty-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.diff-btn-bar {
  display: flex;
  gap: 3px;
  background: rgba(15, 20, 35, 0.7);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.header-diff-btn {
  padding: 4px 10px;
  font-family: var(--font-hud);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-diff-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.header-diff-btn.diff-easy.active {
  background: rgba(34, 197, 94, 0.25);
  border-color: #22c55e;
  color: #4ade80;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.header-diff-btn.diff-normal.active {
  background: rgba(0, 243, 255, 0.25);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.4);
}

.header-diff-btn.diff-hard.active {
  background: rgba(236, 72, 153, 0.25);
  border-color: #ec4899;
  color: #f472b6;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}

/* アシストボタン */
.assist-btn {
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #fef08a;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.assist-btn:hover {
  background: rgba(250, 204, 21, 0.25);
  border-color: #facc15;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.35);
}

.assist-btn.active {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.35), rgba(245, 158, 11, 0.45));
  border-color: #facc15;
  color: #fff;
  box-shadow: 0 0 15px rgba(250, 204, 21, 0.6);
  animation: assist-glow 2s infinite alternate;
}

@keyframes assist-glow {
  0% { box-shadow: 0 0 8px rgba(250, 204, 21, 0.4); }
  100% { box-shadow: 0 0 18px rgba(250, 204, 21, 0.85); }
}

/* スタート画面のクイック設定 */
.start-quick-settings {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.start-setting-label {
  font-family: var(--font-sub);
  font-size: 0.85rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 1px;
}

.start-diff-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.start-diff-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.start-diff-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.start-diff-btn .d-badge {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  font-weight: 900;
}

.start-diff-btn .d-desc {
  font-size: 0.68rem;
  color: #cbd5e1;
}

.start-diff-btn.diff-easy .d-badge { color: #4ade80; }
.start-diff-btn.diff-easy.active {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.4);
}

.start-diff-btn.diff-normal .d-badge { color: var(--cyan); }
.start-diff-btn.diff-normal.active {
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 243, 255, 0.4);
}

.start-diff-btn.diff-hard .d-badge { color: #f472b6; }
.start-diff-btn.diff-hard.active {
  background: rgba(236, 72, 153, 0.2);
  border-color: #ec4899;
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.4);
}

.start-assist-toggle {
  background: rgba(250, 204, 21, 0.08);
  border: 1px dashed rgba(250, 204, 21, 0.4);
  padding: 8px 12px;
  border-radius: 8px;
  color: #fef08a;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  width: 100%;
}

.start-assist-toggle:hover {
  background: rgba(250, 204, 21, 0.18);
  border-color: #facc15;
}

.start-assist-toggle.active {
  background: rgba(234, 179, 8, 0.25);
  border-style: solid;
  border-color: #facc15;
  color: #fff;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.4);
}

/* スピードミニボタン */
.speed-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-speed-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.mini-speed-btn:hover {
  background: var(--cyan);
  color: #000;
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

/* 設定モーダルのアシストエリア */
.assist-setting-box {
  background: rgba(234, 179, 8, 0.06);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 8px;
  padding: 14px;
}

.assist-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #facc15;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 12px;
}

.setting-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}

.toggle-name {
  font-weight: 600;
  color: #f8fafc;
  font-size: 0.9rem;
}

.cyber-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--cyan);
}

.cyber-select {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-neon);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

/* ========================================================
   モバイル・レスポンシブ確定上書きルール (スマホ画面完全収容)
   ======================================================== */
@media (max-width: 768px) {
  /* スマホ・小画面ではスタートカードと設定モーダルに難易度・アシストがあるためヘッダー内は非表示 */
  .header-difficulty-group {
    display: none !important;
  }
  #btn-mobile-connect {
    display: none !important;
  }
  #btn-rec-mode {
    display: none !important;
  }
}

@media (max-width: 600px) {
  #game-header {
    padding: max(6px, env(safe-area-inset-top)) 8px 6px 8px !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }
  .header-left {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    gap: 6px !important;
    overflow: hidden !important;
  }
  .logo-title {
    font-size: 0.92rem !important;
    flex-shrink: 0 !important;
  }
  .song-meta {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  .song-title {
    max-width: 100% !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .song-time {
    font-size: 0.6rem !important;
  }
  .header-right {
    flex: 0 0 auto !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
  .header-right .cyber-btn {
    padding: 4px 6px !important;
    font-size: 0.72rem !important;
    height: 32px !important;
    white-space: nowrap !important;
  }
  .header-right .cyber-btn.icon-only {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
  }
}

@media (max-width: 440px) {
  #game-header {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
  .logo-title {
    font-size: 0.8rem !important;
  }
  /* iPhone縦持ち等の小型画面では、ボタン文字を非表示にしてアイコンのみとし1行に確実に収容 */
  .header-right .cyber-btn .btn-text {
    display: none !important;
  }
  .header-right .cyber-btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 6px !important;
  }
  .header-right .cyber-btn .icon {
    margin: 0 !important;
    font-size: 0.95rem !important;
  }
}

/* ===== モバイルはみ出し修正 ===== */
/* 共通: シークバーが縮まずスピード表示を押し出す問題 */
.seek-container { min-width: 0; }
#seek-bar { min-width: 0; width: 100%; }
.speed-indicator { flex-shrink: 0; white-space: nowrap; }
#app { height: 100vh; height: 100dvh; } /* スマホのアドレスバー分のズレ対策 */

@media (max-width: 600px) {
  #playback-bar { gap: 8px; padding: 6px 10px; }
  .speed-indicator > span:first-child { display: none; } /* 「SPEED:」の文字を隠す */
  .seek-container { gap: 6px; }
}

/* 横向きスマホ */
@media (max-height: 500px) and (orientation: landscape) {
  #game-header {
    padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
    gap: 8px; flex-wrap: nowrap; overflow: hidden;
  }
  .header-left { flex: 1 1 auto; min-width: 0; overflow: hidden; gap: 8px; }
  .logo-title { font-size: 1rem; flex-shrink: 0; }
  .song-meta { min-width: 0; overflow: hidden; }
  .header-right { flex: 0 0 auto; gap: 4px; }
  .header-difficulty-group, #btn-mobile-connect, #btn-rec-mode { display: none; }
  .header-right .cyber-btn { height: 32px; padding: 4px 8px; font-size: .75rem; white-space: nowrap; }
  .header-right .cyber-btn.icon-only { width: 32px; padding: 0; justify-content: center; }
  #playback-bar { padding: 4px max(10px, env(safe-area-inset-left)); }
  .start-card { padding: 10px 16px; max-height: 90%; overflow-y: auto; }
}


