@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&family=VT323&display=swap');

:root {
    color-scheme: dark;
    --bg: #000000;
    --panel-bg: #000000;
    --fg: #ffffff;
    --line: #ffffff;
    --muted-line: rgba(255, 255, 255, 0.25);
}

:root.theme-light,
html.theme-light,
body.theme-light,
html.theme-light body,
body[data-theme='light'] {
    color-scheme: light;
    --bg: #f3ead7;
    --panel-bg: #fff8ea;
    --fg: #1f1a13;
    --line: #2f261b;
    --muted-line: rgba(47, 38, 27, 0.3);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--fg);
}

body {
    min-height: 100vh;
    font-family: 'IBM Plex Mono', monospace;
    text-shadow: none;
    transition: background-color 160ms ease, color 160ms ease;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

.bg-orb {
    display: none;
}

.page-shell {
    width: min(100vw - 8px, 1100px);
    margin: 0 auto;
    padding: 4px 0 24px;
}

.terminal-shell,
.hero-card,
.panel,
.user-card,
.empty-state,
.profile-panel,
.terminal-subpanel,
.terminal-empty,
.state-badge,
.tag,
.search-row input,
.search-row button,
.ghost-link,
.primary-link,
.back-link,
.stat-pill,
.character-card,
.inventory-card {
    border: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    background: var(--panel-bg);
}

.terminal-shell {
    position: relative;
    overflow: hidden;
    background: var(--panel-bg);
}

.terminal-shell::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(255, 255, 255, 0.03) 2px,
        rgba(255, 255, 255, 0.03) 3px
    );
    opacity: 0.65;
}

body.theme-light .terminal-shell::after,
html.theme-light body .terminal-shell::after {
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.05) 2px,
        rgba(0, 0, 0, 0.05) 3px
    );
    opacity: 0.45;
}

.terminal-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
}

body.theme-light .terminal-header,
html.theme-light body .terminal-header {
    background: linear-gradient(180deg, rgba(47, 38, 27, 0.08), rgba(47, 38, 27, 0.02));
}

.terminal-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.terminal-dots span {
    width: 8px;
    height: 8px;
    border: 1px solid var(--fg);
    background: var(--bg);
    border-radius: 0;
}

.terminal-title,
.terminal-status,
.theme-separator,
.theme-toggle,
.terminal-line,
.search-label,
.search-row input,
.search-row button,
.ghost-link.compact,
.eyebrow,
.section-kicker,
.terminal-prompt {
    font-family: 'VT323', monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg);
}

.theme-toggle {
    all: unset;
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--fg);
    padding: 0;
    min-width: 0;
    display: inline;
    box-shadow: none;
    outline: none;
    cursor: pointer;
    line-height: 1;
    font-family: 'VT323', monospace;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.terminal-status,
.theme-toggle,
.theme-separator {
    font-size: 1.15rem;
}

.terminal-right .theme-toggle,
body.theme-light .terminal-right .theme-toggle,
html.theme-light body .terminal-right .theme-toggle {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

#themeToggle,
#themeToggle:link,
#themeToggle:visited,
#themeToggle:hover,
#themeToggle:focus,
#themeToggle:active {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
}

.theme-toggle:hover {
    opacity: 0.75;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.matches-tabs {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.tab-link {
    min-height: 30px;
}

.tab-link.active {
    background: var(--fg);
    color: var(--bg);
}

.hero-actions .primary-link {
    max-width: 100%;
    padding: 8px 10px;
    line-height: 1.1;
}
.terminal-title {
    font-size: 1.45rem;
}

.history-list {
    margin-top: 0;
    display: grid;
    gap: 6px;
}
.history-item {
    border: 1px solid var(--line);
    padding: 6px 8px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
    font-size: 0.86rem;
}

.history-match-type {
    letter-spacing: 0.02em;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-kd {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    opacity: 0.9;
}

.match-history-panel {
    padding-top: 2px;
}

.match-overview-panel,
.scoreboard-panel {
    padding-top: 2px;
}

.scoreboard-panel {
    margin-top: 4px;
}

.scoreboard-panel .table-wrap {
    overflow-x: hidden;
}

.scoreboard-panel .live-scoreboard {
    width: 100%;
    max-width: 100%;
}
.live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
}
.live-match-card {
    display: grid;
    gap: 10px;
}
.live-score-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
}
.score-box {
    border: 1px solid var(--line);
    padding: 8px;
    display: grid;
    gap: 4px;
    text-align: center;
}
.score-box span {
    font-size: 1.5rem;
    line-height: 1;
}
.score-divider {
    font-size: 1.4rem;
}
.live-player-list {
    display: grid;
    gap: 6px;
}
.live-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding-top: 6px;
    font-size: 0.9rem;
}
.live-player-name {
    font-weight: 700;
}
.live-player-meta {
    opacity: 0.9;
}

.match-profile-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.match-meta-grid {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 0.86rem;
    opacity: 0.92;
}

.match-meta-item {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    border-top: 1px dashed var(--muted-line);
    padding-top: 5px;
}

.match-meta-item strong {
    min-width: 68px;
    font-family: 'VT323', monospace;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.table-wrap {
    margin-top: 8px;
    overflow-x: auto;
}

.match-actions-row {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 8px;
    font-size: 0.82rem;
    white-space: nowrap;
}

.match-link-icon {
    min-width: 32px;
    min-height: 28px;
    padding: 4px 7px;
    font-size: 1rem;
    line-height: 1;
}

.completed-copy-tag {
    position: relative;
    cursor: copy;
    text-decoration: none;
}

.completed-copy-tag:hover::after {
    content: 'copy link';
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    border: 1px solid var(--line);
    background: var(--panel-bg);
    color: var(--fg);
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    padding: 2px 6px;
    white-space: nowrap;
    z-index: 3;
}

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.9rem;
    border: 1px solid var(--line);
    background: var(--bg);
}

.scoreboard-table th,
.scoreboard-table td {
    border: 1px solid var(--line);
    padding: 5px 8px;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.scoreboard-table thead th {
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0;
    text-transform: none;
    font-size: 0.88rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.14);
}

.scoreboard-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}

.scoreboard-table td:last-child {
    text-align: center;
}

.live-scoreboard {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--line);
    background: var(--panel-bg);
}

.live-scoreboard thead th {
    background: rgba(255, 255, 255, 0.2);
    white-space: nowrap;
    padding-top: 8px;
    padding-bottom: 8px;
}

.live-scoreboard tbody td {
    background: transparent;
}

.live-scoreboard.player-kd-board th:nth-child(1),
.live-scoreboard.player-kd-board td:nth-child(1) {
    width: 66%;
}

.live-scoreboard.player-kd-board th:nth-child(2),
.live-scoreboard.player-kd-board td:nth-child(2) {
    width: 17%;
    text-align: right;
}

.live-scoreboard.player-kd-board th:nth-child(3),
.live-scoreboard.player-kd-board td:nth-child(3) {
    width: 17%;
    text-align: right;
}

.scoreboard-panel .live-scoreboard.player-kd-board th:nth-child(1),
.scoreboard-panel .live-scoreboard.player-kd-board td:nth-child(1) {
    width: 60%;
}

.scoreboard-panel .live-scoreboard.player-kd-board th:nth-child(2),
.scoreboard-panel .live-scoreboard.player-kd-board td:nth-child(2),
.scoreboard-panel .live-scoreboard.player-kd-board th:nth-child(3),
.scoreboard-panel .live-scoreboard.player-kd-board td:nth-child(3) {
    width: 18%;
}

.live-scoreboard.player-kd-board thead th:nth-child(1),
.live-scoreboard.player-kd-board tbody td:nth-child(1) {
    text-align: left;
}

.live-scoreboard.player-kd-board thead th:nth-child(2),
.live-scoreboard.player-kd-board thead th:nth-child(3),
.live-scoreboard.player-kd-board tbody td:nth-child(2),
.live-scoreboard.player-kd-board tbody td:nth-child(3) {
    text-align: right;
    padding-right: 10px;
    font-variant-numeric: tabular-nums;
}

.scoreboard-panel .live-scoreboard.player-kd-board thead th:nth-child(2),
.scoreboard-panel .live-scoreboard.player-kd-board thead th:nth-child(3),
.scoreboard-panel .live-scoreboard.player-kd-board tbody td:nth-child(2),
.scoreboard-panel .live-scoreboard.player-kd-board tbody td:nth-child(3) {
    padding-right: 6px;
}

.live-scoreboard.player-kd-board th + th,
.live-scoreboard.player-kd-board td + td {
    border-left: 1px solid var(--line);
}

.live-scoreboard.player-kd-board tbody tr + tr td {
    border-top: 1px dashed var(--muted-line);
}

.live-scoreboard.player-kd-board tbody td {
    padding-top: 7px;
    padding-bottom: 7px;
}

.live-scoreboard tbody tr {
    transition: background-color 140ms ease;
}

.live-scoreboard tbody tr:hover {
    background: rgba(255, 255, 255, 0.09);
}

.live-scoreboard .player-name-cell {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.player-profile-link {
    text-decoration: underline;
    text-underline-offset: 2px;
    color: #ff5a5a;
}

.player-profile-link:hover {
    opacity: 0.9;
}

body.theme-light .scoreboard-table thead th,
body.theme-light .live-scoreboard thead th,
html.theme-light body .scoreboard-table thead th,
html.theme-light body .live-scoreboard thead th {
    background: rgba(47, 38, 27, 0.14);
}

body.theme-light .scoreboard-table tbody tr:nth-child(even),
html.theme-light body .scoreboard-table tbody tr:nth-child(even) {
    background: rgba(47, 38, 27, 0.05);
}

body.theme-light .live-scoreboard tbody tr:hover,
html.theme-light body .live-scoreboard tbody tr:hover {
    background: rgba(47, 38, 27, 0.07);
}

body.theme-light .live-scoreboard tbody td,
html.theme-light body .live-scoreboard tbody td {
    background: transparent;
}

body.theme-light .player-profile-link,
html.theme-light body .player-profile-link {
    color: #b30000;
}

.live-scoreboard .team-cell {
    font-family: 'VT323', monospace;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
}

.live-scoreboard .stat-k {
    color: #9cffbe;
    font-weight: 700;
}

.live-scoreboard .stat-d {
    color: #ffb0b0;
    font-weight: 700;
}

.live-scoreboard .stat-k,
.live-scoreboard .stat-d {
    font-family: 'VT323', monospace;
    font-size: 1.12rem;
    letter-spacing: 0.04em;
}

.score-tile {
    display: block;
    width: 100%;
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 5px;
    line-height: 1.1;
}

.score-head {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 700;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    text-align: center;
}

.score-name {
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.live-scoreboard.player-kd-board thead th,
.live-scoreboard.player-kd-board tbody td {
    padding: 2px;
    background: transparent;
}

.live-scoreboard.player-kd-board tbody tr:hover .score-tile {
    background: rgba(255, 255, 255, 0.18);
}

.kill-cell,
.death-cell {
    white-space: nowrap;
}

.live-scoreboard.player-kd-board .player-name-cell,
.live-scoreboard.player-kd-board .kill-cell,
.live-scoreboard.player-kd-board .death-cell {
    background: transparent;
}

.live-scoreboard.player-kd-board tbody tr:hover .player-name-cell,
.live-scoreboard.player-kd-board tbody tr:hover .kill-cell,
.live-scoreboard.player-kd-board tbody tr:hover .death-cell {
    background: transparent;
}

body.theme-light .live-scoreboard.player-kd-board .player-name-cell,
body.theme-light .live-scoreboard.player-kd-board .kill-cell,
body.theme-light .live-scoreboard.player-kd-board .death-cell,
html.theme-light body .live-scoreboard.player-kd-board .player-name-cell,
html.theme-light body .live-scoreboard.player-kd-board .kill-cell,
html.theme-light body .live-scoreboard.player-kd-board .death-cell {
    background: transparent;
}

body.theme-light .live-scoreboard.player-kd-board tbody tr:hover .player-name-cell,
body.theme-light .live-scoreboard.player-kd-board tbody tr:hover .kill-cell,
body.theme-light .live-scoreboard.player-kd-board tbody tr:hover .death-cell,
html.theme-light body .live-scoreboard.player-kd-board tbody tr:hover .player-name-cell,
html.theme-light body .live-scoreboard.player-kd-board tbody tr:hover .kill-cell,
html.theme-light body .live-scoreboard.player-kd-board tbody tr:hover .death-cell {
    background: transparent;
}

body.theme-light .score-tile,
html.theme-light body .score-tile {
    background: rgba(47, 38, 27, 0.08);
}

body.theme-light .live-scoreboard.player-kd-board tbody tr:hover .score-tile,
html.theme-light body .live-scoreboard.player-kd-board tbody tr:hover .score-tile {
    background: rgba(47, 38, 27, 0.2);
}

.kill-cell .stat-k,
.death-cell .stat-d {
    display: inline-block;
    min-width: 2ch;
    text-align: right;
}

.historic-table td:nth-child(4),
.historic-table td:nth-child(5),
.historic-table td:nth-child(6) {
    text-align: center;
}

.historic-table th,
.historic-table td {
    padding: 4px 6px;
    font-size: 0.84rem;
    line-height: 1.15;
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.historic-table thead th {
    font-size: 0.92rem;
}

.historic-table td:nth-child(1) {
    min-width: 90px;
}

.historic-table td:nth-child(2) {
    min-width: 120px;
}

.historic-table td:last-child .action-link {
    min-height: 24px;
    padding: 2px 7px;
    font-size: 0.76rem;
}

.historic-section {
    border-color: rgba(255, 255, 255, 0.7);
}

.historic-table-wrap {
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 4px;
}

.historic-browser {
    display: grid;
    gap: 8px;
}

.live-browser {
    display: grid;
    gap: 8px;
}

.historic-browser .table-wrap {
    margin-top: 0;
    max-height: calc(100vh - 300px);
    overflow: auto;
    padding-right: 4px;
}

.live-browser .table-wrap {
    margin-top: 0;
    max-height: calc(100vh - 300px);
    overflow: auto;
    padding-right: 4px;
}

#live-matches,
#latest-users,
.historic-browser .table-wrap,
.live-browser .table-wrap {
    scrollbar-width: thin;
    scrollbar-color: var(--fg) var(--bg);
}

.historic-search-row {
    grid-template-columns: minmax(140px, 1fr) minmax(130px, 180px);
}

.live-filter-row {
    grid-template-columns: minmax(140px, 220px);
}

.search-row select {
    width: 100%;
    padding: 10px 10px 8px;
    background: #000;
    color: #fff;
    font-size: 1rem;
    border: 1px solid #fff;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color-scheme: dark;
}

.search-row select:focus {
    box-shadow: inset 0 0 0 1px #fff;
}

.search-row select option {
    background: #000;
    color: #fff;
}

body.theme-light .search-row select,
html.theme-light body .search-row select {
    background: #000;
    color: #fff;
    border-color: #fff;
}

body.theme-light .search-row select:focus,
html.theme-light body .search-row select:focus {
    box-shadow: inset 0 0 0 1px #fff;
}

body.theme-light .search-row select option,
html.theme-light body .search-row select option {
    background: #000;
    color: #fff;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 84px;
    border: 1px solid var(--line);
    padding: 2px 8px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.historic-table tbody tr {
    transition: background-color 120ms ease, color 120ms ease;
}

.historic-table tbody tr.historic-click-row,
.live-match-table tbody tr.match-click-row {
    cursor: pointer;
}

.historic-table tbody tr.historic-click-row:focus,
.live-match-table tbody tr.match-click-row:focus {
    outline: 1px solid var(--line);
    outline-offset: -1px;
}

.historic-table tbody tr.is-selected {
    background: rgba(255, 255, 255, 0.18);
}

.historic-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

.live-match-table tbody tr {
    transition: background-color 120ms ease, color 120ms ease;
}

.live-match-table tbody tr.is-selected {
    background: rgba(255, 255, 255, 0.18);
}

.live-match-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

.live-match-table td:nth-child(4),
.live-match-table td:nth-child(5),
.live-match-table td:nth-child(6) {
    text-align: center;
}
.terminal-status {
    font-size: 1.15rem;
}

.terminal-body {
    display: grid;
    gap: 12px;
    padding: 10px;
}

.roster-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 12px;
    align-items: start;
    min-height: 0;
}

.hero-card {
    padding: 12px;
}

.terminal-line,
.terminal-prompt {
    margin-top: 4px;
    font-size: 1.15rem;
}

.terminal-prompt {
    padding: 8px 10px;
    margin-top: 8px;
}

.stat-row,
.profile-tags,
.profile-actions,
.meta-row,
.user-card-top,
.section-header,
.profile-hero,
.profile-grid,
.detail-list,
.inventory-grid {
    display: grid;
    gap: 10px;
}

.stat-row {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-top: 10px;
}

.stat-row.single {
    grid-template-columns: minmax(180px, 260px);
}

.stat-pill {
    padding: 10px 12px;
}

.stat-pill strong {
    display: block;
    font-size: 2rem;
    line-height: 1;
    color: var(--fg);
}

.hero-copy,
.muted,
.panel-copy,
.tag,
.meta-row,
.detail-list dt,
.detail-list dd,
.character-card p,
.inventory-card span,
.empty-state p,
.panel-empty p {
    color: var(--fg);
}

.section-header {
    align-items: end;
    grid-template-columns: 1fr auto;
}

.section-header h1,
.section-header h2,
.section-header h3,
.section-header h4 {
    margin: 0;
    line-height: 1.1;
}

.section-header .tag,
.section-header .completed-copy-tag {
    min-height: 24px;
    min-width: 74px;
    justify-content: center;
    line-height: 1;
    padding: 3px 8px;
    white-space: nowrap;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
}

.search-bar {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.player-search-row {
    grid-template-columns: 1fr;
}

.search-row input {
    width: 100%;
    padding: 10px 10px 8px;
    background: var(--panel-bg);
    color: var(--fg);
    font-size: 1rem;
    outline: none;
    transition: box-shadow 140ms ease;
}

.search-row input:focus {
    box-shadow: inset 0 0 0 1px var(--line);
}

.search-row input::placeholder {
    color: var(--fg);
    opacity: 0.55;
}

.search-row button,
.ghost-link,
.primary-link,
.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--panel-bg);
    color: var(--fg);
    text-transform: uppercase;
    cursor: pointer;
}

.ghost-link.compact {
    padding: 6px 10px;
}

.search-row button:hover,
.ghost-link:hover,
.primary-link:hover,
.back-link:hover {
    background: var(--fg);
    color: var(--bg);
}

.user-card:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
    color: var(--fg);
    border-color: rgba(255, 255, 255, 0.6);
}

.user-card.active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.12));
    border-color: rgba(255, 255, 255, 0.75);
}

body.theme-light .user-card:hover,
html.theme-light body .user-card:hover {
    background: linear-gradient(180deg, rgba(47, 38, 27, 0.14), rgba(47, 38, 27, 0.06));
    border-color: rgba(47, 38, 27, 0.45);
}

body.theme-light .user-card.active,
html.theme-light body .user-card.active {
    background: linear-gradient(180deg, rgba(47, 38, 27, 0.2), rgba(47, 38, 27, 0.1));
    border-color: rgba(47, 38, 27, 0.62);
}

.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-right: 6px;
}

.terminal-grid {
    align-items: start;
}

.user-card,
.empty-state {
    padding: 12px;
}

.user-card {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 84px;
    padding: 10px;
}

.user-avatar-wrap {
    position: relative;
    flex: 0 0 auto;
}

.user-avatar,
.profile-avatar {
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 0;
}

.user-avatar {
    width: 56px;
    height: 56px;
}

.user-card-body {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.user-card h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.handle {
    margin: 0;
    font-size: 0.82rem;
    opacity: 0.8;
}

.state-badge,
.tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
}

.meta-row {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
}

.steam-id {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.72;
}

.profile-hero {
    grid-template-columns: 140px 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.profile-main {
    display: grid;
    gap: 8px;
}

.profile-tags,
.profile-actions {
    grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
}

.profile-main h1 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.15;
}

.hero-copy {
    margin: 0;
    opacity: 0.88;
}

.profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.profile-panel,
.terminal-subpanel {
    padding: 10px;
}

.profile-panel {
    position: sticky;
    top: 8px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
}

.user-grid::-webkit-scrollbar,
.profile-panel::-webkit-scrollbar,
#live-matches::-webkit-scrollbar,
#latest-users::-webkit-scrollbar,
.historic-browser .table-wrap::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.user-grid::-webkit-scrollbar-track,
.profile-panel::-webkit-scrollbar-track,
#live-matches::-webkit-scrollbar-track,
#latest-users::-webkit-scrollbar-track,
.historic-browser .table-wrap::-webkit-scrollbar-track {
    background: var(--bg);
}

.user-grid::-webkit-scrollbar-thumb,
.profile-panel::-webkit-scrollbar-thumb,
#live-matches::-webkit-scrollbar-thumb,
#latest-users::-webkit-scrollbar-thumb,
.historic-browser .table-wrap::-webkit-scrollbar-thumb {
    background: var(--fg);
    border: 2px solid var(--bg);
}

.compact-profile {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 0;
}

.compact-profile .profile-avatar-shell {
    min-height: 0;
    justify-items: start;
}

.compact-profile .profile-avatar {
    width: 96px;
    height: 96px;
}

.compact-profile .profile-tags,
.compact-profile .profile-actions {
    grid-template-columns: 1fr;
}

.panel.span-2 {
    grid-column: span 2;
}

.roster-layout.historic-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    width: 100%;
}

.roster-layout.historic-layout .panel.span-2 {
    grid-column: auto;
}

.roster-layout.historic-layout .historic-section,
.roster-layout.historic-layout .historic-browser,
.roster-layout.historic-layout .table-wrap,
.roster-layout.historic-layout .historic-table {
    width: 100%;
}

.roster-layout.historic-layout .historic-browser,
.roster-layout.historic-layout .historic-table-wrap,
.roster-layout.historic-layout .historic-browser .table-wrap {
    max-width: none;
}

.roster-layout.historic-layout .historic-browser .table-wrap {
    max-height: calc(100vh - 250px);
}

.roster-layout.historic-layout #match-panel {
    width: auto;
    max-width: 340px;
}

.roster-layout.historic-layout .historic-table {
    table-layout: fixed;
}

.roster-layout.historic-layout .historic-table th,
.roster-layout.historic-layout .historic-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roster-layout.historic-layout .historic-table th:nth-child(1),
.roster-layout.historic-layout .historic-table td:nth-child(1) {
    width: 24%;
}

.roster-layout.historic-layout .historic-table th:nth-child(2),
.roster-layout.historic-layout .historic-table td:nth-child(2) {
    width: 24%;
}

.roster-layout.historic-layout .historic-table th:nth-child(3),
.roster-layout.historic-layout .historic-table td:nth-child(3) {
    width: 15%;
    overflow: visible;
    text-overflow: clip;
}

.roster-layout.historic-layout .historic-table th:nth-child(4),
.roster-layout.historic-layout .historic-table td:nth-child(4) {
    width: 11%;
}

.roster-layout.historic-layout .historic-table th:nth-child(5),
.roster-layout.historic-layout .historic-table td:nth-child(5) {
    width: 13%;
}

.roster-layout.historic-layout .historic-table th:nth-child(6),
.roster-layout.historic-layout .historic-table td:nth-child(6) {
    width: 13%;
}

.live-match-table th:nth-child(1),
.live-match-table td:nth-child(1) {
    width: 24%;
}

.live-match-table th:nth-child(2),
.live-match-table td:nth-child(2) {
    width: 24%;
}

.live-match-table th:nth-child(3),
.live-match-table td:nth-child(3) {
    width: 15%;
}

.live-match-table th:nth-child(4),
.live-match-table td:nth-child(4) {
    width: 11%;
}

.live-match-table th:nth-child(5),
.live-match-table td:nth-child(5) {
    width: 13%;
}

.live-match-table th:nth-child(6),
.live-match-table td:nth-child(6) {
    width: 13%;
}

.roster-layout.historic-layout .table-wrap {
    overflow-x: auto;
}

.detail-list {
    margin-top: 10px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.detail-list div {
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.detail-list dt {
    margin-bottom: 4px;
    font-size: 0.75rem;
}

.detail-list dd {
    margin: 0;
    word-break: break-word;
}

.character-card,
.inventory-card {
    padding: 12px;
}

.character-card {
    display: grid;
    gap: 4px;
    margin-top: 10px;
}

.inventory-grid {
    margin-top: 10px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.inventory-card {
    display: grid;
    gap: 6px;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px 12px;
}

.terminal-empty,
.panel-empty {
    padding: 12px;
}

.profile-avatar-shell,
.terminal-avatar-shell {
    position: relative;
    width: 100%;
    min-height: 160px;
    display: grid;
    place-items: center;
}

.profile-avatar {
    width: 140px;
    height: 140px;
}

.profile-avatar-ring {
    display: none;
}

.terminal-profile-grid {
    margin-top: 8px;
}

@media (max-width: 920px) {
    .roster-layout {
        grid-template-columns: 1fr;
    }

    .user-grid {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .profile-panel {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .profile-hero,
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .panel.span-2 {
        grid-column: auto;
    }

    .search-row {
        grid-template-columns: 1fr;
    }

    .match-meta-grid {
        grid-template-columns: 1fr;
    }

    .action-link {
        white-space: normal;
    }
}

@media (max-width: 640px) {
    .hero-actions .primary-link {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100vw - 4px, 1100px);
        padding-top: 2px;
    }

    .terminal-header {
        gap: 8px;
        padding: 6px 8px;
    }

    .terminal-body {
        padding: 8px;
    }

    .user-card {
        align-items: flex-start;
    }

    .profile-avatar-shell,
    .terminal-avatar-shell {
        min-height: 120px;
    }

    .profile-avatar {
        width: 120px;
        height: 120px;
    }
    .matches-tabs {
        width: 100%;
        flex-wrap: wrap;
    }

    .tab-link {
        flex: 1 1 150px;
    }
}

.theme-separator {
    line-height: 1;
}

.winner-strip {
    margin-top: 6px;
    border: 1px solid var(--line);
    padding: 7px 8px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.06);
}

.winner-strip strong {
    font-family: 'VT323', monospace;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.winner-strip small {
    opacity: 0.8;
}

body.theme-light .winner-strip,
html.theme-light body .winner-strip {
    background: rgba(47, 38, 27, 0.07);
}