/* ============================================================
   style.css — Controller Viewer スタイルシート
   ============================================================ */

/* ── リセット / ベース ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0e0e0e;
  color: #f0f0f0;
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── アプリ全体レイアウト ───────────────────────────────────── */
#app {
  width: 100%;
  max-width: 916px;
  padding: 28px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ── ステータスバー ─────────────────────────────────────────── */
#status-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 16px;
}

#device-name {
  font-size: 0.85rem;
  color: #888;
  transition: color 0.3s;
}

#device-name.connected {
  color: #4ddb8a;
}

/* ── コントローラー選択ボタン ───────────────────────────────── */
#controller-select {
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  background: #2a2a2a;
  color: #bbb;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ctrl-btn:hover {
  background: #383838;
  color: #fff;
}

.ctrl-btn.active {
  background: #003c6e;
  color: #7ec8ff;
  border-color: #1a7fc0;
}

/* ── コントローラー表示コンテナ ─────────────────────────────── */
#controller-container {
  overflow: visible;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 16px 0px;
}

/* controller-wrapper のサイズは script.js で動的に設定される */
#controller-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#controller-image {
  display: block;
  width: 100%;
  height: 100%;
  /* fill: ラターボックスなしで wrapper に完全フィット → オーバーレイ座標と一致 */
  object-fit: fill;
  border-radius: 8px;
  /* outline はレイアウトに影響しないためオーバーレイ座標がズレない */
  outline: 1px dashed #333;
  background: #1c1c1c;
}

/* ── オーバーレイレイヤー ───────────────────────────────────── */
#button-overlays {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#stick-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ── ボタンオーバーレイ共通 ─────────────────────────────────── */
.btn-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 押されていない状態: 半透明の枠のみ */
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  transition: background 0.05s, filter 0.05s, border-color 0.05s;
}

.btn-overlay.shape-circle {
  border-radius: 50%;
}

.btn-overlay.shape-rect {
  border-radius: 4px;
}

/* デフォルトは circle */
.btn-overlay:not(.shape-rect) {
  border-radius: 50%;
}

/* ── 押下状態 ───────────────────────────────────────────────── */
.btn-overlay.pressed {
  background: rgba(220, 30, 40, 0.70);
  border-color: rgba(240, 50, 60, 0.90);
  filter: brightness(1.2) drop-shadow(0 0 6px rgba(240, 50, 60, 0.85));
}

/* ── ボタンラベル ───────────────────────────────────────────── */
.btn-label {
  font-size: 10px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.55);
  user-select: none;
  line-height: 1;
  pointer-events: none;
}

.btn-overlay.pressed .btn-label {
  color: #fff;
}

/* ── スティックオーバーレイ ─────────────────────────────────── */
.stick-overlay {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

/* スティックのつまみ（現在位置ドット） */
.stick-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 200, 255, 0.7);
  border: 2px solid rgba(0, 220, 255, 0.9);
  transform: translate(-50%, -50%);
  transition: transform 0.04s linear;
  box-shadow: 0 0 8px rgba(0, 200, 255, 0.5);
}

/* ── ヒントテキスト ─────────────────────────────────────────── */
#hint {
  font-size: 0.8rem;
  color: #888;
  text-align: center;
}

#hint code {
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #1a1a1a;
  padding: 1px 4px;
  border-radius: 3px;
  color: #7ec8ff;
}

#hint a {
  color: inherit;
  text-decoration: none;
}

#hint a:hover code {
  background: #2a2a2a;
  color: #a8dcff;
  outline: 1px solid rgba(126, 200, 255, 0.4);
}

/* ── 配信用透過モード（?controller= 指定時） ────────────────── */
body.transparent-bg {
  background: transparent !important;
}

body.transparent-bg #app {
  padding: 0;
}

/* ── カスタムレバー SVG transition ─────────────────────────── */
#button-overlays svg [id^="lever-shaft-"],
#button-overlays svg [id^="lever-ball-"] {
  transition: cx 0.04s linear, cy 0.04s linear,
              x2 0.04s linear, y2 0.04s linear;
}

/* ── サウンド設定モーダル ───────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  cursor: pointer;
  pointer-events: auto;
}

.modal-content {
  position: fixed;
  /* top と right は JavaScript で動的設定 */
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1001;
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #2a2a2a;
}

.modal-header h2 {
  font-size: 1.2rem;
  color: #f0f0f0;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

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

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.setting-row label {
  font-size: 0.9rem;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.setting-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #1a7fc0;
}

.setting-row input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #2a2a2a;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a7fc0;
  cursor: pointer;
  transition: background 0.15s;
}

.setting-row input[type="range"]::-webkit-slider-thumb:hover {
  background: #2a8fd0;
}

.setting-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a7fc0;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.setting-row input[type="range"]::-moz-range-thumb:hover {
  background: #2a8fd0;
}

#volume-value {
  font-size: 0.85rem;
  color: #aaa;
  min-width: 40px;
  text-align: right;
}

/* 設定ボタン（歯車アイコン）のスタイル調整 */
.settings-btn {
  font-size: 1.1rem;
  padding: 4px 10px;
}

