/* =========================================================
   Responsive business-grade layer
   Keep desktop classic, make mobile playable
   ========================================================= */

:root {
    --shell-max: 1000px;
    --sidebar-width: 200px;
    --main-gap: 20px;
    --site-padding: 12px;
    --mobile-padding: 10px;
}

/* Base fluid safety */
html,
body {
    min-width: 0;
    width: 100%;
}

body {
    overflow-x: hidden;
}

.theme-shell,
.dark-theme-shell,
.theme-wrapper,
.dark-theme-wrapper,
.header,
.header_bg,
.header_meta_bar,
.header_nav_bar,
.footer-inner,
.dark-footer-inner {
    width: 100%;
    max-width: var(--shell-max);
    min-width: 0;
}

/* Keep classic desktop centered */
.theme-shell,
.dark-theme-shell,
.theme-wrapper,
.dark-theme-wrapper,
.header,
.footer-inner,
.dark-footer-inner {
    margin-left: auto;
    margin-right: auto;
}

/* Modern fluid containers */
.theme-shell,
.dark-theme-shell {
    padding-left: var(--site-padding);
    padding-right: var(--site-padding);
}

/* Header improvements */
.header {
    margin-bottom: 12px;
}

.header_bg {
    height: 215px;
    background-size: cover;
    background-position: center center;
}

.player_stats {
    max-width: 230px;
}

.player_assets {
    row-gap: 8px;
}

.asset {
    min-width: 0;
}

/* Top nav should wrap on desktop cleanly */
.header_nav_bar {
    padding: 0;
}

.header_quicklinks {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    position: static;
    width: 100%;
    background: rgba(0, 0, 0, 0.84);
    border-top: 1px solid rgba(48, 67, 90, 0.85);
}

.header_quicklink,
.header_quicklink:link,
.header_quicklink:visited,
.header_quicklink:active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 12px;
    white-space: nowrap;
    border-right: 1px solid rgba(80, 99, 136, 0.22);
}

.header_quicklink:first-child {
    border-left: 1px solid rgba(80, 99, 136, 0.22);
}

/* Main table shell stays classic on desktop */
.layout-table,
.dark-layout-table {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.layout-left,
.dark-layout-left {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
}

.layout-main,
.dark-layout-main {
    width: auto;
    min-width: 0;
    max-width: none;
    padding-left: var(--main-gap);
}

/* Media safety */
img {
    max-width: 100%;
    height: auto;
}

iframe,
embed,
object,
video {
    max-width: 100%;
    width: 100%;
    height: auto;
}

/* Generic table safety */
table {
    max-width: 100%;
    border-collapse: collapse;
}

.table,
table.table {
    width: 100%;
    max-width: 100%;
}

.content-inner table,
.dark-content-inner table,
.theme-content table,
.main-content table,
#content table {
    max-width: 100%;
    width: 100%;
    table-layout: auto;
}

.content-inner th,
.content-inner td,
.dark-content-inner th,
.dark-content-inner td,
.theme-content th,
.theme-content td,
.main-content th,
.main-content td,
#content th,
#content td {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: normal;
    white-space: normal;
    vertical-align: top;
}

/* Form controls get better scaling */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
select,
textarea {
    max-width: 100%;
    box-sizing: border-box;
}

input[type="submit"],
input[type="button"],
button,
.table .action-btn {
    min-height: 38px;
}

/* Long content protection */
.content-inner,
.dark-content-inner,
.theme-sidebar,
.sidebar,
.dark-sidebar {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

pre,
code,
blockquote,
.table,
table.table {
    max-width: 100%;
}

pre,
code {
    white-space: pre-wrap;
    word-break: break-word;
}

/* =========================================================
   Tablet and below
   ========================================================= */
@media (max-width: 1020px) {
    body {
        overflow-x: hidden;
    }

    .theme-shell,
    .dark-theme-shell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .header {
        margin-bottom: 10px;
    }

    .header_bg {
        height: auto;
        min-height: 180px;
        padding: 12px;
        display: flex;
        align-items: flex-start;
        justify-content: flex-end;
        background-size: cover;
    }

    .player_stats {
        position: static;
        width: 100%;
        max-width: 320px;
        margin-left: auto;
        top: auto;
        left: auto;
    }

    .header_meta_bar,
    .header_nav_bar {
        width: 100%;
        min-height: 0;
    }

    .player_assets {
        gap: 8px 14px;
    }

    .asset {
        white-space: normal;
        font-size: 12px;
    }

    /* Convert old table layout into vertical stack */
    .layout-table,
    .dark-layout-table,
    .layout-table tbody,
    .dark-layout-table tbody,
    .layout-table tr,
    .dark-layout-table tr,
    .layout-left,
    .dark-layout-left,
    .layout-main,
    .dark-layout-main {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .layout-left,
    .dark-layout-left {
        margin-bottom: 12px;
    }

    .layout-main,
    .dark-layout-main {
        padding-left: 0;
    }

    .theme-content,
    .main-content,
    #content,
    .dark-main-content {
        min-height: 0;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }

    .content-inner,
    .dark-content-inner {
        padding: 14px;
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
    }

    .theme-sidebar,
    .sidebar,
    #sidebar-left,
    #sidebar-right,
    .dark-sidebar {
        padding: 12px;
    }

    .footer-inner,
    .dark-footer-inner {
        width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Make nav playable on smaller widths */
    .header_quicklinks {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .header_quicklink,
    .header_quicklink:link,
    .header_quicklink:visited,
    .header_quicklink:active {
        flex: 0 0 auto;
    }

    /* Universal mobile table handling */
    .content-inner table,
    .dark-content-inner table,
    .theme-content table,
    .main-content table,
    #content table {
        display: table;
        width: max-content;
        min-width: 100%;
        max-width: none;
    }

    .table,
    table.table {
        width: max-content;
        min-width: 100%;
        max-width: none;
    }

    .content-inner th,
    .content-inner td,
    .dark-content-inner th,
    .dark-content-inner td,
    .theme-content th,
    .theme-content td,
    .main-content th,
    .main-content td,
    #content th,
    #content td {
        white-space: normal;
        overflow-wrap: break-word;
        word-wrap: break-word;
        vertical-align: top;
    }

    /* Better forms */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="file"],
    select,
    textarea {
        width: 100%;
    }

    input[type="submit"],
    input[type="button"],
    button,
    .table .action-btn {
        width: 100%;
        margin: 6px 0;
    }

    /* Achievements */
    .achievement-grid {
        grid-template-columns: 1fr;
    }

    .achievement-summary-top {
        flex-direction: column;
    }

    .achievement-summary-stat {
        min-width: 0;
        width: 100%;
    }
}

/* =========================================================
   Small phones
   ========================================================= */
@media (max-width: 640px) {
    body,
    td,
    th {
        font-size: 13px;
    }

    h1 {
        font-size: 28px;
        line-height: 1.1;
    }

    h2,
    h3,
    h4,
    h5 {
        font-size: 20px;
        line-height: 1.15;
    }

    .header_bg {
        min-height: 140px;
        padding: 10px;
        justify-content: stretch;
    }

    .player_stats {
        max-width: none;
        width: 100%;
        padding: 10px;
    }

    .player_name {
        font-size: 13px;
    }

    .player_stats_lbl,
    .player_stats_percent_value {
        font-size: 11px;
    }

    .player_stats_bar {
        width: 100%;
    }

    .player_assets {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 10px;
    }

    .asset {
        font-size: 12px;
    }

    .header_quicklink,
    .header_quicklink:link,
    .header_quicklink:visited,
    .header_quicklink:active {
        min-height: 42px;
        padding: 10px 12px;
        font-size: 10px;
    }

    .content-inner,
    .dark-content-inner {
        padding: 12px;
    }

    .theme-sidebar,
    .sidebar,
    #sidebar-left,
    #sidebar-right,
    .dark-sidebar {
        padding: 10px;
    }

    .achievement-card-head {
        gap: 10px;
        padding: 10px;
    }

    .achievement-icon-wrap {
        width: 48px;
        height: 48px;
        flex: 0 0 48px;
    }

    .achievement-icon-image {
        width: 40px;
        height: 40px;
    }

    .achievement-card-title {
        font-size: 14px;
    }

    .content-inner th,
    .content-inner td,
    .dark-content-inner th,
    .dark-content-inner td,
    .theme-content th,
    .theme-content td,
    .main-content th,
    .main-content td,
    #content th,
    #content td {
        font-size: 12px;
        padding: 6px;
    }
}

/* =========================================================
   Ultra small phones
   ========================================================= */
@media (max-width: 420px) {
    .player_assets {
        grid-template-columns: 1fr;
    }

    .header_quicklink_count {
        margin-left: 2px;
    }

    .content-inner th,
    .content-inner td,
    .dark-content-inner th,
    .dark-content-inner td,
    .theme-content th,
    .theme-content td,
    .main-content th,
    .main-content td,
    #content th,
    #content td {
        font-size: 11px;
        padding: 5px;
    }
}