/* NextBall - room lobby on phones: an app screen of its own (mobile-lobby.js adds the sheet, steppers, counts).
   Portrait: header, team cards one under the other, match setup card, Start in a bar at the bottom.
   Landscape: teams on the left, match setup on the right, Start at the bottom of the right column. */

html.is-mobile.m-phone #lobby-screen .lobby-container { gap: 10px !important; padding: 8px 10px 92px !important; }
html.is-mobile.m-phone #lobby-screen[style*="fixed"] .lobby-container { padding-top: calc(var(--safe-top, 0px) + 54px) !important; }

/* ---------------------------------------------------------------- header */
html.is-mobile.m-phone #lobby-screen .lobby-header {
    display: grid !important; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
    gap: 8px 8px !important; padding: 12px 12px 10px !important; padding-right: 64px !important;
    border-radius: 14px !important; background: linear-gradient(160deg, #1b2130, #12151d) !important;
    border: 1px solid rgba(255, 255, 255, .07) !important; min-height: 0;
}
html.is-mobile.m-phone #lobby-screen[style*="fixed"] .lobby-header { padding-right: 12px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-header h2 {
    grid-column: 1; grid-row: 1; font-size: 19px !important; line-height: 1.15; margin: 0 !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html.is-mobile.m-phone #lobby-screen #lobby-mode-badge { grid-column: 2; grid-row: 1; margin: 0 !important; font-size: 11px !important; padding: 4px 9px !important; border-radius: 999px !important; }
html.is-mobile.m-phone #lobby-screen #lobby-host-q { grid-column: 1 / -1; grid-row: 2; justify-self: start; margin: 0 !important; font-size: 10px !important; padding: 4px 8px !important; border-radius: 999px !important; }
html.is-mobile.m-phone #lobby-screen #lobby-host-q.hidden { display: none !important; }
html.is-mobile.m-phone #lobby-screen .lobby-actions {
    grid-column: 1 / -1; grid-row: 3; display: flex !important; flex-wrap: nowrap !important; gap: 6px !important;
    width: auto !important; overflow-x: auto; scrollbar-width: none; margin: 2px -64px 0 -12px !important; padding: 0 12px !important;
}
html.is-mobile.m-phone #lobby-screen .lobby-actions::-webkit-scrollbar { display: none; }
html.is-mobile.m-phone #lobby-screen .lobby-actions .btn,
html.is-mobile.m-phone #lobby-screen .lobby-actions .btn-social {
    flex: 0 0 auto !important; height: 36px !important; min-height: 36px !important; padding: 0 14px !important;
    border-radius: 999px !important; font-size: 12px !important; letter-spacing: .04em;
    background: rgba(255, 255, 255, .07) !important; border: 1px solid rgba(255, 255, 255, .08) !important; color: #e8ecf3 !important;
}
html.is-mobile.m-phone #lobby-screen .lobby-actions #btn-leave-room { margin-left: 0 !important; order: 9; background: rgba(239, 68, 68, .16) !important; border-color: rgba(239, 68, 68, .35) !important; color: #ff8a8a !important; }
html.is-mobile.m-phone #lobby-screen .lobby-actions #btn-rec.recording, html.is-mobile.m-phone #lobby-screen .lobby-actions #btn-rec.is-on { color: #ff6b6b !important; }

/* rated / casual line: one compact row */
html.is-mobile.m-phone #lobby-screen .lobby-rated { margin: 0 !important; padding: 8px 10px !important; gap: 6px 8px !important; border-radius: 12px !important; font-size: 12px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-rated .lr-mode { display: none; }
html.is-mobile.m-phone #lobby-screen .lobby-rated .lr-status { flex: 1 1 140px; min-width: 0; font-size: 11.5px; line-height: 1.3; color: #9aa3b2; }
html.is-mobile.m-phone #lobby-screen .lobby-rated .btn { height: 34px !important; min-height: 34px !important; padding: 0 12px !important; font-size: 11px !important; border-radius: 999px !important; }

/* ---------------------------------------------------------------- teams */
html.is-mobile.m-phone #lobby-screen .teams-container { display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important; }
html.is-mobile.m-phone #lobby-screen #col-red { order: 1; grid-row: auto !important; grid-column: auto !important; }
html.is-mobile.m-phone #lobby-screen #col-blue { order: 2; grid-row: auto !important; grid-column: auto !important; }
html.is-mobile.m-phone #lobby-screen #col-spec { order: 3; grid-row: auto !important; grid-column: auto !important; }
html.is-mobile.m-phone #lobby-screen .team-column {
    min-height: 0 !important; border-radius: 14px !important; overflow: hidden; position: relative;
    background: #141821 !important; border: 1px solid rgba(255, 255, 255, .07) !important; border-top: 0 !important;
}
html.is-mobile.m-phone #lobby-screen .team-column::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #5b6476; }
html.is-mobile.m-phone #lobby-screen #col-red::before { background: linear-gradient(#ff5a5a, #c62828); }
html.is-mobile.m-phone #lobby-screen #col-blue::before { background: linear-gradient(#5aa2ff, #1d5fd6); }
html.is-mobile.m-phone #lobby-screen #col-red { background: linear-gradient(90deg, rgba(229, 57, 53, .10), rgba(20, 24, 33, 0) 60%), #141821 !important; }
html.is-mobile.m-phone #lobby-screen #col-blue { background: linear-gradient(90deg, rgba(61, 139, 255, .10), rgba(20, 24, 33, 0) 60%), #141821 !important; }

html.is-mobile.m-phone #lobby-screen .team-header {
    display: flex !important; flex-direction: row !important; align-items: center; justify-content: flex-start !important; gap: 10px;
    padding: 10px 12px 8px 16px !important; min-height: 48px; border: 0 !important; background: none !important;
}
html.is-mobile.m-phone #lobby-screen .team-header h3 { order: 1; margin: 0 !important; font-size: 15px !important; letter-spacing: .12em; flex: 0 0 auto; }
html.is-mobile.m-phone #lobby-screen .team-header .ml-count {
    order: 2; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: rgba(255, 255, 255, .08);
    color: #c7cedb; font: 700 12px/22px var(--f-body, system-ui); text-align: center;
}
html.is-mobile.m-phone #lobby-screen .team-header .btn-join-team {
    order: 3; margin-left: auto !important; width: auto !important; flex: 0 0 auto !important; height: 34px !important; min-height: 34px !important; min-width: 0 !important; padding: 0 14px !important;
    border-radius: 999px !important; font-size: 0 !important; display: inline-flex !important; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, .08) !important; border: 1px solid rgba(255, 255, 255, .1) !important;
}
html.is-mobile.m-phone #lobby-screen .team-header .btn-join-team::before { content: 'Join'; font: 700 12px/1 var(--f-display, system-ui); letter-spacing: .08em; text-transform: uppercase; color: #fff; }
html.is-mobile.m-phone #lobby-screen #col-red .btn-join-team { background: rgba(229, 57, 53, .22) !important; border-color: rgba(229, 57, 53, .5) !important; }
html.is-mobile.m-phone #lobby-screen #col-blue .btn-join-team { background: rgba(61, 139, 255, .22) !important; border-color: rgba(61, 139, 255, .5) !important; }
html.is-mobile.m-phone #lobby-screen .team-column.ml-mine .btn-join-team { display: none !important; }
html.is-mobile.m-phone #lobby-screen #col-spec .ml-join-spec { order: 3; margin-left: auto; }

html.is-mobile.m-phone #lobby-screen .player-list { max-height: none !important; min-height: 0 !important; overflow: visible !important; padding: 0 8px 8px 12px !important; display: flex; flex-direction: column; gap: 6px; }
html.is-mobile.m-phone #lobby-screen .player-list:empty::before { content: 'Nobody here yet'; display: block; padding: 10px 6px 4px; color: #6b7385; font-size: 12px; }
html.is-mobile.m-phone #lobby-screen .player-item {
    min-height: 50px !important; padding: 6px 10px !important; gap: 10px !important; margin: 0 !important; border-radius: 11px !important;
    background: rgba(255, 255, 255, .045) !important; border: 1px solid rgba(255, 255, 255, .05) !important;
    -webkit-tap-highlight-color: transparent; transition: transform .08s ease, background .12s ease;
}
html.is-mobile.m-phone #lobby-screen .player-item:active { transform: scale(.985); background: rgba(255, 255, 255, .09) !important; }
html.is-mobile.m-phone #lobby-screen .player-item.ml-self { border-color: rgba(255, 106, 19, .45) !important; background: rgba(255, 106, 19, .08) !important; }
html.is-mobile.m-phone #lobby-screen .player-item .player-name { flex: 1 1 auto; min-width: 0; font-size: 14px !important; }
html.is-mobile.m-phone #lobby-screen .player-item .pn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.is-mobile.m-phone #lobby-screen .player-item .player-ping { font-size: 11px !important; }
html.is-mobile.m-phone #lobby-screen .player-item.ml-tappable::after {
    content: ''; flex: 0 0 auto; width: 18px; height: 18px; margin-left: 2px; opacity: .55;
    background: radial-gradient(circle, #fff 1.6px, transparent 2px) 0 50% / 6px 6px repeat-x;
}
html.is-mobile.m-phone #lobby-screen .bot-remove-btn { width: 34px !important; height: 34px !important; border-radius: 10px !important; font-size: 14px !important; }
html.is-mobile.m-phone #lobby-screen .add-bot-btn {
    height: 42px !important; border-radius: 11px !important; display: flex; align-items: center; justify-content: center;
    font-size: 12px; letter-spacing: .08em; border: 1px dashed rgba(255, 255, 255, .16) !important; background: transparent !important; margin: 0 !important;
}

/* ---------------------------------------------------------------- match setup */
html.is-mobile.m-phone #lobby-screen .lobby-controls {
    border-radius: 14px !important; padding: 12px !important; gap: 12px !important; background: #141821 !important; border: 1px solid rgba(255, 255, 255, .07) !important;
}
html.is-mobile.m-phone #lobby-screen .lobby-controls::before { content: 'Match setup'; font: 700 12px/1 var(--f-display, system-ui); letter-spacing: .14em; text-transform: uppercase; color: #8b94a5; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .settings-group { order: 1; grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .control-group { order: 2; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .control-group:not(:has(.btn:not([style*="none"]))) { display: none !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .control-group .btn { height: 40px !important; min-height: 40px !important; border-radius: 10px !important; font-size: 12px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .setting-item {
    display: flex !important; flex-direction: column; align-items: stretch !important; gap: 6px !important;
    padding: 10px !important; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .05); margin: 0 !important;
}
html.is-mobile.m-phone #lobby-screen .lobby-controls .setting-item > label { font-size: 10.5px !important; letter-spacing: .12em; text-transform: uppercase; color: #8b94a5 !important; margin: 0 !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #setting-room-mode select { width: 100% !important; height: 44px !important; border-radius: 10px !important; font-size: 15px !important; font-weight: 700; }
/* stadium: name on top, Pick / Load as two big buttons */
html.is-mobile.m-phone #lobby-screen .lobby-controls #setting-stadium { display: grid !important; grid-template-columns: 1fr 1fr; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #setting-stadium > label,
html.is-mobile.m-phone #lobby-screen .lobby-controls #setting-stadium > #stadium-name { grid-column: 1 / -1; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #stadium-name { font: 700 16px/1.2 var(--f-display, system-ui); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #btn-pick-stadium,
html.is-mobile.m-phone #lobby-screen .lobby-controls #btn-load-map { height: 42px !important; min-height: 42px !important; border-radius: 10px !important; width: 100%; font-size: 12px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #btn-pick-stadium:only-of-type,
html.is-mobile.m-phone #lobby-screen .lobby-controls #btn-load-map.hidden + * { grid-column: auto; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #setting-stadium:has(#btn-load-map.hidden) #btn-pick-stadium { grid-column: 1 / -1; }
/* time / score: steppers */
html.is-mobile.m-phone #lobby-screen .ml-stepper { display: flex; align-items: center; gap: 6px; }
html.is-mobile.m-phone #lobby-screen .ml-stepper input.xs { flex: 1 1 auto; width: 100% !important; min-width: 0; height: 40px !important; min-height: 40px !important; text-align: center; font-size: 17px !important; font-weight: 700; border-radius: 10px !important; padding: 0 !important; }
html.is-mobile.m-phone #lobby-screen .ml-step {
    flex: 0 0 40px; height: 40px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, .09); color: #fff;
    font: 700 20px/1 var(--f-body, system-ui); -webkit-tap-highlight-color: transparent;
}
html.is-mobile.m-phone #lobby-screen .ml-step:active { background: rgba(255, 106, 19, .35); }
html.is-mobile.m-phone #lobby-screen .ml-step:disabled { opacity: .35; }

/* ---------------------------------------------------------------- Start: a bar at the bottom */
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group {
    position: fixed !important; left: 0; right: 0; bottom: 0; z-index: 74; margin: 0 !important;
    padding: 10px calc(12px + 116px + var(--safe-right, 0px)) calc(10px + var(--safe-bottom, 0px)) calc(12px + var(--safe-left, 0px)) !important;
    background: linear-gradient(180deg, rgba(10, 12, 17, .0), rgba(10, 12, 17, .92) 30%) !important; border: 0 !important;
}
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group:not(:has(.btn:not(.hidden))) { display: none !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group .btn { height: 50px !important; min-height: 50px !important; border-radius: 14px !important; font-size: 15px !important; letter-spacing: .1em; box-shadow: 0 10px 28px rgba(0, 0, 0, .5); }
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group #btn-start-game:not(:disabled) { background: linear-gradient(180deg, #ff7b2c, #ff5a00) !important; color: #1a0900 !important; border: 0 !important; }
html.is-mobile.m-phone #lobby-screen:not(.hidden) ~ .m-lobby-chat-btn { height: 50px !important; border-radius: 14px !important; }

/* ---------------------------------------------------------------- landscape phone: teams | setup */
html.is-mobile.m-phone.m-land #lobby-screen .lobby-container {
    display: grid !important; grid-template-columns: minmax(0, 1.25fr) minmax(250px, 1fr); grid-auto-rows: min-content; align-items: start;
    padding-bottom: 12px !important;
}
html.is-mobile.m-phone.m-land #lobby-screen .lobby-header,
html.is-mobile.m-phone.m-land #lobby-screen .lobby-rated,
html.is-mobile.m-phone.m-land #lobby-screen .ev-panel { grid-column: 1 / -1; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-header { grid-template-columns: auto auto auto minmax(0, 1fr); }
html.is-mobile.m-phone.m-land #lobby-screen #lobby-host-q { grid-column: 3; grid-row: 1; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-actions { grid-column: 4; grid-row: 1; margin: 0 !important; padding: 0 !important; justify-content: flex-end; }
html.is-mobile.m-phone.m-land #lobby-screen .teams-container { grid-column: 1; grid-template-columns: 1fr 1fr !important; }
html.is-mobile.m-phone.m-land #lobby-screen #col-spec { grid-column: 1 / -1 !important; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-controls { grid-column: 2; position: sticky; top: 8px; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-controls .start-group {
    position: static !important; padding: 0 !important; background: none !important; order: 3;
}

/* ---------------------------------------------------------------- the player sheet */
.ml-sheet { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0); transition: background .18s ease; }
.ml-sheet.open { background: rgba(0, 0, 0, .55); }
.ml-sheet-card {
    width: min(520px, 100%); max-height: 86dvh; overflow-y: auto; box-sizing: border-box;
    padding: 8px 16px calc(16px + var(--safe-bottom, 0px)); border-radius: 20px 20px 0 0;
    background: #151922; border-top: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 -20px 60px rgba(0, 0, 0, .6);
    transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1); color: #e8ecf3; font-family: var(--f-body, system-ui);
}
.ml-sheet.open .ml-sheet-card { transform: none; }
.ml-grab { width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .2); margin: 0 auto 12px; }
.ml-who { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ml-avatar { flex: 0 0 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 800 18px/1 var(--f-display, system-ui); color: #fff; background: #3a4150; border: 2px solid rgba(255, 255, 255, .15); }
.ml-avatar.t-red { background: #d32f2f; } .ml-avatar.t-blue { background: #2563eb; }
.ml-who b { display: block; font: 700 17px/1.2 var(--f-display, system-ui); overflow-wrap: anywhere; }
.ml-who span { font-size: 12px; color: #8b94a5; }
.ml-label { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #8b94a5; margin: 4px 0 8px; }
.ml-teams { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.ml-team {
    height: 64px; border-radius: 14px; border: 2px solid transparent; color: #fff; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    font: 700 13px/1 var(--f-display, system-ui); letter-spacing: .08em; text-transform: uppercase; -webkit-tap-highlight-color: transparent;
}
.ml-team i { width: 16px; height: 16px; border-radius: 50%; display: block; }
.ml-team[data-t="1"] { background: rgba(229, 57, 53, .18); } .ml-team[data-t="1"] i { background: #e53935; }
.ml-team[data-t="0"] { background: rgba(255, 255, 255, .07); } .ml-team[data-t="0"] i { background: #8b94a5; }
.ml-team[data-t="2"] { background: rgba(61, 139, 255, .18); } .ml-team[data-t="2"] i { background: #3d8bff; }
.ml-team.is-here { border-color: rgba(255, 255, 255, .55); }
.ml-team:disabled { opacity: .4; }
.ml-acts { display: grid; gap: 8px; }
.ml-act {
    height: 48px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .07); color: #e8ecf3; cursor: pointer;
    display: flex; align-items: center; gap: 12px; padding: 0 16px; font: 600 14px/1 var(--f-body, system-ui); text-align: left; -webkit-tap-highlight-color: transparent;
}
.ml-act:active, .ml-team:active { filter: brightness(1.25); }
.ml-act.danger { color: #ff8a8a; background: rgba(239, 68, 68, .12); }
.ml-act .ml-ic { width: 20px; text-align: center; opacity: .85; }
.ml-cancel { margin-top: 10px; width: 100%; height: 48px; border-radius: 12px; border: 0; background: transparent; color: #8b94a5; font: 700 13px/1 var(--f-display, system-ui); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }

/* fixes after the first look */
html.is-mobile.m-phone #lobby-screen #setting-mode-opts:empty { display: none !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group { position: static !important; padding: 4px 0 0 !important; background: none !important; order: 3; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group .btn { flex: 1 1 auto; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .start-group { margin-right: 124px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-container { padding-bottom: 76px !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls #btn-load-map { background: rgba(255,255,255,.09) !important; border: 1px solid rgba(255,255,255,.12) !important; }
html.is-mobile.m-phone.m-port #lobby-screen .lobby-controls .start-group { margin-right: 0 !important; }
html.is-mobile.m-phone #lobby-screen .lobby-controls .control-group .btn { background: rgba(255,255,255,.07) !important; border: 1px solid rgba(255,255,255,.09) !important; }
/* hidden settings stay hidden (3 DEF only for 3v3 / 4v4 on Big, Mode only for admins...) */
html.is-mobile.m-phone #lobby-screen .lobby-controls .setting-item.hidden,
html.is-mobile.m-phone #lobby-screen .lobby-controls .hidden { display: none !important; }

/* landscape phone: full-width rows. Red | Blue, then Spectators, then Match setup (owner's layout) */
html.is-mobile.m-phone.m-land #lobby-screen .lobby-container { display: flex !important; flex-direction: column; }
html.is-mobile.m-phone.m-land #lobby-screen .teams-container { grid-template-columns: 1fr 1fr !important; }
html.is-mobile.m-phone.m-land #lobby-screen #col-red { grid-column: 1 !important; grid-row: 1 !important; }
html.is-mobile.m-phone.m-land #lobby-screen #col-blue { grid-column: 2 !important; grid-row: 1 !important; }
html.is-mobile.m-phone.m-land #lobby-screen #col-spec { grid-column: 1 / -1 !important; grid-row: 2 !important; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-controls { position: static !important; width: auto !important; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-controls .settings-group { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-controls #setting-room-mode,
html.is-mobile.m-phone.m-land #lobby-screen .lobby-controls #setting-stadium { grid-column: span 2 !important; }
/* landscape header: the connection pill on its own line, never over Rec */
html.is-mobile.m-phone.m-land #lobby-screen .lobby-header { grid-template-columns: auto auto minmax(0, 1fr) !important; }
html.is-mobile.m-phone.m-land #lobby-screen #lobby-host-q { grid-column: 3 !important; grid-row: 1 !important; justify-self: start; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-actions { grid-column: 1 / -1 !important; grid-row: 2 !important; margin: 4px 0 0 !important; padding: 0 !important; justify-content: flex-start; }
/* the Lock button */
#btn-lock.is-locked { color: #ffb020 !important; }
html.is-mobile.m-phone #lobby-screen .team-header .btn-join-team.nb-nojoin { display: none !important; }
html.is-mobile.m-phone.m-land #lobby-screen .lobby-container > * { width: auto !important; max-width: none !important; align-self: stretch !important; grid-column: auto !important; }
