:root {
    --page: #f4f5f7;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #667085;
    --line: #d7dce2;
    --brand: #e30613;
    --brand-dark: #a8000a;
    --accent: #008f7a;
}

html,
body {
    min-height: 100%;
    background: var(--page);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: var(--brand-dark);
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
}

.app-shell {
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    min-height: 64px;
    padding: 0 32px;
    background: #111820;
    color: white;
    border-bottom: 4px solid var(--brand);
}

.brand-lockup {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 220px;
}

.brand {
    color: white;
    font-size: 1.15rem;
    font-weight: 800;
    text-decoration: none;
}

.environment {
    color: #b9c0c8;
    font-size: .82rem;
}

.main-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.main-nav .nav-link {
    color: #d9dee5;
    border-radius: 6px;
    padding: 8px 12px;
}

.main-nav .nav-link:hover,
.main-nav .nav-link.active {
    background: rgba(255, 255, 255, .12);
    color: white;
}

.content {
    width: min(1180px, calc(100vw - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-title h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.12;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--brand-dark);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.signed-in-pill {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--muted);
    white-space: nowrap;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.metric,
.tool-panel,
.match-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: .86rem;
}

.metric strong {
    display: block;
    margin-top: 6px;
    font-size: 1.85rem;
}

.tool-panel {
    padding: 20px;
}

.tool-panel h2 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    font-weight: 800;
}

.empty-state p {
    margin-bottom: 0;
}

.import-panel {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.import-panel label {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.json-input {
    min-height: 170px;
    font-family: Consolas, "Liberation Mono", monospace;
}

.auth-input {
    min-height: 96px;
    font-family: Consolas, "Liberation Mono", monospace;
}

.scrape-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.join-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.join-form label {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.two-column {
    display: grid;
    grid-template-columns: 1.3fr .7fr;
    gap: 18px;
}

.compact-match,
.leader-row {
    display: grid;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.compact-match {
    grid-template-columns: minmax(0, 1fr) auto;
}

.compact-match:first-of-type,
.leader-row:first-of-type {
    border-top: 0;
}

.compact-match span,
.muted {
    color: var(--muted);
}

.leader-row {
    grid-template-columns: 32px 1fr auto;
}

.leader-row span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #eef1f4;
    font-weight: 800;
}

.leader-row em {
    color: var(--accent);
    font-style: normal;
    font-weight: 800;
}

.home-pick {
    display: grid;
    gap: 2px;
    min-width: 82px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #eef1f4;
    text-align: center;
}

.home-pick span {
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.home-pick strong {
    font-size: .95rem;
}

.home-pick-open {
    background: #f8fafc;
}

.table-link {
    color: inherit;
    text-decoration: none;
}

.table-link:hover {
    color: var(--brand-dark);
    text-decoration: underline;
}

.rank-cell,
.player-cell,
.team-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rank-move {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: .72rem;
    font-weight: 800;
    white-space: nowrap;
}

.rank-up {
    color: #087443;
}

.rank-down {
    color: #b42318;
}

.team-badge {
    min-width: 0;
    vertical-align: middle;
}

.team-badge img {
    width: 24px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: white;
    flex: 0 0 auto;
}

.team-badge span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.player-avatar {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #111820;
    color: white;
    font-size: .72rem;
    font-weight: 800;
    flex: 0 0 auto;
    overflow: hidden;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.match-list {
    display: grid;
    gap: 12px;
}

.match-card {
    padding: 16px;
}

.match-meta,
.odds-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: .84rem;
}

.match-meta span,
.odds-row span,
.odds-row strong {
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
}

.prediction-line {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 64px 16px 64px minmax(160px, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
}

.prediction-line strong:first-child {
    text-align: right;
}

.score-input {
    width: 64px;
    min-height: 38px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.score-chip {
    display: inline-grid;
    place-items: center;
    width: 64px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #eef1f4;
    font-weight: 800;
}

.locked-note {
    color: var(--muted);
    font-size: .84rem;
    font-weight: 800;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.scorito-source {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.scorito-grid {
    display: grid;
    gap: 16px;
}

.scorito-user-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.scorito-user-card header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.scorito-user-card h2,
.scorito-user-card h3 {
    margin: 0;
    font-weight: 800;
}

.scorito-user-card h2 {
    margin-top: 4px;
    font-size: 1.2rem;
}

.scorito-user-card h3 {
    font-size: .92rem;
}

.rank-badge,
.pick-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 800;
}

.prediction-stack {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.imported-match {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfd;
}

.imported-match span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.special-picks {
    display: grid;
    gap: 12px;
}

.players-layout {
    display: grid;
    grid-template-columns: minmax(220px, .32fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.players-sidebar,
.player-detail {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.players-sidebar {
    position: sticky;
    top: 86px;
    overflow: hidden;
}

.player-search {
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.player-list {
    display: grid;
    max-height: calc(100vh - 190px);
    overflow-y: auto;
}

.player-list-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
}

.player-list-item:hover,
.player-list-item.active {
    background: #f8fafc;
}

.player-list-item span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #eef1f4;
    font-weight: 800;
}

.player-list-item strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-list-item em {
    color: var(--accent);
    font-size: .8rem;
    font-style: normal;
    font-weight: 800;
    white-space: nowrap;
}

.player-detail {
    display: grid;
    gap: 18px;
    padding: 18px;
}

.player-detail > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.player-detail h2,
.player-detail h3 {
    margin: 0;
    font-weight: 800;
}

.player-detail h2 {
    font-size: 1.35rem;
}

.topscorer-panel,
.predictions-panel {
    display: grid;
    gap: 12px;
}

.topscorer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

.topscorer-card {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.topscorer-card .player-avatar {
    width: 40px;
    height: 40px;
}

.section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stage-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.filter-chip {
    min-height: 32px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    color: var(--muted);
    font-weight: 800;
}

.filter-chip.active {
    border-color: #111820;
    background: #111820;
    color: white;
}

.prediction-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 10px;
    max-height: 62vh;
    overflow-y: auto;
    padding-right: 4px;
}

.prediction-card {
    display: grid;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 8px;
    background: #fbfcfd;
}

.prediction-card-match {
    display: grid;
    gap: 5px;
}

.prediction-card-match em {
    color: var(--muted);
    font-size: .78rem;
    font-style: normal;
}

.prediction-scoreline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    align-items: center;
    gap: 8px;
}

.prediction-scoreline span:not(.result-pill) {
    display: grid;
    gap: 2px;
}

.prediction-scoreline small {
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.prediction-scoreline strong {
    font-size: 1.15rem;
}

.result-pill {
    align-self: end;
    padding: 4px 7px;
    border-radius: 6px;
    font-size: .74rem;
    font-weight: 800;
}

.prediction-hit {
    border-left-color: #087443;
    background: #f0fdf4;
}

.prediction-close {
    border-left-color: #b7791f;
    background: #fffbeb;
}

.prediction-miss {
    border-left-color: #b42318;
    background: #fff5f5;
}

.prediction-pending {
    border-left-color: #98a2b3;
}

.prediction-hit .result-pill {
    background: #dcfce7;
    color: #087443;
}

.prediction-close .result-pill {
    background: #fef3c7;
    color: #92400e;
}

.prediction-miss .result-pill {
    background: #fee2e2;
    color: #b42318;
}

.prediction-pending .result-pill {
    background: #eef1f4;
    color: var(--muted);
}

.player-profile-grid {
    display: grid;
    gap: 16px;
}

.player-profile {
    display: grid;
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.player-profile header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.player-profile h2,
.player-profile h3 {
    margin: 0;
    font-weight: 800;
}

.player-profile h2 {
    font-size: 1.25rem;
}

.player-profile h3 {
    font-size: 1rem;
}

.pick-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.player-pick {
    gap: 8px;
    padding-left: 4px;
}

.points-pill {
    justify-self: end;
    color: var(--accent);
    font-weight: 800;
}

.toast-message {
    position: fixed;
    right: 24px;
    bottom: 24px;
    margin: 0;
    padding: 10px 14px;
    border-radius: 6px;
    background: #111820;
    color: white;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}

.validation-message {
    margin: 12px 0 0;
    color: var(--brand-dark);
    font-weight: 700;
}

#blazor-error-ui {
    color-scheme: light only;
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    width: min(520px, calc(100vw - 32px));
    padding: 14px 44px 14px 16px;
    border: 1px solid #ffd6d9;
    border-radius: 8px;
    background: #fff1f2;
    color: #7a0010;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 14px;
    cursor: pointer;
}

@media (max-width: 760px) {
    .app-header,
    .page-title,
    .action-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-header {
        padding: 16px;
    }

    .summary-grid,
    .two-column,
    .join-form,
    .scrape-grid,
    .players-layout {
        grid-template-columns: 1fr;
    }

    .players-sidebar {
        position: static;
    }

    .player-list {
        max-height: 280px;
    }

    .section-toolbar,
    .player-detail > header {
        align-items: flex-start;
        flex-direction: column;
    }

    .stage-filter {
        justify-content: flex-start;
    }

    .prediction-card-grid {
        max-height: none;
    }

    .prediction-line {
        grid-template-columns: 1fr 56px 12px 56px 1fr;
    }

    .prediction-line .btn,
    .prediction-line .locked-note {
        grid-column: 1 / -1;
    }

    .team-badge {
        align-items: flex-start;
    }

    .player-profile header {
        flex-direction: column;
    }
}
