.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

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

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

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

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

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

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            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");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ---- ProPair: mobile first. Base = phone, min-width queries add space for larger screens. ---- */
:root {
    --bg: #f6f7f9;
    --fg: #1d2330;
    --muted: #6b7385;
    --line: #dde1e8;
    --accent: #2b5fd9;
    --pad: .75rem;
    --cell: 2.15rem;     /* matrix cell size; 8 columns fit on a 360px phone */
    --tap: 2.75rem;      /* minimum touch target */
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--fg);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; }
h1 { font-size: 1.3rem; margin: .3rem 0 .2rem; line-height: 1.2; }
h2 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
p { margin: .3rem 0; }
.muted { color: var(--muted); }
.error { color: #b3261e; }
button, input, select { font: inherit; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: baseline; gap: .6rem;
    padding: .6rem var(--pad); padding-top: max(.6rem, env(safe-area-inset-top));
    background: #1d2330; color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.topbar .tag { color: #9aa3b5; font-size: .8rem; }
.content { padding: var(--pad) var(--pad) 3rem; }

.cards { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.card {
    display: flex; flex-direction: column; gap: .4rem; width: 100%; min-height: var(--tap); text-align: left;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem;
    color: inherit; text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.card:hover, .card:active { border-color: var(--accent); }
.card:disabled { opacity: .6; cursor: wait; }

.armies { display: flex; flex-wrap: wrap; gap: .25rem; }
.army { font-size: .7rem; font-weight: 600; background: #e8ebf1; border-radius: 4px; padding: .1rem .3rem; }

.progress { height: 4px; background: #e8ebf1; border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

.link {
    display: inline-flex; align-items: center; min-height: var(--tap);
    background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: none;
}

/* share links: stacked on phones */
.share { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .2rem .9rem .8rem; }
.sharelink { display: grid; grid-template-columns: 1fr auto; gap: .3rem .5rem; margin-top: .6rem; }
.sharelink .label { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.sharelink input {
    min-width: 0; min-height: var(--tap); padding: 0 .6rem; font-size: .85rem;
    border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
.btn, .sharelink button, .author button {
    min-height: var(--tap); padding: 0 .9rem; border: 1px solid var(--line); border-radius: 6px;
    background: #fff; cursor: pointer;
}

.author {
    display: grid; grid-template-columns: 1fr auto; gap: .4rem .5rem; margin: .6rem 0;
    padding: .7rem; background: #fff7d6; border-radius: 8px;
}
.author label { grid-column: 1 / -1; font-size: .9rem; }
.author input { min-width: 0; min-height: var(--tap); padding: 0 .6rem; border: 1px solid var(--line); border-radius: 6px; font-size: 16px; /* no iOS zoom */ }

/* matrix: own players in a sticky first column, opponents in a sticky header row */
.matrix-wrap { overflow: auto; margin: .6rem calc(-1 * var(--pad)) 0; padding: 0 var(--pad); -webkit-overflow-scrolling: touch; }
.matrix { border-collapse: separate; border-spacing: 2px; }
.matrix th { padding: 0; font-weight: 500; vertical-align: bottom; }
.matrix th button {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: .15rem;
    width: 100%; min-height: var(--tap); padding: .15rem 0; border: none; border-radius: 6px;
    background: transparent; color: inherit; cursor: pointer;
}
.matrix th button.active { background: #dfe7fb; }
.matrix th .player {
    display: block; max-width: var(--cell); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--muted); font-size: .6rem;
}
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--bg); }
.matrix th.row { position: sticky; left: 0; z-index: 1; background: var(--bg); }
.matrix thead th.corner { left: 0; z-index: 3; }
.matrix th.row button { align-items: flex-start; justify-content: center; padding: 0 .2rem 0 0; width: 3.2rem; }
.matrix th.row .player { max-width: 3rem; }
.matrix td {
    width: var(--cell); min-width: var(--cell); height: var(--cell); padding: 0;
    border: 1px solid var(--line); border-radius: 6px; background: #fff;
    text-align: center; font-weight: 700; font-size: .85rem;
}
.matrix .cellbtn {
    display: block; width: 100%; height: 100%; min-height: var(--cell); padding: 0; border: none; border-radius: 6px;
    background: transparent; color: var(--fg); font: inherit; font-weight: 700; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.legend { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .8rem; }
.legend span { padding: .2rem .55rem; border-radius: 4px; font-weight: 700; font-size: .8rem; }

/* army list of a tapped player */
.listpanel { margin-top: 1rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.listpanel header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.listpanel pre { margin: .4rem 0 0; white-space: pre-wrap; font: inherit; font-size: .8rem; line-height: 1.45; }

/* tablet and up */
@media (min-width: 640px) {
    :root { --pad: 1.25rem; --cell: 3.6rem; }
    h1 { font-size: 1.6rem; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
    .sharelink { grid-template-columns: 6rem 1fr auto; align-items: center; }
    .sharelink .label { grid-column: auto; }
    .share { max-width: 720px; }
    .author { max-width: 560px; }
    .matrix { border-spacing: 3px; }
    .matrix th .player { font-size: .72rem; }
    .matrix th.row button { flex-direction: row; align-items: center; gap: .4rem; width: auto; padding-right: .5rem; }
    .matrix th.row .player { max-width: 8rem; }
    .matrix td { font-size: 1rem; }
}

@media (min-width: 1024px) {
    .content { max-width: 1200px; padding-top: 1.2rem; }
    .matrix-wrap { margin-left: 0; margin-right: 0; padding: 0; }
    .listpanel { max-width: 720px; }
}

/* ---- live pairing (mobile first) ---- */
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; }
.pill {
    flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .9rem;
    border: 1px solid var(--accent); border-radius: 999px; background: #fff; color: var(--accent);
    font-weight: 600; text-decoration: none;
}

/* full-matrix toggle in the empty top-left corner of the table */
.matrix.pairing th.corner { vertical-align: middle; text-align: center; }
.matrix.pairing th.corner .flip {
    /* place-content too: the header-button rule's justify-content: flex-end would push the icon to the right */
    display: grid; place-items: center; place-content: center; width: 2.6rem; height: 2.6rem; min-height: 0; margin: 0 auto; padding: 0;
    border: 1px solid var(--accent); border-radius: 10px; background: #fff; color: var(--accent); cursor: pointer;
}
.matrix.pairing th.corner .flip.on { background: var(--accent); color: #fff; }
.matrix.pairing th.corner .flip:disabled { opacity: .4; cursor: default; }

/* undo: fixed spot in the title bar, next to the running total */
.titlebar .undo {
    flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap);
    border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--fg); cursor: pointer;
}
.titlebar .undo:disabled { opacity: .35; cursor: default; }



.matrix.pairing th button:disabled { cursor: default; color: inherit; }
.matrix.pairing th.def button { background: var(--accent); color: #fff; cursor: pointer; }
.matrix.pairing th.def .army { background: rgba(255, 255, 255, .25); color: #fff; }
.matrix.pairing th.def .player { color: #dfe7fb; }
.matrix.pairing th.att .army { background: #dfe7fb; color: var(--accent); }
.matrix.pairing th.taken { opacity: .35; }

/* step changes: cells glide into their new state with the shared motion; dropped cells fade and shrink a bit */
.matrix.pairing td { transition: opacity var(--motion), filter var(--motion), transform var(--motion), background-color var(--motion); }
.matrix.pairing th button { transition: background-color var(--motion), color var(--motion); }
.matrix.pairing td.dim { transform: scale(.9); }
.matrix.pairing td.tap { cursor: pointer; }
/* greyed out but the rating colour stays faintly visible */
.matrix.pairing td.dim, .matrix.pairing td.taken { opacity: .35; filter: saturate(.55); border-color: transparent; }
.matrix.pairing td.cross {
    background: repeating-linear-gradient(45deg, #e3e6eb 0 4px, #f4f5f7 4px 8px);
    border-color: #e3e6eb; color: transparent; cursor: not-allowed;
}
.matrix.pairing td.pick { outline: 3px solid var(--accent); outline-offset: -3px; box-shadow: 0 0 0 2px #fff inset; }
.matrix td.game { outline: 3px solid var(--fg); outline-offset: -3px; }



@media (min-width: 640px) {
}


/* ---- notes & history ---- */
.matrix { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.matrix td { position: relative; }
.matrix td.has-note::after, .matrix th button.has-note::after {
    content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%;
    background: var(--fg); box-shadow: 0 0 0 1.5px #fff;
}
.matrix th button { position: relative; }
.matrix td.sheet-open { outline: 3px solid var(--accent); outline-offset: -3px; }
.subtle { font-size: .75rem; color: var(--muted); margin-top: .4rem; }
.link.subtle { min-height: auto; margin-top: .8rem; }

.note-editor textarea {
    width: 100%; min-height: 4.5rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; font-size: 16px; resize: vertical; background: #fff;
}
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .3rem; font-size: .8rem; }
.note-text { white-space: pre-wrap; margin: .3rem 0; }
.listpanel .note-editor { margin-top: .6rem; }

/* bottom sheet: thumb-friendly on phones, centered card on desktop */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(29, 35, 48, .35); animation: fade-in var(--motion) both; }
.sheet {
    position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; max-height: 85vh; overflow-y: auto;
    padding: .9rem var(--pad) max(1rem, env(safe-area-inset-bottom));
    background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .15);
    animation: settle-in var(--motion) both;
}
.sheet header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.sheet header strong { font-size: .95rem; }
.sheet h3 { font-size: .85rem; color: var(--muted); margin: 1rem 0 .4rem; font-weight: 600; }
.sheet-levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; margin-top: .8rem; }
.lvl { min-height: var(--tap); border: 2px solid transparent; border-radius: 8px; font-weight: 800; font-size: 1rem; cursor: pointer; }
.lvl.on { border-color: var(--fg); }
.lvl.clear { background: #fff; border-color: var(--line); color: var(--muted); }
.lvl.clear.on { border-color: var(--fg); }
.history { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.history li { display: flex; gap: .6rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.history .change { margin-left: auto; font-weight: 700; }


@media (min-width: 640px) {
    .sheet { bottom: auto; top: 12vh; width: 480px; margin: 0 auto; border-radius: 14px; }
}



/* running total next to the title */
/* phones: title on its own line, controls below (undo always rightmost) */
.titlebar { flex-wrap: wrap; }
.titlebar h1 { flex: 1 1 100%; min-width: 0; margin: 0; font-size: 1.15rem; }
.titlebar .total { order: -1; margin-right: auto; }
.titlebar h1 { order: -2; }
@media (min-width: 640px) {
    .titlebar { flex-wrap: nowrap; }
    .titlebar h1 { flex: 1 1 auto; font-size: 1.6rem; }
    .titlebar .total { order: 0; margin-right: 0; }
}
.total {
    flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 3.4rem; height: var(--tap); padding: 0 .5rem; border-radius: 10px;
    background: #e8ebf1; line-height: 1.05;
}
.total strong { font-size: 1.15rem; }
.total small { font-size: .65rem; color: var(--muted); }
.total.pos { background: #d7f0dc; color: #1d6b2e; }
.total.neg { background: #f8dcd9; color: #9b231c; }

/* fixed matchups under the matrix */
.games { margin-top: 1rem; }
.games h2 { margin: 0 0 .3rem; }
/* "Name UD [rating] VC Name": rating in the middle, right next to both sides */
.gamerow {
    display: grid; grid-template-columns: 1fr auto 2.6rem auto 1fr; align-items: center; gap: .35rem;
    padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .85rem;
}
.gamerow .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gamerow .name.own { text-align: right; }
.gamerow .rating { display: grid; place-items: center; height: 1.8rem; border-radius: 6px; font-weight: 800; }

@media (min-width: 640px) {
    .games { max-width: 720px; }
}

/* ---- motion: one subtle movement everywhere ----
   settle-in: building the matrix, flipping the view, after each pairing step, new matchups, sheets.
   settle-out: the same movement reversed, for players leaving the matrix. */
:root { --motion: .22s cubic-bezier(.2, .7, .3, 1); --motion-ms: 220; }
@keyframes settle-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes settle-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-4px); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.settle { animation: settle-in var(--motion) both; }
.matrix .leaving { animation: settle-out var(--motion) forwards; }

@media (prefers-reduced-motion: reduce) {
    .settle, .matrix .leaving, .sheet, .sheet-backdrop { animation: none; }
    .flip svg { transition: none; }
}

/* ---- army list with line marks ---- */
:root {
    --mark-red: #d9423a;    --mark-red-bg: #fbe3e1;
    --mark-orange: #f39a3d; --mark-orange-bg: #fdecd9;
    --mark-yellow: #e2c02c; --mark-yellow-bg: #fcf4cf;
    --mark-green: #2e9e44;  --mark-green-bg: #dcf1e0;
    --mark-blue: #2b5fd9;   --mark-blue-bg: #dfe7fb;
    --mark-pink: #e46fc0;   --mark-pink-bg: #fbe1f3;
}
.armylist { margin-top: .6rem; font-size: .85rem; line-height: 1.35; }
.listline {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .6rem;
    padding: .3rem .5rem; margin: 1px -.5rem; border-left: 4px solid transparent; border-radius: 4px;
}
.listline.tappable { cursor: pointer; }
.listline.tappable:hover { background: #f1f3f6; }
.listline.editing { outline: 2px solid var(--accent); outline-offset: -2px; }
.listline .marknote { font-style: italic; color: var(--fg); opacity: .8; }
.listline .marknote::before { content: "– "; }
.listline.mark-red { background: var(--mark-red-bg); border-left-color: var(--mark-red); }
.listline.mark-orange { background: var(--mark-orange-bg); border-left-color: var(--mark-orange); }
.listline.mark-yellow { background: var(--mark-yellow-bg); border-left-color: var(--mark-yellow); }
.listline.mark-green { background: var(--mark-green-bg); border-left-color: var(--mark-green); }
.listline.mark-blue { background: var(--mark-blue-bg); border-left-color: var(--mark-blue); }
.listline.mark-pink { background: var(--mark-pink-bg); border-left-color: var(--mark-pink); }

.markeditor { margin: .2rem 0 .5rem; padding: .6rem; background: #f6f7f9; border-radius: 8px; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; }
.swatch { height: 2.4rem; border: 2px solid transparent; border-radius: 8px; cursor: pointer; }
.swatch.on { border-color: var(--fg); box-shadow: inset 0 0 0 2px #fff; }
.swatch.clear { background: #fff; border-color: var(--line); color: var(--muted); }
.swatch:disabled { opacity: .4; cursor: default; }
.swatch.mark-red { background: var(--mark-red); }
.swatch.mark-orange { background: var(--mark-orange); }
.swatch.mark-yellow { background: var(--mark-yellow); }
.swatch.mark-green { background: var(--mark-green); }
.swatch.mark-blue { background: var(--mark-blue); }
.swatch.mark-pink { background: var(--mark-pink); }
.marknote-input { display: flex; gap: .4rem; margin-top: .5rem; }
.marknote-input input {
    flex: 1; min-width: 0; min-height: var(--tap); padding: 0 .6rem; border: 1px solid var(--line); border-radius: 6px;
    font-size: 16px; background: #fff;
}
.listpanel h3 { font-size: .85rem; color: var(--muted); margin: 1rem 0 .4rem; font-weight: 600; }

/* ---- recommendations (only when the eye is on) ---- */
.titlebar .eye {
    flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap);
    border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); cursor: pointer;
}
.titlebar .eye.on { border-color: #2e9e44; color: #2e9e44; background: #e9f6ec; }

.matrix.pairing th .tip {
    position: absolute; top: -.35rem; right: -.2rem; z-index: 1; padding: 0 .25rem; border-radius: 6px;
    font-size: .58rem; font-weight: 800; line-height: 1.35; white-space: nowrap;
    background: #e9f6ec; color: #1d6b2e; box-shadow: 0 0 0 1.5px #fff;
}
.matrix.pairing th.row .tip { top: auto; bottom: -.2rem; right: 0; }
.matrix.pairing th .tip.best { background: #2e9e44; color: #fff; }
.matrix.pairing th .tip.them { background: #eceef1; color: var(--muted); }
.matrix.pairing td.rec { box-shadow: inset 0 0 0 3px #2e9e44; }
/* predicted path: corner triangle per round, split into two isosceles halves (top, right).
   next round = black · round after = black top / light grey right · third = light grey.
   The timeline labels "Runde N" carry the same corner, so they work as the legend. */
.path-1 { --corner-top: #111418; --corner-right: #111418; }
.path-2 { --corner-top: #111418; --corner-right: #aab1bc; }
.path-3 { --corner-top: #aab1bc; --corner-right: #aab1bc; }  /* light, but still visible on white cells */
.matrix.pairing td { overflow: hidden; }
.matrix.pairing td[class*="path-"]::before, .matrix.pairing td[class*="path-"]::after,
.timeline .r::before, .timeline .r::after {
    content: ""; position: absolute; top: 0; right: 0; width: 18px; height: 18px; pointer-events: none;
}
.matrix.pairing td[class*="path-"]::before, .timeline .r::before { background: var(--corner-top); clip-path: polygon(0 0, 100% 0, 50% 50%); }
.matrix.pairing td[class*="path-"]::after, .timeline .r::after { background: var(--corner-right); clip-path: polygon(100% 0, 100% 100%, 50% 50%); }
.timeline .r {
    position: relative; overflow: hidden; align-self: flex-start;
    padding: .2rem 1.6rem .2rem .55rem; border-radius: 6px; background: #f1f3f6; border: 1px solid #dde1e8;
}

/* mode switch */
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; margin-top: .6rem; padding: 2px; background: #eceef1; border-radius: 9px; }
.modes button { min-height: 2.2rem; border: none; border-radius: 7px; background: transparent; color: var(--muted); font-size: .8rem; font-weight: 600; cursor: pointer; }
.modes button.on { background: #fff; color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.advice { margin-top: 1rem; padding: .7rem .8rem; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.advice header { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.advice h2 { margin: 0; }
.picks { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
/* scoped to the panel: plain ".pick" also matched picked matrix cells (td.pick) and broke the table row */
.picks .pick {
    display: grid; grid-template-columns: 1.4rem 1fr auto; align-items: center; gap: .5rem; min-height: var(--tap);
    padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit;
    text-align: left; cursor: pointer;
}
.picks .pick.on { border-color: #2e9e44; background: #f2faf4; }
.picks .pick .rank { font-weight: 800; color: #2e9e44; }
.picks .pick .who { display: flex; flex-wrap: wrap; gap: .15rem .5rem; font-size: .85rem; }
.picks .pick .nums { display: flex; flex-direction: column; align-items: flex-end; gap: .05rem; white-space: nowrap; }
.picks .pick .final { display: flex; align-items: baseline; gap: .3rem; }
.picks .pick .final small { font-size: .7rem; color: var(--muted); }
.picks .pick .final strong { font-size: 1.25rem; line-height: 1.1; }
.picks .pick .final em { font-style: normal; font-size: .75rem; font-weight: 700; color: var(--muted); }
.picks .pick .round { font-size: .72rem; color: var(--muted); }
.modehint { margin: .45rem 0 0; font-size: .75rem; color: var(--muted); line-height: 1.8; }
.chip-inline { display: inline-block; min-width: 1.6rem; margin: 0 .15rem; padding: 0 .3rem; border-radius: 4px; text-align: center; font-weight: 800; color: var(--fg); line-height: 1.4; }
.timeline { list-style: none; margin: .7rem 0 0; padding: 0; font-size: .8rem; }
.timeline li { display: flex; flex-direction: column; gap: .1rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.timeline .r { font-weight: 800; color: var(--fg); margin-bottom: .15rem; }
.timeline .steps { display: flex; flex-direction: column; gap: .1rem; }
.timeline em { font-style: normal; font-weight: 700; color: var(--muted); margin-right: .2rem; }
.pathtotal { margin-top: .5rem; font-size: .8rem; }

@media (min-width: 640px) { .advice { max-width: 720px; } }

/* ---- opponent view: mirrored ratings, every cell ringed red ---- */
.titlebar .enemy-toggle {
    flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap);
    border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); cursor: pointer;
}
.titlebar .enemy-toggle.on { border-color: #d9423a; color: #fff; background: #d9423a; }
.matrix.pairing td.enemy { box-shadow: inset 0 0 0 2px #d9423a; }
.matrix.pairing.enemy-view thead th:not(.corner) .army { background: #f8dcd9; color: #9b231c; }
.rating.enemy { box-shadow: inset 0 0 0 2px #d9423a; }

/* predicted matchups in the timeline: flush left, ratings in one column */
.timeline .st { color: var(--muted); }
.pgames {
    display: grid; grid-template-columns: 5.2rem 2.4rem 2.2rem 2.4rem 1fr;
    align-items: center; gap: .25rem .3rem; margin-top: .25rem; font-size: .8rem;
}
.pgames .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pgames .name.own { text-align: right; }
.pgames .army { justify-self: center; }
.pgames .rating { display: grid; place-items: center; height: 1.5rem; border-radius: 5px; font-weight: 800; }

/* ---- sync state of the local-first pairing ---- */
.sync { margin: .35rem 0 0; font-size: .72rem; color: var(--muted); }
.sync.saved::before { content: "✓ "; color: #2e9e44; font-weight: 800; }
.sync.pending { color: #8a6d00; }
.sync.pending::before { content: "● "; }
.sync.offline { color: #9b231c; }
.sync.offline::before { content: "○ "; }

/* ---- read-only army lists during the pairing ---- */
.armylist-ro header { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .4rem; }
.armylist-ro .notes-toggle {
    margin-left: auto; align-self: center; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; flex: none;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer;
}
.armylist-ro .notes-toggle.on { color: var(--fg); border-color: #c3c8d0; }
.armylist-ro .ro-notes { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
.armylist-ro .ro-notes .note-text { margin: 0; }
.armylist-ro .note-text.matchup { background: #eef3fd; }
.armylist-ro header .muted { font-size: .75rem; }
.armylist-ro .armylist { margin-top: .4rem; }
.armylist-ro .note-text { margin: .6rem 0 0; padding: .5rem .6rem; background: #fff7d6; border-radius: 6px; font-size: .8rem; }

/* ---- matrix | lists switch, list carousel, attacker lists ---- */
.viewtabs { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: .5rem 0 .3rem; padding: 2px; background: #eceef1; border-radius: 9px; }
.viewtabs button { min-height: 2.2rem; min-width: 5.5rem; border: none; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.viewtabs button.on { background: #fff; color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.listview { touch-action: pan-y; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem .9rem; }
.listnav { display: flex; align-items: center; gap: .4rem; margin-bottom: .6rem; }
.listnav .btn { flex: none; width: var(--tap); padding: 0; font-size: 1.3rem; }
.listnav .dots { flex: 1; display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem; }
.listnav .dot { min-height: 1.9rem; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .7rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.listnav .dot.on { background: var(--fg); border-color: var(--fg); color: #fff; }
.listnav .dot.taken { background: #eceef1; border-color: #eceef1; color: #b4bac4; }
.listnav .dot.taken.on { background: #9aa1ad; border-color: #9aa1ad; color: #fff; }

.duo { margin-top: 1rem; }
.duo h2 { margin: 0 0 .4rem; }
.duo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.duo-grid > .armylist-ro { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .55rem; }
.duo-grid .armylist { font-size: .72rem; }
.duo-grid .listline { padding: .2rem .35rem; margin: 1px -.35rem; }
@media (min-width: 640px) { .listview, .duo { max-width: 720px; } .duo-grid .armylist { font-size: .8rem; } }

/* tournament list / New Recruit sync */
.search { width: 100%; min-height: var(--tap); margin: .4rem 0 .7rem; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.past { margin-top: 1rem; }
.past summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; color: var(--muted); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 4px; padding: .1rem .4rem; }
.badge.warn { background: #fdecd3; color: #8a4b00; }
.roster-warning { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; font-size: .85rem; color: #8a4b00; margin: .1rem 0; }
.sync-status { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .7rem; font-size: .85rem; margin: .2rem 0 .4rem; }
.sync-status .link { min-height: 2.2rem; }
.list-changed { display: inline-grid; place-content: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: .65rem; font-weight: 800; font-style: normal; flex: none; }
.list-changed-hint { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }

/* ---- who am I (no login yet) ---- */
.me-trigger {
    display: flex; align-items: center; gap: .6rem; width: 100%; min-height: var(--tap); margin: .6rem 0;
    padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff;
    color: inherit; text-align: left; cursor: pointer;
}
.me-trigger .me-text { flex: 1; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.me-trigger .me-text .muted { font-size: .75rem; }
.me-trigger svg { flex: none; color: var(--muted); }
.me-trigger.unset { background: #fff7d6; border-color: #f0d77a; }
.me-trigger.unset .me-text .muted { color: #8a6d00; }
.me-options { display: flex; flex-direction: column; gap: .35rem; margin-top: .7rem; }
.me-option {
    display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .1rem .6rem; min-height: 3.2rem;
    padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff;
    color: inherit; text-align: left; cursor: pointer;
}
.me-option .army { grid-row: span 2; justify-self: start; }
.me-option .muted { font-size: .75rem; }
.me-option.on { border-color: var(--accent); background: #eef3fd; box-shadow: inset 0 0 0 1px var(--accent); }
.sheet .x {
    flex: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); margin: -.4rem -.4rem -.4rem 0;
    border: none; border-radius: 10px; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer;
}
.card.locked { opacity: .5; cursor: not-allowed; }
.card.locked:hover, .card.locked:active { border-color: var(--line); }
@media (min-width: 640px) { .me-trigger { width: auto; min-width: 280px; } }
/* own row in the matrix */
.matrix tr.me th.row button { background: var(--accent); color: #fff; }
.matrix tr.me th.row .army { background: rgba(255, 255, 255, .25); color: #fff; }
.matrix tr.me th.row .player { color: #dfe7fb; }
.matrix tr.me td { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.matrix tr.me td.current { outline: 3px solid var(--fg); outline-offset: -3px; }
/* quick rating flyout */
.sheet.quick .sheet-levels { margin-top: .9rem; }
.sheet.quick .link.subtle { margin-top: .7rem; }
.lvl:disabled { cursor: default; opacity: .45; }
.lvl.clear { font-size: 1.15rem; }
/* opponent lists under the matrix */
.opplists { margin-top: 1rem; }
.opphead { display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .4rem; }
.opphead strong { font-size: 1.05rem; }
.opphead .muted { font-size: .8rem; }
.opplists .sheet-levels { margin-top: .6rem; }
.opplists .subtle { margin-top: .3rem; }
.listpanel.embedded { margin-top: .2rem; padding: 0; border: none; background: transparent; }
