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

  /* ==============================
     修正: デザイン刷新「トレーディングカード・コレクション」
     - 見つけた約数が金のミニカードとしてトレイに並ぶ（signature要素）
     - ラウンド開始時にカードを配るフリップ演出
     - ターゲットはメダリオン風の大型表示
     骨格は共通テンプレ（固定ヘッダー + 全画面 + 右下ツールバー + モーダル）のまま
     ブランドカラー: 白ベース70% + ネイビー25% + ゴールド5%
     ============================== */
  /* 修正: 全称セレクタは .dcc-app 内だけに限定（サイト全体を壊さないため） */
.dcc-app, .dcc-app * { box-sizing: border-box; margin: 0; padding: 0; }

  /* 修正: html/bodyへの適用をやめ、.dcc-app自体を全画面固定オーバーレイにする */
  .dcc-app {
    position: fixed !important;
    inset: 0 !important;
    height: 100%;
    overflow: hidden;
    font-family: "BIZ UDGothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    z-index: 999999; /* Cocoonのヘッダー等より前面に */
    --base: #FFFFFF;
    --base-light: #FAFAFA;
    --base-dark: #F5F5F5;
    --main: #1e3a5f;
    --main-light: #2d5a8f;
    --main-dark: #0f1e3a;
    --accent: #d4af37;
    --accent-light: #f4cf5f;
    --accent-dark: #b8941f;
    --text: #2C3E50;
    --text-light: #7F8C8D;
    --border: #E8E8E8;
    --success: #10b981;
    --danger: #ef4444;
    color: var(--text);
    /* 修正: 背景画像を追加。文字・カードの視認性を保つため
       ドット地紋 → 白の半透明オーバーレイ → 背景画像 の3層構成にする */
    background-image:
      radial-gradient(rgba(30, 58, 95, 0.05) 1.2px, transparent 1.2px),
      linear-gradient(rgba(255, 255, 255, 0.86), rgba(248, 249, 250, 0.9)),
      url('https://ict-primaryschool-juniorhighschool.com/wp-content/uploads/2026/07/ChatGPT-Image-2026%E5%B9%B47%E6%9C%8815%E6%97%A5-06_19_15.jpg');
    background-size: 22px 22px, 100% 100%, cover;
    background-position: 0 0, center, center;
    background-repeat: repeat, no-repeat, no-repeat;
  }

  /* ---------- ヘッダー ---------- */
  .dcc-header {
    position: fixed !important;
    top: 0; left: 0; right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: linear-gradient(135deg, var(--main-light), var(--main));
    border-top: 3px solid var(--accent);
    border-bottom: 3px solid var(--accent);
    z-index: 10;
    overflow: hidden;
  }
  /* 修正: ヘッダーに金の光が流れるシャインエフェクト（ブランドガイド準拠） */
  .dcc-header::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.22), transparent);
    animation: dccShine 4s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes dccShine {
    0%, 60% { left: -60%; }
    100% { left: 120%; }
  }

  .dcc-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
    white-space: nowrap;
    text-shadow: 0 2px 6px rgba(0,0,0,.25);
  }

  .dcc-status { display: flex; gap: 6px; align-items: center; }

  .dcc-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
  }
  .dcc-chip b { font-size: 15px; }
  .dcc-chip-score b, .dcc-chip-combo b { color: var(--accent-light); }

  /* ---------- ステージ ---------- */
  .dcc-stage {
    position: absolute;
    top: 60px; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    padding: 12px 88px 12px 12px;
  }

  .dcc-stage-inner {
    width: 100%;
    max-width: 1040px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
  }

  /* ---------- ターゲットメダリオン + コレクショントレイ ---------- */
  .dcc-topboard {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 12px;
  }

  /* 修正: ターゲットをメダリオン風の大型表示に */
  .dcc-medallion {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 118px;
    padding: 8px 18px;
    background: var(--base);
    border: 3px solid var(--accent);
    border-radius: 18px;
    box-shadow:
      inset 0 0 0 3px #fff,
      inset 0 0 0 5px rgba(212, 175, 55, 0.35),
      0 6px 16px rgba(30, 58, 95, 0.15);
    position: relative;
  }
  .dcc-medallion .dcc-target-num {
    font-size: clamp(34px, 6vw, 46px);
    font-weight: 900;
    line-height: 1.05;
    background: linear-gradient(135deg, var(--main) 0%, var(--main-light) 55%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 3px rgba(30, 58, 95, 0.18));
  }
  .dcc-medallion .dcc-target-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--main);
    letter-spacing: 0.1em;
  }

  /* 修正: signature要素・コレクショントレイ
     見つけた約数が金のミニカードとして小さい順に並んでいく */
  .dcc-tray {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(180deg, #fffdf6, #fdf6e3);
    border: 1px solid rgba(212, 175, 55, 0.55);
    border-radius: 18px;
    box-shadow: inset 0 2px 6px rgba(184, 148, 31, 0.12);
  }
  .dcc-tray-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-dark);
    letter-spacing: 0.08em;
  }
  .dcc-tray-remain { color: var(--main); }
  .dcc-tray-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
  }
  .dcc-slot {
    min-width: 40px;
    height: 40px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 2px dashed rgba(184, 148, 31, 0.45);
    background: rgba(255, 255, 255, 0.5);
    font-size: 17px;
    font-weight: 900;
    color: transparent;
    transition: all 0.25s ease;
  }
  .dcc-slot.dcc-found {
    border: 2px solid var(--accent-dark);
    background: linear-gradient(160deg, var(--accent-light), var(--accent));
    color: var(--main-dark);
    box-shadow: 0 3px 8px rgba(184, 148, 31, 0.35), inset 0 1px 0 rgba(255,255,255,.6);
    animation: dccSlotPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  @keyframes dccSlotPop {
    0% { transform: scale(0.4) rotate(-8deg); }
    70% { transform: scale(1.15) rotate(2deg); }
    100% { transform: scale(1) rotate(0); }
  }
  /* ラウンドクリア時にトレイ全体が金色に輝く */
  .dcc-tray.dcc-complete {
    animation: dccTrayGlow 1.2s ease-in-out;
  }
  @keyframes dccTrayGlow {
    0%, 100% { box-shadow: inset 0 2px 6px rgba(184, 148, 31, 0.12); }
    40% { box-shadow: 0 0 24px 6px rgba(212, 175, 55, 0.55), inset 0 2px 6px rgba(184, 148, 31, 0.12); }
  }

  /* 修正: ライフ表示をヘッダーへ移動（紺背景向けにスタイル調整） */
  .dcc-lives {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
  }
  /* 修正: ハートを金色に（絵文字化を避けるためJS側は文字「♥」を使用） */
  .dcc-lives .heart {
    color: var(--accent-light);
    text-shadow: 0 0 6px rgba(212, 175, 55, 0.55), 0 1px 2px rgba(0, 0, 0, 0.35);
    transition: all .3s ease;
  }
  .dcc-lives .dead {
    color: rgba(255, 255, 255, 0.35);
    text-shadow: none;
    opacity: .5;
  }

  /* ---------- アリーナ ---------- */
  .dcc-arena {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--base);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 6px 20px rgba(30, 58, 95, 0.08);
    overflow: hidden; /* 修正: 縦スクロール禁止。カードは常に1画面に収める */
  }

  /* 修正: 列数固定をやめ、JSが計算した列数・カードサイズで敷き詰める
     （--dccCols / --dccCardW / --dccCardH / --dccCardFont はJSが設定） */
  .dcc-cards-grid {
    height: 100%;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(var(--dccCols, 5), var(--dccCardW, 1fr));
    gap: 12px;
    justify-content: center;
    align-content: center;
    perspective: 900px; /* カードフリップ演出用 */
  }

  /* 修正: トレーディングカード風デザイン
     二重枠（ネイビー外枠 + 内側の金ライン）+ 四隅の飾り
     サイズはJSが画面に収まるよう計算した値（CSS変数）を使用 */
  .dcc-card {
    width: var(--dccCardW, 90px);
    height: var(--dccCardH, 120px);
    border-radius: 13px;
    background: linear-gradient(160deg, #ffffff 0%, #fdfaf1 100%);
    border: 2px solid var(--main-light);
    box-shadow:
      inset 0 0 0 4px #fff,
      inset 0 0 0 5px rgba(212, 175, 55, 0.55),
      0 4px 10px rgba(30, 58, 95, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: var(--dccCardFont, 24px);
    color: var(--main-dark);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    /* カードを配るフリップ演出（遅延はJSが--dで指定） */
    animation: dccDeal 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
    animation-delay: var(--d, 0ms);
  }
  @keyframes dccDeal {
    from { transform: translateY(-16px) rotateY(90deg); opacity: 0; }
    to   { transform: translateY(0) rotateY(0deg); opacity: 1; }
  }
  /* 四隅の小さなダイヤ飾り（CSSのみ・擬似要素） */
  .dcc-card::before, .dcc-card::after {
    content: '';
    position: absolute;
    width: 7px; height: 7px;
    background: var(--accent);
    transform: rotate(45deg);
    opacity: 0.7;
  }
  .dcc-card::before { top: 9px; left: 9px; }
  .dcc-card::after  { bottom: 9px; right: 9px; }

  .dcc-card:active { transform: scale(0.95); }
  @media (hover: hover) {
    .dcc-card:hover {
      transform: translateY(-4px);
      box-shadow:
        inset 0 0 0 4px #fff,
        inset 0 0 0 5px rgba(212, 175, 55, 0.8),
        0 10px 20px rgba(30, 58, 95, 0.22);
    }
  }

  .dcc-card.dcc-flash {
    animation: dccCardFlash 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 5;
  }
  @keyframes dccCardFlash {
    0% { transform: scale(1); }
    30% {
      transform: scale(1.12);
      box-shadow: 0 0 30px 10px rgba(212, 175, 55, 0.7);
      background: linear-gradient(135deg, var(--accent-light), var(--accent));
    }
    100% { transform: scale(0.7); opacity: 0; }
  }
  .dcc-card.dcc-miss { animation: dccCardMiss 0.4s ease; }
  @keyframes dccCardMiss {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-8px) rotate(-2deg); }
    50% { transform: translateX(8px) rotate(2deg); }
    75% { transform: translateX(-5px) rotate(-1deg); }
  }
  .dcc-card.dcc-cleared { visibility: hidden; pointer-events: none; }

  /* 浮動テキスト */
  .dcc-float {
    position: absolute;
    font-weight: 900;
    font-size: 20px;
    z-index: 20;
    pointer-events: none;
    animation: dccFloatUp 1.6s ease-out forwards;
  }
  .dcc-float.dcc-good { color: var(--success); }
  .dcc-float.dcc-bad { color: var(--danger); }
  .dcc-float.dcc-clear {
    left: 50%; top: 40%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    color: var(--accent-dark);
    text-shadow: 0 2px 6px rgba(212, 175, 55, 0.5);
    animation: dccClear 1.8s ease-out forwards;
  }
  @keyframes dccFloatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(1.2); opacity: 0; }
  }
  @keyframes dccClear {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
  }

  /* アリーナ内オーバーレイ */
  .dcc-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 30, 58, 0.86);
    color: #fff;
    display: none !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    padding: 20px;
    z-index: 30;
    border-radius: 18px;
  }
  .dcc-overlay.dcc-show { display: flex !important; }
  .dcc-overlay h2 { font-size: 24px; color: var(--accent-light); }
  .dcc-overlay p { font-size: 15px; }
  .dcc-overlay .dcc-start-btn { width: auto; padding: 12px 28px; margin-top: 6px; }

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

  /* ---------- モーダル ---------- */
  .dcc-modal {
    position: fixed !important; inset: 0;
    background: rgba(15, 30, 58, 0.55);
    display: none !important;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
  }
  .dcc-modal.dcc-show { display: flex !important; }

  .dcc-modal-card {
    position: relative;
    background: var(--base);
    color: var(--main);
    border-radius: 20px;
    padding: 30px 26px 26px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
  }
  .dcc-modal-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
  }
  .dcc-modal-title {
    font-size: 19px;
    font-weight: 700;
    border-left: 6px solid var(--accent);
    padding-left: 10px;
    margin-bottom: 20px;
  }
  .dcc-practice-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    padding: 12px;
    background: var(--base-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 20px;
    cursor: pointer;
  }
  .dcc-practice-label input { width: 20px; height: 20px; accent-color: var(--main); flex: 0 0 auto; }

  .dcc-start-btn {
    display: block;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
    color: var(--main-dark);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.35);
  }
  .dcc-start-btn:active { transform: scale(0.98); }

  /* 動きを抑える設定への配慮 */
  @media (prefers-reduced-motion: reduce) {
    .dcc-app * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }

  /* ---------- レスポンシブ ---------- */
  @media (max-width: 700px) {
    .dcc-title { font-size: 13px; }
    .dcc-chip { padding: 4px 8px; font-size: 10px; }
    .dcc-chip b { font-size: 13px; }
    .dcc-status { gap: 4px; }
    .dcc-lives { font-size: 12px; padding: 3px 7px; gap: 3px; }
    .dcc-stage { padding: 8px 76px 8px 8px; }
    .dcc-tool { width: 48px; height: 48px; font-size: 20px; }
    .dcc-topboard { flex-direction: row; }
    .dcc-medallion { min-width: 92px; padding: 6px 12px; }
    .dcc-slot { min-width: 34px; height: 34px; font-size: 14px; }
  }


.hidden { display: none !important; }
