/* mobile.css - phone and small-screen layout for every in-game page (loaded after style.css) */
html { -webkit-text-size-adjust: 100%; }
button, .btn, a.btn, .tile, .char-pick, .floor-btn, .spell-opt { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.nav-links .ni { display: none; }
.nav-links .short { display: none; }
img, svg, canvas { max-width: 100%; }
.roster-grid { grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); }
.shop-grid { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.hotel-grid { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }

@media (max-width: 700px) {
    :root { --tabbar: calc(62px + env(safe-area-inset-bottom, 0px)); }
    body { background-attachment: scroll; }
    .container { padding: 10px 12px calc(var(--tabbar) + 24px); }
    h1 { font-size: 1.45rem; }
    .page-head { margin-bottom: 14px; align-items: flex-start; }
    .page-head p { font-size: .88rem; }
    .page-head .btn { width: 100%; }

    /* top bar: just the name, gold and log out; the pages live in a tab bar at the bottom, under the thumb */
    .top-nav { padding: 8px 12px; gap: 8px; margin-bottom: 14px; border-radius: 10px; flex-wrap: nowrap; }
    .brand { font-size: 1rem; gap: 7px; white-space: nowrap; }
    .brand svg { width: 22px; height: 22px; }
    .user-box { gap: 8px; font-size: .8rem; margin-left: auto; }
    .user-box > span:not(.gold):not(.trial-tag) { display: none; }
    /* phones: the bar has no room, so the warning sits as a thin strip just under it */
    .top-nav { position: relative; }
    .top-nav:has(.trial-tag) { margin-bottom: 30px; }
    .user-box .trial-tag { position: absolute; left: 0; right: 0; top: 100%; margin-top: 5px; font-size: 0; text-align: center; pointer-events: none; }
    .user-box .trial-tag small { font-size: .72rem; }
    .user-box .gold { padding: 3px 9px; }
    .user-box .btn { padding: 6px 10px; min-height: 34px; }
    .nav-links {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; gap: 0; justify-content: space-around;
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
        background: linear-gradient(180deg, #1d1a26, #12101a); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0, 0, 0, .5);
    }
    .nav-links a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; border-radius: 10px; font-size: .64rem; line-height: 1.15; text-align: center; }
    .nav-links .ni { display: block; font-style: normal; font-size: 1.25rem; line-height: 1.2; }
    .nav-links .full { display: none; }
    .nav-links .short { display: inline; }
    .toast { bottom: calc(var(--tabbar) + 10px); max-width: calc(100vw - 24px); width: max-content; }
    #sfx-toggle, #music-toggle { top: 64px !important; bottom: auto !important; right: 12px !important; width: 36px !important; height: 36px !important; opacity: .8; }

    /* controls: finger sized, and 16px inputs so iOS doesn't zoom in */
    .btn { min-height: 44px; padding: 10px 14px; }
    .btn.small { min-height: 38px; }
    .btn.big { padding: 14px 20px; width: 100%; }
    input[type=text], input, select, textarea { font-size: 16px; }
    .panel { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
    .panel h2 { font-size: 1rem; margin-bottom: 10px; }
    .filter-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-right: -12px; padding-right: 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .filter-tabs button { flex: none; min-height: 38px; }
    .form-actions .btn { flex: 1 1 100%; }

    /* roster */
    .roster-grid { gap: 12px; }
    .char-card { padding: 14px; gap: 10px; }
    .char-top { gap: 12px; }
    .stat-row { gap: 4px; }
    .stat-chip .v { font-size: 1rem; }
    .card-actions .btn { min-height: 44px; }
    .formation-row { flex-wrap: wrap; }

    /* character editor */
    .editor-layout { gap: 12px; }
    .preview-col { position: static; }
    .tile-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .tile { padding: 10px 4px; }
    .tile .ico { width: 52px; height: 52px; }
    .tile .nm { font-size: .82rem; }
    .ability-grid { gap: 8px; }
    .ability-box .v { font-size: 1.5rem; }
    .hp-row { flex-wrap: wrap; }

    /* shops: lists use the page scroll, not a nested one */
    .scroll-list { max-height: none; overflow: visible; padding-right: 0; min-height: 0; }
    .shop-layout { gap: 12px; }
    .char-select { gap: 8px; flex-wrap: nowrap; overflow-x: auto; margin-right: -12px; padding: 0 12px 4px 0; scrollbar-width: none; }
    .char-pick { flex: none; padding: 6px 12px 6px 6px; }
    .item-card { padding: 7px 8px; gap: 8px; }
    .item-card .btn { min-width: 70px; min-height: 40px; }
    .item-stat { white-space: normal; }
    .hotel-hero { flex-wrap: wrap; }
    .hint { font-size: .82rem; }

    /* dialogs */
    .modal-back, .wp-modal, .fight-result { padding: 10px; align-items: flex-end; }
    .modal, .wp-box { padding: 16px; border-radius: 14px 14px 10px 10px; max-height: 92dvh; overflow-y: auto; }
    .modal .row .btn { flex: 1 1 100%; }
}

@media (max-width: 380px) {
    .brand { font-size: .9rem; }
    .nav-links a { font-size: .58rem; }
    .tile-grid { grid-template-columns: repeat(2, 1fr); }
}
