/* CHIP SFX — game-music.css の上に載せる差分。トーン・ヘッダー・スライダーは共通。 */

.csfx-layout {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.csfx-col { display: grid; gap: 12px; align-content: start; }

@media (min-width: 880px) {
  .csfx-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); padding: 16px; gap: 16px; }
  .csfx-mobile { display: none; }
}

/* 縦一列（スマホ）では 選ぶ → 聞き比べる → 保存 → 調整 → KEEP の順に並べ替える */
@media (max-width: 879px) {
  .csfx-col { display: contents; }
  .csfx-sec--type { order: 1; }
  .csfx-sec--var { order: 2; }
  .csfx-sec--out { order: 3; }
  .csfx-sec--tweak { order: 4; }
  .csfx-sec--keep { order: 5; }
  .csfx-desktop { display: none; }
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
}

/* キー操作の受け皿としてフォーカスを持つが、枠は出さない */
.gm-machine:focus { outline: none; }

/* 押しやすい大きさ（40px以上） */
.csfx-layout .gm-mini { min-height: 40px; }

/* ── グループタブ：英語＋日本語の2段 ─────────────── */

/* 幅に応じて自動で段を組む（広ければ1段、狭ければ2段） */
.csfx-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 4px;
  margin-bottom: 8px;
}

.csfx-groups button {
  display: grid;
  gap: 1px;
  place-content: center;
  min-height: 42px;
  padding: 4px 2px;
  border: 1px solid var(--gm-line);
  border-radius: 6px;
  background: #0d0e10;
  color: var(--gm-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.csfx-groups button small { font-size: 9px; font-weight: 600; letter-spacing: 0; white-space: nowrap; opacity: 0.85; }
.csfx-groups button:hover { border-color: var(--gm-cyan); }
.csfx-groups button.is-active { background: var(--gm-cyan); border-color: var(--gm-cyan); color: #06232a; }

.csfx-any { width: 100%; margin-top: 6px; }

/* ── 種類のグリッド ─────────────────────────────── */

.csfx-types { grid-template-columns: repeat(2, 1fr); margin-bottom: 8px; }
@media (min-width: 360px) { .csfx-types { grid-template-columns: repeat(3, 1fr); } }

.csfx-types button { display: grid; gap: 2px; min-height: 48px; place-content: center; }
.csfx-types button small { font-size: 10px; font-weight: 600; letter-spacing: 0; opacity: 0.9; }

/* ── TWEAK：スライダーは主役なので太め ─────────────── */

.csfx-layout .gm-slider input[type="range"] { height: 36px; }
.csfx-layout .gm-slider input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9px; }
.csfx-layout .gm-slider input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; }
.csfx-mode .gm-seg { margin-top: 2px; }
.csfx-mode .gm-seg button { min-height: 40px; }
.csfx-mode + .gm-hint { margin-top: 6px; }

/* ── VARIATIONS ─────────────────────────────────── */

.csfx-sec--var .gm-generate { margin: 0 0 10px; }

.csfx-pads {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.csfx-pads button {
  display: grid;
  gap: 3px;
  padding: 6px 4px 5px;
  border: 1px solid var(--gm-line);
  border-radius: 6px;
  background: #0d0e10;
  color: var(--gm-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.csfx-pads button:hover { border-color: var(--gm-cyan); }
.csfx-pads button.is-active { border-color: var(--gm-green); color: var(--gm-green); box-shadow: inset 0 0 0 1px var(--gm-green); }
.csfx-pads canvas { display: block; width: 100%; height: 34px; }

/* MUTATE：似た8個を作る。変え幅は隣の3段スイッチ */
.csfx-mutrow { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 10px; align-items: stretch; }
.csfx-mutate { border-color: var(--gm-purple); color: var(--gm-purple); }
.csfx-level button { min-height: 40px; padding: 0 12px; }
@media (max-width: 420px) { .csfx-mutrow { grid-template-columns: 1fr; } }

.csfx-mutbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--gm-purple);
  border-radius: 8px;
  background: #17151f;
  color: var(--gm-text);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.csfx-mutbar > span { flex: 1 1 100%; }
.csfx-mutbar .gm-mini { flex: 1 1 auto; }
.csfx-mutbar .gm-mini:disabled { opacity: 0.4; cursor: default; }

.csfx-varactions { margin-bottom: 10px; }
.csfx-seed { margin-bottom: 0; }
.csfx-seed input { font-family: Menlo, monospace; letter-spacing: 0.12em; }
.csfx-keys { margin: 8px 0 0; }

/* ── OUTPUT ─────────────────────────────────────── */

.csfx-wavebox { position: relative; margin-bottom: 10px; }

.csfx-playhead {
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 0;
  width: 2px;
  background: var(--gm-yellow);
  opacity: 0;
  pointer-events: none;
}

/* transform で動かす（left だと毎フレーム配置計算が走り、音の生成中に止まって見える） */
@keyframes csfx-sweep {
  0% { transform: translateX(0); opacity: 1; }
  99% { opacity: 1; }
  100% { transform: translateX(var(--csfx-travel, 0px)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) { .csfx-playhead { display: none; } }

.csfx-wave {
  display: block;
  width: 100%;
  height: 96px;
  border: 1px solid #34373c;
  border-radius: 6px;
  background: #0a0b0d;
}

/* PLAY / KEEP / WAV が上段、ZIP / COPY が下段 */
.csfx-outactions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.csfx-outactions .gm-mini { grid-column: span 2; }
.csfx-outactions #zipButton, .csfx-outactions #linkButton { grid-column: span 3; }
.csfx-play { border-color: var(--gm-green); color: var(--gm-green); }
.csfx-keepbtn.is-kept { border-color: var(--gm-yellow); color: var(--gm-yellow); }

.csfx-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.csfx-actions .gm-mini { flex: 1 1 auto; }

/* 連番書き出し */
.csfx-rr { margin: 10px 0 0; padding: 10px; border: 1px solid #34373c; border-radius: 8px; background: #101114; }
.csfx-rr__head { margin-bottom: 8px; color: var(--gm-muted); font-size: 11px; letter-spacing: 0.04em; }
.csfx-rr__head strong { margin-right: 8px; color: var(--gm-text); letter-spacing: 0.1em; }
.csfx-rr__row { display: grid; grid-template-columns: 76px 1fr auto; gap: 8px; align-items: end; }
.csfx-rr__field { display: grid; gap: 3px; }
.csfx-rr__field > span { color: var(--gm-muted); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; }
.csfx-rr select, .csfx-rr input { width: 100%; min-height: 40px; padding: 7px 9px; border: 1px solid var(--gm-line); border-radius: 6px; background: #0d0e10; color: var(--gm-text); font-size: 12px; }
.csfx-rr input { font-family: Menlo, monospace; letter-spacing: 0.06em; }
.csfx-rr .gm-hint { margin: 8px 0 0; }

/* 状態メッセージ：スマホでは固定バーのすぐ上に出す */
.csfx-status { min-height: 1.6em; }

@media (max-width: 879px) {
  .csfx-status {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    z-index: 41;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--gm-line);
    border-radius: 8px;
    background: #17181c;
    color: var(--gm-text);
    font-size: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
  .csfx-status:empty { display: none; }
}

/* 使いみち（折りたたみ） */
.csfx-license { margin-top: 10px; padding-top: 10px; border-top: 1px solid #2e3034; }
.csfx-license > summary { cursor: pointer; margin: 0; }
.csfx-license > summary strong { color: var(--gm-text); }
.csfx-license ul { margin: 8px 0 10px; padding-left: 18px; }
.csfx-license li { margin-bottom: 4px; }
.csfx-license a { color: var(--gm-cyan); }

/* ── KEEP ───────────────────────────────────────── */

.csfx-keeps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.csfx-keeps:empty { display: none; }

.csfx-keep {
  display: inline-flex;
  border: 1px solid var(--gm-line);
  border-radius: 6px;
  background: #0d0e10;
  overflow: hidden;
}

.csfx-keep button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--gm-text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.csfx-keep button:hover { background: var(--gm-panel-2); }
.csfx-keep .csfx-keep__x { min-width: 40px; padding: 0; border-left: 1px solid var(--gm-line); color: var(--gm-muted); }

.csfx-starter { width: 100%; margin-top: 8px; border-color: var(--gm-cyan); color: var(--gm-cyan); }
.csfx-starter + .gm-hint { margin-top: 6px; }

/* ── スマホ用の固定バー：親指の届く下端に PLAY / KEEP / WAV ── */

.csfx-dock {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #34373c;
  background: rgba(23, 24, 28, 0.96);
}

.csfx-dock button {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--gm-line);
  border-radius: 8px;
  background: var(--gm-panel-2);
  color: var(--gm-text);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.csfx-dock .csfx-dock__play { flex: 1.4; border-color: var(--gm-green); color: var(--gm-green); }
.csfx-dock button.is-kept { border-color: var(--gm-yellow); color: var(--gm-yellow); }

@media (max-width: 879px) { .csfx-dock { display: flex; } }

/* ── キーボード操作の見える印 ─────────────────────── */

.csfx-layout button:focus-visible,
.csfx-dock button:focus-visible,
.csfx-layout input:focus-visible,
.csfx-license summary:focus-visible,
.gm-topbar a:focus-visible,
.gm-footer a:focus-visible { outline: 2px solid var(--gm-yellow); outline-offset: 2px; }

/* overflow:hidden の枠の中は内側に出す */
.gm-seg button:focus-visible,
.csfx-keep button:focus-visible { outline-offset: -3px; }

/* ── 狭い幅のトップバー：ロゴがLABへのリンクを兼ねるので重複リンクを隠す ── */

@media (max-width: 560px) {
  .gm-topbar__nav a:first-child { display: none; }
  .gm-topbar__logo { padding-right: 8px; }
}

@media (max-width: 380px) {
  .gm-topbar__logo img { width: 92px; }
}
