/* style.css — DonkeyKongKaraoke / dark neon karaoke console */

:root {
  --bg: #070b12;
  --panel: rgba(13, 20, 32, 0.92);
  --panel-2: #111a2a;
  --line: #20344b;
  --cyan: #00e5ff;
  --green: #39ff88;
  --pink: #ff2d95;
  --amber: #ffb02e;
  --text: #e8f1fa;
  --dim: #8ea3b8;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(1100px 700px at 50% -10%, #12263f 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #1a0f26 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.view { display: none; min-height: 100vh; min-height: 100dvh; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.view.active { display: flex; flex-direction: column; align-items: center; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------- 共通パーツ ---------------- */

.btn {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover, .btn:focus-visible { border-color: var(--cyan); box-shadow: 0 0 12px rgba(0, 229, 255, 0.25); outline: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(90deg, #0a9cc8, var(--cyan));
  border-color: transparent;
  color: #04121c;
  font-weight: 700;
}
.btn.primary:hover { box-shadow: 0 0 18px rgba(0, 229, 255, 0.45); }
.btn.ghost { background: rgba(13, 20, 32, 0.66); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-color: rgba(255, 45, 149, 0.45); }
.btn.sm:hover { border-color: var(--pink); box-shadow: 0 0 12px rgba(255, 45, 149, 0.3); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.06em;
  background: rgba(13, 20, 32, 0.8);
  color: var(--dim);
  white-space: nowrap;
}
.badge.demo {
  color: #2a1807;
  background: linear-gradient(90deg, var(--amber), #ffd27a);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(255, 176, 46, 0.45);
}
.badge.pink { color: var(--pink); border-color: rgba(255, 45, 149, 0.5); }
.badge.cyan { color: var(--cyan); border-color: rgba(0, 229, 255, 0.5); }
.badge.warn { color: var(--amber); border-color: rgba(255, 176, 46, 0.5); }
.badge.subtle { background: rgba(13, 20, 32, 0.55); }

.footnote {
  position: fixed;
  bottom: 4px;
  left: 10px;
  font-size: 10px;
  color: #5b7085;
  z-index: 60;
  pointer-events: none;
  text-shadow: 0 1px 2px #000;
}

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 92vw;
  background: rgba(13, 22, 36, 0.96);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pink);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 100;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.status-line { min-height: 20px; font-size: 13px; color: var(--dim); }
.status-line.error { color: var(--pink); }

.list-empty {
  text-align: center;
  padding: 26px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(13, 20, 32, 0.55);
  color: var(--dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.list-empty-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--pink);
  letter-spacing: 0.06em;
}
.list-empty-desc { font-size: 12px; }

/* ---------------- 検索画面 ---------------- */

#view-search { padding: clamp(28px, 6vh, 64px) 16px 72px; gap: 16px; }

.masthead { text-align: center; }
.logo {
  margin: 0 0 4px;
  font-size: clamp(30px, 7vw, 54px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 0 22px rgba(0, 229, 255, 0.35);
}
.logo span {
  background: linear-gradient(90deg, var(--cyan) 0%, var(--pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  margin: 0 0 12px;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.28em;
}
.chip-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.search-form {
  display: flex;
  gap: 10px;
  width: min(560px, 100%);
}
#search-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
#search-input:focus { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0, 229, 255, 0.22); }
#search-input::placeholder { color: #57718c; }

.song-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  width: min(640px, 100%);
}
.song-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: linear-gradient(90deg, rgba(17, 26, 42, 0.9), rgba(13, 20, 32, 0.75));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.song-item:hover, .song-item:focus-visible {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.2);
  outline: none;
}
.song-no {
  font-family: var(--mono);
  color: var(--dim);
  font-size: 13px;
  min-width: 2em;
}
.song-thumb {
  width: 46px; height: 46px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--panel-2);
  flex: none;
}
.song-main { flex: 1; min-width: 0; }
.song-name {
  display: block;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-artist {
  display: block;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-badges { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------- 演奏画面 ---------------- */

#view-play {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
}
/* 背景: MV（伴奏に同期、音なし）。MV の無い曲はジャケット画像 */
.play-bg {
  position: absolute;
  inset: 0;
  background: #000 center / cover no-repeat;
  filter: brightness(0.42) saturate(0.9);
}
/* 縦画面: ジャケット（タイトル入りの画像もある）が切れないよう全体を見せる。MV がある曲は MV が上に重なる */
#view-play.portrait .play-bg { background-size: contain; background-position: 50% 62%; }
.play-mv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  filter: brightness(0.82);
}
/* 縦画面: 横長の MV を画面いっぱいに中央で切り抜く（帯で区切ると背景が継ぎはぎに見えるため） */

/* ---------------- 歌詞テロップ（DAM 風） ----------------
 * 歌う前: 白文字＋濃紺の縁。歌った所: 青文字＋白の縁。漢字の上にふりがな。
 * 上段は左寄せ・下段は右寄せで、どちらも画面端から少し内側に置く。 */

.lyrics {
  --lyr-fill: #1f4dff;
  --lyr-edge: #10163a;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 34px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  padding: 0 max(4%, env(safe-area-inset-right)) 0 max(4%, env(safe-area-inset-left));
  font-family: "heisei-mincho-std", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "MS PMincho", serif;
  font-size: clamp(24px, 5.2vw, 62px);
  pointer-events: none;
}
.lyr-row {
  display: flex;
  align-items: flex-end;
  min-height: 1.95em;   /* 1 行 + ふりがな */
  padding-top: 0.6em;   /* ふりがなの分 */
}
.lyr-row[data-align="left"] { justify-content: flex-start; padding-left: 2%; padding-right: 14%; }
.lyr-row[data-align="right"] { justify-content: flex-end; padding-right: 2%; padding-left: 14%; }
.lyr-row[data-align="center"] { justify-content: center; }
.lyr-line {
  position: relative;
  flex: none;
  white-space: nowrap;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.02em;
  filter: drop-shadow(0 0.05em 0.06em rgba(0, 0, 0, 0.75));
}
.lyr-base, .lyr-fill { -webkit-text-stroke: 0.15em var(--lyr-edge); paint-order: stroke fill; }
.lyr-base { color: #fff; }
.lyr-fill {
  position: absolute;
  inset: 0;
  color: var(--lyr-fill);
  -webkit-text-stroke-color: #fff;
  clip-path: inset(-120% 100% -30% -0.2em);
}
/* 曲の歌詞をすべて一度描いておき、Adobe Fonts（ダイナミックサブセット）に必要な字を先に読み込ませる */
.lyr-glyphs {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  font-family: "heisei-mincho-std", serif;
  font-weight: 900;
  white-space: pre-wrap;
  pointer-events: none;
}
.lyr-rb { position: relative; display: inline-block; }
.lyr-rt {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  margin-bottom: -0.02em;
  font-size: 0.44em;
  letter-spacing: 0;
  line-height: 1.1;
  white-space: nowrap;
  -webkit-text-stroke-width: 0.26em;
}
@media (max-width: 480px) {
  .lyr-row[data-align="left"] { padding-right: 6%; }
  .lyr-row[data-align="right"] { padding-left: 6%; }
}
#guide-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  z-index: 5;
}
.hud-top {
  top: 0;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(4, 8, 14, 0.88) 0%, rgba(4, 8, 14, 0) 100%);
}
.hud-tools { display: contents; }
.hud-bottom {
  bottom: 0;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  align-items: flex-end;
  background: linear-gradient(0deg, rgba(4, 8, 14, 0.72) 0%, rgba(4, 8, 14, 0) 100%);
  padding-top: 24px;
}
.hud .btn { flex: none; }

.song-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 700;
  font-size: clamp(14px, 2.6vw, 18px);
  text-shadow: 0 1px 6px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.score-box {
  flex: none;
  text-align: right;
  font-family: var(--mono);
  line-height: 1.15;
}
.score-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--dim);
}
.score-value {
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 800;
  color: var(--green);
  text-shadow: 0 0 14px rgba(57, 255, 136, 0.55);
}
.score-value.no-mic { color: #5b7085; text-shadow: none; }
.score-sub { font-size: 13px; color: var(--cyan); }

.tap-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(3, 6, 10, 0.6);
  font-size: 20px;
  cursor: pointer;
}
.tap-icon {
  font-size: 44px;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(0, 229, 255, 0.7);
}

/* ---------------- 結果画面 ---------------- */

#view-result { padding: clamp(28px, 5vh, 56px) 16px 72px; gap: 10px; }

.result-card {
  width: min(760px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 20px 22px;
  text-align: center;
  box-shadow: 0 0 48px rgba(0, 229, 255, 0.08);
}
.banner {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255, 45, 149, 0.12);
  border: 1px solid rgba(255, 45, 149, 0.4);
  color: #ff9cc8;
}
.result-song {
  font-weight: 700;
  font-size: clamp(15px, 3vw, 18px);
  margin-bottom: 6px;
}
.total-score {
  font-family: var(--mono);
  font-weight: 900;
  font-size: clamp(64px, 18vw, 108px);
  line-height: 1;
  color: var(--green);
  text-shadow: 0 0 30px rgba(57, 255, 136, 0.55);
}
.score-unit { font-size: 0.28em; color: var(--dim); margin-left: 4px; font-weight: 400; }
.total-score.blank { font-size: clamp(28px, 8vw, 44px); color: var(--dim); text-shadow: none; letter-spacing: 0.14em; }
.total-score.blank .score-unit { display: none; }
.rank-line {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  color: var(--cyan);
  font-size: clamp(14px, 3.4vw, 20px);
  margin-bottom: 14px;
  min-height: 1.2em;
}

.bars-label { font-size: 12px; color: var(--dim); letter-spacing: 0.14em; margin-bottom: 6px; }
.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding: 8px 6px;
  background: rgba(5, 9, 16, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.bars i {
  flex: 1;
  min-height: 3px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, var(--cyan), #0a5f78);
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.25);
}
.bars i.empty { background: #223246; box-shadow: none; }
.bars i.low { background: linear-gradient(180deg, var(--pink), #7e1b4a); box-shadow: 0 0 6px rgba(255, 45, 149, 0.25); }

.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* 採点モード切替 */
.mode-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.mode-toggle label { position: relative; cursor: pointer; }
.mode-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-toggle span {
  display: block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--dim);
  transition: background 0.15s, color 0.15s;
}
.mode-toggle input:checked + span { background: linear-gradient(90deg, #0a9cc8, var(--cyan)); color: #04121c; font-weight: 700; }
.mode-toggle input:focus-visible + span { box-shadow: 0 0 0 2px var(--cyan); }

/* ---------------- 演奏画面: 精密採点の表示 ---------------- */

/* 演奏区間（24 区間を 4 つずつ 6 組） */
.section-ind {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.78);
  font-size: 11px;
  color: #cfd6df;
}
.section-ind-label { margin-right: 4px; letter-spacing: 0.08em; }
.section-ind b {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 13px;
}
.section-ind b.on { background: #ffd62e; color: #1b1400; box-shadow: 0 0 10px rgba(255, 214, 46, 0.7); }

/* 技巧の回数と AI感性メーター（音程バーの帯の下。--band-top / --band-h は app.js が帯の位置に合わせて入れる） */
.tech-row {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--band-top, 64px) + var(--band-h, 30vh) + 8px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  flex-wrap: wrap;
}
/* 技法の回数（DAM 風: 暗い半透明の札にアイコン・名前・色付きの回数。検出した瞬間だけ札がその色に光る） */
.tech-list { display: contents; }
.tech {
  --c: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 8px;
  border-radius: 3px;
  background: rgba(22, 22, 28, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f2f2f2;
  transition: background 0.5s, box-shadow 0.5s;
}
.tech b {
  margin-left: 6px;
  font-family: var(--mono);
  font-size: 16px;
  min-width: 2ch;
  text-align: right;
  color: var(--c);
}
.tech.hit {
  background: color-mix(in srgb, var(--c) 42%, rgba(30, 24, 10, 0.85));
  box-shadow: inset 0 0 0 1px var(--c), 0 0 12px color-mix(in srgb, var(--c) 55%, transparent);
  transition: none;
}
.tech.hit b { color: #fff; }
.ai-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 2px solid #b89a4a;
  background: rgba(16, 24, 36, 0.92);
  font-size: 13px;
  color: #e9eef5;
}
/* 中央が 0。右へ加点（＋）、左へ減点（−） */
.ai-live-track {
  position: relative;
  display: block;
  width: min(240px, 30vw);
  height: 14px;
  border-radius: 3px;
  background: #0d2a4a;
  overflow: hidden;
}
.ai-live-track::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.7);
}
.ai-live-track b {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  transition: width 0.4s;
}
.ai-live-track b.add { left: 50%; background: linear-gradient(90deg, #ff6fd0, #ff2db4); }
.ai-live-track b.ded { right: 50%; background: linear-gradient(270deg, #6fb8ff, #2d7bff); }
.ai-live-num { font-style: normal; font-family: var(--mono); font-size: 13px; min-width: 4ch; }
.ai-live-num.plus { color: #ff8fdc; }
.ai-live-num.minus { color: #8fc4ff; text-align: right; }

/* 技法のアイコン（音程バーに出すものと同じ形・色。techIcons.js） */
.tech-ico { width: 20px; height: 20px; flex: none; overflow: visible; }

/* キー変更 */
.key-ctl {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 999px;
  background: rgba(10, 12, 18, 0.78);
  font-size: 12px;
  color: #cfd6df;
}
.key-ctl .btn { min-width: 30px; padding-left: 6px; padding-right: 6px; }
.key-val b { display: inline-block; min-width: 3ch; text-align: center; font-family: var(--mono); font-size: 15px; color: #fff; }
.key-val b.shifted { color: #ffd62e; }

/* ---------------- 結果画面: 精密採点 ---------------- */

.sm-result { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.sm-panel {
  border: 2px solid #1fb6d9;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8, 26, 46, 0.95), rgba(6, 14, 28, 0.95));
  box-shadow: 0 0 22px rgba(0, 200, 255, 0.18), inset 0 0 18px rgba(0, 160, 220, 0.12);
  padding: 14px;
}

/* 1 枚目 */
.sm-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px 14px;
}
.sm-sum-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sm-title { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.sm-artist { font-size: 13px; color: var(--dim); }
.sm-bonus { align-self: flex-end; font-size: 12px; color: #d8e4f0; }
.sm-bonus b { font-family: var(--mono); color: #fff; }
.sm-total { line-height: 1; white-space: nowrap; }
.sm-total-num {
  font-family: var(--mono);
  font-weight: 900;
  font-size: clamp(44px, 11vw, 76px);
  background: linear-gradient(180deg, #fff7c2 0%, #ffd23a 45%, #c58a00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(255, 190, 40, 0.35));
}
.sm-unit { font-size: 18px; color: #ffd23a; margin-left: 4px; font-weight: 700; }
.sm-hist { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--dim); }
.sm-hist b { font-family: var(--mono); color: var(--text); }
.sm-hist time { margin-left: auto; font-family: var(--mono); }
.sm-sum-right { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sm-radar { width: 100%; height: auto; }
.sm-radar-ring { fill: rgba(0, 40, 70, 0.5); stroke: #1fb6d9; stroke-width: 2; }
.sm-radar-grid { fill: none; stroke: rgba(255, 220, 80, 0.35); stroke-width: 1; }
.sm-radar-value { fill: rgba(255, 214, 46, 0.55); stroke: #ffe14d; stroke-width: 2; }
.sm-radar-label { fill: #e6eef7; font-size: 11px; font-weight: 700; }
.sm-ai-meter { display: flex; align-items: center; gap: 8px; }
.sm-ai-logo { font-weight: 900; font-style: italic; color: #7fd6ff; font-size: 15px; }
.sm-ai-logo small { font-size: 11px; color: #e6eef7; font-style: normal; margin-left: 2px; }
.sm-ai-track {
  position: relative;
  flex: 1;
  height: 14px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, #0c1c30 0 9.5%, #2b3d55 9.5% 10%);
  overflow: hidden;
}
.sm-ai-track::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.7);
}
.sm-ai-add { position: absolute; top: 0; bottom: 0; left: 50%; background: linear-gradient(90deg, #ff9be4, #ff2db4); }
.sm-ai-ded { position: absolute; top: 0; bottom: 0; right: 50%; background: linear-gradient(270deg, #6fb8ff, #2d7bff); }
.sm-ai-num { font-style: normal; font-family: var(--mono); font-size: 13px; min-width: 4ch; }
.sm-ai-num.plus { color: #ff8fdc; }
.sm-ai-num.minus { color: #8fc4ff; text-align: right; }
.sm-report {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(120, 20, 50, 0.6), rgba(60, 10, 30, 0.6));
  border: 1px solid rgba(255, 120, 160, 0.45);
}
.sm-report-label { font-size: 12px; color: #ffd0de; }
.sm-report p { margin: 0; font-size: 15px; line-height: 1.6; white-space: pre-line; }
.sm-report small { grid-column: 2; font-size: 10px; color: rgba(255, 220, 230, 0.6); font-family: var(--mono); }

/* 2 枚目 */
.sm-detail { display: flex; flex-direction: column; gap: 10px; }
.sm-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.sm-head { align-items: center; }
.sm-head-score { font-family: var(--mono); font-size: 20px; color: #fff; }
.sm-head-song { color: var(--dim); font-size: 13px; margin-left: auto; }
.sm-block { padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(31, 182, 217, 0.5); background: rgba(4, 16, 30, 0.6); }
.sm-tag { font-weight: 800; font-style: italic; color: #fff; text-shadow: 0 0 6px rgba(0, 200, 255, 0.6); }
.sm-tag-ai { color: #7fd6ff; }
.sm-kv { font-size: 13px; color: #ffe14d; }
.sm-kv b { font-family: var(--mono); font-size: 18px; color: #fff; margin: 0 2px; }
.sm-row small { font-size: 11px; color: #ffe14d; opacity: 0.85; }
.sm-chart { display: block; width: 100%; height: auto; margin-top: 4px; }
.sm-ch-grid { stroke: rgba(255, 255, 255, 0.22); stroke-width: 1; }
.sm-ch-axis { fill: #cfd6df; font-size: 9px; }
.sm-ch-group { fill: rgba(255, 255, 255, 0.08); font-size: 44px; font-weight: 900; }
.sm-ch-sabi { fill: rgba(255, 214, 46, 0.18); }
.sm-ch-sabi-label { fill: rgba(255, 240, 200, 0.75); font-size: 10px; }
.sm-ch-line { fill: none; stroke: #5ee6e0; stroke-width: 2; }
.sm-ch-dot { fill: #fff; stroke: #5ee6e0; stroke-width: 1.5; }
.sm-ch-dot.low { fill: #ff3d7f; stroke: #ff9bbc; }
.sm-ch-add { fill: #ff4fc8; }
.sm-ch-ded { fill: #3a8dff; }
.sm-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.sm-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(31, 182, 217, 0.5);
  background: rgba(4, 16, 30, 0.6);
  min-width: 0;
}
.sm-cell-wide { grid-column: 1 / -1; }
.sm-vib { grid-row: span 2; align-items: flex-start; flex-direction: column; }
.sm-vib-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sm-vib-type { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: #ffe14d; }
.sm-vib-type b { color: #fff; }
.sm-wave { width: 100px; height: 40px; background: #06140a; border: 1px solid #2e6b3c; border-radius: 4px; }
.sm-wave-line { fill: none; stroke: #39ff88; stroke-width: 2; }
.sm-diamonds { display: inline-flex; gap: 3px; }
.sm-diamonds i {
  width: 14px;
  height: 14px;
  transform: rotate(45deg) scale(0.8);
  border: 2px solid #e8f4ff;
  background: transparent;
}
.sm-diamonds i.on { background: #e8f4ff; box-shadow: 0 0 6px rgba(160, 220, 255, 0.8); }
.sm-ends { font-size: 11px; color: #ffe14d; }
.sm-stab { display: inline-flex; align-items: flex-end; gap: 2px; height: 22px; }
.sm-stab i { width: 6px; background: #2b3d55; }
.sm-stab i.on { background: #e8f4ff; }
.sm-rhythm { display: inline-flex; gap: 3px; }
.sm-rhythm i { width: 8px; height: 18px; border: 1px solid #6c8fb5; border-radius: 2px; }
.sm-rhythm i.center { border-color: #e8f4ff; }
.sm-rhythm i.on { background: #e8f4ff; border-color: #fff; box-shadow: 0 0 6px rgba(160, 220, 255, 0.9); }
.sm-keys { flex: 1; min-width: 180px; max-width: 360px; height: auto; }
.sm-key-w { fill: #f2f5f8; stroke: #6c7a88; stroke-width: 0.5; }
.sm-key-w.on { fill: #7fd6ff; }
.sm-key-b { fill: #1a1f27; }
.sm-key-b.on { fill: #1f7fb5; }
.sm-key-label { fill: #ffe14d; font-size: 9px; font-weight: 700; }

/* 3 枚目: カロリー */
.sm-calorie { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.sm-cal-label { font-weight: 800; color: #9cf27a; letter-spacing: 0.06em; font-size: 13px; }
.sm-cal-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #7ee24a, #2f9a16);
  border: 4px solid #d8ffb8;
  box-shadow: 0 0 16px rgba(120, 230, 80, 0.5);
}
.sm-cal-badge b { font-family: var(--mono); font-size: 26px; color: #fff; line-height: 1; }
.sm-cal-badge small { font-size: 12px; color: #f0ffe0; }

/* 内部パラメータ */
.sm-internal { display: flex; flex-direction: column; gap: 6px; border-color: #3a5570; }
.sm-internal small { color: var(--dim); }
.sm-in-group { border: 1px solid var(--line); border-radius: 8px; background: rgba(4, 12, 22, 0.6); }
.sm-in-group > summary { cursor: pointer; padding: 8px 10px; font-weight: 700; font-size: 13px; color: #cfe6f5; }
.sm-in-group[open] > summary { border-bottom: 1px solid var(--line); }
.sm-in-group > :not(summary) { margin: 8px 10px; max-width: calc(100% - 20px); }
.sm-in-scroll { overflow-x: auto; }
.sm-in-table { border-collapse: collapse; font-size: 12px; width: 100%; }
.sm-in-table caption { text-align: left; color: var(--dim); font-size: 11px; padding: 2px 0 4px; }
.sm-in-table th, .sm-in-table td { padding: 3px 8px; border-bottom: 1px solid rgba(32, 52, 75, 0.7); text-align: left; vertical-align: top; }
.sm-in-table th { color: #9fc3dc; font-weight: 600; white-space: nowrap; }
.sm-in-table td { font-family: var(--mono); color: var(--text); overflow-wrap: anywhere; }
.sm-in-table td.sm-in-note { font-family: inherit; color: var(--dim); font-size: 11px; }
.sm-in-wide { width: auto; }
.sm-in-wide th, .sm-in-wide td { text-align: right; padding: 3px 5px; }

/* 演奏中の内部パラメータ */
.live-internal {
  position: absolute;
  right: 12px;
  top: calc(var(--band-top, 64px) + var(--band-h, 30vh) + 56px);
  max-height: calc(100% - var(--band-top, 64px) - var(--band-h, 30vh) - 64px);
  overflow-y: auto;
  z-index: 6;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 12px;
  margin: 0;
  padding: 10px 12px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.86);
  font-size: 12px;
}
.live-internal dt { color: var(--dim); white-space: nowrap; }
.live-internal dd { margin: 0; font-family: var(--mono); color: var(--text); text-align: right; }

/* ---------------- レスポンシブ (360px〜) ---------------- */

@media (max-width: 480px) {
  .search-form { flex-direction: row; }
  .search-form .btn { padding: 10px 14px; }
  .song-item { padding: 8px 10px; gap: 8px; }
  .song-thumb { width: 38px; height: 38px; }
  .song-badges .badge { padding: 2px 6px; font-size: 10px; }
  .hud { padding: 8px 8px; }
  .score-box { line-height: 1.05; }
  .score-sub { display: none; }
  .hud-bottom { padding-top: 20px; }
  .bars { height: 96px; gap: 2px; }
  .result-card { padding: 20px 12px 18px; }
  .sm-summary, .sm-grid { grid-template-columns: minmax(0, 1fr); }
  .sm-vib { grid-row: auto; }
  .tech { padding: 3px 6px; font-size: 11px; gap: 2px; }
  .tech b { font-size: 14px; margin-left: 2px; }
  .tech-name { display: none; } /* 6 つ並べるため、狭い画面ではアイコンと回数だけ */
  .ai-live { margin-left: 0; }
  .section-ind-label { display: none; }
  .section-ind b { width: 18px; height: 18px; font-size: 11px; }
  .tech-row { gap: 4px; padding: 0 8px; }
  .tech-ico { width: 16px; height: 16px; font-size: 10px; }
  .ai-live { flex: 1 1 100%; padding: 3px 8px; gap: 6px; font-size: 11px; }
  .ai-live-track { flex: 1; width: auto; }
  .ai-live-num { font-size: 12px; min-width: 3.5ch; }
  .live-internal { left: 8px; right: 8px; font-size: 11px; }
}

/* 狭い画面: 上の HUD を 2 段に（1 段目 = 中止・曲名・点数、2 段目 = 内部・キー・演奏区間） */
@media (max-width: 720px) {
  .hud-top { flex-wrap: wrap; row-gap: 6px; align-items: center; }
  .hud-tools {
    order: 9;
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .hud-tools .section-ind { margin-left: auto; }
  .song-title { text-align: left; font-size: 14px; }
  .score-value { font-size: 26px; }
}

/* 横向きのスマホ（高さが低い）: HUD を詰めて音程バーの帯を確保する */
@media (max-height: 500px) and (orientation: landscape) {
  .hud { padding-top: 6px; padding-bottom: 6px; }
  .hud-top { padding-top: max(6px, env(safe-area-inset-top)); }
  .score-sub { display: none; }
  .score-value { font-size: 24px; }
  .score-label { display: none; }
  .tech { padding: 2px 6px; font-size: 11px; gap: 4px; }
  .tech b { font-size: 14px; }
  .hud-bottom { padding-top: 12px; }
}

/* タッチ操作: ボタンを押しやすい大きさに */
@media (pointer: coarse) {
  .btn.sm { min-height: 40px; min-width: 40px; }
  .mode-toggle span { padding: 9px 18px; }
}

/* 好み: コントラストが十分ある高コントラストユーザー設定への追従 */
@media (prefers-contrast: more) {
  :root { --dim: #b4c6d8; --line: #3a5570; }
}

/* ---------------- エラーの詳細パネル ---------------- */

.error-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 4, 8, 0.72);
}
.error-box {
  width: min(720px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 18px 18px 14px;
  border: 1px solid rgba(255, 45, 149, 0.55);
  border-radius: 12px;
  background: var(--panel-2);
  box-shadow: 0 0 32px rgba(255, 45, 149, 0.2);
}
.error-title { margin: 0 0 6px; font-size: 17px; color: #ff8cc0; }
.error-message { margin: 0 0 8px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.error-hint {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 176, 46, 0.1);
  border: 1px solid rgba(255, 176, 46, 0.4);
  color: #ffd18a;
  font-size: 13px;
}
.error-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 12px;
  margin: 0 0 10px;
  font-size: 12px;
}
.error-meta dt { color: var(--dim); }
.error-meta dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.error-details > summary { cursor: pointer; font-size: 13px; color: var(--cyan); margin-bottom: 6px; }
.error-calls-wrap { overflow-x: auto; margin-bottom: 8px; }
.error-calls { border-collapse: collapse; width: 100%; font-size: 11px; }
.error-calls caption { text-align: left; color: var(--dim); padding-bottom: 4px; }
.error-calls th, .error-calls td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.error-calls th { color: var(--dim); font-weight: 600; white-space: nowrap; }
.error-calls td { font-family: var(--mono); overflow-wrap: anywhere; }
.error-raw {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(4, 8, 14, 0.8);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.error-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
