@charset "UTF-8";

/* =========================================
   基本設定 & フォント読み込み (Isolation Mode)
========================================= */
@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700&display=swap');

:root {
    --tp-primary-color: #ff6b81;
    --tp-secondary-color: #FFD700;
    --tp-text-color: #333;
    --tp-bg-color: #f9f9f9;
    --tp-card-bg: #fff;
    --tp-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --tp-hover-shadow: 0 8px 25px rgba(255, 107, 129, 0.2);
    --tp-border-radius: 16px;
    --tp-font-family: 'M PLUS Rounded 1c', sans-serif;
}

/* 
   ----------------------------------------------------
   ISOLATION BOOTSTRAP: 
   テーマCSSからの影響を徹底的に排除するリセットスタイル
   (Unified with Main Container block below)
   ----------------------------------------------------
*/

/* 子要素全てにbox-sizing強制 */
.toretame-poll-container * {
    box-sizing: border-box !important;
}

/* ... (Intermediate code) ... */

/* =========================================
   1. メインコンテナ (Main Container)
   ========================================= */
.toretame-poll-container {
    /* all: initial 撤去 & 定義統一 */
    box-sizing: border-box !important;
    font-family: var(--tp-font-family) !important;
    display: block;
    width: 100% !important;
    /* Added: Force full width */
    max-width: 800px;
    background-color: #fff !important;
    border: none !important;
    color: var(--tp-text-color);
    line-height: 1.5;
    position: relative;
    overflow: visible;
    /* Vertical overflow visible for crowns etc */
    overflow-x: hidden !important;
    /* Added: Prevent horizontal scroll */
    margin: 12px auto !important;
    /* Unified margin */
    padding: 20px;
    border-radius: 12px !important;
    /* Unified radius */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.toretame-poll-container *,
.toretame-poll-container *::before,
.toretame-poll-container *::after {
    box-sizing: border-box !important;
}

/* ... (Intermediate code) ... */



/* 画像リセット：テーマのGlobal IMGスタイルを無効化 */
/* width/height は各画像クラスで個別に制御するため、ここでは設定しない */
.toretame-poll-container img {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    max-width: none !important;
    max-height: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    display: block !important;
    position: static !important;
}

/* タイトル */
.toretame-poll-title {
    text-align: center !important;
    font-size: 1.8rem !important;
    font-weight: 700 !important;
    margin: 0 0 25px 0 !important;
    padding: 0 !important;
    color: var(--tp-primary-color) !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.4 !important;
    border: none !important;
}

/* =========================================
   1. 投票前：グリッドデザイン (Grid)
========================================= */
.toretame-poll-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 20px !important;
    margin-bottom: 30px !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 0 !important;
}

/* 投票後は確実に非表示 */
.toretame-poll-container.has-voted .toretame-poll-grid {
    display: none !important;
}





/* ネームスペース付きクラス */
.tp-poll-card {
    background: var(--tp-card-bg) !important;
    border-radius: var(--tp-border-radius) !important;
    padding: 15px !important;
    text-align: center !important;
    box-shadow: var(--tp-shadow) !important;
    transition: all 0.3s ease;
    border: 2px solid transparent !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    height: auto !important;
    width: 100% !important;
    margin: 0 !important;
}

.tp-poll-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--tp-hover-shadow) !important;
    border-color: var(--tp-primary-color) !important;
}

/* Rank 1 Highlight (Card) */
.tp-poll-card.rank-1 {
    border: 2px solid var(--tp-secondary-color) !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4) !important;
    z-index: 5 !important;
}

/* 画像ラッパー (強制正方形) */
.tp-poll-card-image-wrapper {
    margin: 0 0 12px 0 !important;
    padding: 0 !important;
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 1 / 1 !important;
    overflow: hidden !important;
    border-radius: 12px !important;
    background: #f0f0f0;
    /* Pure CSS Approach: Flexbox Centering */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* カード画像 — JS が aspect ratio に基づき width/height を設定 (admin preview と同一ロジック) */
.toretame-poll-container img.tp-poll-card-image {
    /* JS applyCoverSizing が width or height を設定するまで非表示 */
    flex-shrink: 0 !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    display: block !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform-origin: center center !important;
    object-fit: fill !important;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tp-poll-card-name {
    font-weight: 700 !important;
    font-size: 1.2rem !important;
    /* フォントサイズUP */
    margin: 0 0 15px 0 !important;
    padding: 0 !important;
    color: var(--tp-text-color) !important;
    line-height: 1.4 !important;
    width: 100%;
    word-break: break-word !important;
    border: none !important;
    background: none !important;
}

/* 投票ボタン */
.tp-poll-vote-button {
    background: linear-gradient(45deg, var(--tp-primary-color), #ff8e9e) !important;
    color: white !important;
    border: none !important;
    padding: 10px 0 !important;
    width: 100% !important;
    max-width: 140px;
    border-radius: 50px !important;
    font-size: 0.95rem !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: all 0.3s;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 10px rgba(255, 107, 129, 0.3) !important;
    margin-top: auto !important;
    text-decoration: none !important;
}

.tp-poll-vote-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(255, 107, 129, 0.5) !important;
}

.tp-poll-vote-button i {
    margin-right: 6px;
    font-size: 1.1rem;
}

/* Spinner */
.tp-spinner {
    border: 2px solid #fff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: inline-block;
    animation: tp-spin 1s linear infinite;
}

@keyframes tp-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* =========================================
   2. 投票後：ランキングデザイン (Results)
========================================= */
.toretame-poll-results {
    display: block;
    width: 100%;
    /* Remove borders/bg as they are now on the parent container */
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.tp-poll-result-item {
    background: var(--tp-card-bg) !important;
    padding: 15px !important;
    border-radius: 12px !important;
    margin-bottom: 15px !important;
    box-shadow: var(--tp-shadow) !important;
    display: flex !important;
    align-items: center !important;
    position: relative !important;
    width: 100% !important;
    border: none !important;
}

/* 順位バッジ */
.tp-result-rank {
    font-size: 1.2rem !important;
    font-weight: bold !important;
    margin-right: 15px !important;
    width: 35px !important;
    height: 35px !important;
    flex-shrink: 0 !important;
    text-align: center !important;
    color: #555 !important;
    background: #eee !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

/* 1位〜3位のカラーリング */
.tp-poll-result-item.rank-1 .tp-result-rank {
    background: #FFD700 !important;
    /* Gold */
    color: #fff !important;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) !important;
    font-size: 1.4rem !important;
}

.tp-poll-result-item.rank-2 .tp-result-rank {
    background: #C0C0C0 !important;
    /* Silver */
    color: #fff !important;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) !important;
    font-size: 1.4rem !important;
}

.tp-poll-result-item.rank-3 .tp-result-rank {
    background: #CD7F32 !important;
    /* Bronze */
    color: #fff !important;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2) !important;
    font-size: 1.4rem !important;
}

/* 絵文字削除 */
.tp-poll-result-item.rank-1 .tp-result-rank::before,
.tp-poll-result-item.rank-2 .tp-result-rank::before,
.tp-poll-result-item.rank-3 .tp-result-rank::before {
    content: none !important;
}

/* Results View Image Wrapper */
.tp-result-image-wrapper {
    width: 60px !important;
    height: 60px !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    position: relative !important;
    flex-shrink: 0 !important;
    margin-right: 15px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    background-color: #f0f0f0 !important;
    /* Pure CSS Approach: Flexbox Centering */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.toretame-poll-container img.tp-result-image {
    /* JS applyCoverSizing が width or height を設定するまで非表示 (admin preview と同一ロジック) */
    flex-shrink: 0 !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform-origin: center center !important;
    object-fit: fill !important;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tp-result-info {
    flex-grow: 1 !important;
    min-width: 0 !important;
}

.tp-result-header {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 8px !important;
    font-weight: bold !important;
    width: 100%;
    align-items: center !important;
}

.tp-result-name {
    font-size: 1.3rem !important;
    /* フォントサイズUP */
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-right: 10px !important;
    color: var(--tp-text-color) !important;
}

.tp-result-votes {
    color: var(--tp-primary-color) !important;
    white-space: nowrap !important;
}

.tp-result-bar-container {
    background: transparent !important;
    /* Remove grey background */
    border-radius: 10px !important;
    height: 14px !important;
    overflow: hidden !important;
    width: 100% !important;
    position: relative !important;
}

.tp-result-bar {
    height: 100% !important;
    /* Combine stripes (top) and color gradient (bottom) */
    background-image:
        linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent),
        linear-gradient(90deg, #ff8e9e, var(--tp-primary-color)) !important;
    background-size: 20px 20px, 100% 100% !important;
    background-repeat: repeat, no-repeat !important;
    border-radius: 10px !important;
    width: 0;
    transition: none !important;
    animation: none !important;
}

@keyframes tp-progress-stripes {
    from {
        background-position: 20px 0;
    }

    to {
        background-position: 0 0;
    }
}


/* =========================================
   3. シェアボタンエリア (Icon Only)
========================================= */
.tp-share-section {
    margin-top: 40px !important;
    text-align: center !important;
    padding-top: 20px !important;
    border-top: 2px dashed #eee !important;
    width: 100%;
}

.tp-share-title {
    font-size: 1.1rem !important;
    font-weight: bold !important;
    margin: 0 0 15px 0 !important;
    color: #555 !important;
    display: block !important;
}

.tp-share-buttons-container {
    display: flex !important;
    flex-wrap: nowrap !important;
    /* Force single row */
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    max-width: 100% !important;
}

/* Share Section in Grid (Full Width) */
.toretame-poll-grid .tp-share-section {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    margin-top: 30px !important;
    text-align: center !important;
}

.tp-share-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    /* Force smaller size */
    height: 32px !important;
    flex: 0 0 32px !important;
    /* Prevent resizing */
    border-radius: 50% !important;
    text-decoration: none !important;
    color: white !important;
    font-size: 1rem !important;
    transition: all 0.3s ease;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 32px !important;
    background-image: none !important;
}

.tp-share-button svg {
    margin: 0 !important;
    width: 16px !important;
    /* Smaller icon */
    height: 16px !important;
    fill: currentColor !important;
    display: block !important;
    max-width: 16px !important;
    max-height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
}

.tp-share-button:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2) !important;
    filter: brightness(1.1);
}

/* Colors */
.tp-share-button.is-x {
    background-color: #000000 !important;
}

.tp-share-button.is-line {
    background-color: #06C755 !important;
}

.tp-share-button.is-facebook {
    background-color: #1877F2 !important;
}

.tp-share-button.is-copy {
    background-color: #7f8c8d !important;
}

@media (max-width: 480px) {
    .tp-share-buttons-container {
        gap: 12px !important;
    }

    .tp-share-button {
        width: 32px !important;
        height: 32px !important;
        font-size: 1rem !important;
    }
}


/* =========================================
   4. モーダル (Popup)
========================================= */
.toretame-modal {
    display: none;
    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;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin: 0 !important;
}

.toretame-modal.is-visible {
    display: flex !important;
    opacity: 1;
}

.tp-modal-content {
    background: #fff !important;
    padding: 30px 20px !important;
    border-radius: 20px !important;
    text-align: center !important;
    max-width: 400px !important;
    width: 100% !important;
    position: relative !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    transform: scale(0.8);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: var(--tp-font-family) !important;
    box-sizing: border-box !important;
}

.toretame-modal.is-visible .tp-modal-content {
    transform: scale(1);
}

.tp-modal-close {
    position: absolute !important;
    top: 10px !important;
    right: 15px !important;
    font-size: 2rem !important;
    cursor: pointer !important;
    color: #aaa !important;
    line-height: 1 !important;
    transition: color 0.2s;
    font-weight: 300 !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
}

.tp-modal-close:hover {
    color: var(--tp-primary-color) !important;
}

.tp-modal-title {
    font-size: 1.5rem !important;
    color: var(--tp-primary-color) !important;
    margin: 10px 0 20px 0 !important;
    font-weight: bold !important;
    border: none !important;
    padding: 0 !important;
}

/* Modal View Image Wrapper */
.tp-modal-image-wrapper {
    width: 150px !important;
    height: 150px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    position: relative !important;
    margin: 0 auto 20px auto !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15) !important;
    border: 4px solid #fff !important;
    background-color: #fff !important;
    /* Pure CSS Approach: Flexbox Centering */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.toretame-modal img.tp-modal-voted-image {
    /* JS applyCoverSizing が width or height を設定するまで非表示 (admin preview と同一ロジック) */
    flex-shrink: 0 !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    display: block !important;
    transform-origin: center center !important;
    object-fit: fill !important;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tp-modal-message {
    font-size: 1.1rem !important;
    margin-bottom: 25px !important;
    font-weight: bold !important;
    line-height: 1.4 !important;
}

.tp-modal-share-area p {
    margin: 0 0 10px !important;
    padding: 0 !important;
    border: none !important;
}

.tp-modal-share-area .tp-share-button.is-x {
    /* モーダル内もサイズ統一 */
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    margin: 0 5px !important;
    display: inline-flex !important;
}

/* =========================================
   1. メインコンテナ (Main Container)
   ========================================= */


/* =========================================
   5. トースト通知 (Toast Notification)
   ========================================= */
.toretame-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background-color: rgba(51, 51, 51, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: bold;
    z-index: 1000000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-family: var(--tp-font-family);
    white-space: nowrap;
}

.toretame-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =========================================
   6. 画像カスタマイズ (Image Customization)
   ========================================= */

/*
 * NOTE: Primary wrapper and image rules are defined above
 * in their respective component sections (Grid, Results, Modal).
 * This section only contains supplementary rules.
 */

/* Result image link — must act as flex container to pass centering through */
.tp-result-image-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* =========================================
   Vote screen (before vote) Mobile tuning
========================================= */
@media (max-width: 600px) {

    /* 外枠 */
    .toretame-poll-container {
        margin: 12px auto !important;
        padding: 12px !important;
        border-radius: 12px !important;
    }

    /* タイトル */
    .toretame-poll-title {
        font-size: 1.35rem !important;
        margin-bottom: 16px !important;
    }

    /* グリッド密度 */
    .toretame-poll-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        justify-content: stretch !important;
        grid-auto-flow: row !important;
        gap: 12px !important;
        margin-bottom: 18px !important;
    }

    /* 投票前カード */
    .tp-poll-card {
        min-width: 0 !important;
        width: 100% !important;
        padding: 10px !important;
        border-radius: 14px !important;
    }

    /* 画像ラッパー */
    .tp-poll-card-image-wrapper {
        max-width: 100% !important;
    }

    /* 名前テキスト */
    .tp-poll-card-name {
        font-size: 1.0rem !important;
        margin-bottom: 10px !important;
    }

    /* 投票ボタン */
    .tp-poll-vote-button {
        max-width: 104px !important;
        font-size: 0.86rem !important;
        padding: 8px 0 !important;
    }
}

/* さらに小さい端末 */
@media (max-width: 480px) {
    .toretame-poll-title {
        font-size: 1.25rem !important;
    }

    .toretame-poll-grid {
        gap: 10px !important;
    }

    .tp-poll-card {
        padding: 9px !important;
    }

    .tp-poll-vote-button {
        max-width: 96px !important;
        font-size: 0.82rem !important;
        padding: 7px 0 !important;
    }
}