:root {
    --ink: #1f2528;
    --muted: #667176;
    --line: #d8dddf;
    --panel: #ffffff;
    --field: #f7f8f6;
    --page: #eef1ec;
    --blue: #245f86;
    --blue-dark: #18405b;
    --red: #9b3a35;
    --gold: #a87b21;
    --green: #436d4f;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 2rem;
    font-weight: 750;
}

h1:focus {
    outline: none;
}

h2 {
    font-size: 1rem;
    font-weight: 750;
}

button,
input,
select,
textarea {
    font: inherit;
}

textarea {
    resize: vertical;
}

.page {
    min-height: 100vh;
    display: block;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.app-brand {
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.app-brand:hover,
.app-brand:focus {
    color: var(--blue-dark);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.app-nav-link {
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.app-nav-link:hover,
.app-nav-link:focus {
    color: var(--blue-dark);
    background: #edf5f7;
}

.app-nav-link.active {
    border-color: #b9d1dc;
    background: #e2f0f4;
    color: var(--blue-dark);
}

main {
    min-width: 0;
}

.content {
    padding: 1.25rem;
}

.help-shell {
    max-width: 118rem;
    margin: 0 auto;
}

.access-shell {
    max-width: 36rem;
    margin: 0 auto;
    padding-top: 2rem;
}

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

.access-copy {
    display: grid;
    gap: 0.45rem;
}

.access-copy p:not(.eyebrow) {
    color: var(--muted);
}

.turnstile-widget {
    min-height: 4.1rem;
}

.help-hero {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 1rem;
    padding: 1.1rem 0 0.2rem;
}

.help-lede {
    max-width: 58rem;
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 1.04rem;
}

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

.help-toc {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.help-toc ol {
    display: grid;
    gap: 0.45rem;
    margin: 0;
    padding-left: 1.25rem;
}

.help-toc a {
    color: var(--blue-dark);
    font-weight: 700;
    text-decoration: none;
}

.help-toc a:hover,
.help-toc a:focus {
    text-decoration: underline;
}

.help-content {
    display: grid;
    gap: 1rem;
}

.help-section {
    scroll-margin-top: 1rem;
    display: grid;
    grid-template-columns: minmax(18rem, 0.8fr) minmax(24rem, 1.2fr);
    gap: 1rem;
    align-items: start;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.help-section-compact {
    grid-template-columns: 1fr;
}

.help-copy {
    display: grid;
    gap: 0.65rem;
}

.help-copy p,
.help-copy ul,
.help-copy ol {
    margin: 0;
}

.help-copy ul,
.help-copy ol {
    display: grid;
    gap: 0.38rem;
    padding-left: 1.25rem;
}

.help-shot {
    display: grid;
    gap: 0.45rem;
    margin: 0;
}

.help-shot img {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
    box-shadow: 0 0.35rem 1rem rgba(31, 37, 40, 0.12);
}

.help-shot figcaption {
    color: var(--muted);
    font-size: 0.84rem;
}

.app-shell {
    max-width: 118rem;
    margin: 0 auto;
}

.workspace-header,
.game-banner,
.dashboard,
.orders-board,
.command-grid {
    display: grid;
    gap: 1rem;
}

.workspace-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-bottom: 1rem;
}

.title-lockup {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.publisher-links {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.publisher-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    transition: transform 160ms ease, filter 160ms ease;
}

.publisher-link:hover,
.publisher-link:focus-visible {
    transform: scale(1.12);
    filter: drop-shadow(0 0.25rem 0.35rem rgba(31, 37, 40, 0.2));
}

.publisher-link:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 4px;
}

.publisher-link img {
    display: block;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.publisher-link-fts img {
    height: 2.65rem;
}

.publisher-link-mmp img {
    height: 2.35rem;
}

.publisher-link-gamers img {
    height: 1.85rem;
}

.eyebrow {
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.header-actions,
.inline-form,
.split {
    display: flex;
    gap: 0.5rem;
}

.header-actions,
.inline-form {
    flex-wrap: wrap;
}

.header-actions {
    align-items: center;
}

.save-mode {
    color: #35454d;
    font-size: 0.86rem;
    font-weight: 800;
    white-space: nowrap;
}

.split > * {
    flex: 1 1 14rem;
}

.side-selector {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.side-selector .form-select {
    flex: 1 1 auto;
}

.side-selector-compact .form-select {
    flex: 0 1 13rem;
}

.side-flag {
    flex: 0 0 auto;
    width: 4.1rem;
    height: 2.45rem;
    padding: 0.12rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    object-fit: contain;
    box-shadow: 0 0.15rem 0.35rem rgba(31, 37, 40, 0.12);
}

.game-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
}

.game-box {
    display: block;
    object-fit: contain;
}

.game-box-picker {
    width: 4.75rem;
    height: 4.75rem;
}

.game-box-banner {
    width: 6rem;
    height: 6rem;
}

.file-button {
    position: relative;
    overflow: hidden;
}

.file-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.command-grid {
    grid-template-columns: minmax(22rem, 33rem) minmax(0, 1fr);
    align-items: start;
}

.rail,
.workspace {
    display: grid;
    gap: 1rem;
}

.panel,
.empty-state,
.game-banner,
.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
}

.empty-state {
    min-height: 18rem;
    display: grid;
    place-content: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--muted);
}

.game-banner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    padding: 1rem;
}

.game-banner p,
.muted,
.formation-row small,
.game-row small,
.order-card small {
    color: var(--muted);
}

.dashboard {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

.metric {
    flex: 0 0 auto;
    min-width: 5.25rem;
    padding: 0.85rem;
    text-align: center;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    font-weight: 800;
}

.metric strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.7rem;
}

.orders-board {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr);
}

.rail .panel {
    max-height: 34rem;
    overflow-y: auto;
}

.orders-board .panel {
    max-height: none;
    overflow: visible;
}

.stacked-form,
.game-list,
.reissue-list {
    display: grid;
    gap: 0.6rem;
}

.reissue-tracker {
    display: grid;
    gap: 0.4rem;
    margin-left: 1.75rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--field);
    font-size: 0.88rem;
}

.reissue-tracker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.reissue-target-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
}

.formation-editor {
    display: grid;
    gap: 0.6rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.leader-casualty-editor {
    display: grid;
    gap: 0.5rem;
}

.formation-add-form {
    display: grid;
    gap: 0.6rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
}

.formation-add-form h3 {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.reissue-row {
    display: grid;
    gap: 0.35rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.reissue-row-status-accepted {
    border-color: #bad8b7;
    background: #eef8ec;
}

.reissue-row-status-fluked {
    border-color: #e7bbbb;
    background: #f9eeee;
}

.reissue-row-status-aborted {
    border-color: #d5d9da;
    background: #f1f1f1;
}

.reissue-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.reissue-row > strong,
.reissue-tracker > strong {
    font-size: 0.82rem;
}

.reissue-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
}

.reissue-fields label {
    display: grid;
    gap: 0.15rem;
}

.reissue-fields label span {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 800;
}

.reissue-fields .form-select {
    min-height: 2rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    font-size: 0.86rem;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.readonly-value {
    min-height: 2rem;
    padding: 0.35rem 0;
    white-space: pre-wrap;
}

.order-spacer-row td {
    height: 0.75rem;
    padding: 0;
    border: 0;
    background: var(--panel);
}

.order-summary-row td {
    border-top: 2px solid #111;
    border-bottom: 0;
    border-left: 0;
    background-color: #ffffff;
}

.order-summary-row td:first-child {
    border-left: 2px solid #111;
    border-top-left-radius: 8px;
}

.order-summary-row td:last-child {
    border-right: 2px solid #111;
    border-top-right-radius: 8px;
}

.order-detail-row td,
.reissue-detail-row td {
    border-right: 2px solid #111;
    border-bottom: 0;
    border-left: 2px solid #111;
    background-color: #fbfcfa;
}

.order-summary-row.order-row-status-accepted td,
.order-detail-row.order-row-status-accepted td {
    background-color: #eef8ec;
}

.order-summary-row.order-row-status-posted td,
.order-detail-row.order-row-status-posted td {
    background-color: #edf4fb;
}

.order-summary-row.order-row-status-fluked td,
.order-detail-row.order-row-status-fluked td {
    background-color: #f9eeee;
}

.order-summary-row.order-row-status-aborted td,
.order-detail-row.order-row-status-aborted td {
    background-color: #f1f1f1;
}

.order-detail-row td {
    border-bottom: 2px solid #111;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.order-summary-row:has(+ .order-detail-row) td:first-child {
    border-bottom-left-radius: 0;
}

.order-summary-row:has(+ .order-detail-row) td:last-child {
    border-bottom-right-radius: 0;
}

.order-detail-row:has(+ .reissue-detail-row) td {
    border-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.reissue-detail-row td {
    border-bottom: 2px solid #111;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.order-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
    padding: 0.2rem 0;
}

.order-detail-field,
.reissue-order-text {
    display: grid;
    gap: 0.2rem;
}

.order-detail-field strong,
.reissue-order-text span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.order-detail-field span {
    min-height: 1.25rem;
    white-space: pre-wrap;
}

.order-detail-text {
    grid-column: 1 / -1;
}

.reissue-order-text textarea {
    min-height: 4.5rem;
    resize: vertical;
}

.game-list-item,
.game-row,
.formation-row,
.order-card {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--field);
    text-align: left;
}

.game-list-item {
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    position: relative;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.game-row {
    min-width: 0;
    border: 0;
    border-radius: 0;
    cursor: pointer;
    flex: 1;
}

.game-delete {
    flex: 0 0 auto;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
}

.game-row span,
.game-row small,
.formation-row span {
    overflow-wrap: anywhere;
}

.formation-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.6rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.game-list-item.selected,
.selected-row {
    border-color: var(--blue);
    background: #edf5f7;
}

.game-list-item.selected {
    border-color: var(--blue-dark);
    background: #e2f0f4;
    outline: 2px solid rgba(36, 95, 134, 0.35);
    outline-offset: 1px;
    box-shadow: 0 0.35rem 0.9rem rgba(24, 64, 91, 0.2);
    transform: translateX(0.15rem);
}

.game-list-item.selected::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 0.45rem;
    background: var(--blue);
    pointer-events: none;
}

.game-list-item.selected .game-row {
    background: #e2f0f4;
}

.game-list-item.selected .game-row span {
    color: var(--blue-dark);
    font-weight: 800;
}

.game-list-item.selected .game-row small {
    color: #315a70;
    font-weight: 700;
}

.status-message {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--green);
    background: #f6fbf4;
    color: #243d29;
}

.cache-warning {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #dcc58d;
    border-left: 4px solid var(--gold);
    border-radius: 8px;
    background: #fff8e8;
    color: #4d3810;
}

.cache-warning strong {
    font-weight: 800;
}

.cloud-save-status {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid #a9c9b0;
    border-left: 4px solid var(--green);
    border-radius: 8px;
    background: #f2faf3;
    color: #243d29;
}

.cloud-save-status strong {
    font-weight: 800;
}

.cloud-save-status .spinner-border {
    margin-right: 0.45rem;
    vertical-align: -0.1em;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.orders-board table {
    border-collapse: separate;
    border-spacing: 0;
    min-width: 62rem;
}

th,
td {
    padding: 0.72rem 0.6rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

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

.clickable {
    cursor: pointer;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    padding: 0.15rem 0.45rem;
    border: 1px solid #d6c294;
    border-radius: 6px;
    background: #fbf6e8;
    color: #5f4510;
    white-space: nowrap;
}

.status-group td {
    padding: 0.55rem 0.6rem;
    border-top: 2px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-group-issued td {
    background: #eef5f8;
    color: #17415b;
}

.status-group-accepted td {
    background: #f0f7ef;
    color: #315939;
}

.status-group-posted td {
    background: #edf4fb;
    color: #274e73;
}

.status-group-reissued td {
    background: #fbf6e8;
    color: #65470e;
}

.status-group-fluked td {
    background: #f8eeee;
    color: #743333;
}

.status-group-aborted td {
    background: #f1f1f1;
    color: #3f4547;
}

.compact-select {
    max-width: 13rem;
}

.btn {
    border-radius: 6px;
}

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
}

.form-control,
.form-select {
    min-height: 2.45rem;
    border-radius: 6px;
    min-width: 0;
}

textarea.form-control {
    width: 100%;
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #d7dddf;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--blue);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 1180px) {
    .command-grid {
        grid-template-columns: minmax(19rem, 26rem) minmax(0, 1fr);
    }
}

@media (max-width: 980px) {
    .command-grid,
    .orders-board,
    .game-banner,
    .help-layout,
    .help-section {
        grid-template-columns: 1fr;
    }

    .help-toc {
        position: static;
    }

    .header-actions {
        justify-content: start;
    }

    .rail .panel {
        max-height: none;
    }

    .game-banner {
        align-items: start;
    }

    .side-selector-compact {
        justify-self: start;
        width: min(100%, 22rem);
    }

    .side-selector-compact .form-select {
        flex: 1 1 auto;
    }
}

@media (max-width: 760px) {
    h1 {
        font-size: 1.55rem;
    }

    .publisher-links {
        gap: 0.5rem;
    }

    .publisher-link-fts img {
        height: 2.25rem;
    }

    .publisher-link-mmp img {
        height: 2rem;
    }

    .publisher-link-gamers img {
        height: 1.65rem;
    }

    .game-picker {
        grid-template-columns: 1fr;
    }

    .game-box-picker {
        width: 4.25rem;
        height: 4.25rem;
    }

    .order-details,
    .reissue-fields {
        grid-template-columns: 1fr;
    }

    .reissue-tracker {
        margin-left: 0;
    }

    .reissue-target-row {
        grid-template-columns: 1fr;
    }

    .reissue-target-row .btn {
        width: 100%;
    }
}

@media (max-width: 620px) {
    .content {
        padding: 0.75rem;
    }

    .workspace-header,
    .dashboard,
    .split,
    .inline-form,
    .header-actions {
        flex-direction: column;
    }

    .workspace-header {
        grid-template-columns: 1fr;
    }

    .header-actions,
    .header-actions .btn,
    .inline-form,
    .inline-form .btn,
    .split > * {
        width: 100%;
    }

    .split > * {
        flex-basis: auto;
    }

    .title-lockup {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.65rem;
    }

    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 0.75rem;
    }

    .app-nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .app-nav-link {
        flex: 1 1 8rem;
        justify-content: center;
    }

    .dashboard {
        flex-direction: row;
        gap: 0.5rem;
    }

    .game-list-item,
    .game-row,
    .formation-row,
    .order-card,
    .order-details,
    .reissue-fields {
        align-items: flex-start;
        flex-direction: column;
        grid-template-columns: 1fr;
    }

    .game-delete {
        width: 100%;
        border-top: 1px solid var(--line);
        border-left: 0;
    }

    .panel,
    .game-banner,
    .metric {
        border-radius: 6px;
    }

    .panel,
    .game-banner {
        padding: 0.85rem;
    }

    .game-banner {
        gap: 0.75rem;
    }

    .game-box-banner {
        width: 4.75rem;
        height: 4.75rem;
    }

    .side-selector {
        width: 100%;
    }

    .side-flag {
        width: 3.8rem;
        height: 2.25rem;
    }

    .form-check {
        align-items: flex-start;
    }

    .form-check-input {
        margin-top: 0.28rem;
    }
}

@media (max-width: 420px) {
    .content {
        padding: 0.55rem;
    }

    h1 {
        font-size: 1.35rem;
    }

    .publisher-link-fts img {
        height: 1.95rem;
    }

    .publisher-link-mmp img {
        height: 1.75rem;
    }

    .publisher-link-gamers img {
        height: 1.45rem;
    }

    .cache-warning,
    .status-message {
        padding: 0.7rem 0.75rem;
    }

    .side-selector {
        align-items: stretch;
        flex-direction: column;
    }

    .side-flag {
        width: 4.1rem;
    }
}
