/* ==========================================================================
   My Custom Popup - Final Style (High Priority)
   ========================================================================== */

/* 全体を覆うラッパー：displayはJSで制御するため !important は付けない */
.mcp-popup-wrapper {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999999 !important; /* 他の要素に負けない超高層 */
    display: none;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    pointer-events: auto !important;
}

/* JSでこのクラスが付いた時だけ表示 */
.mcp-popup-wrapper.mcp-shown {
    display: flex !important;
}

/* 背景（オーバーレイ） */
.mcp-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.75) !important; /* 少し濃くして視認性アップ */
    cursor: pointer !important;
    z-index: 1 !important;
}

/* ポップアップ本体 */
.mcp-container {
    position: relative !important;
    background: #ffffff !important;
    padding: 0 !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
    width: auto !important;
    max-width: 95% !important;
    max-height: 90vh !important;
    z-index: 2 !important;
    border-radius: 12px !important; /* 少し柔らかい印象に */
    overflow-y: auto !important;
    animation: mcpFadeIn 0.3s ease-out !important;
    display: flex !important;
    flex-direction: column !important;
    color: #333 !important;
}

/* コンテンツ内部 */
.mcp-content {
    width: 100% !important;
    overflow-x: hidden !important;
}

.mcp-content img {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
}

/* 文字周りの余白（サニタイズ対策） */
.mcp-content p, 
.mcp-content h1, .mcp-content h2, .mcp-content h3 {
    margin: 1em 25px !important;
    line-height: 1.6 !important;
    color: #333 !important;
}

/* 閉じるボタン（デザインを維持しつつ強化） */
.mcp-close-btn {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    background: rgba(0,0,0,0.5) !important;
    color: #ffffff !important;
    border: 2px solid #fff !important; /* 視認性向上のための白枠 */
    font-size: 24px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    cursor: pointer !important;
    z-index: 10 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    transition: all 0.2s !important;
}

.mcp-close-btn:hover {
    background: rgba(0,0,0,0.8) !important;
    transform: scale(1.1);
}

/* アニメーション */
@keyframes mcpFadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* スライドインモード用の調整 */
.mcp-mode-slide-in {
    justify-content: flex-end !important;
    align-items: flex-end !important;
    padding: 0 !important;
    pointer-events: none !important;
}
.mcp-mode-slide-in .mcp-overlay {
    display: none !important;
}
.mcp-mode-slide-in .mcp-container {
    margin: 20px !important;
    pointer-events: auto !important;
    animation: mcpSlideUp 0.4s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

@keyframes mcpSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}