    * { margin: 0; padding: 0; box-sizing: border-box; }

    body {
      background: #000;
      color: #fff;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      height: 100dvh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    #canvas-container {
      position: relative;
      flex: 1;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #111;
    }

    #outputCanvas {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    video { display: none; }

    #loading {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      z-index: 10;
      pointer-events: none;
    }

    #loading .spinner {
      width: 48px;
      height: 48px;
      border: 4px solid rgba(255,255,255,0.2);
      border-top-color: #fff;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      margin: 0 auto 12px;
    }

    @keyframes spin { to { transform: rotate(360deg); } }

    #status-bar {
      position: absolute;
      top: 12px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(0,0,0,0.55);
      backdrop-filter: blur(8px);
      padding: 5px 14px;
      border-radius: 20px;
      font-size: 13px;
      z-index: 5;
      white-space: nowrap;
      transition: opacity 0.3s;
    }

    /* ──── モード切り替えリンク ──── */
    #mode-links {
      position: absolute;
      top: 12px;
      left: 12px;
      display: flex;
      gap: 6px;
      z-index: 5;
    }
    #mode-links a {
      background: rgba(0,0,0,0.55);
      backdrop-filter: blur(8px);
      color: rgba(255,255,255,0.7);
      text-decoration: none;
      padding: 4px 10px;
      border-radius: 14px;
      font-size: 11px;
      font-weight: 500;
      border: 1px solid rgba(255,255,255,0.15);
      transition: color 0.15s, background 0.15s;
    }
    #mode-links a:hover { color: #fff; }
    #mode-links a.current {
      background: rgba(255,255,255,0.2);
      color: #fff;
      border-color: rgba(255,255,255,0.4);
    }

    #doc-links {
      position: absolute;
      top: 12px;
      right: 12px;
      display: flex;
      gap: 6px;
      z-index: 5;
    }
    #doc-links a {
      background: rgba(0,0,0,0.55);
      backdrop-filter: blur(8px);
      color: rgba(255,255,255,0.7);
      text-decoration: none;
      padding: 4px 10px;
      border-radius: 14px;
      font-size: 11px;
      font-weight: 500;
      border: 1px solid rgba(255,255,255,0.15);
      transition: color 0.15s;
    }
    #doc-links a:hover { color: #fff; }

    /* ──── コントロールパネル ──── */
    #controls {
      background: rgba(10,10,10,0.85);
      backdrop-filter: blur(14px);
      padding: 10px 12px 16px;
      flex-shrink: 0;
    }

    /* フレームサムネイル行 */
    #frame-list {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      padding-bottom: 4px;
      scrollbar-width: none;
    }
    #frame-list::-webkit-scrollbar { display: none; }

    .frame-thumb {
      width: 58px;
      height: 58px;
      border-radius: 10px;
      border: 2.5px solid transparent;
      cursor: pointer;
      flex-shrink: 0;
      overflow: hidden;
      transition: border-color 0.15s, transform 0.1s;
      position: relative;
      background: #222;
    }
    .frame-thumb:active { transform: scale(0.93); }
    .frame-thumb.active { border-color: #fff; }

    .frame-thumb canvas,
    .frame-thumb img {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: cover;
    }

    .frame-thumb .thumb-label {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: rgba(0,0,0,0.45);
      font-size: 9px;
      text-align: center;
      padding: 2px 0;
    }

    /* アクション行 */
    #action-row {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 28px;
      margin-top: 12px;
    }

    .side-btn {
      width: 46px;
      height: 46px;
      border-radius: 50%;
      background: rgba(255,255,255,0.15);
      border: none;
      cursor: pointer;
      font-size: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: background 0.15s, transform 0.1s;
    }
    .side-btn:active { transform: scale(0.9); background: rgba(255,255,255,0.25); }

    #capture-btn {
      width: 72px;
      height: 72px;
      border-radius: 50%;
      background: #fff;
      border: 4px solid rgba(255,255,255,0.35);
      cursor: pointer;
      transition: transform 0.1s, background 0.1s;
      box-shadow: 0 0 0 3px rgba(255,255,255,0.15);
    }
    #capture-btn:active { transform: scale(0.88); background: #ddd; }
    #capture-btn:disabled { opacity: 0.4; cursor: default; }

    /* ──── プレビューモーダル ──── */
    #preview-modal {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,0.92);
      z-index: 200;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 20px;
      padding: 20px;
    }
    #preview-modal.show { display: flex; }

    #preview-img {
      max-width: 100%;
      max-height: 65dvh;
      border-radius: 14px;
      box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    }

    .modal-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      justify-content: center;
      max-width: 360px;
    }

    .modal-btn {
      padding: 13px 28px;
      border-radius: 28px;
      border: none;
      font-size: 15px;
      font-weight: 600;
      cursor: pointer;
      transition: transform 0.1s;
    }
    .modal-btn:active { transform: scale(0.95); }
    .modal-btn.save { background: #0a84ff; color: #fff; }
    .modal-btn.share-x { background: #000; color: #fff; }
    .modal-btn.retake { background: rgba(255,255,255,0.18); color: #fff; flex: 1 1 100%; text-align: center; }

    /* クレジット表示 */
    #credit {
      position: absolute;
      bottom: 8px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 10px;
      color: rgba(255,255,255,0.4);
      white-space: nowrap;
      pointer-events: none;
      z-index: 5;
    }

    /* フラッシュアニメーション */
    #flash {
      position: absolute;
      inset: 0;
      background: #fff;
      opacity: 0;
      pointer-events: none;
      z-index: 50;
    }
    #flash.flash-anim {
      animation: flash 0.3s ease-out forwards;
    }
    @keyframes flash {
      0%   { opacity: 0.9; }
      100% { opacity: 0; }
    }

    /* フレームなし時のプレースホルダー */
    .no-frame-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      font-size: 24px;
    }

    /* ──── 横向きレイアウト ──── */
    @media (orientation: landscape) {

      body {
        flex-direction: row;
        align-items: stretch;
      }

      #controls {
        display: flex;
        height: 100%;
        padding: 10px 8px 14px;
        overflow: hidden;
        box-sizing: border-box;
        flex-shrink: 0;
      }

      #frame-list {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        flex: 1;
        gap: 6px;
        padding-bottom: 0;
      }

      #action-row {
        flex-direction: column;
        gap: 10px;
        margin-top: 10px;
        align-items: center;
      }
    }


  /* フレームリスト非表示 */
  /* #frame-list {
    display:none;
} */