/* =========================
   周期表
========================= */

html,
body{
    margin:0 !important;
    padding:0 !important;
    min-height:100%;
    width:100%;
    overflow-x:hidden;
}

*,
*::before,
*::after{
    box-sizing:border-box;
}

body{
    min-height:100vh;
    display:flex;
    flex-direction:column;
}

html,
body{
    margin:0;
    padding:0;
    min-height:100%;
}

body{
    min-height:100vh;
    display:flex;
    flex-direction:column;
}

.periodic-container{
    width:min(92%,1180px);
    max-width:1180px;
    margin:26px auto 0;
    padding:26px;
    border-radius:26px;
    background:linear-gradient(135deg,#ffffff12,#ffffff08);
    border:1px solid #ffffff18;
    box-shadow:0 18px 50px rgba(0,0,0,.24);
    flex:1;
}

.periodic-header{
    text-align:center;
    margin-bottom:18px;
}

.periodic-logo-row{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:12px;
    margin-bottom:8px;
}

.periodic-logo-mark{
    width:42px;
    height:42px;
    border-radius:14px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,#38bdf8,#22c55e);
    color:#082f49;
    font-weight:900;
    box-shadow:0 12px 30px rgba(14,165,233,.25);
}

.periodic-header h1{
    margin:0;
    color:#e0f2fe;
    font-size:34px;
    font-weight:850;
}

.periodic-header p{
    color:#cbd5e1;
    line-height:1.7;
    margin:8px 0 0;
    font-size:14px;
}

.mobile-view-switch{
    display:none;
    justify-content:center;
    gap:10px;
    margin:14px 0;
}

.view-switch-btn{
    border:none;
    border-radius:999px;
    padding:9px 14px;
    background:#334155;
    color:white;
    font-weight:850;
    cursor:pointer;
    transition:.18s ease;
}

.view-switch-btn.active{
    background:linear-gradient(135deg,#7dd3fc,#38bdf8);
    color:#082f49;
}

.view-switch-btn:hover{
    transform:translateY(-2px);
    filter:brightness(1.05);
}

.periodic-view{
    width:100%;
}

.periodic-scroll{
    width:100%;
    overflow-x:auto;
    padding-bottom:8px;
    -webkit-overflow-scrolling:touch;
}

.periodic-grid{
    display:grid;
    grid-template-columns:repeat(18,52px);
    grid-template-rows:repeat(7,60px);
    gap:4px;
    margin-top:20px;
    width:max-content;
    margin-left:auto;
    margin-right:auto;
}

.periodic-tile{
    width:52px;
    height:56px;
    padding:2px;
    border-radius:7px;
    text-decoration:none;
    color:white;
    background:rgba(255,255,255,0.08);
    border:1px solid rgba(255,255,255,0.18);
    box-sizing:border-box;
    backdrop-filter:blur(10px);
    transition:.18s ease;
    text-align:center;
    overflow:hidden;
}

.periodic-tile:hover{
    transform:scale(1.08);
    z-index:10;
    box-shadow:0 0 10px rgba(255,255,255,0.3);
}

.tile-number{
    font-size:8px;
    color:#fffefe;
    line-height:1.1;
}

.tile-symbol{
    font-size:20px;
    font-weight:900;
    color:#e0f2fe;
    line-height:1.25;
}

.tile-name{
    font-size:7px;
    line-height:1.2;
    color:#f8fafc;
}

/* 分類色 */

.alkali_metal{
    background:#ff6b6b;
}

.alkaline_earth_metal{
    background:#ffb86b;
}

.transition_metal{
    background:#f4d35e;
}

.post_transition_metal{
    background:#a6a831;
}

.metalloid{
    background:#8eff3dd8;
}

.nonmetal{
    background:#51cf66d4;
}

.halogen{
    background:#845ef7;
}

.noble_gas{
    background:#4dabf7;
}

.lanthanide{
    background:#ff9ff3;
}

.actinide{
    background:#ff6bcb;
}

/* fブロック */

.f-block-container{
    margin-top:20px;
    text-align:center;
}

.f-row{
    display:flex;
    justify-content:center;
    gap:3px;
    margin-bottom:10px;
}

.f-block-container h3{
    margin-top:18px;
    margin-bottom:8px;
    color:#cbd5e1;
    font-size:14px;
}

/* 凡例 */

.legend{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    gap:10px;
    margin:12px 0;
    font-size:13px;
    color:#e2e8f0;
}

.legend div{
    display:flex;
    align-items:center;
    gap:5px;
}

.legend-box{
    width:15px;
    height:15px;
    border-radius:4px;
    display:inline-block;
    border:1px solid #ffffff33;
}

.back-link{
    text-align:center;
    margin-top:24px;
}

.back-link a{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    background:#64748b;
    color:white;
    text-decoration:none;
    padding:12px 22px;
    border-radius:13px;
    font-weight:850;
    transition:.18s ease;
}

.back-link a:hover{
    transform:translateY(-2px);
    filter:brightness(1.05);
}

/* スマホ：全体表示と拡大表示を切り替える */

@media(max-width:760px){

    .periodic-container{
        width:94%;
        margin-top:18px;
        padding:20px 12px;
        border-radius:22px;
    }

    .periodic-logo-mark{
        width:38px;
        height:38px;
        border-radius:13px;
    }

    .periodic-header h1{
        font-size:28px;
    }

    .periodic-header p{
        font-size:13px;
    }

    .mobile-view-switch{
        display:flex;
    }

    .legend{
        justify-content:flex-start;
        overflow-x:auto;
        flex-wrap:nowrap;
        gap:8px;
        padding:8px 2px 10px;
        margin:8px 0 4px;
        -webkit-overflow-scrolling:touch;
    }

    .legend div{
        flex:0 0 auto;
        font-size:12px;
        background:#02061770;
        border:1px solid #334155;
        border-radius:999px;
        padding:6px 9px;
    }

    .legend-box{
        width:12px;
        height:12px;
    }

    .fit-mode .periodic-scroll{
        overflow-x:hidden;
    }

    .fit-mode .periodic-grid{
        width:100%;
        display:grid;
        grid-template-columns:repeat(18,minmax(0,1fr));
        grid-template-rows:repeat(7,clamp(28px,8.25vw,42px));
        gap:2px;
        margin-top:14px;
    }

    .fit-mode .periodic-tile{
        width:auto;
        height:clamp(28px,8.25vw,42px);
        min-width:0;
        padding:1px;
        border-radius:4px;
    }

    .fit-mode .tile-number{
        font-size:clamp(5px,1.4vw,7px);
    }

    .fit-mode .tile-symbol{
        font-size:clamp(8px,2.7vw,13px);
        line-height:1.2;
    }

    .fit-mode .tile-name{
        display:none;
    }

    .fit-mode .f-block-container{
        margin-top:12px;
    }

    .fit-mode .f-row{
        display:grid;
        grid-template-columns:repeat(15,minmax(0,1fr));
        gap:2px;
        margin-bottom:8px;
    }

    .fit-mode .f-row .periodic-tile{
        width:auto;
    }

    .fit-mode .f-block-container h3{
        font-size:12px;
        margin-top:12px;
        margin-bottom:6px;
    }

    .readable-mode .periodic-scroll{
        overflow-x:auto;
    }

    .readable-mode .periodic-grid{
        grid-template-columns:repeat(18,52px);
        grid-template-rows:repeat(7,60px);
        gap:4px;
        width:max-content;
        margin-left:0;
        margin-right:0;
    }

    .readable-mode .periodic-tile{
        width:52px;
        height:56px;
        padding:2px;
        border-radius:7px;
    }

    .readable-mode .tile-number{
        font-size:8px;
    }

    .readable-mode .tile-symbol{
        font-size:20px;
    }

    .readable-mode .tile-name{
        display:block;
        font-size:7px;
    }

    .readable-mode .f-block-container{
        overflow-x:auto;
        -webkit-overflow-scrolling:touch;
        text-align:left;
        padding-bottom:6px;
    }

    .readable-mode .f-row{
        width:max-content;
        justify-content:flex-start;
    }

}

@media(max-width:370px){

    .fit-mode .periodic-grid{
        gap:1px;
        grid-template-rows:repeat(7,clamp(24px,7.9vw,31px));
    }

    .fit-mode .periodic-tile{
        height:clamp(24px,7.9vw,31px);
    }

    .fit-mode .tile-symbol{
        font-size:clamp(7px,2.45vw,10px);
    }

}

/* 固定ホームボタン */


.floating-home-btn{
    position:fixed;
    right:22px;
    bottom:22px;
    z-index:9999;
    display:flex;
    align-items:center;
    gap:8px;
    background:linear-gradient(135deg,#38bdf8,#22c55e);
    color:#082f49;
    text-decoration:none;
    border-radius:999px;
    padding:12px 16px;
    font-size:14px;
    font-weight:850;
    box-shadow:0 14px 30px rgba(0,0,0,.35);
    border:1px solid #ffffff55;
    transition:.18s ease;
}

.floating-home-btn:hover{
    transform:translateY(-3px);
    filter:brightness(1.05);
}

.floating-home-btn:active{
    transform:translateY(-1px);
}

.floating-home-btn svg{
    width:20px;
    height:20px;
    flex-shrink:0;
}

@media(max-width:620px){

    .floating-home-btn{
        right:16px;
        bottom:16px;
        width:52px;
        height:52px;
        padding:0;
        justify-content:center;
        border-radius:50%;
    }

    .floating-home-btn span{
        display:none;
    }

    .floating-home-btn svg{
        width:23px;
        height:23px;
    }

}

.cs-footer{
    margin-top:0 !important;
    width:100%;
    max-width:100%;
    flex-shrink:0;
}

body > *{
    max-width:100%;
}

.periodic-scroll,
.f-block-container,
.legend{
    max-width:100%;
}

.cs-footer{
    margin-top:0;
}