/* ==========================================================
   アクションペイント ミニ — action-paint.css
   すべてのセレクタを .ap-root 以下にスコープ化
   ========================================================== */

/* リセット（ap-root内のみ） */
.ap-root *, .ap-root *::before, .ap-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* フォント読み込み */
.ap-root {
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'BIZ UDGothic', sans-serif;
}

/* ===== メインエリア ===== */
.ap-root #ap-main {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: #0a1020;
}

.ap-root #ap-canvas-area {
  position: absolute;
  inset: 0;
  background: #fff;
}

.ap-root #ap-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  cursor: crosshair;
  display: block;
}

/* ===== カメラ小窓（右上） ===== */
.ap-root #ap-cam-preview {
  position: absolute;
  top: 68px; right: 12px;
  width: 160px; height: 120px;
  border: 2px solid #1e3a5f;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  display: none;
  z-index: 10;
}

.ap-root #ap-cam-preview video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

.ap-root #ap-cam-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6);
  font-size: 11px;
  text-align: center;
  color: #d4af37;
  padding: 2px;
}

/* ===== ステータス（左上） ===== */
.ap-root #ap-status {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(13,30,58,0.88);
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: #a0c4d8;
  pointer-events: none;
  z-index: 10;
  max-width: calc(100% - 80px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== ハンバーガーボタン（右上） ===== */
.ap-root #ap-menu-btn {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 10;
  width: 44px; height: 44px;
  background: rgba(13,30,58,0.88);
  border: 1px solid #1e3a5f;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

.ap-root #ap-menu-btn span {
  display: block;
  width: 20px; height: 2px;
  background: #d4af37;
  border-radius: 2px;
}

/* ===== HUDバー（左下） ===== */
.ap-root #ap-hud {
  position: absolute;
  bottom: 16px; left: 16px;
  z-index: 10;
  display: none; /* 起動時はサイドパネルが開くため非表示 */
  align-items: center;
  gap: 10px;
  background: rgba(13,30,58,0.92);
  border: 1.5px solid #1e3a5f;
  border-radius: 14px;
  padding: 8px 12px;
}

.ap-root .ap-hud-mode {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ap-root .ap-hud-mode-btn {
  padding: 6px 12px;
  border: 1.5px solid #2a4a6a;
  border-radius: 8px;
  background: #1e2a40;
  color: #8aacbe;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ap-root .ap-hud-mode-btn:active { transform: scale(0.96); }

.ap-root .ap-hud-mode-btn.active {
  background: #d4af37;
  border-color: #d4af37;
  color: #0d1e3a;
}

.ap-root .ap-hud-sep {
  width: 1px;
  height: 32px;
  background: #2a4a6a;
  flex-shrink: 0;
}

.ap-root .ap-hud-colors {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ap-root .ap-hud-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.15s;
}

.ap-root .ap-hud-swatch:hover  { transform: scale(1.15); }

.ap-root .ap-hud-swatch.active {
  border-color: #fff;
  transform: scale(1.2);
}

/* ===== オーバーレイ ===== */
.ap-root #ap-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.ap-root #ap-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ===== サイドパネル（右スライド） ===== */
.ap-root #ap-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: 220px;
  background: #0d1e3a;
  border-left: 3px solid #d4af37;
  z-index: 101;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  color: #fff;
}

.ap-root #ap-panel.open { transform: translateX(0); }

.ap-root #ap-panel-header {
  padding: 14px 12px 10px;
  border-bottom: 1px solid rgba(212,175,55,0.3);
}

.ap-root #ap-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: block;
}

.ap-root #ap-panel-sub {
  font-size: 11px;
  color: #f4cf5f;
  display: block;
  margin-top: 4px;
}

.ap-root .ap-section {
  padding: 12px;
  border-bottom: 1px solid #1e3a5f;
}

.ap-root .ap-section-title {
  font-size: 11px;
  color: #5a8aa0;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

/* ===== 操作ボタン ===== */
.ap-root .ap-btn {
  display: block;
  width: 100%;
  padding: 10px 8px;
  margin-bottom: 6px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.ap-root .ap-btn:active  { transform: scale(0.97); }
.ap-root .ap-btn:last-child { margin-bottom: 0; }
.ap-root .ap-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.ap-root .ap-btn-start { background: #1e7a4f; color: #fff; }
.ap-root .ap-btn-start:not(:disabled):hover { background: #28a065; }
.ap-root .ap-btn-stop  { background: #7a3a1e; color: #fff; }
.ap-root .ap-btn-stop:not(:disabled):hover  { background: #a04a28; }
.ap-root .ap-btn-clear { background: #1e2a40; color: #8aacbe; border: 1px solid #1e3a5f; }
.ap-root .ap-btn-clear:hover { background: #253550; }
.ap-root .ap-btn-save  { background: #b5860d; color: #fff; }
.ap-root .ap-btn-save:not(:disabled):hover  { background: #d4a010; }

/* ===== モードボタン（パネル内） ===== */
.ap-root .ap-mode-btn {
  display: block;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 6px;
  border: 1.5px solid #1e3a5f;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 700;
  color: #8aacbe;
  background: #1e2a40;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.ap-root .ap-mode-btn:last-child { margin-bottom: 0; }

.ap-root .ap-mode-btn.active {
  background: #d4af37;
  color: #0d1e3a;
  border-color: #d4af37;
}

.ap-root .ap-mode-desc {
  display: block;
  font-size: 10px;
  font-weight: 400;
  margin-top: 2px;
  opacity: 0.75;
}

/* ===== 色パレット（パネル内） ===== */
.ap-root .ap-palette {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.ap-root .ap-color-swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}

.ap-root .ap-color-swatch:hover  { transform: scale(1.15); }

.ap-root .ap-color-swatch.active {
  border-color: #fff;
  transform: scale(1.2);
}

/* ===== 感度スライダー ===== */
.ap-root .ap-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ap-root .ap-slider-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #1e3a5f;
  border-radius: 2px;
  outline: none;
}

.ap-root .ap-slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: #d4af37;
  border-radius: 50%;
  cursor: pointer;
}

.ap-root .ap-slider-val {
  font-size: 12px;
  color: #d4af37;
  min-width: 24px;
  text-align: right;
}

/* ===== 閉じるボタン ===== */
.ap-root #ap-panel-close {
  margin: auto 12px 16px;
  padding: 10px;
  border: 1.5px solid rgba(212,175,55,0.4);
  border-radius: 8px;
  background: transparent;
  color: #f4cf5f;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  display: block;
  width: calc(100% - 24px);
}

.ap-root #ap-panel-close:hover { background: rgba(212,175,55,0.15); }
