:root {
    --bg-color: #0b0e14;
    --card-bg: #1a1f29;
    --primary-gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --accent-blue: #2a415f;
    --text-main: #e0e6ed;
    --text-muted: #94a3b8;
    --border-color: #2d3748;
    --font-family: 'Inter', 'Noto Sans JP', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.brand-text {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.gold {
    color: var(--primary-gold);
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.header-affiliate {
    margin-top: 1.5rem;
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
}

/* ヘッダー広告の縦並びコンテナ */
.ad-banner-stacked {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

/* 各バナーアイテム（確実にブロック表示） */
.ad-banner-stacked .ad-banner-item {
    display: block;
    text-align: center;
}

.ad-banner-stacked .ad-banner-item img {
    max-width: 100%;
    height: auto;
}

.main-layout {
    display: grid;
    /* 右カラムもコンスタントな幅ではなく、最大350pxかつ縮小可能に */
    grid-template-columns: 300px 1fr minmax(0, 350px);
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    /* グリッドアイテムの内容物がコンテナを押し広げるのを防ぐ */
    min-width: 0;
    overflow: hidden;
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 0; /* ヘッダー内の並び調整のため一旦リセット */
    border-left: 4px solid var(--primary-gold);
    padding-left: 0.8rem;
}

.selection-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.cache-warning {
    font-size: 0.75rem;
    color: var(--primary-gold);
    background: rgba(212, 175, 55, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    flex: 1;
    min-width: 300px;
    line-height: 1.4;
}

/* サイドバー設定パネル */
.config-group {
    margin-bottom: 2rem;
}

.loto-selector {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.loto-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.loto-btn.active {
    background: var(--accent-blue);
    border-color: var(--primary-gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

.technique-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-tab {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
}

@media (hover: hover) {
    .radio-tab:hover {
        background: rgba(255, 255, 255, 0.05);
    }
}


/* 数字グリッド */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.8rem;
    margin: 2rem 0;
}

.num-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #252b36;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.num-cell.selected {
    background: var(--primary-gold);
    color: #000;
    box-shadow: 0 0 15px var(--gold-glow);
    transform: scale(1.1);
}

/* アクションボタン */
.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-gold), #b38f00);
    color: #000;
    border: none;
    padding: 1rem 2rem;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s;
}

@media (hover: hover) {
    .primary-btn:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 5px 20px var(--gold-glow);
    }
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #555;
    color: #999;
    box-shadow: none;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
}

/* アフィリエイトエリア */
.affiliate-area {
    margin-top: 2rem;
    border-style: dashed;
    text-align: center;
}

.ad-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.ad-space {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    font-size: 0.8rem;
}

/* 広告のデバイス別表示切替（基本はPC表示用） */
.ad-pc-only {
    display: block !important;
}

.ad-sp-only,
.ad-sp-only a,
.ad-sp-only img {
    display: none !important;
}

/* フッターアフィリエイト */
.footer-affiliate {
    margin-top: 1rem;
    padding-top: 0;
}

/* フッター広告コンテナ */
.ad-banner-horizontal {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border-color);
    overflow: hidden;
    position: relative;
    /* 1px画像用の基準点 */
    padding: 0.5rem 0;
    box-sizing: border-box;
}

/* A8.netなどが挿入する1pxの計測用画像がレイアウトを崩すのを防ぐ */
.ad-banner-horizontal img[width="1"][height="1"],
.ad-banner-medium img[width="1"][height="1"],
.ad-banner-small img[width="1"][height="1"],
.ad-space img[width="1"][height="1"],
.ad-banner-stacked img[width="1"][height="1"] {
    position: absolute;
    width: 1px !important;
    height: 1px !important;
    opacity: 0;
    pointer-events: none;
}

/* トグルグループ（保証プラン選択用） */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.guarantee-toggle {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.guarantee-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.guarantee-toggle.selected {
    background: var(--accent-blue);
    border-color: var(--primary-gold);
    color: var(--text-main);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.hidden {
    display: none;
}

/* ナンバーズ用マルチグリッド */
.grid-row {
    margin-bottom: 1.5rem;
}

.row-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}


.separator {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    width: 100%;
    text-align: left;
    transition: all 0.2s;
}

@media (hover: hover) {
    .toggle-btn:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

.toggle-btn.active {
    border-color: var(--primary-gold);
    color: var(--primary-gold);
}

/* モバイルレスポンシブ */
@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 0.5rem;
        overflow-x: hidden;
        max-width: 100vw;
    }

    .brand-text {
        font-size: 1.5rem;
    }

    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 0.5rem;
    }


    .num-cell {
        font-size: 0.9rem;
    }

    .actions {
        flex-direction: column;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
        text-align: center;
    }

    .card {
        padding: 0.8rem;
    }

    /* 広告表示のスマホ専用切り替え */
    .ad-pc-only,
    .ad-pc-only a,
    .ad-pc-only img {
        display: none !important;
    }

    .ad-sp-only {
        display: block !important;
    }

    .ad-sp-only a {
        display: flex !important;
    }

    /* スマホ時のサイドバー下部広告枠の余白縮小 */
    .affiliate-area {
        padding: 0.5rem;
    }

    .ad-space {
        min-height: auto;
        padding: 0.5rem 0;
    }

    /* 広告等の強制縮小（親要素を越えさせない） */
    .ad-banner-medium,
    .ad-banner-small,
    .ad-banner-horizontal,
    .ad-space,
    .ad-banner-stacked,
    .header-affiliate {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0;
        padding-right: 0;
        box-sizing: border-box;
    }

    .selection-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .cache-warning {
        min-width: 100%;
        font-size: 0.7rem;
    }
}

/* 広告用スタイル */
.ad-text-link {
    margin: 0.5rem 0 1rem;
    font-size: 0.85rem;
    text-align: left;
}

.ad-text-link.centered {
    text-align: center;
    margin: 1rem 0;
}

.ad-text-link a {
    color: var(--primary-gold);
    text-decoration: none;
    transition: opacity 0.2s;
}

.ad-text-link a:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.ad-banner-medium {
    margin-bottom: 1.5rem;
    text-align: center;
}

.ad-banner-small {
    margin: 0.5rem 0 1.2rem;
    text-align: center;
}

.ad-banner-small.centered {
    margin: 1rem 0;
}

/* --------------- 広告の万全なレスポンシブ・縮小対応 --------------- */

/* 1. 広告コンテナ共通設定（Flexboxの中央合わせ） */
.ad-banner-medium,
.ad-banner-small,
.ad-space,
.ad-banner-stacked .ad-banner-item {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
    /* 1px画像用の基準 */
    box-sizing: border-box;
}

/* 2. a要素への制限（Flex指定でmin-widthを上書き必須） */
.ad-banner-medium a,
.ad-banner-small a,
.ad-banner-horizontal a,
.ad-space a,
.ad-banner-stacked .ad-banner-item a {
    display: flex;
    justify-content: center;
    max-width: 100% !important;
    min-width: 0 !important;
    /* Flexbox特有の「中身の幅まで広がる」挙動を強制解除し縮小を許可 */
    box-sizing: border-box;
}

/* 3. 画像本体への制限 */
.ad-banner-medium img:not([width="1"]),
.ad-banner-small img:not([width="1"]),
.ad-banner-horizontal img:not([width="1"]),
.ad-space img:not([width="1"]),
.ad-banner-stacked .ad-banner-item img:not([width="1"]) {
    display: block !important;
    max-width: 100% !important;
    width: auto !important;
    /* A8.net等のwidth="468"属性を無効化 */
    height: auto !important;
    object-fit: contain;
}

/* 4. 計測用1px画像の完全無効化とレイアウト影響の排除 */
img[width="1"][height="1"] {
    position: absolute !important;
    clip: rect(0, 0, 0, 0);
    width: 1px !important;
    height: 1px !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* --------------- ページ全体のはみ出し防衛線 --------------- */
html,
body,
.app-container,
.main-layout {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
    box-sizing: border-box;
}

html,
body {
    -webkit-text-size-adjust: 100%;
}