body {
  margin: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Arial", sans-serif;
  background-color: #0d0f12;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 90px);
  z-index: 1;
}

/* ==========================================================================
   1. カスタムスクロールバー（サイバーハイテク仕様・常時表示・操作可能）
   ========================================================================== */
.custom-scroll,
#side-custom-panel,
#slot-items-list {
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 rgba(4, 20, 36, 0.95);
  -webkit-overflow-scrolling: touch;
}

.custom-scroll::-webkit-scrollbar,
#side-custom-panel::-webkit-scrollbar,
#slot-items-list::-webkit-scrollbar {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  display: block;
}

.custom-scroll::-webkit-scrollbar-track,
#side-custom-panel::-webkit-scrollbar-track,
#slot-items-list::-webkit-scrollbar-track {
  -webkit-appearance: none;
  background: rgba(3, 16, 28, 0.95);
  border-left: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: inset 1px 0 3px rgba(0, 0, 0, 0.6);
}

.custom-scroll::-webkit-scrollbar-thumb,
#side-custom-panel::-webkit-scrollbar-thumb,
#slot-items-list::-webkit-scrollbar-thumb {
  -webkit-appearance: none;
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 50%, #1e40af 100%);
  border-radius: 5px;
  border: 1.5px solid rgba(3, 16, 28, 0.95);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
  min-height: 40px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover,
#side-custom-panel::-webkit-scrollbar-thumb:hover,
#slot-items-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 50%, #2563eb 100%);
  box-shadow: 0 0 16px rgba(56, 189, 248, 1);
}

.custom-scroll::-webkit-scrollbar-corner,
#side-custom-panel::-webkit-scrollbar-corner,
#slot-items-list::-webkit-scrollbar-corner {
  background: transparent;
}

/* ==========================================================================
   2. グラスパネル基底スタイル
   ========================================================================== */
.glass-panel {
  background: rgba(15, 20, 28, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   3. FPS カウンター HUD リッチ装飾（サイドパネル内計器仕様）
   ========================================================================== */
#fps-counter {
  position: relative;
  background: linear-gradient(135deg, rgba(6, 33, 58, 0.95) 0%, rgba(4, 20, 36, 0.98) 100%);
  border: 1px solid #1e4976;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 6px rgba(56, 189, 248, 0.15);
  overflow: hidden;
}

#fps-counter::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(56, 189, 248, 0.6) 50%, transparent 100%);
}

#fps-counter::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 5px;
  height: 5px;
  border-bottom: 2px solid #38bdf8;
  border-right: 2px solid #38bdf8;
}

/* ==========================================================================
   4. サイドカスタムパネル（サイバーハンガー・デッキ仕様）
      ※レイアウトとベースカラー（#082c4d）は完全に維持
   ========================================================================== */
#side-custom-panel {
  /* 微細なサイバードットグリッド（色味を崩さず質感のみ向上） */
  background-color: #082c4d;
  background-image: 
    radial-gradient(rgba(56, 189, 248, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(8, 44, 77, 0.98) 0%, rgba(5, 30, 54, 0.99) 100%);
  background-size: 10px 10px, 100% 100%;
  border-left: 1px solid #1e4976;
  box-shadow: -8px 0 35px rgba(0, 0, 0, 0.75), inset 1px 0 0 rgba(56, 189, 248, 0.25);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 90px;
  width: 440px;
  max-width: 100vw;
  box-sizing: border-box;
  height: calc(100vh - 90px);
  overflow-y: scroll; /* スクロールバー領域を常に確保し快適操作 */
  scrollbar-gutter: stable;
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

#side-custom-panel.translate-x-full {
  transform: translateX(100%) !important;
}

/* パネル左端のサイバーネオンインジケーターライン */
#side-custom-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, 
    transparent 0%, 
    rgba(56, 189, 248, 0.6) 15%, 
    rgba(56, 189, 248, 0.2) 50%, 
    rgba(56, 189, 248, 0.7) 85%, 
    transparent 100%
  );
  pointer-events-none;
}

/* ==========================================================================
   5. 上部ボタングループ（連結セグメントコントロール: 一体型ブロック ＆ 間仕切りフチ ※面取りなし）
   ========================================================================== */
#side-custom-panel #top-nav-button-group {
  position: relative;
  background: #08223d;
  border: 1px solid #38bdf8; /* 全体の外周: 1px明るいシアン輪郭 */
  padding: 0;
  gap: 0;
  overflow: hidden;
}

#side-custom-panel #top-nav-button-group > button {
  position: relative;
  background: linear-gradient(180deg, #103258 0%, #0a2442 100%);
  border-right: 1px solid rgba(56, 189, 248, 0.4); /* ボタン間の間仕切りフチ */
  transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#side-custom-panel #top-nav-button-group > button:last-child {
  border-right: none;
}

#side-custom-panel #top-nav-button-group > button:hover {
  background: linear-gradient(180deg, #1e4a7a 0%, #0f3560 100%);
}

#side-custom-panel #top-nav-button-group > button:active {
  background: #09223d;
}

#side-custom-panel #top-nav-button-group > button i {
  transition: transform 160ms ease-out;
}
#side-custom-panel #top-nav-button-group > button:hover i {
  transform: scale(1.12);
}

/* Games ボタン: 他ボタンと同系統で少しだけ明るいトーン */
#side-custom-panel #btn-panel-games {
  background: linear-gradient(180deg, #184a7d 0%, #0f365e 100%) !important;
  border-left: 1px solid rgba(56, 189, 248, 0.45);
  color: white !important;
}

#side-custom-panel #btn-panel-games:hover {
  background: linear-gradient(180deg, #2464a6 0%, #154779 100%) !important;
}

#side-custom-panel #btn-panel-games:active {
  background: #0d2c4d !important;
}

/* ==========================================================================
   6. セレクター＆表示ボックス（テキストエリアは枠なし・切替ボタンは1px面取り輪郭）
   ========================================================================== */
#label-pose,
#label-material,
.part-name-display {
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15), 0 1px 0 rgba(255, 255, 255, 0.05);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 0.04em;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

/* セレクター切替ボタン（▲▼ メカニカルキー: 面取り＆1px明るい輪郭線） */
#btn-pose-prev, #btn-pose-next,
#btn-mat-prev, #btn-mat-next {
  position: relative;
  isolation: isolate;
  background: #fde047; /* ベースのオレンジより明るいイエローゴールド輪郭（1px） */
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition: background 150ms ease, transform 120ms ease;
}

#btn-pose-prev::before, #btn-pose-next::before,
#btn-mat-prev::before, #btn-mat-next::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%); /* ベースアンバーオレンジ */
  clip-path: polygon(2.5px 0, calc(100% - 2.5px) 0, 100% 2.5px, 100% calc(100% - 2.5px), calc(100% - 2.5px) 100%, 2.5px 100%, 0 calc(100% - 2.5px), 0 2.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 150ms ease;
}

#btn-pose-prev:hover, #btn-pose-next:hover,
#btn-mat-prev:hover, #btn-mat-next:hover {
  background: #ffffff; /* ホバーで輪郭が白く発光 */
}
#btn-pose-prev:hover::before, #btn-pose-next:hover::before,
#btn-mat-prev:hover::before, #btn-mat-next:hover::before {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}

.btn-part-prev, .btn-part-next {
  position: relative;
  isolation: isolate;
  background: #60a5fa; /* ベースのブルーより明るいライトブルー輪郭（1px） */
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition: background 150ms ease, transform 120ms ease;
}

.btn-part-prev::before, .btn-part-next::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #2563eb 0%, #1e40af 100%); /* ベースブルー */
  clip-path: polygon(2.5px 0, calc(100% - 2.5px) 0, 100% 2.5px, 100% calc(100% - 2.5px), calc(100% - 2.5px) 100%, 2.5px 100%, 0 calc(100% - 2.5px), 0 2.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 150ms ease;
}

.btn-part-prev:hover, .btn-part-next:hover {
  background: #ffffff; /* ホバーで輪郭が白く発光 */
}
.btn-part-prev:hover::before, .btn-part-next:hover::before {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
}

/* ==========================================================================
   7. カラーパッチボタン（装甲スウォッチ: 面取り＆明るい1px輪郭）
   ========================================================================== */
.color-swatch-btn {
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75), 0 0 0 1px rgba(56, 189, 248, 0.8);
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 150ms ease-out;
}
.color-swatch-btn:hover {
  transform: scale(1.18);
  box-shadow: inset 0 0 0 1.5px #ffffff, 0 0 0 1px #38bdf8;
  z-index: 10;
}
.color-swatch-btn:active {
  transform: scale(0.95);
}

/* ライトカラープレビュー */
#btn-light-color-swatch {
  position: relative;
  isolation: isolate;
  background: #fde047; /* 1px明るいゴールド輪郭 */
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
}
#btn-light-color-swatch::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #06213a;
  clip-path: polygon(2.5px 0, calc(100% - 2.5px) 0, 100% 2.5px, 100% calc(100% - 2.5px), calc(100% - 2.5px) 100%, 2.5px 100%, 0 calc(100% - 2.5px), 0 2.5px);
  z-index: -1;
  pointer-events: none;
}
#btn-light-color-swatch:hover {
  background: #ffffff;
}

/* ==========================================================================
   8. スライダー＆LOCATIONセレクター＆折りたたみヘッダー
   ========================================================================== */
#details-customize-parts summary,
#details-visual-settings summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

#side-custom-panel input[type=range] {
  background: rgba(15, 23, 42, 0.8) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
}
#side-custom-panel input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  clip-path: polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 0 calc(100% - 2px), 0 2px);
  background: #fde047;
  cursor: pointer;
  transition: transform 100ms ease;
}
#side-custom-panel input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  background: #ffffff;
}

/* ==========================================================================
   9. アクションボタン（SAVE / LOAD / CLOSE / CUSTOMIZE）＆ FPS計器
   ========================================================================== */
#fps-counter {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

#btn-open-save-slots {
  position: relative;
  isolation: isolate;
  background: #60a5fa; /* ベースの濃紺青より明るいブルー輪郭（1px） */
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: background 160ms ease, transform 120ms ease;
}
#btn-open-save-slots::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #1e40af 0%, #1e3a8a 100%); /* ベースカラー */
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 160ms ease;
}
#btn-open-save-slots:hover {
  background: #ffffff; /* ホバーで輪郭が白く発光 */
}
#btn-open-save-slots:hover::before {
  background: linear-gradient(180deg, #2563eb 0%, #1e40af 100%);
}

#btn-open-load-slots {
  position: relative;
  isolation: isolate;
  background: #2dd4bf; /* ベースの濃い緑より明るいティール輪郭（1px） */
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: background 160ms ease, transform 120ms ease;
}
#btn-open-load-slots::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #0d9488 0%, #115e59 100%); /* ベースカラー */
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 160ms ease;
}
#btn-open-load-slots:hover {
  background: #ffffff;
}
#btn-open-load-slots:hover::before {
  background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
}

#btn-close-panel {
  position: relative;
  isolation: isolate;
  background: #6ee7b7; /* ベースより明るいエメラルド輪郭（1px） */
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  letter-spacing: 0.12em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transition: background 160ms ease, transform 120ms ease;
}
#btn-close-panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #10b981 0%, #047857 100%); /* ベースカラー */
  clip-path: polygon(5.5px 0, calc(100% - 5.5px) 0, 100% 5.5px, 100% calc(100% - 5.5px), calc(100% - 5.5px) 100%, 5.5px 100%, 0 calc(100% - 5.5px), 0 5.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 160ms ease;
}
#btn-close-panel:hover {
  background: #ffffff;
  transform: translateY(-1px);
}
#btn-close-panel:hover::before {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
}
#btn-close-panel:active {
  transform: translateY(1px);
}

#btn-open-panel {
  position: relative;
  isolation: isolate;
  background: #38bdf8; /* 明るいシアン輪郭（1px） */
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  transition: background 160ms ease, transform 120ms ease;
}
#btn-open-panel::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #082c4d 0%, #041c33 100%);
  clip-path: polygon(5.5px 0, calc(100% - 5.5px) 0, 100% 5.5px, 100% calc(100% - 5.5px), calc(100% - 5.5px) 100%, 5.5px 100%, 0 calc(100% - 5.5px), 0 5.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 160ms ease;
}
#btn-open-panel:hover {
  background: #ffffff;
}
#btn-open-panel:hover::before {
  background: linear-gradient(180deg, #0c3b66 0%, #082c4d 100%);
}

/* ==========================================================================
   9b. モーダル内ボタン & Photoモードボタン（面取り＆1px明るい輪郭）
   ========================================================================== */
#btn-color-copy,
#btn-color-paste {
  position: relative;
  isolation: isolate;
  background: #38bdf8;
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition: background 150ms ease;
}
#btn-color-copy::before,
#btn-color-paste::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #0f3b63;
  clip-path: polygon(2.5px 0, calc(100% - 2.5px) 0, 100% 2.5px, 100% calc(100% - 2.5px), calc(100% - 2.5px) 100%, 2.5px 100%, 0 calc(100% - 2.5px), 0 2.5px);
  z-index: -1;
  pointer-events: none;
}
#btn-color-copy:hover,
#btn-color-paste:hover:not(:disabled) {
  background: #ffffff;
}

#modal-preset-palette button {
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.75);
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
#modal-preset-palette button:hover {
  transform: scale(1.15);
  box-shadow: inset 0 0 0 1.5px #ffffff;
  z-index: 5;
}

#btn-color-modal-ok {
  position: relative;
  isolation: isolate;
  background: #60a5fa; /* 1px明るいブルー輪郭 */
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: background 160ms ease;
}
#btn-color-modal-ok::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #2563eb;
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
}
#btn-color-modal-ok:hover {
  background: #ffffff;
}

#btn-slot-modal-bottom-close {
  position: relative;
  isolation: isolate;
  background: #94a3b8; /* 1px明るいスレート輪郭 */
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: background 160ms ease;
}
#btn-slot-modal-bottom-close::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #334155;
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
}
#btn-slot-modal-bottom-close:hover {
  background: #ffffff;
}

.slot-action-btn {
  position: relative;
  isolation: isolate;
  background: #38bdf8;
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
}
.slot-action-btn::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: rgba(15, 23, 42, 0.9);
  clip-path: polygon(2.5px 0, calc(100% - 2.5px) 0, 100% 2.5px, 100% calc(100% - 2.5px), calc(100% - 2.5px) 100%, 2.5px 100%, 0 calc(100% - 2.5px), 0 2.5px);
  z-index: -1;
  pointer-events: none;
}

.slot-delete-btn {
  position: relative;
  isolation: isolate;
  background: #fda4af; /* 1px明るいローズ輪郭 */
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
}
.slot-delete-btn::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #e11d48;
  clip-path: polygon(2.5px 0, calc(100% - 2.5px) 0, 100% 2.5px, 100% calc(100% - 2.5px), calc(100% - 2.5px) 100%, 2.5px 100%, 0 calc(100% - 2.5px), 0 2.5px);
  z-index: -1;
  pointer-events: none;
}
.slot-delete-btn:hover {
  background: #ffffff;
}

#btn-delete-confirm-cancel {
  position: relative;
  isolation: isolate;
  background: #94a3b8;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
}
#btn-delete-confirm-cancel::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #334155;
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
}

#btn-delete-confirm-ok {
  position: relative;
  isolation: isolate;
  background: #fda4af;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
}
#btn-delete-confirm-ok::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #e11d48;
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
}

/* ゲーム選択ボタン（Games モーダル内） */
.game-select-btn {
  position: relative;
  isolation: isolate;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: all 160ms ease;
}

.game-select-btn.active-game {
  background: #38bdf8; /* 1px明るいシアン輪郭 */
}
.game-select-btn.active-game::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #163f6e 0%, #0c2b4c 100%);
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
  transition: background 160ms ease;
}
.game-select-btn.active-game:hover {
  background: #ffffff;
}
.game-select-btn.active-game:hover::before {
  background: linear-gradient(180deg, #1e5694 0%, #103964 100%);
}

.game-select-btn.coming-soon-game {
  background: #334155; /* 1pxダークスレート輪郭 */
}
.game-select-btn.coming-soon-game::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: linear-gradient(180deg, #141c2b 0%, #0b111a 100%);
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
}

#btn-games-modal-close {
  position: relative;
  isolation: isolate;
  background: #94a3b8; /* 1pxスレート輪郭 */
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: background 160ms ease;
}
#btn-games-modal-close::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #334155;
  clip-path: polygon(3.5px 0, calc(100% - 3.5px) 0, 100% 3.5px, 100% calc(100% - 3.5px), calc(100% - 3.5px) 100%, 3.5px 100%, 0 calc(100% - 3.5px), 0 3.5px);
  z-index: -1;
  pointer-events: none;
}
#btn-games-modal-close:hover {
  background: #ffffff;
}

#btn-exit-photo,
#btn-aspect-ratio {
  position: relative;
  isolation: isolate;
  background: #38bdf8;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  transition: background 160ms ease, transform 120ms ease;
}
#btn-exit-photo::before,
#btn-aspect-ratio::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: #0f172a;
  clip-path: polygon(4.5px 0, calc(100% - 4.5px) 0, 100% 4.5px, 100% calc(100% - 4.5px), calc(100% - 4.5px) 100%, 4.5px 100%, 0 calc(100% - 4.5px), 0 4.5px);
  z-index: -1;
  pointer-events: none;
}
#btn-exit-photo:hover,
#btn-aspect-ratio:hover {
  background: #ffffff;
}

/* ==========================================================================
   10. モーダルカード（右メインパネルの上に完全重ねて表示）
   ========================================================================== */
#color-picker-card,
#slot-modal-card {
  position: fixed !important;
  top: 14px;
  right: 16px;
  width: 408px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 90px - 28px);
  z-index: 50;
  background-color: #082c4d;
  background-image: 
    radial-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(8, 44, 77, 0.98) 0%, rgba(4, 25, 46, 0.99) 100%);
  background-size: 8px 8px, 100% 100%;
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.95), 
    0 0 30px rgba(6, 182, 212, 0.2), 
    inset 0 0 0 1px rgba(56, 189, 248, 0.3);
}

@media (max-width: 640px) {
  #color-picker-card,
  #slot-modal-card {
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    top: 8px !important;
  }
}

/* モーダルカード四隅のサイバーL字コーナーブラケット装飾 */
#color-picker-card::before,
#slot-modal-card::before,
#games-modal-card::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  width: 10px;
  height: 10px;
  border-top: 3px solid #38bdf8;
  border-left: 3px solid #38bdf8;
  pointer-events-none;
}
#color-picker-card::after,
#slot-modal-card::after,
#games-modal-card::after {
  content: "";
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-bottom: 3px solid #38bdf8;
  border-right: 3px solid #38bdf8;
  pointer-events-none;
}

/* ==========================================================================
   11. パーツカテゴリラベル（サイバーインジケーター）
   ========================================================================== */
#parts-controls-list [data-cat] > span:first-child {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#parts-controls-list [data-cat] > span:first-child::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 10px;
  background: #38bdf8;
  box-shadow: 0 0 5px #38bdf8;
  border-radius: 1px;
}

/* ==========================================================================
   12. スマホ・狭い画面向けのレスポンシブ最適化
   ========================================================================== */
@media (max-width: 640px) {
  #ui-layer {
    padding: 0.35rem;
  }
  .glass-panel {
    border-radius: 0;
  }
  #side-custom-panel {
    width: 100% !important;
    max-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
    box-sizing: border-box !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    padding-bottom: 2rem !important;
    overflow-x: hidden !important;
  }
  /* スマホでの各コントロール行の詰め */
  #parts-controls-list [data-cat] > span:first-child {
    width: 44px;
    font-size: 10px;
    letter-spacing: 0.02em;
  }
  #parts-controls-list .part-name-display {
    font-size: 10px;
  }
  #fps-counter {
    width: 68px;
    padding: 0 4px;
  }
}

/* ==========================================================================
   13. 最下部 固定広告バナーエリア（全要素の最前面・完全独立）
   ========================================================================== */
#details-visual-settings summary::-webkit-details-marker {
  display: none;
}
#details-visual-settings summary {
  list-style: none;
}

#bottom-ad-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90px;
  background-color: #000000;
  border-top: 1px solid #1e293b;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.95);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  user-select: none;
}
