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

  /* ==============================
     約数カードコレクターと同じデザインシステム
     （固定ヘッダー + 全画面ステージ + 右下ツールバー + モーダル + コレクショントレイ）
     2つの数字を扱うため、メダリオンだけ「AとB」表示用に調整
     ブランドカラー: 白ベース70% + ネイビー25% + ゴールド5%
     ============================== */
  /* 修正: 全称セレクタは .cdc-app 内だけに限定（サイト全体を壊さないため） */
.cdc-app, .cdc-app * { box-sizing: border-box; margin: 0; padding: 0; }

  /* 修正: html/bodyへの適用をやめ、.cdc-app自体を全画面固定オーバーレイにする */
  .cdc-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);
    background-image:
      radial-gradient(rgba(30, 58, 95, 0.05) 1.2px, transparent 1.2px),
      linear-gradient(135deg, #FFFFFF 0%, #F8F9FA 50%, #F0F2F5 100%);
    background-size: 22px 22px, 100% 100%;
  }

  /* ---------- ヘッダー ---------- */
  .cdc-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;
  }
  .cdc-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: cdcShine 4s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes cdcShine {
    0%, 60% { left: -60%; }
    100% { left: 120%; }
  }

  .cdc-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);
  }

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

  .cdc-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;
  }
  .cdc-chip b { font-size: 15px; }
  .cdc-chip-score b, .cdc-chip-combo b { color: var(--accent-light); }

  .cdc-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);
  }
  .cdc-lives .heart { color: var(--accent-light); text-shadow: 0 0 6px rgba(212, 175, 55, 0.55), 0 1px 2px rgba(0,0,0,.35); }
  .cdc-lives .dead { color: rgba(255, 255, 255, 0.35); text-shadow: none; opacity: .5; }

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

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

  /* ---------- メダリオン(2数字) + コレクショントレイ ---------- */
  .cdc-topboard {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 12px;
  }

  /* 修正: 約数版と違い2つの数字を扱うため横幅を広めに確保 */
  .cdc-medallion {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 150px;
    padding: 8px 16px;
    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;
  }
  .cdc-medallion .cdc-target-pair {
    display: flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
  }
  .cdc-medallion .cdc-target-num {
    font-size: clamp(24px, 4.6vw, 34px);
    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));
  }
  .cdc-medallion .cdc-target-and {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-light);
  }
  .cdc-medallion .cdc-target-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--main);
    letter-spacing: 0.1em;
    margin-top: 2px;
  }

  .cdc-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);
  }
  .cdc-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;
  }
  .cdc-tray-remain { color: var(--main); }
  .cdc-tray-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
  }
  .cdc-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;
  }
  .cdc-slot.cdc-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: cdcSlotPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  @keyframes cdcSlotPop {
    0% { transform: scale(0.4) rotate(-8deg); }
    70% { transform: scale(1.15) rotate(2deg); }
    100% { transform: scale(1) rotate(0); }
  }
  .cdc-tray.cdc-complete { animation: cdcTrayGlow 1.2s ease-in-out; }
  @keyframes cdcTrayGlow {
    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); }
  }

  /* ---------- アリーナ ---------- */
  .cdc-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; /* 縦スクロールなし */
  }

  .cdc-cards-grid {
    height: 100%;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(var(--cdcCols, 4), var(--cdcCardW, 1fr));
    gap: 12px;
    justify-content: center;
    align-content: center;
    perspective: 900px;
  }

  .cdc-card {
    width: var(--cdcCardW, 90px);
    height: var(--cdcCardH, 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(--cdcCardFont, 24px);
    color: var(--main-dark);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    animation: cdcDeal 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
    animation-delay: var(--d, 0ms);
  }
  @keyframes cdcDeal {
    from { transform: translateY(-16px) rotateY(90deg); opacity: 0; }
    to   { transform: translateY(0) rotateY(0deg); opacity: 1; }
  }
  .cdc-card::before, .cdc-card::after {
    content: '';
    position: absolute;
    width: 7px; height: 7px;
    background: var(--accent);
    transform: rotate(45deg);
    opacity: 0.7;
  }
  .cdc-card::before { top: 9px; left: 9px; }
  .cdc-card::after  { bottom: 9px; right: 9px; }

  .cdc-card:active { transform: scale(0.95); }
  @media (hover: hover) {
    .cdc-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);
    }
  }

  .cdc-card.cdc-flash {
    animation: cdcCardFlash 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 5;
  }
  @keyframes cdcCardFlash {
    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; }
  }
  .cdc-card.cdc-miss { animation: cdcCardMiss 0.4s ease; }
  @keyframes cdcCardMiss {
    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); }
  }
  .cdc-card.cdc-cleared { visibility: hidden; pointer-events: none; }

  .cdc-float {
    position: absolute;
    font-weight: 900;
    font-size: 20px;
    z-index: 20;
    pointer-events: none;
    animation: cdcFloatUp 1.6s ease-out forwards;
  }
  .cdc-float.cdc-good { color: var(--success); }
  .cdc-float.cdc-bad { color: var(--danger); }
  .cdc-float.cdc-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: cdcClear 1.8s ease-out forwards;
  }
  @keyframes cdcFloatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(1.2); opacity: 0; }
  }
  @keyframes cdcClear {
    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; }
  }

  .cdc-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;
  }
  .cdc-overlay.cdc-show { display: flex !important; }
  .cdc-overlay h2 { font-size: 24px; color: var(--accent-light); }
  .cdc-overlay p { font-size: 15px; }
  .cdc-overlay .cdc-start-btn { width: auto; padding: 12px 28px; margin-top: 6px; }

  /* ---------- 右下ツールバー ---------- */
  .cdc-toolbar {
    position: fixed !important;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
  }
  .cdc-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;
  }
  .cdc-tool:active { transform: scale(0.92); }
  .cdc-tool:disabled { opacity: 0.4; cursor: not-allowed; }
  .cdc-tool-main { background: var(--accent); color: var(--main-dark); }

  /* ---------- モーダル ---------- */
  .cdc-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;
  }
  .cdc-modal.cdc-show { display: flex !important; }

  .cdc-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;
  }
  .cdc-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));
  }
  .cdc-modal-title {
    font-size: 19px;
    font-weight: 700;
    border-left: 6px solid var(--accent);
    padding-left: 10px;
    margin-bottom: 20px;
  }
  .cdc-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;
  }
  .cdc-practice-label input { width: 20px; height: 20px; accent-color: var(--main); flex: 0 0 auto; }

  .cdc-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);
  }
  .cdc-start-btn:active { transform: scale(0.98); }

  @media (prefers-reduced-motion: reduce) {
    .cdc-app * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }

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


.hidden { display: none !important; }
