/*
 * Responsive layer for the archived 2016 template (fixed 1200px layout).
 * Loaded last by header.php/intro.php; desktop (>= 1200px) is unchanged.
 *   <= 1199px  fluid containers, stacked home columns
 *   <=  900px  hamburger menu, compact header, sidebar below the content
 *   <=  600px  phone typography and single-column blocks
 */

.mnav-toggle {
    display: none;
}

@media (max-width: 1199px) {
    #firstWrapper {
        min-width: 0;
    }

    #contentsWrapper {
        width: auto;
        max-width: 1200px;
        padding: 0 12px;
    }

    img,
    video,
    iframe {
        max-width: 100%;
    }

    /* Content images with a fixed height attribute keep their aspect ratio once max-width shrinks them */
    #bodyContentsWrapper img[height],
    #baseSingleBodyWrapper img[height] {
        height: auto;
    }

    /* Header: centred logo instead of the fixed 513px offset */
    #header h1,
    body.main #header h1 {
        left: 50%;
        margin-left: -87px;
    }

    /* Six-column hover menu keeps working, columns share the width */
    nav.inside_body ul.outerCategory > li {
        width: 16.6667%;
    }

    nav.inside_body ul.outerCategory > li.marginLeft {
        width: calc(16.6667% - 1px);
    }

    /* Home: weapon of the week and the top-5 ranking stack */
    #specialItems,
    #ranking {
        float: none;
        width: auto;
        height: auto;
        margin: 33px 0 0 0;
    }

    #specialItems .hmd {
        max-width: 800px;
    }

    #ranking ul {
        width: auto;
    }

    #ranking ul li .nt {
        width: calc(100% - 54px - 48px - 127px);
    }

    #news {
        margin-top: 33px;
    }

    #news ul li.type1 {
        width: calc(50% - 2px);
        background-size: cover;
    }

    #news ul li.type1 a.bg1,
    #news ul li.type1 a.bg2 {
        background-size: cover;
    }

    #news ul li.type1 a p .contents {
        width: auto;
    }

    #news ul li.type2 {
        width: 100%;
    }

    #news ul li.type2.marginLeft {
        margin-left: 0;
    }

    /* Content + sidebar pages */
    #bodyContentsWrapper {
        width: calc(100% - 320px);
    }

    #bodyContentsWrapper .guide_wrapper .guide_body .padding_maker {
        width: auto;
        margin: 40px 30px;
    }

    #bodyContentsWrapper .emporium_body .img1,
    #bodyContentsWrapper .emporium_body .img5,
    #bodyContentsWrapper .mission_body .img3 {
        width: auto;
        max-width: calc(100% - 66px);
        margin: 20px 33px;
    }

    #bodyContentsWrapper .emporium_body .shop1,
    #bodyContentsWrapper .emporium_body .forge1,
    #bodyContentsWrapper .emporium_body .custom1 {
        width: calc(52% - 33px);
    }

    #bodyContentsWrapper .emporium_body .img2,
    #bodyContentsWrapper .emporium_body .img3,
    #bodyContentsWrapper .emporium_body .img4 {
        width: calc(48% - 43px);
    }

    #bodyContentsWrapper .mission_body .img1,
    #bodyContentsWrapper .mission_body .img2 {
        width: calc(50% - 50px);
    }

    #bodyContentsWrapper .mission_body .divided4 li {
        width: calc(25% - 8px);
    }

    #bodyContentsWrapper .mission_body .divided4 li img,
    #bodyContentsWrapper .mission_body .divided2 li img {
        width: 100%;
        height: auto;
    }

    #bodyContentsWrapper .mission_body .divided2 li {
        width: calc(50% - 8px);
    }

    #bodyContentsWrapper .mission_body .img4 {
        width: auto;
        max-width: calc(100% - 57px);
    }

    /* Single-column pages (rankings, download, account, support, GC) */
    #baseSingleBodyWrapper .rankingWrapper .search_pname_form,
    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper,
    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper .pager_wrapper,
    .profile-card,
    .profile-stats,
    .profile-notice,
    .profile-back {
        width: auto;
        max-width: 1070px;
        margin-left: 15px;
        margin-right: 15px;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper {
        height: auto;
    }

    /* Wide data tables scroll sideways inside their box instead of widening the page */
    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper .ranking_tbl,
    #bodyContentsWrapper .achive_body .tbl_achive,
    #bodyContentsWrapper .emporium_body .roulette_tbl,
    #bodyContentsWrapper .mission_body .mission1_tbl,
    #bodyContentsWrapper .rank_body .rank_guid_tbl {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .construction {
        left: 50%;
        width: 90%;
        max-width: 550px;
        margin-left: 0;
        transform: translateX(-50%);
    }

    /* Footer link columns wrap */
    footer #sitemap .d0 {
        width: auto;
        max-width: 1000px;
        margin: 33px 20px;
    }
}

@media (max-width: 900px) {
    /* Compact header: language + menu button on top, logo, then account links */
    #header {
        height: auto;
    }

    #header header {
        height: auto;
        padding: 10px 10px 0 10px;
        box-sizing: border-box;
        text-align: center;
    }

    #header header > br {
        display: none;
    }

    #header header > a {
        display: block;
    }

    #header h1,
    body.main #header h1 {
        position: relative;
        left: auto;
        top: auto;
        margin: 0 auto;
    }

    #header .languagepicker {
        position: absolute;
        left: 10px;
        top: 10px;
        z-index: 4;
        margin: 0;
    }

    #commonGnb {
        position: static;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        height: auto;
        margin: 8px -10px 0 -10px;
        padding: 0 5px;
    }

    #commonGnb li {
        float: none;
        height: auto;
        margin: 0 8px;
    }

    #commonGnb li a,
    #commonGnb .gnb-link-button {
        display: inline-block;
        font-size: 14px;
        line-height: 38px;
    }

    .mnav-toggle {
        position: absolute;
        right: 10px;
        top: 10px;
        z-index: 4;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        height: 40px;
        padding: 0 12px;
        cursor: pointer;
        color: #c4b69b;
        font-family: "Roboto", 'Lucida Sans';
        font-size: 14px;
        font-weight: 500;
        text-transform: uppercase;
        background: rgba(0, 0, 0, .75);
        border: 1px solid #3a342b;
    }

    .mnav-toggle-bars,
    .mnav-toggle-bars::before,
    .mnav-toggle-bars::after {
        display: block;
        width: 20px;
        height: 2px;
        background: #d88b00;
        transition: transform .2s ease;
    }

    .mnav-toggle-bars {
        position: relative;
    }

    .mnav-toggle-bars::before,
    .mnav-toggle-bars::after {
        position: absolute;
        left: 0;
        content: "";
    }

    .mnav-toggle-bars::before {
        top: -6px;
    }

    .mnav-toggle-bars::after {
        top: 6px;
    }

    .mnav-open .mnav-toggle-bars {
        background: transparent;
    }

    .mnav-open .mnav-toggle-bars::before {
        transform: translateY(6px) rotate(45deg);
    }

    .mnav-open .mnav-toggle-bars::after {
        transform: translateY(-6px) rotate(-45deg);
    }

    /* Main menu: collapsed behind the button, every category open when shown */
    nav.inside_body {
        display: none;
        height: auto;
        margin-top: 10px;
    }

    .mnav-open nav.inside_body {
        display: block;
    }

    nav.inside_body ul.outerCategory,
    nav.inside_body ul.outerCategory:hover {
        height: auto;
    }

    nav.inside_body ul.outerCategory > li,
    nav.inside_body ul.outerCategory > li.marginLeft {
        float: none;
        width: auto;
        height: auto;
        margin: 0 0 1px 0;
        text-align: left;
    }

    nav.inside_body ul.outerCategory .innerCategory,
    nav.inside_body ul.outerCategory .innerCategory:hover {
        display: flex;
        flex-wrap: wrap;
        height: auto;
        overflow: visible;
        line-height: 44px;
        background: #131313;
    }

    nav.inside_body ul.outerCategory .innerCategory li {
        width: 50%;
        clear: none;
    }

    nav.inside_body ul.outerCategory .innerCategory li.ic1 {
        width: 100%;
    }

    nav.inside_body ul li a {
        height: auto;
        padding: 0 16px;
        box-sizing: border-box;
        font-size: 14px;
        line-height: 44px;
    }

    nav.inside_body ul.outerCategory .innerCategory .ic1 a,
    nav.inside_body ul.outerCategory .innerCategory:hover .ic1 a {
        color: #d88b00;
        font-size: 15px;
        font-weight: 600;
        background: #0a0a0a;
    }

    nav.inside_body ul.outerCategory .innerCategory.menu6 .ic1 a {
        color: #131313;
        background: #d88b00;
    }

    /* Sidebar pages: content first, sidebar below */
    #bodyContentsWrapper,
    #sidebarWrapper {
        float: none;
        width: auto;
    }

    #sidebarWrapper {
        margin: 33px 0 0 0;
    }

    #sidebarWrapper .sideNavi li,
    #sidebarWrapper .sideNews {
        width: auto;
    }

    #sidebarWrapper .sideNavi li a {
        width: auto;
        display: block;
    }

    #bodyContentsWrapper .board_list .board_list_search {
        width: auto;
        float: none;
        clear: both;
        padding: 10px 15px 0 15px;
    }

    #bodyContentsWrapper .board_list .board_list_search {
        display: flex;
        flex-direction: row-reverse;
        box-sizing: border-box;
    }

    #bodyContentsWrapper .board_list .board_list_search .search_input {
        float: none;
        width: auto;
        min-width: 0;
        flex: 1;
        box-sizing: border-box;
        height: 28px;
    }

    #bodyContentsWrapper .board_list .board_list_search select,
    #bodyContentsWrapper .board_list .board_list_search .search_btn {
        float: none;
        flex: none;
    }

    /* Guide pages: images and text follow each other */
    #bodyContentsWrapper .emporium_body .shop1,
    #bodyContentsWrapper .emporium_body .forge1,
    #bodyContentsWrapper .emporium_body .custom1,
    #bodyContentsWrapper .emporium_body .img2,
    #bodyContentsWrapper .emporium_body .img3,
    #bodyContentsWrapper .emporium_body .img4,
    #bodyContentsWrapper .mission_body .img1,
    #bodyContentsWrapper .mission_body .img2,
    #bodyContentsWrapper .mission_body .img4 {
        float: none;
        display: block;
        width: auto;
        max-width: calc(100% - 40px);
        height: auto;
        margin: 20px;
    }

    #bodyContentsWrapper .guide_wrapper .guide_body .padding_maker {
        margin: 30px 20px;
    }

    #bodyContentsWrapper .guide_wrapper .guide_body .padding_maker .interface_detail ul li,
    #bodyContentsWrapper .guide_wrapper .guide_body .padding_maker .uldetail li {
        width: 100%;
        float: none;
    }

    #bodyContentsWrapper .achive_body p,
    #bodyContentsWrapper .emporium_body p,
    #bodyContentsWrapper .emporium_body .shop_p1,
    #bodyContentsWrapper .rank_body p.top {
        margin-left: 20px;
        margin-right: 20px;
    }

    #bodyContentsWrapper .mission_body .slogan,
    #bodyContentsWrapper .mission_body h3,
    #bodyContentsWrapper .mission_body h4,
    #bodyContentsWrapper .mission_body p.yellow,
    #bodyContentsWrapper .rank_body h3 {
        margin-left: 20px;
        margin-right: 20px;
    }

    #bodyContentsWrapper .mission_body .divided4,
    #bodyContentsWrapper .mission_body .divided2 {
        margin: 0 20px;
    }

    /* Download page */
    #baseSingleBodyWrapper .downloadWrapper .more_info {
        width: auto;
        margin: 30px 15px 0 15px;
    }

    #baseSingleBodyWrapper .downloadWrapper .more_info2 {
        padding: 0 15px;
    }

    #baseSingleBodyWrapper .downloadWrapper .more_info2 li {
        float: none;
        display: inline-block;
    }

    #baseSingleBodyWrapper .downloadWrapper .more_link {
        display: block;
        margin: 40px 15px 0 15px;
    }

    #baseSingleBodyWrapper .downloadWrapper .more_link li,
    #baseSingleBodyWrapper .downloadWrapper .more_link li.lnk_2 {
        float: none;
        margin: 0 0 10px 0;
        list-style: none;
    }

    #baseSingleBodyWrapper .downloadWrapper .more_link a {
        display: block;
        min-width: 0;
        font-size: 18px;
    }

    #baseSingleBodyWrapper .downloadWrapper .down_tbl {
        width: calc(100% - 20px);
        font-size: 13px;
        line-height: 20px;
    }

    #baseSingleBodyWrapper .downloadWrapper .down_tbl col {
        width: auto;
    }

    #baseSingleBodyWrapper .downloadWrapper .down_tbl th,
    #baseSingleBodyWrapper .downloadWrapper .down_tbl td {
        padding: 8px 6px;
    }

    #baseSingleBodyWrapper .downloadWrapper .pagi16 {
        margin: 40px auto;
    }

    /* Ranking search form */
    #baseSingleBodyWrapper .rankingWrapper .search_pname_form ul {
        margin: 25px 15px;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_pname_form .txt_pn,
    #baseSingleBodyWrapper .rankingWrapper .search_pname_form ul li.li_pn span {
        width: 100%;
        box-sizing: border-box;
    }

    /* The 100px gap above the footer (template value) is empty black on small screens */
    footer {
        margin-top: 30px;
    }

    #contentsWrapper:has(> .discord-panel) {
        min-height: 0;
    }

    /* Footer columns: three per row */
    footer #sitemap .d0 .c1,
    footer #sitemap .d0 .c1.first {
        width: calc(33.333% - 14px);
        margin: 0 7px 20px 7px;
    }
}

@media (max-width: 600px) {
    #contentsWrapper {
        padding: 0 8px;
    }

    #header header {
        padding-top: 58px;
    }

    #header h1,
    body.main #header h1 {
        width: 140px;
        height: 62px;
        background-size: contain;
    }

    /* Weapon of the week: normal document flow */
    #specialItems h2,
    #ranking h2,
    #news h2 {
        font-size: 11pt;
        padding-right: 40px;
    }

    #ranking .pd {
        margin-top: 12px;
    }

    #ranking ul li .dt {
        width: 110px;
    }

    #ranking ul li .dt .cn {
        width: 110px;
    }

    #ranking ul li .nt {
        width: calc(100% - 54px - 48px - 110px);
        font-size: 10pt;
    }

    #ranking ul li .nt img {
        margin: 21px 6px 19px 8px;
    }

    #news ul li.type1,
    #news ul li.type1.marginLeft {
        width: 100%;
        margin-left: 0;
        height: 200px;
    }

    #news ul li .category,
    #news ul li .title {
        font-size: 12pt;
    }

    #news ul li.type2 {
        height: auto;
    }

    #news ul li.type2 a {
        display: block;
        padding: 10px 0;
    }

    #news ul li.type2 .category,
    #news ul li.type2 .title,
    #news ul li.type2 .date {
        float: none;
        display: block;
        line-height: 24px;
        margin: 0 15px;
    }

    #news ul li.type2 .title {
        white-space: normal;
    }

    #bodyContentsWrapper .board_list h2,
    #bodyContentsWrapper .board_detail h2,
    #baseSingleBodyWrapper h2 {
        font-size: 24px;
    }

    /* News lists: the view counter column is dropped, event rows stack image and title */
    #bodyContentsWrapper .board_list .board_list_table thead th:nth-child(3),
    #bodyContentsWrapper .board_list .board_list_table td.board_list_table_count,
    #bodyContentsWrapper .board_list .board_list_table td.event_list_table_count,
    #bodyContentsWrapper .board_list .board_list_table colgroup col.board_list_table_count {
        display: none;
    }

    #bodyContentsWrapper .board_list .board_list_table colgroup col.board_list_table_date {
        width: 30%;
    }

    #bodyContentsWrapper .board_list .board_list_table tbody tr td.event_list_table_title a.evt_01 {
        width: 100%;
        height: auto;
        float: none;
        margin: 0 0 6px 0;
    }

    #bodyContentsWrapper .board_list .board_list_table tbody tr td.event_list_table_title a.evt_01 img {
        width: 100%;
        height: auto;
    }

    #bodyContentsWrapper .board_list .board_list_table tbody tr td.event_list_table_title a.evt_02 {
        width: auto;
        height: auto;
        float: none;
        padding-top: 0;
    }

    #bodyContentsWrapper .board_list .board_list_table tbody tr td.event_list_table_title .event_stat {
        margin-top: 6px;
    }

    #bodyContentsWrapper .board_detail .board_detail_nav li {
        margin-right: 15px;
    }

    #bodyContentsWrapper .mission_body .divided4 li {
        width: calc(50% - 8px);
    }

    #bodyContentsWrapper .mission_body .divided2 li {
        width: 100%;
        margin-right: 0;
    }

    #baseSingleBodyWrapper .rankingWrapper {
        padding-bottom: 40px;
    }

    #baseSingleBodyWrapper .downloadWrapper h3 {
        font-size: 24px;
        margin: 30px auto 25px auto;
    }

    #baseSingleBodyWrapper .downloadWrapper #cae_download_link {
        padding-left: 30px;
        font-size: 20px;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_pname_form ul li {
        float: none;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_pname_form ul li.li_sc_btn {
        margin: 10px 0 0 0;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper h3 {
        font-size: 20px;
    }

    /* Rankings: readable cells, the table scrolls sideways */
    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper .ranking_tbl th,
    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper .ranking_tbl td {
        padding: 0 10px;
        font-size: 14px;
        white-space: nowrap;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper .pager_wrapper {
        height: auto;
        line-height: 40px;
    }

    #baseSingleBodyWrapper .rankingWrapper .search_result_wrapper .pager_wrapper span.display_area a {
        min-width: 0;
    }

    footer #sitemap .d0 .c1,
    footer #sitemap .d0 .c1.first {
        width: calc(50% - 14px);
    }

    footer #copyright p {
        display: inline-block;
        line-height: 18px;
        padding: 16px 10px 10px 10px;
        background-position: center top;
    }

    /* Home Discord panel: join button under the online counter */
    .discord-panel-summary {
        flex-wrap: wrap;
        gap: 10px;
    }

    .discord-panel-join {
        flex: 1 1 100%;
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    /* Login / register dialogs fit the screen */
    .register-panel {
        max-width: calc(100vw - 24px);
        box-sizing: border-box;
    }

    .register-logo {
        width: 160px;
    }
}

/*
 * Weapon of the week below 800px (the absolute 800x308 desktop box no longer fits): normal document flow.
 * Its height must not change while the description is typed word by word or the slides rotate (site.js),
 * otherwise everything below jumps every few seconds:
 *   - all slides share one grid cell, the inactive ones only invisible, so the box is as tall as the tallest slide;
 *   - an invisible copy of the full description (::before, zero-width float) reserves the text height up front.
 */
@media (max-width: 800px) {
    #specialItems .hmd {
        display: grid;
        height: auto;
        padding-bottom: 50px;
    }

    #specialItems .hmd .weapon-slide,
    #specialItems .hmd .weapon-slide[hidden] {
        display: block;
        grid-area: 1 / 1;
        min-width: 0;
        visibility: hidden;
    }

    #specialItems .hmd .weapon-slide.is-active {
        visibility: visible;
    }

    #specialItems .hmd .weapon-slide h3 {
        float: none;
        margin: 12px 12px 0 12px;
        font-size: 13pt;
    }

    #specialItems .hmd .weapon-slide p,
    #specialItems .hmd p {
        position: static;
        display: flow-root;
        width: auto;
        margin: 8px 12px 0 12px;
        overflow-wrap: anywhere;
    }

    #specialItems .hmd .weapon-slide p::before {
        content: attr(data-weapon-description) "\2003";
        float: left;
        width: 100%;
        margin-right: -100%;
        visibility: hidden;
    }

    #specialItems .hmd .weapon-slide .weapon,
    #specialItems .hmd .weapon {
        position: static;
        display: block;
        width: 100%;
        height: 180px;
        margin: 8px 0;
    }

    #specialItems .hmd .weapon-slide .ws,
    #specialItems .hmd .ws {
        position: static;
        margin: 0 12px;
        font-size: 8pt;
        line-height: 16px;
    }

    #specialItems .hmd .ws li span.dt {
        width: 90px;
    }

    #specialItems .weapon-nav {
        top: 110px;
    }

    #specialItems .hmd .wl {
        right: 10px;
    }
}
