/* Supreme Empires — phones and small tablets.
   Loaded after every other stylesheet, so it can settle the older breakpoints. */

.menu-toggle,
.menu-who,
.admin-nav-pick { display: none; }

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.card { overflow-wrap: break-word; }

/* ——— Top bar: the tabs fold into a menu ——— */
@media (max-width: 860px) {
    .gamebar-top { gap: 10px; }
    .gamebar-side { gap: 8px; }
    .gamebar-user { display: none; }

    .menu-toggle {
        display: inline-grid;
        place-items: center;
        flex: none;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 2.5px solid var(--rim);
        border-radius: 12px;
        background: var(--gloss), var(--blue);
        box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
        cursor: pointer;
    }
    .menu-toggle:active { transform: scale(0.95); }
    .menu-toggle:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
    .menu-toggle-bars,
    .menu-toggle-bars::before,
    .menu-toggle-bars::after {
        display: block;
        width: 20px;
        height: 3px;
        border-radius: 2px;
        background: #fff;
        transition: transform 0.18s ease-out, background-color 0.18s ease-out;
    }
    .menu-toggle-bars { position: relative; }
    .menu-toggle-bars::before,
    .menu-toggle-bars::after {
        content: "";
        position: absolute;
        left: 0;
    }
    .menu-toggle-bars::before { top: -7px; }
    .menu-toggle-bars::after { top: 7px; }
    .menu-toggle[aria-expanded="true"] .menu-toggle-bars { background-color: transparent; }
    .menu-toggle[aria-expanded="true"] .menu-toggle-bars::before { transform: translateY(7px) rotate(45deg); }
    .menu-toggle[aria-expanded="true"] .menu-toggle-bars::after { transform: translateY(-7px) rotate(-45deg); }

    .gamebar-tabs { display: none; }
    .gamebar.is-menu-open .gamebar-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 6px 0 14px;
        max-height: calc(100vh - 72px);
        max-height: calc(100dvh - 72px);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .gamebar.is-menu-open .menu-who {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0 0 2px;
        padding: 5px 14px 5px 5px;
        border-radius: 999px;
        background: rgba(0, 0, 0, 0.35);
        color: #dbeaf7;
        font-size: 13px;
        line-height: 1.2;
    }
    .menu-who .avatar {
        flex: none;
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        border: 2.5px solid var(--rim);
        background: var(--gloss), var(--yellow);
        color: var(--brown);
        font-family: var(--font-display);
        font-size: 17px;
    }
    .menu-who > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .menu-who strong { margin-right: 4px; color: #fff; font-size: 15px; font-weight: 600; }

    .gamebar.is-menu-open .tab,
    .gamebar.is-menu-open .tab-form { width: 100%; min-width: 0; }
    .gamebar.is-menu-open .tab {
        justify-content: center;
        height: 46px;
        padding: 0 10px;
        font-size: 17px;
        text-align: center;
    }
    .gamebar.is-menu-open .tab:hover { transform: none; }
    .tab span {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Admin: a section picker replaces the long row of tabs. */
    .admin-nav { display: none; }
    .admin-nav-pick {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border-top: 3px solid var(--rim);
        background: var(--parchment);
    }
    .admin-nav-pick label {
        flex: none;
        margin: 0;
        font-family: var(--font-display);
        font-weight: 400;
        font-size: 17px;
    }
    .admin-nav-pick select { flex: 1; min-width: 0; }

    /* Sub-panels and page tabs scroll sideways instead of stacking into a wall. */
    .panel-nav,
    .page-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .panel-nav::-webkit-scrollbar,
    .page-tabs::-webkit-scrollbar { display: none; }
    .panel-nav button,
    .panel-nav a,
    .page-tabs a {
        flex: none;
        min-height: 40px;
        white-space: nowrap;
    }
    .panel-nav { padding: 12px 14px 10px; }
    .page-tabs { margin-left: -2px; margin-right: -2px; padding: 2px 2px 6px; }

    .coc-chat-drawer {
        height: min(640px, calc(100vh - 36px));
        height: min(640px, calc(100dvh - 36px));
    }
    .coc-chat.is-open .coc-chat-tab { left: min(316px, calc(100vw - 58px)); }
}

/* ——— Phones ——— */
@media (max-width: 720px) {
    .stage { padding: 0 10px 36px; }
    .gamebar { padding: 0 10px; }
    .legal-banner { border-radius: 14px; font-size: 11px; }
    .page { margin-top: 16px; }

    .card { padding: 18px 14px 20px; border-radius: 20px; }
    .card + .card { margin-top: 16px; }
    h2 { margin: 20px 0 12px; font-size: 18px; }
    .page-head { gap: 12px; }
    .page-head img.head-art,
    .page-head .head-art { width: 56px; height: 56px; border-radius: 14px; }
    .lede { font-size: 15px; }

    .actions { gap: 10px; }
    .actions .btn { flex: 1 1 auto; }
    .lang-switch select { font-size: 16px; }

    .table,
    table { font-size: 14px; }
    .table th,
    table th,
    .table td,
    table td { padding: 8px 10px; }
    .table th,
    table th { white-space: nowrap; }

    .admin-shell { padding: 0; }
    .admin-shell > .admin-hero { padding: 16px 14px 14px; }
    .admin-shell > .admin-hero .grid { gap: 8px; }
    .admin-workspace > .panel-pane,
    .admin-workspace > form > .panel-pane,
    .admin-workspace > .event-panel { padding: 4px 14px 18px; }
    .admin-head { gap: 8px; }
    .account-tools { justify-content: flex-start; }

    .grid { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; }
    .stat { padding: 8px 10px; gap: 8px; }
    .stat img { width: 30px; height: 30px; }
    .stat b { font-size: 16px; }

    .coc-chat-tab { top: auto; bottom: 14px; width: 44px; height: 54px; }

    .se-modal-card { padding: 16px 14px 14px; }
    .se-modal-actions .btn { flex: 1 1 auto; }

    .legal { margin-top: 40px; padding: 26px 12px 22px; }
    .legal .foot { font-size: 19px; flex-wrap: wrap; justify-content: center; }
    .legal .foot-discord {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    .legal .foot-discord a { min-height: 40px; }
    .foot-lang button { min-height: 36px; padding: 4px 8px; }
}

/* ——— Small phones ——— */
@media (max-width: 420px) {
    .gamebar-top { gap: 8px; }
    .gamebar-side { gap: 6px; }
    .gamebar-brand img { height: 36px; }
    .gamebar-side .lang-globe { display: none; }
    .gamebar-side .lang-switch select { max-width: 92px; padding: 4px 22px 4px 8px; min-height: 40px; }
    .gamebar-side .btn-play { min-height: 40px; padding: 6px 12px; font-size: 16px; }
    .menu-toggle { width: 40px; height: 40px; }
    .gamebar.is-menu-open .tab { font-size: 15px; }

    .stage { padding: 0 8px 32px; }
    .card { padding: 16px 12px 18px; }
    .admin-workspace > .panel-pane,
    .admin-workspace > form > .panel-pane,
    .admin-workspace > .event-panel { padding: 4px 10px 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .menu-toggle-bars,
    .menu-toggle-bars::before,
    .menu-toggle-bars::after { transition: none; }
}
