/* Tribe City — mobile & touch-friendly layouts */

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

body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

body.rail-scroll-lock {
    overflow: hidden;
    touch-action: none;
}

/* ── Admin panel ── */
.hud-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    margin-inline-end: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg3);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.hud-menu-btn svg {
    width: 22px;
    height: 22px;
}

.rail-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.55);
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 900px) {
    .hud-menu-btn { display: inline-flex; }

    .rail {
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -8px 0 40px rgba(0, 0, 0, 0.45);
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .shell.rail-open .rail {
        transform: translateX(0);
    }

    .shell.rail-open .rail-backdrop {
        display: block;
    }

    .workspace {
        margin-right: 0;
        width: 100%;
    }

    .hud {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.65rem 1rem;
        padding-top: max(0.65rem, env(safe-area-inset-top));
    }

    .hud-start {
        flex: 1;
        min-width: 0;
    }

    .hud-end {
        flex-wrap: wrap;
        justify-content: flex-start;
        width: 100%;
        gap: 0.45rem;
    }

    .hud-server-name { display: none; }

    #bridge-status span:last-child {
        max-width: 7rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .stage {
        padding: 1rem 0.85rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .view-head h1 { font-size: 1.28rem; }
    .view-head { margin-bottom: 1rem; }

    .stat-grid { grid-template-columns: 1fr; }
    .shortcut-grid { grid-template-columns: 1fr; }

    .live-grid {
        grid-template-columns: 1fr;
    }

    .dossier-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .dossier-identity h1 { font-size: 1.35rem; }

    .dossier-finance {
        flex-direction: column;
        align-items: stretch;
    }

    .inv-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 0.5rem;
        padding: 0.85rem;
    }

    .inv-cell img { width: 40px; height: 40px; }

    .table-scroll,
    .table-wrap {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }

    .data-table { min-width: 520px; }

    .dialog {
        width: 100%;
        max-width: 100%;
        max-height: min(92dvh, 92vh);
        margin: 0.5rem;
        border-radius: var(--radius);
    }

    .overlay {
        align-items: flex-end;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .webhook-grid { grid-template-columns: 1fr; }

    .btn,
    .rail-link,
    .tog-btn,
    .filter-tab,
    .shop-cat-tab {
        min-height: 44px;
    }

    .btn-sm { min-height: 40px; }

    .rail-link { padding-top: 0.65rem; padding-bottom: 0.65rem; }

    #btn-back {
        font-size: 0.82rem;
        padding-inline: 0.65rem;
    }
}

@media (max-width: 480px) {
    .hud-breadcrumb { font-size: 0.88rem; }

    .hud-chip { font-size: 0.75rem; padding: 0.3rem 0.55rem; }

    .pill { font-size: 0.78rem; }

    .dash-hero { flex-direction: column; align-items: flex-start; }

    .live-card-actions {
        flex-direction: column;
    }

    .live-card-actions .btn { width: 100%; }

    .dupe-location-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-head-actions {
        width: 100%;
    }

    .view-head-actions .btn { flex: 1; min-width: 0; }
}

/* ── Login ── */
@media (max-width: 480px) {
    .login-page .login-center {
        padding: 1.25rem 1rem;
        padding-top: max(2rem, env(safe-area-inset-top));
    }

    .login-back {
        top: max(0.75rem, env(safe-area-inset-top));
        inset-inline-start: 0.75rem;
    }

    .login-title { font-size: 1.45rem; }

    .login-btn {
        min-height: 48px;
        font-size: 1rem;
    }
}

/* ── Public site (home.css pages) ── */
@media (max-width: 480px) {
    .pub-hero-title { font-size: clamp(1.75rem, 8vw, 2.5rem); }

    .pub-hero-actions {
        flex-direction: column;
        width: 100%;
    }

    .pub-hero-actions .pub-btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }

    .pub-nav-bar {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
}

/* ── Shop page ── */
@media (max-width: 600px) {
    .shop-page .shop-hero-banner-inner {
        flex-direction: column;
        text-align: center;
    }

    .shop-categories {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.35rem;
        scrollbar-width: none;
    }

    .shop-categories::-webkit-scrollbar { display: none; }

    .shop-cat-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .shop-checkout-panel,
    .shop-cart-drawer {
        max-height: 85dvh;
    }
}

/* ── Rules page ── */
@media (max-width: 860px) {
    .rules-topbar-inner {
        flex-wrap: wrap;
        gap: 0.65rem;
    }

    .rules-topnav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        width: 100%;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .rules-topnav::-webkit-scrollbar { display: none; }

    .rules-topnav a {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 0.5rem 0.85rem;
        border-radius: 999px;
        background: var(--rl-surface-2);
        border: 1px solid var(--rl-border);
    }

    .rules-head-row {
        flex-direction: column;
    }

    .rules-stats {
        flex-direction: row;
        width: 100%;
    }
}

/* ── Leaderboard: see leaderboard.css @720px ── */
