:root {
    --bg-color: #12151a;
    --card-bg: #1c2128;
    --border-color: #2d333b;
    --text-primary: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --online-color: #3fb950;
    --offline-color: #7d8590;
    --warning-color: #d29922;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 2rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.stats-badge span {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-left: 0.5rem;
}

.alert {
    border: 1px solid var(--warning-color);
    border-radius: 8px;
    color: var(--warning-color);
    padding: 1rem 1.5rem;
    margin: 0 0 1.5rem;
}

.alert strong {
    color: var(--text-primary);
}

.roster-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.roster-card + .roster-card {
    margin-top: 1.5rem;
}

.server-meta {
    color: var(--text-muted);
    margin: 0;
}

.server-meta strong {
    color: var(--text-primary);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.status-pill {
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.status-pill.online {
    background: rgba(63, 185, 80, 0.2);
    color: var(--online-color);
}

.status-pill.latest {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}

.status-pill.offline {
    background: rgba(125, 133, 144, 0.2);
    color: var(--offline-color);
}

.player-name {
    font-weight: 600;
}

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}
/* Admin pages */

a {
    color: var(--accent);
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.inline {
    display: inline;
    margin: 0;
}

.narrow {
    max-width: 420px;
    margin: 0 auto;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.row-form,
.log-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

label.checkbox {
    flex-direction: row;
    align-items: center;
}

input,
select {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font: inherit;
}

button,
.button {
    background: var(--accent);
    color: #0b1016;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button.secondary,
.button.secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

button.danger {
    background: #da3633;
    color: #fff;
}

button.link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font-weight: normal;
}

.notice {
    background: rgba(88, 166, 255, 0.12);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin: 0 0 1.5rem;
}

.card-head {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.server-card.is-silent {
    border-color: #d29922;
}

.status-pill.frozen {
    background: rgba(210, 153, 34, 0.2);
    color: #d29922;
}

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.5rem;
    margin: 1rem 0;
}

.facts dt {
    color: var(--text-muted);
}

.facts dd {
    margin: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.muted {
    color: var(--text-muted);
}

.log-view {
    background: #0b0e12;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 70vh;
    overflow: auto;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

.secret {
    font-size: 1.1rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-color);
    border-radius: 6px;
    user-select: all;
}

.one-time {
    border-color: var(--accent);
    margin-bottom: 1.5rem;
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
}

.dialog-backdrop .dialog {
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.release.current {
    border-color: var(--online-color);
}

.release h3 {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.site-footer {
    margin-top: 2rem;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 640px) {
    body {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .log-view {
        font-size: 0.7rem;
    }

    th,
    td {
        padding: 0.5rem;
    }
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tabs a {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
}

.tabs a[aria-current="page"] {
    background: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--accent);
}

div.log-view {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    height: 70vh;
}

.log-line {
    white-space: pre-wrap;
}

.log-time,
.log-start {
    color: var(--text-muted);
}

.log-start {
    text-align: center;
    padding-bottom: 0.5rem;
}

/* Outlined secondary button: the page's background, a blue border */
button.outline,
.button.outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

button.outline:hover,
.button.outline:hover {
    background: rgba(88, 166, 255, 0.12);
}

button.small {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

.logout-instead button {
    width: 100%;
}

.logout-instead {
    margin-top: 0.75rem;
}

.secret-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.secret-row .secret {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    word-break: break-all;
}

.icon-button {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
}

.table-scroll {
    overflow-x: auto;
}

table.accounts td {
    vertical-align: middle;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

dialog.modal {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    width: min(420px, calc(100vw - 2rem));
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

dialog.modal h2 {
    margin-top: 0;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.site-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.version-tag {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-muted);
    text-decoration: none;
}

.version-tag:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.status-pill {
    white-space: nowrap;
}

/* The browser's own arrow sits against the edge; this one has room */
select {
    appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238b949e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 12px 8px;
}

.dialog-intro {
    margin-bottom: 1.25rem;
}

.nav-button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Phones */

.stats-badge {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stats-badge span {
    margin-left: 0;
}

@media (max-width: 720px) {
    header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    h1 {
        font-size: 1.5rem;
        margin: 0;
    }
}

/* Tables become cards on phones and tablets, where their columns don't fit */
@media (max-width: 860px) {
    /* Tables become a card per row, each value labelled */
    table.stack-table,
    .stack-table tbody,
    .stack-table tr,
    .stack-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .stack-table thead {
        display: none;
    }

    .stack-table tr {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.75rem 1rem;
        margin-top: 0.75rem;
        background: var(--bg-color);
    }

    .stack-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        padding: 0.35rem 0;
        border: none;
        text-align: right;
    }

    .stack-table td[data-label]::before {
        content: attr(data-label);
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }

    .stack-table td.card-title,
    .stack-table td.player-name,
    .stack-table td.card-meta {
        justify-content: flex-start;
        text-align: left;
    }

    .stack-table td.player-name {
        font-size: 1.05rem;
    }

    .stack-table td.card-meta {
        color: var(--text-muted);
        font-size: 0.85rem;
    }

    .stack-table td.card-actions:empty,
    .stack-table td.card-actions:not(:has(*)) {
        display: none;
    }

    .stack-table .row-actions {
        width: 100%;
        padding-top: 0.5rem;
    }

    .stack-table .row-actions form,
    .stack-table .row-actions button {
        flex: 1;
        width: 100%;
    }

    .stack-table td.empty {
        justify-content: center;
        text-align: center;
    }

    .table-scroll {
        overflow-x: visible;
    }
}

@media (max-width: 640px) {
    .roster-card {
        padding: 1rem;
    }

    /* Forms take the full width */
    .row-form,
    .log-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .log-controls label.checkbox {
        flex-direction: row;
    }

    .facts {
        grid-template-columns: 1fr;
        gap: 0.1rem;
    }

    .facts dd {
        margin-bottom: 0.5rem;
    }

    .actions > * {
        flex: 1;
    }

    .actions .button,
    .actions button {
        width: 100%;
        text-align: center;
    }

    div.log-view {
        height: 60vh;
    }
}

.page-links {
    display: flex;
    gap: 1rem;
}

.actions button,
.actions .button {
    white-space: nowrap;
}

.narrow + .narrow,
.narrow + div > .narrow {
    margin-top: 1.5rem;
}

.nickname {
    font-weight: normal;
    font-size: 0.8rem;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    margin-left: 0.25rem;
    white-space: nowrap;
}

.account-role {
    display: block;
    margin-top: 0.4rem;
    line-height: 1.4;
    font-weight: normal;
    font-size: 0.8rem;
    color: var(--text-muted);
}

table.accounts th,
table.accounts td {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.account-role .status-pill {
    display: block;
    width: fit-content;
    margin-top: 0.5rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.65rem;
    line-height: 1.3;
}

table.accounts td {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
}

td.nowrap {
    white-space: nowrap;
}

.nickname-form {
    display: flex;
    gap: 0.4rem;
    margin: 0;
}

.nickname-form input {
    width: 9rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
}

@media (max-width: 860px) {
    .nickname-cell .nickname-form {
        flex: 1;
        min-width: 0;
        justify-content: flex-end;
    }

    .nickname-cell .nickname-form input {
        flex: 1;
        width: 0;
        min-width: 0;
    }

    .nickname-cell:not(:has(form)) {
        display: none;
    }
}

/* Dashboard roster */

.server-cards {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    margin-bottom: 1.5rem;
}

.server-chip {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 9rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.server-chip.active {
    border-color: var(--accent);
}

.chip-name {
    font-weight: 600;
}

.chip-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.roster-head {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.roster-head h2 {
    margin: 0;
}

.roster-search {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    max-width: 22rem;
}

.roster-search input {
    flex: 1;
    width: 0;
    min-width: 0;
}

.segmented {
    display: inline-flex;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.segmented a {
    padding: 0.35rem 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.segmented a + a {
    border-left: 1px solid var(--border-color);
}

.segmented a[aria-current] {
    background: rgba(88, 166, 255, 0.15);
    color: var(--text-primary);
}

table.roster td {
    vertical-align: middle;
}

.roster .who {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.6rem;
    align-items: center;
}

.roster .steam-id {
    grid-column: 2;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.status-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--offline-color);
    grid-row: span 2;
}

.status-dot.online {
    background: var(--online-color);
    box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.2);
}

.where-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-right: 0.15rem;
}

.online-now {
    color: var(--online-color);
}

.num {
    text-align: right;
    white-space: nowrap;
}

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.pager-links {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .roster-search {
        max-width: none;
        flex-basis: 100%;
    }

    /* One compact row per player: name and where on the left, playtime
       and last seen on the right */
    table.roster thead,
    table.roster .wide-only {
        display: none;
    }

    table.roster,
    table.roster tbody {
        display: block;
    }

    table.roster tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "who playtime"
            "where seen";
        column-gap: 0.75rem;
        row-gap: 0.2rem;
        padding: 0.65rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    table.roster td {
        padding: 0;
        border: none;
        font-size: 0.9rem;
    }

    table.roster .who { grid-area: who; }
    table.roster .where { grid-area: where; color: var(--text-muted); font-size: 0.8rem; }
    table.roster .seen { grid-area: seen; text-align: right; color: var(--text-muted); font-size: 0.8rem; }
    table.roster .playtime { grid-area: playtime; }

    table.roster .steam-id {
        display: none;
    }

    .status-dot {
        grid-row: auto;
    }

    table.roster td.empty {
        grid-column: 1 / -1;
        padding: 1.5rem 0;
    }
}

/* Notifications bell: after Log out on wide screens, beside Menu on phones */
header {
    gap: 1rem;
}

header h1 {
    margin-right: auto;
}

/* Header: page links, then the bell, settings and log out */
.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.icon-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
}

.icon-link:hover,
.icon-link[aria-current="page"] {
    border-color: var(--accent);
    color: var(--accent);
}

.bell-count {
    position: absolute;
    top: -0.45rem;
    right: -0.45rem;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.3rem;
    box-sizing: border-box;
    border-radius: 999px;
    background: #da3633;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.15rem;
    text-align: center;
}

.bell-count[hidden] {
    display: none;
}

.notifications tr.unread {
    background: rgba(88, 166, 255, 0.06);
}

.notifications tr.level-warning strong {
    color: #d29922;
}

.notifications tr.level-ok strong {
    color: var(--online-color);
}

.event-body {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.new-tag {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 0 0.3rem;
    margin-left: 0.3rem;
}

@media (max-width: 720px) {
    /* The title gets its own row; links and icons share the next */
    header h1 {
        width: 100%;
        margin-right: 0;
    }

    header .admin-nav {
        margin-right: auto;
    }
}

@media (max-width: 860px) {
    .notifications td.event {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        text-align: left;
    }

    .notifications td.event::before {
        align-self: flex-start;
    }
}

/* Settings: a sidebar beside the page on wide screens, tabs above it on phones */
.container.wide {
    max-width: 1200px;
}

.settings-layout {
    display: grid;
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-nav h2 {
    margin: 0 0 0.5rem 0.75rem;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.settings-nav a {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    border-left: 3px solid transparent;
    color: var(--text-primary);
    text-decoration: none;
}

.settings-nav a small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.settings-nav a:hover {
    background: var(--card-bg);
}

.settings-nav a[aria-current="page"] {
    background: var(--card-bg);
    border-left-color: var(--accent);
    font-weight: 600;
}

.settings-main > .roster-card + .roster-card {
    margin-top: 1.5rem;
}

/* My account: the two forms side by side when there is room */
.settings-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.settings-columns > .roster-card {
    margin: 0;
    max-width: none;
}

@media (max-width: 860px) {
    .settings-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }

    .settings-nav {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        border-bottom: 1px solid var(--border-color);
        gap: 0;
    }

    .settings-nav h2,
    .settings-nav a small {
        display: none;
    }

    .settings-nav a {
        flex-shrink: 0;
        border-left: none;
        border-bottom: 2px solid transparent;
        border-radius: 0;
        padding: 0.6rem 0.9rem;
    }

    .settings-nav a[aria-current="page"] {
        background: none;
        border-bottom-color: var(--accent);
    }
}

.settings-column > .roster-card {
    max-width: none;
    margin: 0;
}

.settings-columns .narrow + div > .narrow {
    margin-top: 0;
}

.login-note {
    margin: 1.25rem 0 0;
}

/* Which servers an account can see */
.server-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.server-picker legend {
    padding: 0 0.35rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.server-picker[disabled] {
    opacity: 0.5;
}

.server-choices {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-left: 1.5rem;
}

.server-picker label.checkbox {
    gap: 0.5rem;
    color: var(--text-primary);
}

.server-picker .server-meta {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
}
