/* ==============================
   素数花火ゲーム - スタイル
   修正: 単体HTML版から移植する際、グローバルセレクタ（*, html, body）を
   .pfg-app にスコープし直し、他ページ・他プラグインへの影響を排除。
   Cocoonテーマ対策として、レイアウトに直結するプロパティに !important を付与。
   ============================== */

  /* ==============================
     倍数花火ゲーム・分数花火ゲームと同じ骨格
     （固定ヘッダー + 全画面キャンバス + 右下ツールバー + モーダル）
     紺 #1e3a5f / 金 #d4af37 のブランド配色
     ============================== */
  /* 修正: 全称セレクタは .pfg-app 内だけに限定（サイト全体を壊さないため） */
.pfg-app, .pfg-app * { box-sizing: border-box; margin: 0; padding: 0; }

  /* 修正: html/bodyへの適用をやめ、.pfg-app自体を全画面固定オーバーレイにする */
  .pfg-app {
    position: fixed !important;
    inset: 0 !important;
    height: 100%;
    overflow: hidden;
    font-family: "BIZ UDGothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
    background: #0b1020;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    z-index: 999999; /* Cocoonのヘッダー等より前面に */
  }

  .pfg-app canvas {
    position: fixed !important;
    inset: 0;
    display: block;
  }

  /* ---------- 固定ヘッダー ---------- */
  .pfg-header {
    position: fixed !important;
    top: 0; left: 0; right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(10, 18, 38, 0.72);
    border-bottom: 1px solid rgba(212, 175, 55, 0.35);
    z-index: 10;
  }

  .pfg-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
  }

  .pfg-status { display: flex; gap: 8px; align-items: center; }

  .pfg-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 13px;
    white-space: nowrap;
  }
  .pfg-chip b { font-size: 17px; }
  .pfg-chip-target {
    background: linear-gradient(180deg, #e3c04c, #d4af37);
    border-color: #d4af37;
    color: #16324f;
    font-weight: 700;
  }
  .pfg-chip-score b { color: #f4cf5f; }
  .pfg-chip-combo b { color: #f4cf5f; }

  /* ---------- 進捗ドット ---------- */
  .pfg-progress {
    position: fixed !important;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    max-width: 90vw;
    z-index: 10;
  }
  .pfg-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s;
  }
  .pfg-dot.pfg-filled {
    background: linear-gradient(135deg, #f4cf5f, #d4af37);
    border-color: #d4af37;
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
  }

  /* ---------- 右下ツールバー ---------- */
  .pfg-toolbar {
    position: fixed !important;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
  }
  .pfg-tool {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #1e3a5f;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
  }
  .pfg-tool:active { transform: scale(0.92); }
  .pfg-tool:disabled { opacity: 0.4; cursor: not-allowed; }
  .pfg-tool-main { background: #d4af37; color: #16324f; }

  /* ---------- トースト ---------- */
  .pfg-msg {
    position: fixed !important;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 30, 58, 0.92);
    padding: 16px 24px;
    border-radius: 18px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    border: 2px solid rgba(212, 175, 55, 0.5);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    z-index: 60;
    max-width: 320px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .pfg-msg.pfg-show { opacity: 1; }
  .pfg-msg.pfg-success { border-color: #2e9e5b; background: rgba(20, 70, 45, 0.92); }
  .pfg-msg.pfg-error { border-color: #c0392b; background: rgba(90, 25, 20, 0.92); }

  /* ---------- ゲーム終了オーバーレイ ---------- */
  .pfg-overlay {
    position: fixed !important;
    inset: 0;
    background: rgba(10, 18, 38, 0.78);
    display: none !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 20px;
    z-index: 50;
  }
  .pfg-overlay.pfg-show { display: flex !important; }
  .pfg-overlay h2 { font-size: 26px; color: #f4cf5f; }
  .pfg-overlay p { font-size: 16px; }

  /* ---------- モーダル（難易度選択） ---------- */
  .pfg-modal {
    position: fixed !important;
    inset: 0;
    background: rgba(10, 18, 38, 0.78);
    display: none !important;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
  }
  .pfg-modal.pfg-show { display: flex !important; }

  .pfg-modal-card {
    background: #fff;
    color: #1e3a5f;
    border-radius: 20px;
    padding: 28px 26px;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  }
  .pfg-modal-title {
    font-size: 20px;
    font-weight: 700;
    border-left: 6px solid #d4af37;
    padding-left: 10px;
    margin-bottom: 16px;
  }

  .pfg-level-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .pfg-level-btn {
    padding: 14px 8px;
    border: 2px solid #c6d3e0;
    border-radius: 999px;
    background: #fff;
    color: #1e3a5f;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
  }
  .pfg-level-btn small { display: block; font-weight: 400; font-size: 11px; color: #5b7186; margin-top: 2px; }
  .pfg-level-btn.pfg-selected {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #fff;
  }
  .pfg-level-btn.pfg-selected small { color: #d4af37; }

  .pfg-rules {
    background: #f5f7fa;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 16px;
  }

  .pfg-start-btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #e3c04c, #d4af37);
    color: #16324f;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.15em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  }
  .pfg-start-btn:active { transform: scale(0.98); }
  .pfg-overlay .pfg-start-btn { width: auto; padding: 12px 32px; margin-top: 8px; }

  .hidden { display: none !important; }

  /* ---------- レスポンシブ ---------- */
  @media (max-width: 700px) {
    .pfg-title { font-size: 14px; }
    .pfg-chip { padding: 4px 10px; font-size: 11px; }
    .pfg-chip b { font-size: 14px; }
    .pfg-status { gap: 4px; }
    .pfg-tool { width: 48px; height: 48px; font-size: 20px; }
    .pfg-level-grid { grid-template-columns: 1fr; }
    .pfg-dot { width: 12px; height: 12px; }
  }


.hidden { display: none !important; }
