/* ============ SquadUp themes ============ */
:root, [data-theme="dark"] {
    --bg-app: #0f1117;
    --bg-surface: #171a23;
    --bg-elevated: #1f2330;
    --border: #2a2f3f;
    --text-primary: #f2f3f7;
    --text-secondary: #9aa0b4;
    --accent: #6c5ce7;
    --accent-hover: #7d6ef0;
    --accent-soft: rgba(108, 92, 231, .16);
    --danger: #e74c3c;
    --ok: #2ecc71;
}
[data-theme="light"] {
    --bg-app: #f5f6fa;
    --bg-surface: #ffffff;
    --bg-elevated: #eef0f7;
    --border: #d9dce6;
    --text-primary: #1b1d27;
    --text-secondary: #5d6275;
    --accent: #5b4bd6;
    --accent-hover: #4a3ac4;
    --accent-soft: rgba(91, 75, 214, .12);
}
[data-theme="pink"] {
    --bg-app: #1a1016;
    --bg-surface: #241620;
    --bg-elevated: #31202b;
    --border: #462c3c;
    --text-primary: #ffeef6;
    --text-secondary: #c79bb2;
    --accent: #ff5fa2;
    --accent-hover: #ff7ab3;
    --accent-soft: rgba(255, 95, 162, .16);
}

/* presence colors (theme independent) */
:root {
    --c-online: #2ecc71;
    --c-away: #f1c40f;
    --c-busy: #e74c3c;
    --c-lfg: #00cec9;
    --c-ready: #a29bfe;
    --c-offline: #5d6275;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14.5px;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; margin: .4rem 0; }
h3 { font-size: 1.02rem; margin: .3rem 0 .6rem; }
hr { border: none; border-top: 1px solid var(--border); margin: .4rem 0; }
.dim { color: var(--text-secondary); font-size: .88em; }
.flag { font-size: .75em; border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; }
.row-end { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ============ app shell ============ */
.app-shell { display: grid; grid-template-columns: 72px 1fr 300px; height: 100vh; }
.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-body { flex: 1; overflow-y: auto; padding: 22px 28px; }
.app-loading { display: grid; place-items: center; height: 100vh; color: var(--text-secondary); }
@media (max-width: 1100px) { .app-shell { grid-template-columns: 72px 1fr; } .friends-rail { display: none; } }

/* nav rail */
.nav-rail {
    background: var(--bg-surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0;
}
.nav-logo { font-size: 26px; margin-bottom: 10px; }
.nav-item {
    width: 46px; height: 46px; display: grid; place-items: center; font-size: 20px;
    border-radius: 12px; color: var(--text-primary); position: relative; border: none; background: none; cursor: pointer;
}
.nav-item:hover { background: var(--bg-elevated); }
.nav-item.active { background: var(--accent-soft); outline: 1px solid var(--accent); }
.nav-spacer { flex: 1; }
.nav-badged { position: relative; }
.badge {
    position: absolute; top: 2px; right: 0; background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 9px; min-width: 16px; text-align: center;
}

/* topbar */
.topbar {
    display: flex; align-items: center; gap: 14px; padding: 10px 22px;
    background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.topbar-search { flex: 1; max-width: 380px; }
.topbar-search input { width: 100%; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-menu { position: relative; }
.user-chip {
    display: flex; align-items: center; gap: 8px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px 4px 4px;
    color: var(--text-primary); cursor: pointer;
}
.dropdown {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 60;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px;
    padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.dropdown-wide { min-width: 330px; max-height: 420px; overflow-y: auto; }
.dropdown-title { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-weight: 600; }
.dropdown-item {
    display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 8px 10px;
    background: none; border: none; color: var(--text-primary); cursor: pointer; border-radius: 8px; font-size: .92rem;
}
.dropdown-item:hover { background: var(--accent-soft); }
.bell-wrap { position: relative; }
/* max-width and word-break: the panel used to hang off the LEFT edge of a phone screen, every row
   losing its first 66 px, and one long token blew it out to 1224 px (mobile-15) */
.dropdown-wide { min-width: min(340px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: 440px; overflow-y: auto; padding: 8px; overflow-wrap: anywhere; }
.notif {
    flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px;
    border-radius: 10px; border: 1px solid var(--border); background: var(--bg-surface);
}
.notif + .notif { margin-top: 8px; }
.notif:hover { background: var(--accent-soft); }
.notif-unread { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.notif-title { font-weight: 600; line-height: 1.3; }
.notif-body { font-size: .8rem; line-height: 1.35; }
.notif-time { font-size: .75rem; opacity: .75; }

/* guilds */
.guild-section { margin-bottom: 26px; }
.guild-section > h3 { margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.count-badge {
    font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 12px;
    background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text-primary);
}
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 14px; }
.guild-card {
    display: flex; flex-direction: column; gap: 12px; padding: 16px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elevated);
    color: var(--text-primary); text-decoration: none;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
a.guild-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.25); }
.guild-card-top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.guild-icon-badge {
    flex: 0 0 auto; display: grid; place-items: center; width: 48px; height: 48px;
    font-size: 1.5rem; border-radius: 12px; border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--accent-soft), transparent);
}
.guild-title { min-width: 0; flex: 1; }
.guild-name { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guild-game { font-size: .82rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guild-state { flex: 0 0 auto; }
.guild-icon { font-size: 1.6rem; }
.guild-motto {
    font-style: italic; color: var(--text-secondary); font-size: .86rem; line-height: 1.4;
    border-left: 3px solid var(--accent); background: var(--accent-soft);
    padding: 6px 12px; border-radius: 0 8px 8px 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.guild-card-foot {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: auto;
    padding-top: 12px; border-top: 1px solid var(--border);
    font-size: .85rem; color: var(--text-secondary);
}
.guild-foot-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.guild-search-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.guild-search-row > input { flex: 1 1 220px; width: auto; }
.guild-search-row .field { flex: 1 1 220px; display: flex; flex-direction: column; min-width: 0; }
.guild-search-row .field label { margin-bottom: 4px; }
.guild-search-row > .btn { flex: 0 0 auto; }
.guild-invite-banner { border: 1px solid var(--accent); }
.title-pill { background: linear-gradient(135deg, var(--accent-soft), transparent); border-color: var(--accent); }
.invite-subhead { font-weight: 600; letter-spacing: .04em; font-size: .78rem; text-transform: uppercase; margin: 14px 0 6px; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.emoji-pick {
    font-size: 1.25rem; padding: 6px 8px; background: none; border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer;
}
.emoji-pick:hover { border-color: var(--accent); }
.emoji-selected { border-color: var(--accent); background: var(--accent-soft); }

/* favorites & friend groups */
.fav-star {
    background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 0 2px;
    color: var(--text-primary); opacity: .45;
}
.fav-star:hover { opacity: 1; }
.fav-star.fav-on { color: #f5b942; opacity: 1; }
.group-block { padding: 6px 0; border-bottom: 1px solid var(--border); }
.group-block:last-child { border-bottom: none; }
.group-members { font-size: .85rem; padding: 0 0 6px 4px; }

/* friend-picker quick bar */
.quick-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.quick-select { max-width: 220px; font-size: .85rem; padding: 4px 8px; }
.picker-warning { color: #e0a030; font-size: .85rem; margin: 4px 0; }

/* friends rail */
.friends-rail {
    background: var(--bg-surface); border-left: 1px solid var(--border);
    overflow-y: auto; padding: 14px 12px;
}
.friends-head { display: flex; justify-content: space-between; font-weight: 700; letter-spacing: .08em; font-size: .78rem; color: var(--text-secondary); margin-bottom: 10px; }
.friends-group { margin-top: 14px; }
.group-title { font-size: .72rem; letter-spacing: .08em; color: var(--text-secondary); margin: 8px 0 4px; }
.friend-card {
    display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 10px; cursor: pointer;
}
.friend-card:hover { background: var(--bg-elevated); }
.friend-avatar { position: relative; }
.friend-avatar .status-dot { position: absolute; bottom: -1px; right: -1px; border: 2px solid var(--bg-surface); }
.friend-name { font-weight: 600; font-size: .92rem; }
.friend-time { font-size: .78rem; color: var(--text-secondary); }

/* ready now */
.readynow-rail { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 10px; }
.rail-title { font-size: .72rem; font-weight: 700; letter-spacing: .08em; margin-bottom: 6px; }
.readynow-card { background: var(--bg-elevated); border-radius: 10px; padding: 8px; margin-top: 6px; }
.readynow-card.mine { outline: 1px dashed var(--accent); }
.rn-row { display: flex; gap: 8px; align-items: center; }
.rn-name { font-weight: 700; font-size: .88rem; }
.rn-game { font-size: .78rem; color: var(--text-secondary); }
.rn-msg { font-size: .82rem; font-style: italic; margin: 6px 0 2px; }
.rn-actions { display: flex; gap: 6px; margin-top: 6px; }
.rn-joined { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; }
/* Inline dashboard respond section: the friends rail hides at max-width: 1100px (see the
   app-shell rules) and it holds the app's only other "I'm in!" buttons — without this a pinged
   phone user cannot answer at all. Hidden at desktop widths where the rail already covers it. */
.readynow-inline { display: none; margin-bottom: 14px; }
@media (max-width: 1100px) { .readynow-inline { display: block; } }
.btn-readynow {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; border: none;
    border-radius: 18px; padding: 7px 16px; font-weight: 700; cursor: pointer;
}
.btn-readynow:hover { filter: brightness(1.1); }
.rn-live {
    display: flex; align-items: center; gap: 8px; background: var(--accent-soft);
    border: 1px solid var(--accent); border-radius: 18px; padding: 4px 10px; font-size: .85rem;
}
.rn-pulse { font-weight: 800; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

/* ============ widgets ============ */
.avatar { border-radius: 50%; object-fit: cover; display: inline-grid; }
.avatar-initials {
    background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center;
    border-radius: 50%; font-weight: 700;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-online { background: var(--c-online); }
.dot-away { background: var(--c-away); }
.dot-busy { background: var(--c-busy); }
.dot-lfg { background: var(--c-lfg); }
.dot-ready { background: var(--c-ready); }
.dot-offline { background: var(--c-offline); }

.btn {
    border-radius: 10px; padding: 8px 16px; border: 1px solid var(--border);
    background: var(--bg-elevated); color: var(--text-primary); cursor: pointer; font-size: .92rem;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-xs { padding: 4px 10px; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }

input, select, textarea {
    background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-primary);
    border-radius: 10px; padding: 9px 12px; font-size: .92rem; font-family: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: .88rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 0; }
.form-row > div.shrink { flex: 0 0 170px; }
@media (max-width: 700px) { .form-row > div, .form-row > div.shrink { flex: 1 1 100%; } }
.form-error { background: rgba(231, 76, 60, .15); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.form-ok { background: rgba(46, 204, 113, .15); border: 1px solid var(--ok); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }

.card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 16px 18px; margin-bottom: 14px;
}
.card-accent { border-color: var(--accent); background: var(--accent-soft); }
.form-card label:first-child { margin-top: 0; }
.hero-card { border-color: var(--accent); }
.hero-time { font-size: 1.05rem; margin: 8px 0; }
.session-card { cursor: pointer; transition: transform .1s; }
.session-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.session-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session-name { font-weight: 700; }
.invite-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.invite-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.joiner-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

.pill {
    font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 10px;
    background: var(--bg-elevated); border: 1px solid var(--border); white-space: nowrap;
}
.pill-active { background: rgba(231, 76, 60, .2); border-color: var(--danger); }
.pill-scheduled, .pill-open { background: var(--accent-soft); border-color: var(--accent); }
.pill-completed, .pill-resolved { background: rgba(46, 204, 113, .15); border-color: var(--ok); }
.pill-cancelled { opacity: .6; }
.pill-invite { background: rgba(241, 196, 15, .2); border-color: var(--c-away); }
.pill-mine-in { background: rgba(46, 204, 113, .15); border-color: var(--ok); }
.pill-mine-out { opacity: .7; }
.pill-closing { background: rgba(241, 196, 15, .2); border-color: var(--c-away); }

.page { max-width: 1080px; }
.page-narrow { max-width: 720px; }
.page-full { max-width: none; height: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
/* min(…, 100%): a 330 px minimum column in a 262 px space clipped the "Open" action off every
   poll card on a phone (mobile-53) */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 12px; }
.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 960px) { .detail-grid { grid-template-columns: 1fr; } }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { background: none; border: 1px solid var(--border); border-radius: 18px; padding: 6px 16px; color: var(--text-secondary); cursor: pointer; }
.tab-active { background: var(--accent-soft); border-color: var(--accent); color: var(--text-primary); font-weight: 600; }
.participant-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.participant-row:last-child { border-bottom: none; }

/* polls */
.poll-option { display: flex; align-items: center; gap: 10px; padding: 8px 4px; position: relative; font-weight: 400; margin: 0; }
.poll-option input { width: auto; }
.poll-label { min-width: 220px; z-index: 1; }
.poll-bar { position: absolute; left: 0; top: 4px; bottom: 4px; background: var(--accent-soft); border-radius: 8px; z-index: 0; transition: width .3s; }
.poll-count { margin-left: auto; font-weight: 700; z-index: 1; }
.slot-row { display: flex; gap: 6px; margin-bottom: 6px; }

/* chat */
.chat-panel { display: flex; flex-direction: column; height: 520px; }
.chat-card { position: sticky; top: 0; }
.chat-pinned { background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; font-size: .82rem; margin-bottom: 6px; }
.chat-scroll { flex: 1; overflow-y: auto; padding-right: 4px; }
/* The scroll-up history sentinel: one row above the first message that is in turn the
   IntersectionObserver's target, the fallback button, the "loading" row and the
   start-of-conversation marker. Its height must stay the same in all three states — the swap that
   retires the button happens in the SAME render as a prepended page, so any height it gains or
   loses there lands on top of the offset the scroll-anchor restore is compensating for and the
   reader is left off by exactly that much. */
.chat-top { display: flex; justify-content: center; align-items: center; min-height: 34px; }
.chat-more { display: block; }
.chat-start { color: var(--text-secondary); font-size: .78rem; }
.chat-msg { display: flex; gap: 8px; margin: 10px 0; }
.chat-mine .chat-bubble { background: var(--accent-soft); }
.chat-bubble-wrap { min-width: 0; flex: 1; }
.chat-meta { display: flex; gap: 8px; align-items: baseline; font-size: .78rem; }
.chat-sender { font-weight: 700; }
.chat-bubble { background: var(--bg-elevated); border-radius: 10px; padding: 7px 11px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.chat-deleted { font-style: italic; color: var(--text-secondary); }
.chat-edit { margin-top: 2px; }
.chat-reactions { display: flex; gap: 4px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.reaction { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 1px 8px; font-size: .78rem; cursor: pointer; color: var(--text-primary); }
.reaction-mine { border-color: var(--accent); background: var(--accent-soft); }
.chat-tools { display: none; gap: 2px; }
.chat-msg:hover .chat-tools, .chat-msg:focus-within .chat-tools { display: flex; }
/* a touch screen has no hover: the actions were unreachable there (chat-118) */
@media (hover: none) { .chat-tools { display: flex; } }
.chat-day { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: .74rem; color: var(--text-secondary); letter-spacing: .04em; text-transform: uppercase; }
.chat-day::before, .chat-day::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.chat-gone { display: block; text-align: center; padding: 20px 0; }
.chat-composer-off { padding: 9px 12px; border: 1px dashed var(--border); border-radius: 10px; font-size: .88rem; }
.tool { background: none; border: none; cursor: pointer; font-size: .85rem; opacity: .7; padding: 1px 3px; }
.tool:hover { opacity: 1; }
.chat-composer { display: flex; gap: 8px; margin-top: 10px; }

/* messages page */
.messages-grid { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: calc(100vh - 130px); }
.dm-pane-head { display: none; align-items: center; gap: 10px; margin-bottom: 8px; }
.dm-pane-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.dm-list { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; overflow-y: auto; }
.dm-item { display: flex; gap: 10px; width: 100%; padding: 8px; border-radius: 10px; background: none; border: none; color: var(--text-primary); cursor: pointer; text-align: left; }
.dm-item:hover, .dm-active { background: var(--accent-soft); }
.dm-meta { min-width: 0; }
.dm-name { font-weight: 700; display: flex; gap: 6px; align-items: center; }
.dm-name .badge { position: static; }
.dm-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
/* min-height: 0 overrides the grid item's content-based automatic minimum: without it the pane
   grows to the full conversation height, .chat-panel's height:100% collapses to content size, and
   the chat can only be scrolled as a whole page with the composer below the fold (chat-25/32/60) */
.dm-pane { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; min-height: 0; }
.dm-pane .chat-panel { height: 100%; }
.dm-placeholder { display: grid; place-items: center; height: 100%; }

/* pickers — results float as a dropdown so they never push the page layout */
.picker-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70;
    max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-elevated); box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.picker-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; background: none; border: none; border-bottom: 1px solid var(--border); color: var(--text-primary); cursor: pointer; text-align: left; }
.picker-item:last-child { border-bottom: none; }
.picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-genres { flex: 0 1 auto; max-width: 45%; font-size: .78rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item:hover { background: var(--accent-soft); }
.picker-selected { background: var(--accent-soft); border-left: 3px solid var(--accent); }
/* single-select: chosen game rendered at exactly input height */
.picker-chosen {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; padding: 9px 12px; border: 1px solid var(--accent); border-radius: 10px;
    background: var(--accent-soft); font-size: .92rem; line-height: normal; box-sizing: border-box;
}
.picker-chosen-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.picker-chosen button { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 0 2px; }
.picker-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 14px; padding: 3px 10px; font-size: .82rem; display: inline-flex; gap: 6px; align-items: center; }
.chip button { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 0; }
.friend-pick { display: flex; gap: 8px; align-items: center; padding: 5px 0; font-weight: 400; margin: 0; }
.friend-pick input { width: auto; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { text-align: center; }
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--accent); }
.hour-chart { display: flex; gap: 3px; align-items: flex-end; height: 130px; min-width: 0; }
.hour-col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hour-bar { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.hour-label { text-align: center; font-size: .62rem; overflow: hidden; }
/* twenty-four labels do not fit a phone; every other one is enough to read the axis (stats-99) */
@media (max-width: 520px) { .hour-col:nth-child(even) .hour-label { visibility: hidden; } }

/* profile */
.profile-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 100; }
.modal { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: min(440px, 92vw); max-height: 86vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 16px; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 340px; }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }

/* auth */
.auth-shell { min-height: 100vh; display: grid; place-items: center; position: relative; padding: 20px; }
.auth-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 25% 20%, var(--accent-soft), transparent 50%), radial-gradient(circle at 80% 85%, var(--accent-soft), transparent 45%); }
.auth-card { position: relative; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px; width: min(460px, 94vw); }
.auth-logo { font-size: 1.6rem; font-weight: 800; margin-bottom: 14px; }
.auth-logo span { color: var(--accent); }
.auth-links { margin-top: 14px; font-size: .88rem; display: flex; gap: 8px; }

/* misc */
.localtime .countdown { color: var(--accent); font-weight: 600; }
details summary { cursor: pointer; margin: 8px 0; color: var(--accent); }
.game-picker { position: relative; }

/* avatar crop editor */
.avatar-editor { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.avatar-editor-preview { position: relative; }
.avatar-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.avatar-crop-canvas {
    width: 192px; height: 192px; border-radius: 50%;
    background: var(--bg-app); border: 2px solid var(--accent);
    touch-action: none; cursor: grab;
}
.avatar-crop-canvas:active { cursor: grabbing; }
.avatar-editor-controls { display: flex; flex-direction: column; gap: 6px; width: 192px; }
.avatar-zoom { width: 100%; accent-color: var(--accent); }
.avatar-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.btn-sm { padding: 5px 12px; font-size: 0.85rem; }

/* ---- circuit-death banner -------------------------------------------------------------------
   Blazor toggles #blazor-error-ui to display:block when the circuit is gone. It MUST default to
   display:none — the element is always present in the markup, so without this rule every page
   would permanently show "the connection was lost". */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 20px;
    background: var(--danger, #b3261e);
    color: #fff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .3);
    text-align: center;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: 10px; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; padding: 0 6px; }

/* ---- contained page failure (PageErrorBoundary) ---- */
.page-error { padding: 32px; max-width: 520px; margin: 0 auto; text-align: center; }
.page-error h2 { margin-bottom: 8px; }
.page-error .btn { margin-top: 16px; }

/* ---- circuit reconnect dialog (avatar-21) ---------------------------------------------------
   Everything below styles the element App.razor declares as #components-reconnect-modal.
   blazor.web.js owns its CLASS list and nothing else: it adds exactly one of
   components-reconnect-{show,hide,retrying,paused,failed,resume-failed,rejected} — retrying
   arrives on top of show — and writes the retry counters into the three spans inside. A class the
   stylesheet has no rule for is a state the user never sees, so all seven are handled here.
   Appended as one block on purpose: this file is edited by several people at once. */
#components-reconnect-modal {
    display: none;   /* the element is in the markup of every page */
    position: fixed;
    inset: 0;
    z-index: 2000;   /* over #blazor-error-ui (1000): a lost circuit outranks any page banner */
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(6, 7, 11, .74);
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-paused,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-resume-failed,
#components-reconnect-modal.components-reconnect-rejected { display: flex; }

/* Most drops are recovered inside a second (a redeploy, a phone changing network), and an overlay
   that flashes for half a second is worse than no overlay at all — so the retrying state fades in
   only after the framework's first few instant attempts have had their chance.

   pointer-events is the other half of that delay. `both` fill-mode applies the from-keyframe
   (opacity 0) for the whole 900 ms, so without this the page spends every disconnect under a
   full-viewport, completely transparent, perfectly clickable overlay. Circuit-bound controls are
   dead anyway, but ordinary <a href> navigation and text selection still work while a circuit is
   down and are the fastest way out — a full page load recovers the app. Swallowing those while
   showing nothing is the worst of both. The states that appear immediately below re-enable it,
   as does the animation's end. */
#components-reconnect-modal.components-reconnect-show { animation: reconnect-appear 160ms ease-out 900ms both; pointer-events: none; }
#components-reconnect-modal.components-reconnect-show .reconnect-card { pointer-events: auto; }

/* The states nothing can recover from on its own appear at once: they are waiting on the user. */
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-resume-failed,
#components-reconnect-modal.components-reconnect-rejected { animation: none; opacity: 1; pointer-events: auto; }

/* what takes the overlay away again after a successful rejoin — last, so it wins on ties */
#components-reconnect-modal.components-reconnect-hide { display: none; }

#components-reconnect-modal .reconnect-card {
    width: 100%;
    max-width: 380px;
    padding: 24px;
    text-align: center;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
}
#components-reconnect-modal .reconnect-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 6px; }
#components-reconnect-modal .reconnect-line { margin: 0; color: var(--text-secondary); }
#components-reconnect-modal .reconnect-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 14px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: reconnect-spin 900ms linear infinite;
}
#components-reconnect-modal.components-reconnect-failed .reconnect-spinner,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-spinner,
#components-reconnect-modal.components-reconnect-rejected .reconnect-spinner { display: none; }

/* one state's wording at a time */
#components-reconnect-modal .reconnect-on-retrying,
#components-reconnect-modal .reconnect-on-paused,
#components-reconnect-modal .reconnect-on-failed,
#components-reconnect-modal .reconnect-on-rejected { display: none; }
#components-reconnect-modal.components-reconnect-show .reconnect-on-retrying,
#components-reconnect-modal.components-reconnect-retrying .reconnect-on-retrying,
#components-reconnect-modal.components-reconnect-paused .reconnect-on-paused,
#components-reconnect-modal.components-reconnect-failed .reconnect-on-failed,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-on-failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-on-rejected { display: block; }

#components-reconnect-modal .reconnect-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 18px;
}
/* Reload is the only action that works in every state — "rejected" above all, where the server has
   already thrown the circuit away and retrying can never succeed — so it is never hidden. */
#components-reconnect-modal .reconnect-retry,
#components-reconnect-modal .reconnect-resume { display: none; }
#components-reconnect-modal.components-reconnect-failed .reconnect-retry,
#components-reconnect-modal.components-reconnect-paused .reconnect-resume,
#components-reconnect-modal.components-reconnect-resume-failed .reconnect-resume { display: inline-block; }

@keyframes reconnect-spin { to { transform: rotate(360deg); } }
@keyframes reconnect-appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    #components-reconnect-modal .reconnect-spinner { animation: none; }
    #components-reconnect-modal.components-reconnect-show { animation-duration: 1ms; }
}

/* ---- settings timezone picker ----
   A combobox rather than a <datalist>: the suggestion has to carry the offset and the clock on
   the wall in that zone, which a datalist cannot render, and each row has to be pickable by
   thumb — the mobile shell holds every other control to a 44px target. */
.tzpicker { position: relative; }
.tzpicker-input { width: 100%; }
/* In the flow of the form, not floating over it: floated, the open list covered the reminder
   select, the mute checkbox and "Save profile", and a click aimed at Save chose a time zone
   instead (tz-128). The form grows while the list is open; nothing sits underneath it. */
.tzpicker-list {
    position: relative; margin-top: 6px;
    max-height: min(320px, 50vh); overflow-y: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-elevated); box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.tzpicker-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: 100%; min-height: 44px; padding: 8px 12px; background: none; border: none;
    border-bottom: 1px solid var(--border); color: var(--text-primary);
    cursor: pointer; text-align: left; font-size: .9rem;
}
.tzpicker-item:last-child { border-bottom: none; }
.tzpicker-item:hover, .tzpicker-active { background: var(--accent-soft); }
/* inset instead of a real border so the highlighted row does not shift by 3px as it moves */
.tzpicker-active { box-shadow: inset 3px 0 0 var(--accent); }
.tzpicker-auto { font-weight: 600; }
.tzpicker-where { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tzpicker-city { font-weight: 600; }
.tzpicker-region { margin-left: 6px; }
.tzpicker-meta {
    flex: 0 0 auto; font-size: .78rem; color: var(--text-secondary);
    white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tzpicker-empty { padding: 10px 12px; }
.tzpicker-hint, .tzpicker-error { margin: 4px 0 0; font-size: .82rem; }
.tzpicker-error { color: var(--danger); }

/* ---- phones (mobile-13/14/15/54/116) ----------------------------------------------------------
   The desktop shell assumed ~1100 px and had one breakpoint. Below 700 px every signed-in page was
   ~84 px wider than the screen (the top bar never wrapped, the account chip fell off), /messages
   laid its whole conversation pane off the right edge, fixed overlays were centred in that widened
   viewport, and nothing was sized for a thumb. */
@media (max-width: 700px) {
    .app-shell { grid-template-columns: 56px 1fr; }
    .nav-item { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
    .nav-logo { font-size: 22px; }
    .app-body { padding: 14px 12px; }
    .topbar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
    .topbar-search { flex: 1 1 100%; max-width: none; order: 2; }
    .topbar-actions { margin-left: auto; gap: 6px; min-width: 0; flex-wrap: wrap; }
    .user-chip > span:not(.status-dot) { display: none; }   /* the avatar is the chip */
    .user-chip { padding: 3px; }
    .rn-live { font-size: .78rem; padding: 3px 8px; }
    .btn-readynow { padding: 6px 12px; }
    .dropdown, .dropdown-wide { position: fixed; left: 10px; right: 10px; top: 58px; min-width: 0; max-width: none; }
    .page-head { flex-direction: column; align-items: stretch; }
    .detail-grid { grid-template-columns: 1fr; }
    .chat-card { position: static; }
    .modal { width: calc(100vw - 20px); }
    /* one column: the list, or the conversation with a way back */
    .messages-grid { grid-template-columns: 1fr; height: calc(100vh - 110px); }
    .messages-grid.has-room .dm-list { display: none; }
    .messages-grid:not(.has-room) .dm-pane { display: none; }
    .dm-pane-head { display: flex; }
    .dm-last { max-width: none; }
}
/* thumbs, not pointers: the phone web build shipped none of the mobile shell's target sizing
   (mobile-54). Coarse pointer = touch, whatever the width. */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-xs { min-height: 38px; padding: 8px 12px; }
    input:not([type=checkbox]):not([type=range]), select, textarea { min-height: 44px; font-size: 1rem; }
    input[type=checkbox] { width: 20px; height: 20px; }
    .dropdown-item { padding: 12px; }
    .tool { font-size: 1.05rem; padding: 6px 8px; }
    .reaction { padding: 4px 10px; }
    .friend-pick { padding: 10px 6px; }
}

/* ---- about / version ----
   Deliberately quiet. The build identity earns its place because it is the first thing a support
   conversation needs, not because anyone wants to read it on every visit: no accent, no border of
   its own, and on /more it is one dim line under the fold of the menu. */
.about-card .about-app { font-weight: 600; }
.about-card .about-meta { margin-top: 2px; font-variant-numeric: tabular-nums; }
.m-version {
    margin: 18px 0 0;
    text-align: center;
    font-size: .76rem;
    opacity: .7;
}
