/* ---------- Theme ---------- */
:root {
    color-scheme: dark;
    --bg: #111317;
    --surface: #1b1e24;
    --surface-2: #252a32;
    --border: #333a45;
    --text: #eef0f3;
    --muted: #9aa3af;
    --accent: #e0a84b;
    --danger: #ef4444;
    --radius: 14px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --bg: #f3f4f6;
        --surface: #ffffff;
        --surface-2: #eef0f3;
        --border: #d6dae0;
        --text: #15181d;
        --muted: #5f6873;
        --accent: #b7791f;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100vh; }

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

button {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    touch-action: manipulation; /* no double-tap zoom when tapping +1 quickly */
    user-select: none;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
button.on { border-color: var(--accent); color: var(--accent); }
button.big { font-size: 1.15rem; padding: 0.8rem 1.4rem; width: 100%; }
button.icon { padding: 0.25rem 0.55rem; background: transparent; }

input, select {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}

/* ---------- Setup ---------- */
.setup {
    max-width: 480px;
    margin: 0 auto;
    padding: 1.5rem 16px 3rem;
    display: grid;
    gap: 1rem;
}
.setup h1 { margin: 0 0 0.5rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { color: var(--muted); font-size: 0.9rem; }
.field-row { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.check, .radio { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.stepper { display: flex; align-items: center; gap: 1rem; }
.stepper button { width: 2.6rem; height: 2.6rem; font-size: 1.3rem; padding: 0; }
.stepper strong { font-size: 1.4rem; min-width: 1.5rem; text-align: center; }
.player-names { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.player-names li { display: flex; align-items: center; gap: 0.6rem; }
.player-names input:not([type]) { flex: 1; min-width: 0; }
.player-names .radio span { color: var(--muted); font-size: 0.85rem; }
.swatch { width: 0.9rem; height: 2.3rem; border-radius: 4px; flex: none; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.turn { display: flex; flex-direction: column; line-height: 1.2; }
.turn strong { font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* ---------- Panels ---------- */
.panel {
    margin: 0.75rem 16px 0;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.dice-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dice-result { font-size: 1.6rem; font-weight: 700; margin: 0.6rem 0 0; animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.log ol { margin: 0; padding-left: 1.4rem; max-height: 40vh; overflow-y: auto; display: grid; gap: 0.25rem; }
.log .muted { font-size: 0.8rem; margin-right: 0.4rem; }

/* ---------- Board ---------- */
.board {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem 16px 2rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
/* Keep even groups in tidy rows (2x2, 3x2, 4x2) instead of e.g. 3 + 1. */
@media (min-width: 640px) {
    .board.players-2, .board.players-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
    .board.players-3, .board.players-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) {
    .board.players-8 { grid-template-columns: repeat(4, 1fr); }
}

.player {
    position: relative;
    display: grid;
    gap: 0.6rem;
    padding: 0.8rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-top: 6px solid var(--player-color);
    border-radius: var(--radius);
    transition: transform 0.3s, opacity 0.3s, border-color 0.2s;
}
.player.active { border-color: var(--player-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--player-color) 35%, transparent); }
.player.flipped { transform: rotate(180deg); }
.player.out { opacity: 0.55; }

.player header { display: flex; align-items: center; gap: 0.5rem; }
.player h2 { margin: 0; font-size: 1.15rem; cursor: text; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .rename { flex: 1; min-width: 0; }
.player .tools { margin-left: auto; display: flex; }
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--player-color);
    color: #fff;
    white-space: nowrap;
}

.life { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.life-btn { height: 5rem; font-size: 2.4rem; font-weight: 300; border-radius: 12px; }
.life-total { display: grid; justify-items: center; min-width: 6.5rem; }
.life-total .number { font-size: 4.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.out-label { color: var(--danger); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.08em; }
.life-small { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem; }
.life-small button { padding: 0.4rem 0; }

.counters, .commander { display: grid; gap: 0.3rem; }
.section-label { color: var(--muted); font-size: 0.8rem; }
.counter {
    display: grid;
    grid-template-columns: 1fr 2.2rem 2.2rem 2.2rem;
    align-items: center;
    gap: 0.3rem;
    color: var(--muted);
}
.counter .label { display: flex; align-items: center; gap: 0.4rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.counter button { padding: 0.25rem 0; }
.counter .value { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.counter.nonzero { color: var(--text); }
.counter.lethal .value { color: var(--danger); }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; flex: none; }

/* ---------- Deck art on player cards ---------- */
.player .names { display: grid; min-width: 0; }
.player .deck-name { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .deck-art {
    position: absolute;
    inset: 0 0 auto 0;
    height: 7rem;
    border-radius: calc(var(--radius) - 4px) calc(var(--radius) - 4px) 0 0;
    background: var(--deck-art) center 30% / cover no-repeat;
    opacity: 0.35;
    -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent);
    mask-image: linear-gradient(to bottom, #000 30%, transparent);
    pointer-events: none;
}
.player > :not(.deck-art) { position: relative; }

/* ---------- Shared bits for the deck pages ---------- */
a { color: var(--accent); }
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.small { font-size: 0.85rem; }
.grow { flex: 1 1 10rem; min-width: 0; }
.grow input, .grow select { width: 100%; min-width: 0; }
.notice { padding: 0.7rem 0.9rem; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: 0.4rem 0 0; }
.error-text { color: var(--danger); }
.unsaved { color: var(--accent); }
code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 6px; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 0; justify-self: start; }

a.button {
    display: inline-block;
    font: inherit;
    color: var(--text);
    text-decoration: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    white-space: nowrap;
}
a.button:hover { border-color: var(--accent); }
a.button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }

textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    width: 100%;
    resize: vertical;
}
input[type="search"], input[type="email"] { min-width: 0; }

.page { max-width: 760px; margin: 0 auto; padding: 1rem 16px 3rem; display: grid; gap: 1rem; align-content: start; }
.page.wide { max-width: 1200px; }
.page-head { display: grid; gap: 0.2rem; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.back { text-decoration: none; font-size: 0.9rem; }
.setup-like { display: grid; gap: 0.8rem; }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline-form input { flex: 1 1 12rem; }

.panel.account { margin: 0; display: grid; gap: 0.7rem; }
.panel.account h2 { margin: 0; font-size: 1.15rem; }
.panel.account p { margin: 0; }

.sign-in { max-width: 520px; }
.benefits { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.25rem; }
.provider-buttons { display: grid; gap: 0.6rem; }
.provider-button {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
    width: 100%; min-height: 48px; font-weight: 600;
}
.provider-icon { width: 20px; height: 20px; flex: none; }
.first-sign-in { max-width: 560px; padding-top: 6vh; }
.claim-code { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.claim-code code { font-size: 1.3rem; letter-spacing: 0.12em; padding: 0.2rem 0.6rem; border: 1px dashed var(--border); border-radius: 8px; }
.badge { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }

.account-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.6rem 1rem;
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.field.compact > span { font-size: 0.8rem; }
.invite { display: flex; align-items: center; gap: 0.4rem; }
.invite code { font-size: 1.05rem; letter-spacing: 0.08em; }

.toolbar input[type="search"] { flex: 1 1 14rem; }

/* ---------- Deck list ---------- */
.deck-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.deck-tile {
    display: grid;
    height: 100%;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.deck-tile:hover { border-color: var(--accent); }
.deck-tile .art { aspect-ratio: 16 / 7; background: var(--surface-2) center 25% / cover no-repeat; }
.deck-tile .info { display: grid; gap: 0.15rem; padding: 0.6rem 0.75rem 0.75rem; min-width: 0; }
.deck-tile .info > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Deck editor ---------- */
.editor { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 900px) {
    .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .search-side { position: sticky; top: 0.75rem; max-height: calc(100vh - 1.5rem); overflow-y: auto; }
}
.deck-side, .search-side { display: grid; gap: 0.9rem; min-width: 0; }
.search-side h2 { margin: 0; font-size: 1.1rem; }
.deck-fields { display: grid; gap: 0.6rem; }
.deck-fields details textarea { margin-top: 0.4rem; }
.save-bar { position: sticky; top: 0; z-index: 5; padding: 0.5rem 0; background: var(--bg); }

.legality { padding: 0.6rem 0.8rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.legality.good strong { color: #22c55e; }
.legality.bad { border-color: color-mix(in srgb, var(--danger) 60%, var(--border)); }
.legality.bad > strong { color: var(--danger); }
.legality ul { margin: 0.4rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.2rem; font-size: 0.9rem; }

.deck-section h3, .curve h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.deck-section ul { list-style: none; margin: 0; padding: 0; display: grid; }
.deck-line {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.deck-line.unknown .card-name { color: var(--danger); }
.deck-line .qty { display: flex; align-items: center; gap: 0.1rem; }
.deck-line .qty span { min-width: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.deck-line .qty button { padding: 0.15rem 0.45rem; }
.card-name {
    background: none;
    border: none;
    padding: 0.2rem 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: text;
}
.card-name:hover { color: var(--accent); }
.deck-line .price { font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: right; min-width: 3.6rem; }
.section-value { float: right; font-weight: 400; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.deck-value { font-variant-numeric: tabular-nums; }
.deck-line .move { padding: 0.2rem 0.3rem; font-size: 0.8rem; max-width: 6.5rem; }
@media (max-width: 639px) {
    /* Phones: give the card name more room now that each line also shows a price. */
    .deck-line { gap: 0.3rem; }
    .deck-line .qty button { padding: 0.15rem 0.35rem; }
    .deck-line .qty span { min-width: 1.3rem; }
    .deck-line .price { min-width: 0; font-size: 0.75rem; }
    .deck-line .move { max-width: 4.6rem; }
}

.mana { display: inline-flex; gap: 1px; align-items: center; white-space: nowrap; }
.mana img { width: 1rem; height: 1rem; }

.curve .bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.3rem; height: 6rem; align-items: end; }
.bar-col { display: grid; grid-template-rows: auto 1fr auto; height: 100%; justify-items: center; font-size: 0.75rem; color: var(--muted); }
.bar-col .bar { align-self: end; width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }

/* ---------- Card search ---------- */
.card-search { display: grid; gap: 0.6rem; }
.search-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.search-results li { display: grid; gap: 0.3rem; }
.card-thumb { padding: 0; border: none; background: none; border-radius: 6px; overflow: hidden; aspect-ratio: 146 / 204; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb span { display: grid; place-items: center; height: 100%; padding: 0.4rem; background: var(--surface-2); font-size: 0.8rem; }
.add-buttons { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem; }
.add-buttons button { padding: 0.3rem 0.4rem; font-size: 0.85rem; }

/* ---------- Overlays ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.7);
}
.card-preview { margin: 0; display: grid; gap: 0.5rem; justify-items: center; max-width: min(92vw, 400px); }
.card-preview img { width: 100%; border-radius: 4.75% / 3.5%; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.card-preview figcaption { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: center; color: #ddd; font-size: 0.85rem; }
.text-card { background: var(--surface); padding: 1rem; border-radius: var(--radius); }
.text-card .oracle { white-space: pre-line; }
.dialog {
    width: min(600px, 100%);
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.dialog h2 { margin: 0; }
.dialog p { margin: 0; }
.dialog textarea { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }

/* ---------- Card scanner ---------- */
.scanner-overlay { align-items: start; overflow-y: auto; }
.dialog.scanner { width: min(480px, 100%); }
.dialog.scanner > * { min-width: 0; }
.scanner-view {
    position: relative;
    aspect-ratio: 3 / 4;
    max-height: 62vh;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 10px;
    background: #000;
}
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 88%;
    aspect-ratio: 63 / 88;
    transform: translate(-50%, -50%);
    border: 2px solid var(--accent);
    border-radius: 4.75% / 3.5%;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
    pointer-events: none;
}
.scanner-guide span { position: absolute; border: 1px dashed rgba(255, 255, 255, 0.7); border-radius: 4px; }
.scanner-guide .title-zone { left: 6.5%; top: 4.5%; width: 68%; height: 8%; }
.scanner-guide .bottom-zone { left: 2.5%; top: 88.5%; width: 46%; height: 8.5%; }
label.button {
    display: inline-block;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
}
label.button:hover { border-color: var(--accent); }
label.button.disabled { opacity: 0.5; pointer-events: none; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.scan-result { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.scan-result img { width: 100%; border-radius: 4.75% / 3.5%; }
.scan-result-info { display: grid; gap: 0.35rem; min-width: 0; }
.printing-picker { display: grid; gap: 0.5rem; }
.printing-picker input { width: 100%; }
.printing-picker ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    max-height: 50vh;
    overflow-y: auto;
}
.printing-picker button.printing {
    width: 100%;
    display: grid;
    gap: 0.15rem;
    padding: 0.3rem;
    text-align: left;
    font-size: 0.75rem;
    border-radius: 8px;
    white-space: normal;
}
.printing-picker button.printing.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.printing-picker img { width: 100%; aspect-ratio: 146 / 204; object-fit: cover; border-radius: 4.75% / 3.5%; }
.printing-picker .set-name { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- Setup: deck pickers ---------- */
.player-names .seat { flex: 1; min-width: 0; display: grid; gap: 0.3rem; }
.player-names .seat select { font-size: 0.9rem; padding: 0.35rem 0.5rem; }
.setup h1 { margin: 0; }

/* ---------- Blazor template bits ---------- */
#blazor-error-ui {
    background: lightyellow;
    color: #111;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    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: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem auto; }
.loading-progress circle { fill: none; stroke: var(--surface-2); stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--accent);
    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"); }

/* ---------- Deck import ---------- */
.mode-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.precon-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; max-height: 26rem; overflow-y: auto; }
.precon-list button,
.precon-chosen { display: grid; gap: 0.15rem; width: 100%; text-align: left; background: var(--surface); }
.precon-list button > *,
.precon-chosen strong { overflow-wrap: anywhere; }
.precon-list .muted,
.precon-chosen .muted { font-size: 0.85rem; }
.precon-chosen { padding: 0.7rem 0.9rem; border: 1px solid var(--accent); border-radius: var(--radius); gap: 0.5rem; }
.precon-chosen > div { display: grid; gap: 0.15rem; }

/* ---------- Player profiles ---------- */
.profile-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.profile-tile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 100%;
    padding: 0.75rem;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.profile-tile:hover { border-color: var(--accent); }
.profile-tile .info { display: grid; gap: 0.15rem; min-width: 0; }
.profile-tile .info > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 25%, var(--surface-2));
    color: var(--text);
    font-weight: 700;
    font-size: 1.15rem;
}

.stat-row { margin: 0; display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); }
.stat-row > div { padding: 0.6rem 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.stat-row dt { color: var(--muted); font-size: 0.8rem; }
.stat-row dd { margin: 0.1rem 0 0; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.profile-section, .history { display: grid; gap: 0.6rem; min-width: 0; align-content: start; }
.profile-section h2, .history h2 { margin: 0; font-size: 1.15rem; }
.profile-section > p, .history > p { margin: 0; }
.owned-deck { display: grid; gap: 0.3rem; }
.owned-deck .link { justify-self: start; }

.deck-line.collection-line { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.collection-line .printing { white-space: nowrap; font-variant-numeric: tabular-nums; }

.deck-records { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.deck-records th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.deck-records th, .deck-records td { padding: 0.3rem 0.4rem; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.deck-records td:not(:first-child), .deck-records th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.deck-records td:first-child { overflow-wrap: anywhere; }

.game-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.game-history li { display: grid; gap: 0.2rem; padding: 0.55rem 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.game-history .row > * { min-width: 0; overflow-wrap: anywhere; }
.game-history .seats { display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; }
.game-history button.icon { padding: 0 0.35rem; margin-left: 0.3rem; font-size: 0.75rem; }
.won { color: #22c55e; }
.lost { color: var(--danger); }
@media (prefers-color-scheme: light) { .won { color: #15803d; } }

/* Playgroup admin */
.profile-grid li { display: grid; gap: 0.2rem; align-content: start; }
button.danger { color: var(--danger); border-color: var(--danger); }

/* Backups */
.backup { padding: 0.2rem 0; }
.backup summary { cursor: pointer; color: var(--muted); }
.backup[open] { display: grid; gap: 0.5rem; }
.backup p { margin: 0; }
.file-button { position: relative; overflow: hidden; cursor: pointer; }
.file-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
