/* 🎮 かわいいクイズフロントエンドスタイル（モーダル対応＆元デザイン完全再現版） */

/* ========== プレースホルダー（高さ確保） ========== */
.cute-quiz-placeholder {
    min-height: 650px !important;
    display: block !important;
    position: relative !important;
    margin: 40px 0 !important;
    clear: both !important;
    overflow: visible !important;
}

/* ========== クイズラッパー ========== */
.cute-quiz-wrapper {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    clear: both !important;
    float: none !important;
    position: relative !important;
    z-index: 1 !important;
}

/* ========== クイズコンテナ（元の#cute-quizと同じスタイル） ========== */
.cute-quiz-container {
    display: block !important;
    width: 440px !important; /* 固定幅に変更 */
    max-width: 90vw !important; /* モバイル対応 */
    margin: 32px auto !important;
    background: #fffefa;
    border-radius: 18px;
    box-shadow: 0 4px 20px rgba(137, 171, 151, 0.2); /* コーポレートカラーに変更 */
    padding: 24px 16px 38px 16px;
    text-align: center;
    font-size: 1em;
    box-sizing: border-box;
    position: relative !important;
    z-index: 1 !important;
    float: none !important;
    clear: both !important;
}

/* データ読み込み前は透明に */
.cute-quiz-container[data-quiz-loaded="false"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* データ読み込み後に表示 */
.cute-quiz-container[data-quiz-loaded="true"] {
    opacity: 1;
}

/* ========== モーダル関連のスタイル ========== */
.cute-quiz-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 999999 !important;
    display: none;
}

.cute-quiz-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 999999 !important;
}

.cute-quiz-modal-content {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: white !important;
    padding: 20px !important;
    border-radius: 20px !important;
    max-width: 90% !important;
    max-height: 90% !important;
    overflow-y: auto !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    z-index: 1000000 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.cute-quiz-modal-close {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    width: 40px !important;
    height: 40px !important;
    background: #89AB97 !important; /* コーポレートカラー */
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    font-size: 24px !important;
    line-height: 40px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 1000001 !important;
    transition: all 0.3s !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.cute-quiz-modal-close:hover {
    background: #7A9A88 !important;
    transform: scale(1.1) !important;
}

/* モーダル内のクイズコンテナ調整 */
.cute-quiz-modal .cute-quiz-container {
    margin: 0 auto !important;
    width: 440px !important;
    max-width: 95vw !important;
}

.cute-quiz-modal .cute-quiz-placeholder {
    min-height: auto !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* クイズ開始ボタン */
.cute-quiz-popup-trigger {
    background: #E5B458; /* コーポレートカラーに戻す */
    color: white;
    padding: 20px 40px 20px 80px; /* 左側のパディングを増やす */
    border: none;
    border-radius: 15px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(137, 171, 151, 0.3);
    transition: all 0.3s;
    display: block; /* blockに変更 */
    position: relative;
    overflow: visible;
    max-width: 600px;
    margin: 20px auto;
    text-align: center;
}

.cute-quiz-popup-trigger:hover {
    background: #E5B458;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(137, 171, 151, 0.4);
}

/* キャラクターアイコン */
.cute-quiz-popup-trigger::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background-image: url('https://naruhodoagent.com/wp-content/uploads/2023/09/スクリーンショット-2023-09-14-14.13.21.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: characterSwing 2s ease-in-out infinite;
    z-index: 1;
}

/* より楽しげな揺れアニメーション */
@keyframes characterSwing {
    0%, 100% {
        transform: translateY(-50%) rotate(-8deg) scale(1);
    }
    25% {
        transform: translateY(-52%) rotate(8deg) scale(1.05);
    }
    50% {
        transform: translateY(-50%) rotate(-8deg) scale(1);
    }
    75% {
        transform: translateY(-52%) rotate(8deg) scale(1.05);
    }
}

/* ボタンのメインテキスト */
.quiz-button-main-text {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 8px;
    display: block;
}

/* ティッカー部分のコンテナ */
.quiz-ticker-container {
    height: 24px;
    overflow: hidden;
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* ティッカーのテキスト */
.quiz-ticker-text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 14px;
    line-height: 24px;
    opacity: 0;
    transform: translateY(30px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

/* 各テキストのアニメーションタイミング */
.quiz-ticker-text:nth-child(1) {
    animation: tickerSlide 25s infinite 0s;
}

.quiz-ticker-text:nth-child(2) {
    animation: tickerSlide 25s infinite 5s;
}

.quiz-ticker-text:nth-child(3) {
    animation: tickerSlide 25s infinite 10s;
}

.quiz-ticker-text:nth-child(4) {
    animation: tickerSlide 25s infinite 15s;
}

.quiz-ticker-text:nth-child(5) {
    animation: tickerSlide 25s infinite 20s;
}

/* ティッカーアニメーション */
@keyframes tickerSlide {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    4%, 16% {
        opacity: 1;
        transform: translateY(0);
    }
    20% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px);
    }
}

/* ボタンの内部構造 */
.quiz-button-content {
    display: block;
    width: 100%;
}

/* ========== 元のデザインのスタイルをそのまま適用 ========== */

/* メインブロック */
.cute-quiz-container .cq-main {
    position: static !important;
    z-index: 1 !important;
}

/* クリア画面 */
.cute-quiz-container .cq-clear {
    position: static !important;
    z-index: 1 !important;
    margin-top: 32px;
}

/* スター */
.cute-quiz-container .cq-stars {
    margin-bottom: 10px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    position: static !important;
}

.cute-quiz-container .cq-star {
    font-size: 2.1em;
    color: #e0e0e0;
    text-shadow: 0 2px 16px rgba(224, 224, 224, 0.13), 0 0px 8px rgba(255, 253, 230, 0.07);
    transition: color .22s, text-shadow .18s;
    opacity: 1;
    transform: scale(1);
    display: inline-block;
}

.cute-quiz-container .cq-star.cq-on {
    color: #ffe66b;
    text-shadow: 0 2px 14px rgba(255, 219, 109, 0.33), 0 1px 10px rgba(255, 230, 107, 0.67);
    animation: cqStarPop .45s cubic-bezier(.26, 2.1, .7, 1.05) forwards;
}

@keyframes cqStarPop {
    0% {
        opacity: 1;
        transform: scale(0.7) rotate(-40deg);
    }
    55% {
        opacity: 1;
        transform: scale(1.22) rotate(16deg);
    }
    85% {
        transform: scale(.98) rotate(-8deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

/* スコア */
.cute-quiz-container .cq-score {
    color: #ff8c3e;
    font-size: 1.13em;
    font-weight: bold;
    margin: 10px 0 13px 0;
    position: static !important;
}

/* クイズ画像 */
.cute-quiz-container .cq-qimgwrap {
    display: flex;
    justify-content: center;
    align-items: center;
    position: static !important;
}

.cute-quiz-container .cq-qimg {
    width: 136px;
    height: 136px;
    object-fit: contain;
    margin: 4px auto 10px auto;
    display: block;
    transition: transform .24s;
    position: static !important;
    z-index: 1;
}

.cute-quiz-container .cq-qimg.cq-anim {
    animation: cqJump 0.65s;
}

@keyframes cqJump {
    0% { transform: scale(1); }
    20% { transform: scale(1.22); }
    40% { transform: scale(.96); }
    60% { transform: scale(1.11); }
    100% { transform: scale(1); }
}

.cute-quiz-container .cq-qimg.cq-sad {
    animation: cqSad .7s;
}

@keyframes cqSad {
    0% { transform: rotate(0deg) scale(1); }
    30% { transform: rotate(-16deg) scale(.85); }
    80% { transform: rotate(-8deg) scale(.9); }
    100% { transform: rotate(0deg) scale(1); }
}

/* 吹き出し */
.cute-quiz-container .cq-balloon-wrap {
    display: flex;
    justify-content: center;
    position: static !important;
}

.cute-quiz-container .cq-balloon {
    background: #fff;
    border-radius: 20px;
    position: relative;
    min-width: 60%;
    display: inline-block;
    margin-bottom: 18px;
    box-shadow: 0 2px 8px rgba(242, 136, 62, 0.09);
    padding: 18px 22px 18px 22px;
    text-align: left;
    font-size: 1.08em;
    font-weight: bold;
    color: #333;
    line-height: 1.7;
    z-index: 2;
}

.cute-quiz-container .cq-balloon:after {
    content: "";
    position: absolute;
    left: 35px;
    bottom: -16px;
    border: 12px solid transparent;
    border-top: 18px solid #fff;
    filter: drop-shadow(0 1px 5px rgba(242, 136, 62, 0.1));
    z-index: 2;
}

/* 選択肢 */
.cute-quiz-container .cq-choices {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    position: static !important;
}

.cute-quiz-container .cq-choice {
    background: #C9EDE8; /* 指定の背景色に変更 */
    border-radius: 14px;
    border: none;
    color: #5A5A5A;
    font-size: 1.11em;
    font-weight: bold;
    padding: 15px 20px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(137, 171, 151, 0.1);
    transition: background .13s, transform .11s;
    outline: none;
    letter-spacing: 0.02em;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    position: static !important;
    text-align: center; /* テキストを中央揃え */
    width: 100%; /* 幅を統一 */
}

.cute-quiz-container .cq-choice:hover {
    background: #B8E2DB;
    transform: translateY(-2px);
}

.cute-quiz-container .cq-choice:active {
    transform: scale(1.02);
}

.cute-quiz-container .cq-choice.cq-correct {
    background: #5AB7B2; /* 正解時の色を指定色に変更 */
    color: #fff;
    animation: cqBounce .7s;
}

.cute-quiz-container .cq-choice.cq-wrong {
    background: #e1e1e1;
    color: #bbb;
    animation: cqShake .5s;
}

@keyframes cqBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.18); }
    60% { transform: scale(.95); }
    100% { transform: scale(1); }
}

@keyframes cqShake {
    10% { transform: translateX(-7px); }
    20% { transform: translateX(7px); }
    30% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    100% { transform: translateX(0); }
}

/* フィードバック */
.cute-quiz-container .cq-feedback {
    min-height: 39px;
    font-size: 1.19em;
    font-weight: bold;
    margin-bottom: 8px;
    position: static !important;
}

.cute-quiz-container .cq-stamp {
    color: #5AB7B2; /* 正解時のフィードバックも同じ色に */
}

/* 次へボタン */
.cute-quiz-container .cq-next {
    background: #89AB97; /* コーポレートカラー */
    color: #fff;
    font-weight: bold;
    border-radius: 16px;
    padding: 11px 33px;
    border: none;
    margin-top: 10px;
    font-size: 1em;
    cursor: pointer;
    box-shadow: 0 2px 9px rgba(137, 171, 151, 0.2);
    position: static !important;
    transition: all 0.3s;
}

.cute-quiz-container .cq-next:hover {
    background: #7A9A88;
    transform: translateY(-2px);
}

/* プログレスバー */
.cute-quiz-container .cq-bar-wrap {
    position: relative;
    height: 14px;
    width: 100%;
    margin: 15px 0 0 0;
}

.cute-quiz-container .cq-bar-bg {
    width: 100%;
    height: 12px;
    background: #E8E8E8;
    border-radius: 8px;
    overflow: hidden;
    position: absolute;
    left: 0;
    top: 0;
}

.cute-quiz-container .cq-bar-inner {
    height: 12px;
    background: #89AB97; /* コーポレートカラー */
    border-radius: 8px;
    width: 100%;
    transition: width .18s;
}

/* クリア画面 */
.cute-quiz-container .cq-clearimg {
    margin-top: 2px;
    max-width: 240px;
    width: 92%;
    border-radius: 13px;
    box-shadow: 0 4px 14px rgba(137, 171, 151, 0.15);
}

.cute-quiz-container .cq-cleartitle {
    font-size: 1.33em;
    color: #89AB97; /* コーポレートカラー */
    margin-bottom: 8px;
    font-weight: bold;
}

.cute-quiz-container .cq-clearsub {
    font-size: 1.11em;
    color: #7A9A88;
    margin-bottom: 8px;
    font-weight: bold;
}

.cute-quiz-container .cq-retry {
    margin: 18px auto 0 auto;
    background: #89AB97; /* コーポレートカラー */
    color: #fff;
    font-weight: bold;
    border: none;
    font-size: 1.1em;
    padding: 13px 34px 12px 34px;
    border-radius: 19px;
    box-shadow: 0 3px 12px rgba(137, 171, 151, 0.2);
    cursor: pointer;
    transition: background .13s;
}

.cute-quiz-container .cq-retry:hover {
    background: #7A9A88;
}

.cute-quiz-container .cq-cleargroup {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cute-quiz-container .cq-clearstars {
    margin-bottom: 7px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

/* モアインフォ（元のデザインに追加可能） */
.cute-quiz-container .cq-moreinfo {
    margin: 24px 0 0 0;
    font-size: 1.01em;
    color: #36a;
    font-weight: bold;
    display: block;
}

.cute-quiz-container .cq-moreinfo a {
    color: #07a;
    text-decoration: underline;
}

/* ローディング */
.quiz-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* レスポンシブ対応（元のデザインと同じ） */
@media (max-width: 500px) {
    .cute-quiz-container {
        font-size: 0.80em;
        width: 95vw !important; /* モバイルでは画面幅の95%に */
        max-width: 400px !important; /* 最大幅を制限 */
        margin: 20px auto !important; /* 中央配置を確実に */
    }
    .cute-quiz-container .cq-qimg {
        width: 88px;
        height: 88px;
    }
    .cute-quiz-container .cq-clearimg {
        max-width: 90px;
    }
    .cute-quiz-container .cq-balloon {
        font-size: 1em;
        padding: 13px 8px;
    }
    .cute-quiz-container .cq-cleartitle {
        font-size: 1.09em;
    }
    .cute-quiz-container .cq-clearsub {
        font-size: 0.99em;
    }
    
    /* モバイルでのボタン調整 */
    .cute-quiz-popup-trigger {
        min-width: 300px;
        font-size: 18px;
        padding: 20px 40px 20px 70px;
    }
    
    .cute-quiz-popup-trigger::before {
        width: 50px;
        height: 50px;
        left: 5px;
    }
    
    .quiz-button-main-text {
        font-size: 18px;
    }
    
    .quiz-ticker-text {
        font-size: 12px;
    }
}

@media (max-width: 400px) {
    .cute-quiz-container {
        width: 98vw !important; /* さらに小さな画面では98%に */
        max-width: 350px !important;
        margin: 15px auto !important;
        padding: 20px 12px 30px 12px !important; /* パディングも調整 */
    }
    
    .cute-quiz-container .cq-choice {
        font-size: 0.9em;
        padding: 10px 6px;
        line-height: 1.2;
    }
    
    .cute-quiz-container .cq-balloon {
        font-size: 1.02em;
        padding: 16px 18px;
    }
}

/* ========== Elementor対策 ========== */
.elementor-widget .cute-quiz-wrapper,
.elementor-widget-container .cute-quiz-wrapper,
.elementor-shortcode .cute-quiz-wrapper {
    position: static !important;
    z-index: 1 !important;
}

.elementor-widget .cute-quiz-container,
.elementor-widget-container .cute-quiz-container,
.elementor-shortcode .cute-quiz-container {
    position: static !important;
    z-index: 1 !important;
}

/* ========== 強制的な重なり防止 ========== */

/* すべてのクイズ関連要素を含むコンテナに境界を設定 */
.cute-quiz-placeholder::before,
.cute-quiz-placeholder::after {
    content: "";
    display: table;
    clear: both;
}

/* 次の要素への影響を完全に遮断 */
.cute-quiz-placeholder {
    contain: layout style;
    isolation: isolate;
}

/* Elementor環境での追加対策 */
.elementor-widget .cute-quiz-placeholder {
    min-height: 700px !important;
}

/* 次の要素を確実に下に配置 */
.cute-quiz-placeholder + * {
    clear: both !important;
    position: relative !important;
    margin-top: 20px !important;
}

/* ========== z-index競合対策 ========== */

/* 他の要素よりも確実に前面に表示 */
body.quiz-modal-open {
    overflow: hidden !important;
}

/* 特定の要素のz-indexを調整 */
.cute-quiz-modal {
    z-index: 2147483647 !important; /* 最大値に近い値 */
}

.cute-quiz-modal-overlay {
    z-index: 2147483646 !important;
}

.cute-quiz-modal-content {
    z-index: 2147483647 !important;
}

/* Elementorの要素より前面に */
.elementor-widget,
.elementor-element,
.elementor-top-section {
    z-index: auto !important;
}

/* WordPressの管理バーよりも前面に */
#wpadminbar {
    z-index: 99999 !important;
}

/* その他の一般的な要素のz-index調整 */
.cute-quiz-modal.active,
.cute-quiz-modal:not([style*="display: none"]) {
    z-index: 2147483647 !important;
}

/* スマホ表示での左右パディング追加 */
@media (max-width: 500px) {
    .cute-quiz-container {
        font-size: 0.80em;
        width: calc(95vw - 20px) !important; /* 左右10pxずつパディングを考慮 */
        max-width: calc(400px - 20px) !important; /* 最大幅からもパディングを引く */
        margin: 20px 10px !important; /* 左右10pxのマージン */
        padding: 20px 12px 30px 12px !important; /* 内部パディングはそのまま */
    }
    
    /* モーダル内でのスマホ表示調整 */
    .cute-quiz-modal .cute-quiz-container {
        width: calc(95vw - 20px) !important;
        max-width: calc(350px - 20px) !important;
        margin: 0 10px !important;
    }
    
    .cute-quiz-container .cq-qimg {
        width: 88px;
        height: 88px;
    }
    .cute-quiz-container .cq-clearimg {
        max-width: 90px;
    }
    .cute-quiz-container .cq-balloon {
        font-size: 1em;
        padding: 13px 8px;
    }
    .cute-quiz-container .cq-cleartitle {
        font-size: 1.09em;
    }
    .cute-quiz-container .cq-clearsub {
        font-size: 0.99em;
    }
    
    /* モバイルでのボタン調整 */
    .cute-quiz-popup-trigger {
        min-width: calc(300px - 20px);
        font-size: 18px;
        padding: 20px 40px 20px 70px;
        margin: 20px 10px; /* 左右10pxのマージン */
    }
    
    .cute-quiz-popup-trigger::before {
        width: 50px;
        height: 50px;
        left: 5px;
    }
    
    .quiz-button-main-text {
        font-size: 18px;
    }
    
    .quiz-ticker-text {
        font-size: 12px;
    }
}

@media (max-width: 400px) {
    .cute-quiz-container {
        width: calc(98vw - 20px) !important; /* さらに小さな画面でも左右10pxパディング */
        max-width: calc(350px - 20px) !important;
        margin: 15px 10px !important; /* 左右10pxのマージン */
        padding: 20px 12px 30px 12px !important;
    }
    
    /* モーダル内でのより小さな画面調整 */
    .cute-quiz-modal .cute-quiz-container {
        width: calc(98vw - 20px) !important;
        max-width: calc(320px - 20px) !important;
        margin: 0 10px !important;
    }
    
    .cute-quiz-container .cq-choice {
        font-size: 0.9em;
        padding: 10px 6px;
        line-height: 1.2;
    }
    
    .cute-quiz-container .cq-balloon {
        font-size: 1.02em;
        padding: 16px 18px;
    }
    
    /* ポップアップトリガーボタンの調整 */
    .cute-quiz-popup-trigger {
        min-width: calc(280px - 20px);
        margin: 15px 10px;
        padding: 15px 35px 15px 60px;
    }
}