/*
 * Application styles
 */

/* ── Type scale ─────────────────────────────────────────────────────────────
 * Every font size in the app is one of these (no one-off sizes): */
:root {
  --fs-micro: 0.75rem;  /* 12px — what's written on the cards themselves: power, counters, marks, the mat's labels */
  --fs-small: 0.875rem; /* 14px — labels, hints, secondary text, small buttons */
  --fs-body:  1rem;     /* 16px — text to read: the status bar, the log, panels, fields */
  --fs-large: 1.2rem;   /* an effect's question, titles */
  --fs-xl:    1.5rem;   /* the deck count */
  --fs-h2:    clamp(1.5rem, 3vw, 2rem);     /* section and page titles */
  --fs-h1:    clamp(2.4rem, 6vw, 4.2rem);   /* the home's wordmark only */
}

/* ── Fonts (DESIGN.md: self-hosted, app/assets/fonts, SIL OFL) ──────────────
 * Bricolage Grotesque: titles (and, with the board, its numbers: narrow).
 * Hanken Grotesk: everything else. latin + latin-ext: pt-BR's accents. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 600 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("/assets/bricolage-grotesque-latin-ext-2b3bb0b0.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 600 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("/assets/bricolage-grotesque-latin-f6deee0c.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/hanken-grotesk-latin-ext-b6254e3b.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/hanken-grotesk-latin-7b3229a0.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Colors: "Mesa de loja à noite" (DESIGN.md) ──────────────────────────────
 * Every color in this file is one of these: components never write a hex
 * (spec/assets/color_tokens_spec.rb). Two themes — dark (the store table at
 * night, the default) and light (a light-grey neoprene mat by day) — picked
 * on <html data-theme> by the layout (Theme); "system" follows the device. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  /* the table */
  --mat: #11151b;           /* the page: the playmat */
  --mat-raised: #1a1f27;    /* panels, buttons, dialogs: card stock */
  --mat-sunken: #0d1116;    /* fields, wells */
  --mat-edge: #2b323d;      /* borders, zone outlines */
  --stitch: #3a4350;        /* the stitched edge, dividers, stronger borders */
  --hover: #212733;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* text */
  --chalk: #e9e5dc;
  --chalk-strong: #ffffff;  /* a hovered link, a name to stand out */
  --chalk-muted: #8b94a1;
  --chalk-faint: #5d6672;   /* captions only (~3:1) */
  /* the one accent: DON!! gold */
  --focus: #f0c040;         /* gold as text and focus rings */
  --don-border: #c99a22;
  --don-tint: #221d0d;      /* a gold-tinted panel ("your turn") */
  --don-tint-edge: #5a4a1a;
  /* semantic */
  --danger: #e5533d;
  --danger-text: #ff8f7a;
  --danger-bg: #3a1915;
  --danger-border: #6b2a22;
  --success: #46c47e;
  --success-bg: #13261b;
  --warning: #f6ad55;       /* not ready yet: a deck short of cards */
  --info-bg: #13202e;       /* the tutorial's boxes */
  /* the board's choices (looked at again with the board, rollout step 4) */
  --target: #38b2ac;        /* can be chosen */
  --target-strong: #81e6d9; /* chosen */
  --playable: #3182ce;
  --playable-text: #90cdf4;
  --extra: #9f7aea;         /* Extra Regulation */
  --extra-text: #d6bcfa;
  /* stickers: the format badges */
  --sticker: #e9e5dc;
  --sticker-extra: #b7c3d4;
  --on-sticker: #1a1f27;
}
/* The same in both themes: DON!!, what's printed on a card, the card colors */
:root {
  --don: #f0c040;
  --don-hover: #f5cd5c;
  --don-light: #fff3c4;
  --on-don: #1b1405;
  --on-card: #e9e5dc;       /* text on a card's dark chip */
  --c-red: #d9443b;
  --c-green: #3e9c5c;
  --c-blue: #2f80d2;
  --c-purple: #8c52c4;
  --c-black: #4a4f57;       /* always with a --chalk-muted ring */
  --c-yellow: #f6df4a;      /* lemon: never DON!! gold */
}
/* (system: the device's choice — the layout leaves data-theme off) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --mat: #e6e8ec;
    --mat-raised: #f7f5f0;
    --mat-sunken: #fdfcf9;
    --mat-edge: #c3c9d2;
    --stitch: #aab2bd;
    --hover: #efede7;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --chalk: #1a1f27;
    --chalk-strong: #000000;
    --chalk-muted: #545d6a;
    --chalk-faint: #7f8894;
    --focus: #7a5600;
    --don-border: #a87c12;
    --don-tint: #f6ecd0;
    --don-tint-edge: #d9c27a;
    --danger: #c2412d;
    --danger-text: #b3361f;
    --danger-bg: #fbe9e5;
    --danger-border: #e4a69a;
    --success: #19733f;
    --success-bg: #e3f2e8;
    --warning: #9a5b00;
    --info-bg: #e3edf7;
    --target: #1f8a85;
    --target-strong: #11706a;
    --playable: #2f6fb8;
    --playable-text: #1f5a99;
    --extra: #6b46c1;
    --extra-text: #5b3aa6;
    --sticker: #1a1f27;
    --sticker-extra: #545d6a;
    --on-sticker: #f7f5f0;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --mat: #e6e8ec;
  --mat-raised: #f7f5f0;
  --mat-sunken: #fdfcf9;
  --mat-edge: #c3c9d2;
  --stitch: #aab2bd;
  --hover: #efede7;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --chalk: #1a1f27;
  --chalk-strong: #000000;
  --chalk-muted: #545d6a;
  --chalk-faint: #7f8894;
  --focus: #7a5600;
  --don-border: #a87c12;
  --don-tint: #f6ecd0;
  --don-tint-edge: #d9c27a;
  --danger: #c2412d;
  --danger-text: #b3361f;
  --danger-bg: #fbe9e5;
  --danger-border: #e4a69a;
  --success: #19733f;
  --success-bg: #e3f2e8;
  --warning: #9a5b00;
  --info-bg: #e3edf7;
  --target: #1f8a85;
  --target-strong: #11706a;
  --playable: #2f6fb8;
  --playable-text: #1f5a99;
  --extra: #6b46c1;
  --extra-text: #5b3aa6;
  --sticker: #1a1f27;
  --sticker-extra: #545d6a;
  --on-sticker: #f7f5f0;
}

/* ── Reset / base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  background: var(--grain), var(--mat);
  color: var(--chalk);
}

/* The Home Screen app's top edge (an iPhone, iOS 26+): the system blurs
   whatever scrolls under the top of the page — unless a fixed, full-width
   box of one solid colour sits right at that edge, whose colour it extends
   into the status bar instead (WebKit hit-tests it a few px inside the
   edge: a real element, taking touches). The page starts below it (#320). */
:root { --home-edge: 0px; }
html.home-screen-app { --home-edge: 8px; }
.home-screen-edge { display: none; }
html.home-screen-app .home-screen-edge {
  display: block; position: fixed; top: 0; left: 0; right: 0; height: var(--home-edge); z-index: 2000;
  background: var(--mat);
}
html.home-screen-app body { padding-top: var(--home-edge); }

/* Titles: Bricolage Grotesque (the wordmark too) */
h1, h2, .top-bar__brand {
  font-family: "Bricolage Grotesque", "Arial Narrow", sans-serif; font-weight: 800; text-wrap: balance;
}

a { color: inherit; text-decoration: none; }

/* Browsers default <button> to a UA font (commonly Arial, not the page's
 * system-ui stack) unless told otherwise — every .btn-primary/secondary/
 * danger applied to a <button> (button_to) rendered at a different font,
 * and therefore a different height, than the identical class applied to
 * an <a> (link_to) sitting right next to it. */
button, input, select, textarea { font: inherit; } /* (fields too: their text, and a submit's) */

/* ── Card grid ────────────────────────────────────────────────────────────── */
/*
 * Responsive grid: cards fill the available width.
 * Each card is at least 130px wide; at wider viewports more fit per row.
 * Breakpoints are implicit via auto-fill — no media queries needed.
 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  padding: 12px 0;
}

/* ── Card thumbnail ───────────────────────────────────────────────────────── */
.card-thumb {
  display: flex;
  flex-direction: column;
  background: var(--mat-raised);
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}

.card-thumb--addable {
  cursor: pointer;
}

.card-thumb--addable:hover {
  border-color: var(--don);
  transform: translateY(-2px);
}

/* Fixed aspect ratio for the image area — real OPTCG card art is 63:88mm
 * (≈0.716), not the classic US-card 2.25:3.5 (9:14 ≈ 0.643) this used to
 * assume. That mismatch didn't crop anything here directly (this box just
 * displays whatever Card#thumbnail already is), but it must stay in sync
 * with Card::THUMBNAIL_TRANSFORM's own ratio — if the two ever disagree,
 * `object-fit: cover` crops the already-correctly-cropped thumbnail a
 * second time. */
.card-thumb__image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 63 / 88;
  background: var(--mat-sunken);
  overflow: hidden;
}

/* "Unreleased": a card whose set isn't out yet (CardSet) — only the
   Unreleased format allows it. */
.card-thumb__unreleased {
  position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px);
  padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--mat-sunken) 85%, transparent); border: 1px solid var(--warning);
  color: var(--warning); font-size: var(--fs-small); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}

.card-thumb__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-thumb__placeholder {
  width: 100%;
  aspect-ratio: 63 / 88;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hover);
  padding: 8px;
  text-align: center;
  font-size: var(--fs-small);
  color: var(--chalk-muted);
}
/* (a card with no picture, or one that didn't load: its name and code — card_image_controller.js) */
.card-thumb__placeholder { flex-direction: column; gap: 4px; }
.card-thumb__code { color: var(--chalk-muted); font-size: var(--fs-micro); letter-spacing: 0.04em; }

.card-thumb__name {
  margin: 0;
  padding: 4px 6px;
  font-size: var(--fs-micro);
  line-height: 1.2;
  color: var(--chalk);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Filter form ──────────────────────────────────────────────────────────── */
.filter-group {
  margin-bottom: 14px;
}

.filter-group label,
.filter-group > label {
  display: block;
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  margin-bottom: 4px;
}

/* Colors is the one filter that gates whether anything renders at all —
 * called out in the accent color so it doesn't read as just another
 * optional filter next to cost/category. */
.filter-group__required {
  color: var(--focus);
  font-weight: 600;
  text-transform: none;
}

.filter-group input[type="text"],
.filter-group input[type="number"],
.filter-group select {
  width: 100%;
  height: 36px; /* (fields and the select alike) */
  padding: 6px 8px;
  background: var(--mat-raised);
  border: 1px solid var(--mat-edge);
  border-radius: 4px;
  color: var(--chalk);
  font-size: var(--fs-small);
}

/* The search box's ×, inside its right end — only while there's something
   to clear (the box has a placeholder: empty, it's shown). */
.filter-search { position: relative; }
.filter-group.filter-search input[type="text"] { padding-right: 32px; }
.filter-search__clear {
  position: absolute; right: 2px; top: 2px; width: 32px; height: 32px;
  padding: 0; border: none; border-radius: 4px; background: none;
  color: var(--chalk-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.filter-search__clear:hover { color: var(--chalk-strong); background: var(--hover); }
.filter-search input:placeholder-shown + .filter-search__clear { display: none; }

.filter-ranges { display: flex; flex-wrap: wrap; column-gap: 12px; grid-column: 1 / -1; }
.filter-group--cost  { flex: 2 1 130px; }
.filter-group--power { flex: 3 1 190px; }
.filter-range { display: flex; align-items: center; gap: 6px; }
.filter-range input { min-width: 0; flex: 1 1 0; }
.filter-range__dash { color: var(--chalk-faint); }

.filter-group--checkbox label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-small);
  color: var(--chalk);
}

/* Single row of compact color-swatch toggles (not text-labeled chips) —
 * the 220px filter sidebar isn't wide enough to fit 6 labeled checkboxes
 * on one line, so color is the label. Name is still exposed to assistive
 * tech via aria-label on the checkbox itself, and to sighted mouse users
 * via the wrapping <label>'s title tooltip. */
.color-swatches {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.color-swatch {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
}

.color-swatch__input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.color-swatch__fill {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  pointer-events: none; /* purely decorative — let clicks fall through to the checkbox beneath it */
}

.color-swatch__input:checked ~ .color-swatch__fill {
  border-color: var(--don);
  transform: scale(0.82);
}

.color-swatch__input:focus-visible ~ .color-swatch__fill {
  outline: 2px solid var(--don);
  outline-offset: 2px;
}

.color-swatch--red    .color-swatch__fill { background: var(--c-red); }
.color-swatch--green  .color-swatch__fill { background: var(--c-green); }
.color-swatch--blue   .color-swatch__fill { background: var(--c-blue); }
.color-swatch--purple .color-swatch__fill { background: var(--c-purple); }
.color-swatch--black  .color-swatch__fill { background: var(--c-black); box-shadow: 0 0 0 1px var(--chalk-muted); }
.color-swatch--yellow .color-swatch__fill { background: var(--c-yellow); }

.btn-clear {
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  text-decoration: underline;
  cursor: pointer;
  /* (on a <button>: none of the browser's button box) */
  background: none;
  border: none;
  padding: 0;
}

/* Buttons: one box for all three looks, whether a link (link_to), a
 * <button> (button_to) or a submit — so side by side they're the same
 * height and line up. (The match bar and the decision panel size theirs
 * further down.) */
.btn-primary,
.btn-secondary,
.btn-danger,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.45), 0 2px 5px rgb(0 0 0 / 0.35);
  transition: background-color 120ms, border-color 120ms, box-shadow 120ms, transform 120ms;
}
.btn-primary:active, .btn-secondary:active, .btn-danger:active, input[type="submit"]:active { box-shadow: none; transform: translateY(1px); }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible, input[type="submit"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary, input[type="submit"] { background: var(--don); color: var(--on-don); border-color: var(--don-border); font-weight: 700; }
.btn-primary:hover, input[type="submit"]:hover { background: var(--don-hover); }
.btn-secondary { background: var(--mat-raised); color: var(--chalk); border-color: var(--mat-edge); }
.btn-secondary:hover { background: var(--hover); border-color: var(--stitch); }
.btn-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-border); }
/* (disabled: dimmed, no hover — it shouldn't look like it works) */
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled, input[type="submit"]:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:disabled:hover, input[type="submit"]:disabled:hover { background: var(--don); }
.btn-secondary:disabled:hover { background: var(--mat-raised); border-color: var(--mat-edge); }
.btn-danger:disabled:hover { background: var(--danger-bg); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled, input[type="submit"]:disabled { box-shadow: none; transform: none; }
/* (button_to wraps its button in a form: no box of its own) */
form.button_to { display: contents; }

/* ── Result / pagination ──────────────────────────────────────────────────── */
.result-count {
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  margin: 0 0 8px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font-size: var(--fs-small);
}

.pagination__disabled { color: var(--chalk-faint); }
.pagination__info     { color: var(--chalk-muted); }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state {
  color: var(--chalk-faint);
  padding: 32px 0;
  text-align: center;
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash {
  padding: 10px 16px;
  font-size: var(--fs-body);
  max-height: 200px;
  overflow: hidden;
  transition: opacity 0.3s, max-height 0.3s, padding 0.3s;
}
/* (going away: fades and folds up, so the page doesn't jump) */
.flash--leaving { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; }
.flash--alert { display: flex; align-items: center; gap: 12px; }
.flash__close { margin-left: auto; background: none; border: none; color: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.flash--notice { background: var(--success-bg); color: var(--success); }
.flash--alert  { background: var(--danger-bg); color: var(--danger-text); }

/* ── Deck builder — full-height sidebar | drag handle | workspace ─────────
 * The sidebar (filters + hovered card) runs the full screen height, so a
 * deck strip that grows as you build never eats into the card preview.
 * Its width comes from sidebar_resize_controller.js (380px until dragged).
 * The workspace stacks topbar / errors / deck strip / card grid.
 */
.deck-builder {
  display: grid;
  grid-template-columns: var(--db-sidebar-width, 380px) 6px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.deck-builder--resizing { cursor: col-resize; user-select: none; }

.db-workspace {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr); /* (the top bar: one row, two when its buttons don't fit) */
  min-width: 0;
  overflow: hidden;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.db-topbar {
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end; /* (a second row — the buttons — on the right too) */
  align-items: center;
  gap: 8px 16px;
  min-height: 52px;
  padding: 7px 16px;
  background: var(--mat-sunken);
  border-bottom: 1px solid var(--mat-edge);
}

.db-name-input {
  /* a field sunk into the mat (DESIGN.md), the name in the titles' font */
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 6px;
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.4);
  color: var(--chalk);
  font-family: "Bricolage Grotesque", "Arial Narrow", sans-serif;
  font-size: var(--fs-body);
  font-weight: 800;
  padding: 6px 10px;
  /* (gives up room first, so the buttons — Save above all — always fit;
     a small basis: the bar wraps only when 100px of name doesn't fit) */
  flex: 1 1 100px;
  max-width: 260px;
  min-width: 100px;
  margin-right: auto; /* (the count and the buttons to the right) */
  outline: none;
}

.db-name-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.db-count {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--focus);
  white-space: nowrap;
}

/* (too narrow for all of them — 761 to ~1340px wide: they go under the
   name, on the right, and wrap there too; never past the edge) */
.db-topbar__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-width: 0; }

/* ── Errors bar ───────────────────────────────────────────────────────────── */
/* The builder's messages: over the page, under its top bar — they never
   push the deck and the grid down (nor pull them back up when gone); a
   tap closes one. */
.db-errors {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 1200;
  width: max-content; max-width: min(560px, calc(100vw - 24px));
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); cursor: pointer;
  background: var(--danger-bg);
  color: var(--danger-text);
  padding: 8px 16px;
  font-size: var(--fs-small);
  overflow: hidden;
}
.db-errors p { margin: 2px 0; }
.db-errors:has(.db-errors__close) { padding-right: 40px; }
.db-errors__close { position: absolute; top: 4px; right: 6px; min-width: 32px; min-height: 32px; background: none; border: none; color: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.db-errors--notice { background: var(--success-bg); color: var(--success); }
/* A challenge they're building for: it stays, so it's in the page. */
.db-invite { grid-row: 2; margin: 0; padding: 6px 16px; background: var(--success-bg); color: var(--success); font-size: var(--fs-small); }

/* ── Deck display strip (full workspace width) ────────────────────────────
 * A CSS grid, not flex-wrap: every stack (leader included — same size as
 * everything else, see .deck-stack below) sits in a uniform-width column, so
 * column boundaries stay fixed across every row regardless of how many
 * cards you've added. Padding here is the strip's outer edge, kept
 * comfortably wider than the tight 6px gap between stacks themselves.
 *
 * Every stack row is exactly --stack-row tall (124px pile + 3px gap + 14px
 * quantity line, see .deck-stack__images/__qty), so the stack area can be
 * capped at exactly two full rows. Past two rows it scrolls a row at a
 * time. Only the stack area scrolls: the strip's own padding stays put
 * around it, so no scroll position shows part of a row (or its "1×"
 * labels) at either edge. A bare max-height on the strip used to cut the
 * second row's labels off.
 */
.db-deckstrip {
  --stack-row: 141px;
  --stack-gap: 6px;
  grid-row: 3;
  /* The deck laid out on the mat (DESIGN.md): neoprene, its stitched edge */
  position: relative;
  margin: 10px 12px 0;
  background: var(--grain), var(--mat);
  border-radius: 14px;
  padding: 16px 18px;
}
.db-deckstrip::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px dashed var(--stitch);
  border-radius: 10px;
  pointer-events: none;
}

/* The deck's summary (deck_builder_controller.js#renderSummary): a bar
   for each cost, 0 to 10, as tall as its share of the tallest, with its
   count over it; then the counters. On a desktop in the sidebar, where the
   hovered card shows (that card over it, while there is one); on a phone
   over the deck, one short row shut behind its button (.db-summary-toggle). */
.db-summary {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 24px;
  margin-bottom: 10px;
}
.db-summary__costs { display: flex; align-items: flex-end; gap: 4px; }
.db-summary__cost {
  display: grid; grid-template-rows: auto 22px auto; justify-items: center;
  width: 22px; font-size: var(--fs-small); line-height: 1.2; color: var(--chalk);
}
.db-summary__count { font-variant-numeric: tabular-nums; }
.db-summary__cost--none .db-summary__count { color: var(--chalk-faint); }
.db-summary__bar { align-self: end; width: 14px; min-height: 2px; background: var(--don); border-radius: 2px 2px 0 0; }
.db-summary__label { color: var(--chalk-muted); border-top: 1px solid var(--stitch); width: 100%; text-align: center; }
.db-summary__counters { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-small); color: var(--chalk-muted); padding-bottom: 2px; }
.db-summary__counter b { color: var(--focus); font-variant-numeric: tabular-nums; }
.db-summary-toggle { display: none; }
.db-summary--strip { display: none; }
.db-summary-side { flex: none; margin-top: 4px; }
.db-sidebar:has(.db-preview__image) .db-summary-side { display: none; }
.db-summary--side { flex-direction: column; align-items: stretch; gap: 12px; margin: 0; }
.db-summary--side .db-summary__costs { justify-content: space-between; }
.db-summary--side .db-summary__cost { grid-template-rows: auto 72px auto; width: auto; flex: 1 1 0; }
.db-summary--side .db-summary__bar { width: 60%; }
.db-summary--side .db-summary__counters { flex-direction: column; gap: 4px; font-size: var(--fs-body); }
.db-summary--side .db-summary__counter { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--mat-edge); }

.db-display__inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, 95px);
  grid-auto-rows: var(--stack-row);
  gap: var(--stack-gap);
  align-content: start;
  /* Always two rows tall, even with one row of cards: if it grew when a
     card starts the second row, everything below — the card grid being
     clicked — would jump down under the pointer. Past two rows it scrolls. */
  height: calc(2 * var(--stack-row) + var(--stack-gap));
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}
.db-display__inner > * { scroll-snap-align: start; }
/* (a phone, a read-only deck: the Leader and the piles in that one grid) */
.db-deck-leader, .db-deck-piles { display: contents; }

/* A desktop: the Leader half as big again, in a column of its own, centred
   between two rows of up to 9 piles; past 18 piles those scroll, the Leader
   stays. The cards grow with the room there is (a narrower sidebar: bigger
   cards) — never under 80px wide (fewer piles in a row then), nor over
   120px. A row's width: the Leader (1.5 × card), its 16px gap, 9 piles
   (card + 15px fan) with 8 gaps, the scrollbar's 16px: 10.5 × card + 230px.
   Sizes go to the stacks through --stack-card-w/--stack-card-h/--stack-w. */
@media (min-width: 761px) {
  .deck-builder:not(.deck-builder--readonly) .db-display__inner {
    container-type: inline-size;
    display: flex; align-items: center; gap: 16px;
    height: auto; overflow: visible; scroll-snap-type: none;
  }
  .deck-builder:not(.deck-builder--readonly) :is(.db-deck-leader, .db-deck-piles) {
    --pile-w: clamp(80px, (100cqw - 230px) / 10.5, 120px);
  }
  .deck-builder:not(.deck-builder--readonly) .db-deck-piles {
    --stack-card-w: var(--pile-w);
    --stack-card-h: calc(var(--pile-w) * 1.4);
    --stack-w: calc(var(--pile-w) + 15px);
    --stack-row: calc(var(--pile-w) * 1.4 + 29px); /* (12px fan + card + 3px + 14px quantity line) */
    flex: 1 1 auto; min-width: 0;
    max-width: calc(9 * var(--stack-w) + 8 * var(--stack-gap) + 16px);
    display: grid;
    grid-template-columns: repeat(auto-fill, var(--stack-w));
    grid-auto-rows: var(--stack-row);
    gap: var(--stack-gap);
    align-content: start;
    height: calc(2 * var(--stack-row) + var(--stack-gap));
    overflow-y: auto;
    scrollbar-gutter: stable;
    scroll-snap-type: y mandatory;
  }
  .deck-builder:not(.deck-builder--readonly) .db-deck-piles > * { scroll-snap-align: start; }
  .deck-builder:not(.deck-builder--readonly) .db-deck-leader {
    --stack-card-w: calc(var(--pile-w) * 1.5);
    --stack-card-h: calc(var(--pile-w) * 2.1);
    --stack-w: var(--stack-card-w); /* (one card: no fan) */
    display: block; flex: none; width: var(--stack-card-w);
  }
  /* (no fan above it to make room for) */
  .deck-builder:not(.deck-builder--readonly) .db-deck-leader .deck-stack__images { margin-top: -12px; }
}

/* Filters on top, the hovered card filling whatever height is left. On a
   short screen the preview keeps a minimum height and the sidebar scrolls
   rather than shrinking the card to nothing. */
.db-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: var(--mat-sunken);
}

.db-sidebar__filters {
  flex: 0 0 auto;
  container-type: inline-size;
}

/* A widened sidebar lays the filters out in two columns, so they take
   less height and the card preview below gets more. */
@container (min-width: 340px) {
  .db-sidebar__filters form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
  }
  /* The search box needs the full width; everything else pairs up. */
  .db-sidebar__filters .filter-group:first-child { grid-column: 1 / -1; }
  .db-sidebar__filters .filter-group--checkbox label { white-space: nowrap; }
}

.db-preview {
  flex: 1 1 auto;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  border-top: 1px solid var(--mat-edge);
  padding-top: 12px;
}

.db-preview__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  border-radius: 8px;
}

.db-preview__empty {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--chalk-faint);
  text-align: center;
}

.db-resize-handle {
  cursor: col-resize;
  background: var(--mat-sunken);
  border-right: 1px solid var(--mat-edge);
  touch-action: none;
}
.db-resize-handle:hover,
.db-resize-handle:focus-visible,
.deck-builder--resizing .db-resize-handle { background: var(--hover); outline: none; }

.db-sidebar__heading {
  margin: 0 0 8px;
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--chalk-muted);
}

/* ── Card stacks inside the deck display ──────────────────────────────────── */
/* Leader and every regular stack render at the same size now — the card
 * itself (.deck-stack__img) is 80×112, and everything else here is derived
 * from that one number plus the fan's own reach, so nothing needs a
 * `--leader` size override any more (it keeps the class only for the
 * "Leader" label's text color, below).
 *
 * 80×112 is a 63:88 ratio (≈0.714) — matching Card::THUMBNAIL_TRANSFORM's
 * own real-card-art ratio, same as `.card-thumb__image-wrap` above. Getting
 * this out of sync with the thumbnail's actual ratio is exactly what
 * cropped the card's printed border and pushed its cost/power badges off
 * the edge in an earlier pass here — `object-fit: cover` will silently
 * crop *any* mismatch between a box's ratio and its image's real ratio, so
 * this number must track THUMBNAIL_TRANSFORM's, not the other way around.
 *
 * The fan (#stackHTML in deck_builder_controller.js) offsets each stacked
 * card `i*5px` right and, via FAN_MAX_LIFT there, `12-i*4px` up, so a full
 * 4-card pile's true footprint is 95×124 (80+3×5 wide, 112+12 tall) — not
 * 80×112. `.deck-stack__images` is sized to that true footprint: the back
 * card (i=0) always sits 12px down from the box's own top regardless of
 * pile size, which (a) reserves exactly the fan's max upward reach above it
 * so a full 4× pile's frontmost card lands flush with the box's top instead
 * of overflowing above it, and (b) puts every pile's back card — leader
 * included — on the exact same baseline, since that 12px offset is applied
 * uniformly rather than depending on how many cards are actually in a pile.
 */
/* Only a pile's cards answer the mouse (its preview, a click taking one
   out): the rest of its box — the fan's empty corners, the room kept for
   cards not there, the "4×" line — is "on no card", so the pointer can
   rest between piles (the preview gone, the deck's summary showing). */
.deck-stack {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  width: var(--stack-w, 95px);
  pointer-events: none;
}

.deck-stack:hover .deck-stack__img { opacity: 0.85; }

.deck-stack--empty {
  width: var(--stack-w, 95px);
  opacity: 0.4;
  cursor: default;
}

.deck-stack__images {
  position: relative;
  width: var(--stack-w, 95px);
  height: calc(var(--stack-card-h, 112px) + 12px);
}

.deck-stack__img {
  position: absolute;
  pointer-events: auto;
  width: var(--stack-card-w, 80px);
  height: var(--stack-card-h, 112px);
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--stitch);
  transition: opacity 0.1s;
  background: var(--mat-sunken);
}

.deck-stack__img--blank {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  text-align: center;
  font-size: var(--fs-micro);
  color: var(--chalk-faint);
  background: var(--mat-raised);
}

.deck-stack__qty {
  display: block;
  text-align: center;
  font-size: var(--fs-micro);
  line-height: 14px; /* fixed — part of --stack-row, see .db-deckstrip */
  font-weight: 700;
  color: var(--focus);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-stack--leader .deck-stack__qty { color: var(--chalk-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Card browser (scrollable main area) ──────────────────────────────────── */
.db-main {
  grid-row: 4;
  overflow-y: auto;
  padding: 12px 16px;
}

.db-main turbo-frame { display: block; }

/* ── Decks index ──────────────────────────────────────────────────────────── */
.decks-index {
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.decks-index__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.decks-index__title { display: flex; align-items: baseline; gap: 12px; }
.decks-index__title h1 { margin: 0; }
.decks-index__count { color: var(--chalk-muted); font-size: var(--fs-small); }
.decks-index__no-ready { margin: -8px 0 20px; color: var(--chalk-muted); font-size: var(--fs-small); text-align: right; }
@media (max-width: 640px) { .decks-index__no-ready { text-align: left; } }
.decks-index__header-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; } /* (the Portuguese labels are longer: on a phone they wrap) */
/* Phone: the buttons on a line of their own below the title, as wide as
   the page — two by two (one alone, the whole line). */
@media (max-width: 640px) {
  .decks-index__header { gap: 12px; }
  .decks-index__header-actions { width: 100%; margin-left: 0; }
  .decks-index__header-actions > * { flex: 1 1 calc(50% - 4px); }
}

/* ── The top bar (shared/_top_bar): DonDeck and the menus ─────────────────
   Desktop: Play, Decks, Tournaments, then the player's at the far end, each
   opening its list under it. Phone (≤ 640px): one "Menu" button whose sheet
   covers the page below the bar, grouped the same way. */
.top-bar {
  position: relative; z-index: 40; display: flex; align-items: center; gap: 8px;
  height: 64px; padding: 0 24px; border-bottom: 1.5px dashed var(--stitch); background: var(--mat);
}
.top-bar__brand { margin-right: 16px; color: var(--chalk); font-size: 1.4rem; font-weight: 800; letter-spacing: -0.01em; text-decoration: none; }
.top-bar__brand:hover { color: var(--chalk-strong); }
.top-bar__menus { display: flex; align-items: center; gap: 4px; flex-grow: 1; }
.top-bar__menu { position: relative; }
.top-bar__toggle {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--chalk); font: inherit; font-weight: 600; cursor: pointer;
}
.top-bar__toggle:hover, .top-bar__toggle[aria-expanded="true"] { background: var(--hover); border-color: var(--stitch); }
.top-bar__toggle:focus-visible, .top-bar__item:focus-visible, .top-bar__brand:focus-visible { outline: 2px solid var(--don); outline-offset: 2px; }
.top-bar__caret { width: 7px; height: 7px; margin: -3px 2px 0; border: solid var(--chalk-muted); border-width: 0 1.8px 1.8px 0; transform: rotate(45deg); }
.top-bar__toggle[aria-expanded="true"] .top-bar__caret { margin-top: 3px; transform: rotate(-135deg); }
.top-bar__count {
  min-width: 20px; height: 20px; padding: 0 6px; box-sizing: border-box; border-radius: 10px;
  background: var(--don); color: var(--on-don); font-size: var(--fs-micro); font-weight: 800; line-height: 20px; text-align: center;
}
.top-bar__toggle--player { gap: 10px; padding: 0 12px 0 6px; border-color: var(--stitch); border-radius: 20px; background: var(--mat-raised); }
.top-bar__avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--stitch); font-weight: 800; line-height: 28px; text-align: center; }
.top-bar__name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar__list {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 240px;
  display: grid; gap: 2px; padding: 6px; background: var(--mat-raised); border: 1px solid var(--stitch); border-radius: 10px; box-shadow: 0 12px 32px rgb(0 0 0 / 0.5);
}
.top-bar__list--end { left: auto; right: 0; }
.top-bar__list[hidden], .top-bar__sheet[hidden] { display: none; }
.top-bar__form { margin: 0; }
.top-bar__item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; box-sizing: border-box;
  padding: 10px 12px; border: 0; border-radius: 6px; background: none; color: var(--chalk); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer;
}
.top-bar__item:hover { background: var(--hover); color: var(--focus); }
.top-bar__item-text { display: flex; flex-direction: column; gap: 2px; }
.top-bar__item-text > span:first-child { white-space: nowrap; }
.top-bar__hint { color: var(--chalk-muted); font-size: var(--fs-small); font-weight: 400; }
.top-bar__pill { padding: 2px 8px; border-radius: 10px; background: var(--don); color: var(--on-don); font-size: var(--fs-micro); font-weight: 700; white-space: nowrap; }
/* The theme (shared/_theme_switch): three buttons side by side */
.theme-switch { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; padding: 8px 12px 10px; border-top: 1.5px dashed var(--stitch); border-bottom: 1.5px dashed var(--stitch); }
.theme-switch__label { color: var(--chalk-muted); font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.theme-switch__options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px; border: 1px solid var(--mat-edge); border-radius: 8px; background: var(--mat-sunken); }
.theme-switch__option { height: 30px; border: 0; border-radius: 6px; background: none; color: var(--chalk-muted); font-size: var(--fs-small); font-weight: 600; cursor: pointer; }
.theme-switch__option[aria-checked="true"] { background: var(--mat-edge); color: var(--chalk); }
.theme-switch__option:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.top-bar__turn, .top-bar__phone { display: none; }
@media (max-width: 640px) {
  .top-bar { height: 56px; padding: 0 16px; }
  .top-bar__brand { flex-grow: 1; margin-right: 0; }
  .top-bar__menus, .top-bar__player { display: none; }
  .top-bar__turn {
    display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px; border-radius: 8px;
    color: var(--chalk); font-size: var(--fs-small); font-weight: 600; text-decoration: none;
  }
  .top-bar__phone { display: block; }
  .top-bar__toggle--phone { height: 44px; border-color: var(--stitch); background: var(--mat-raised); }
  .top-bar__burger, .top-bar__burger::before, .top-bar__burger::after { display: block; width: 16px; height: 2px; border-radius: 1px; background: var(--chalk); }
  .top-bar__burger { position: relative; }
  .top-bar__burger::before, .top-bar__burger::after { content: ""; position: absolute; left: 0; }
  .top-bar__burger::before { top: -5px; }
  .top-bar__burger::after { top: 5px; }
  .top-bar__toggle--phone[aria-expanded="true"] .top-bar__burger { background: none; }
  .top-bar__toggle--phone[aria-expanded="true"] .top-bar__burger::before { top: 0; transform: rotate(45deg); }
  .top-bar__toggle--phone[aria-expanded="true"] .top-bar__burger::after { top: 0; transform: rotate(-45deg); }
  .top-bar__sheet {
    position: fixed; top: 57.5px; left: 0; right: 0; bottom: 0; z-index: 30; overflow-y: auto;
    display: flex; flex-direction: column; padding: 8px 16px 24px; background: var(--mat);
  }
  .top-bar__group { display: flex; flex-direction: column; padding: 12px 0; border-bottom: 1.5px dashed var(--stitch); }
  .top-bar__group:last-child { border-bottom: 0; }
  .top-bar__group-title { margin: 0 0 4px; color: var(--chalk-muted); font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
  .top-bar__group .top-bar__item { min-height: 44px; padding: 0; font-size: 1.05rem; }
  .top-bar__group .top-bar__hint { display: none; }
}

.decks-index__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.decks-index__search {
  flex: 1 1 260px;
  max-width: 420px;
  min-height: 38px;
  padding: 0 12px;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 6px;
  color: var(--chalk);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.4);
}
.decks-index__search:focus-visible, .decks-index__sort select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.decks-index__sort { display: flex; align-items: center; gap: 8px; color: var(--chalk-muted); font-size: var(--fs-small); }
.decks-index__sort select {
  min-height: 38px;
  padding: 0 10px;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 6px;
  color: var(--chalk);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 0.4);
}

/* ── The mat (DESIGN.md): a screen's main area — the playmat, its stitched
   edge inset 6px. For the board and a page's main area, not every panel. */
.mat {
  position: relative;
  padding: 32px 24px;
  background: var(--grain), var(--mat);
  border-radius: 14px;
}
.mat::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px dashed var(--stitch);
  border-radius: 10px;
  pointer-events: none;
}

/* ── Stickers (DESIGN.md): the format badges, like stickers on a deck box
   lid — small, uppercase, all tilted the same -2° (parallel to each other). */
.sticker {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--sticker);
  color: var(--on-sticker);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
  max-width: 100%;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.45);
  transform: rotate(-2deg);
}
.sticker--extra { background: var(--sticker-extra); }
.sticker--unreleased { background: var(--don); color: var(--on-don); }

/* ── My Decks: the shelf of deck boxes (DESIGN.md, "Deck box") ────────────
   A box in light perspective: the Leader's art on the front (the top of the
   card, where the character is), the name on both spines, a soft shadow
   under it. A click turns it round (deck_box_controller.js): Edit and
   Delete on the back, in ~450ms. Two per row on a phone. */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
  gap: 40px 16px;
}
.deck-box {
  --box-w: 168px;
  --box-h: 212px;
  --box-d: 64px; /* (38% of its width: a deck box holds a sleeved deck, the Leader and the DON!!) */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 0;
}
.deck-box[hidden] { display: none; }
.deck-box__stage {
  position: relative;
  width: var(--box-w);
  height: var(--box-h);
  margin-top: 8px;
  perspective: 900px;
  perspective-origin: 50% 50%; /* (seen level with its middle: the spine narrows the same at the top and the bottom) */
}
/* (the shadow it stands on) */
.deck-box__stage::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -10px;
  height: 12px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.55);
  filter: blur(8px);
}
.deck-box__box {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(24deg);
  transition: transform 450ms cubic-bezier(0.3, 0.7, 0.3, 1);
}
.deck-box:has(.deck-box__turn:hover) .deck-box__box { transform: rotateY(14deg); }
.deck-box--turned .deck-box__box,
.deck-box--turned:has(.deck-box__turn:hover) .deck-box__box { transform: rotateY(204deg); }

.deck-box__front,
.deck-box__back,
.deck-box__spine,
.deck-box__lid {
  position: absolute;
  backface-visibility: hidden;
  background: var(--mat-raised);
  border: 1px solid var(--mat-edge);
}
.deck-box__front,
.deck-box__back {
  inset: 0;
  border-radius: 4px;
  overflow: hidden;
}
.deck-box__front { transform: translateZ(calc(var(--box-d) / 2)); }
.deck-box__back {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  transform: rotateY(180deg) translateZ(calc(var(--box-d) / 2));
}
.deck-box__back > *, .deck-box__back form > button { width: 100%; }
.deck-box__updated { margin: 4px 0 0; color: var(--chalk-muted); font-size: var(--fs-micro); text-align: center; }
.deck-box__turn-back { justify-self: center; color: var(--chalk-muted); font-size: var(--fs-small); }
.deck-box__turn-back:hover { color: var(--chalk); }

/* (the spines: the box's two sides, in the Leader's colors — one, or two in a
   band from top to bottom; no name: it's under the box) */
.deck-box__spine {
  top: 0;
  left: calc(50% - var(--box-d) / 2);
  width: var(--box-d);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--spine-a, var(--hover)), var(--spine-b, var(--spine-a, var(--hover))));
}
.deck-box__spine--a-red { --spine-a: var(--c-red); }
.deck-box__spine--a-green { --spine-a: var(--c-green); }
.deck-box__spine--a-blue { --spine-a: var(--c-blue); }
.deck-box__spine--a-purple { --spine-a: var(--c-purple); }
.deck-box__spine--a-black { --spine-a: var(--c-black); }
.deck-box__spine--a-yellow { --spine-a: var(--c-yellow); }
.deck-box__spine--b-red { --spine-b: var(--c-red); }
.deck-box__spine--b-green { --spine-b: var(--c-green); }
.deck-box__spine--b-blue { --spine-b: var(--c-blue); }
.deck-box__spine--b-purple { --spine-b: var(--c-purple); }
.deck-box__spine--b-black { --spine-b: var(--c-black); }
.deck-box__spine--b-yellow { --spine-b: var(--c-yellow); }
.deck-box__spine--left { transform: rotateY(-90deg) translateZ(calc(var(--box-w) / 2)); }
.deck-box__spine--right { transform: rotateY(90deg) translateZ(calc(var(--box-w) / 2)); }
.deck-box__lid {
  top: calc(50% - var(--box-d) / 2);
  left: 0;
  width: 100%;
  height: var(--box-d);
  border-radius: 2px;
  background: var(--hover);
  transform: rotateX(90deg) translateZ(calc(var(--box-h) / 2));
}

.deck-box__turn {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.deck-box__turn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
/* (the card a little larger than the front, from its top: the character, not the effect text) */
.deck-box__art { display: block; width: 118%; max-width: none; height: auto; margin-left: -9%; }
.deck-box__no-leader {
  display: flex; height: 100%; align-items: center; justify-content: center; padding: 16px;
  color: var(--chalk-faint); font-size: var(--fs-small); text-align: center;
}
.deck-box__stickers {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 4px;
}
/* (on the box, no tilt of their own: the front is already in perspective,
   and −2° on top of it read as crooked against the box's edges) */
.deck-box__stickers .sticker { transform: none; }

/* (under the box: its name, the Leader, ready or what's missing) */
.deck-box__label { display: flex; flex-direction: column; gap: 4px; width: min(100%, calc(var(--box-w) + 32px)); }
.deck-box__name { margin: 0; font-size: var(--fs-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-box__leader { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--chalk-muted); font-size: var(--fs-small); }
.deck-box__color { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.deck-box__color--red    { background: var(--c-red); }
.deck-box__color--green  { background: var(--c-green); }
.deck-box__color--blue   { background: var(--c-blue); }
.deck-box__color--purple { background: var(--c-purple); }
.deck-box__color--black  { background: var(--c-black); box-shadow: 0 0 0 1px var(--chalk-muted); }
.deck-box__color--yellow { background: var(--c-yellow); }
.deck-box__leader .deck-box__color:last-of-type { margin-right: 4px; }
.deck-box__status { margin: 0; font-size: var(--fs-small); }
.deck-box__status--ready { color: var(--success); }
.deck-box__status--unfinished { color: var(--warning); }

@media (max-width: 640px) {
  .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 12px; padding: 24px 12px; }
  .deck-box { --box-w: 140px; --box-h: 176px; --box-d: 53px; }
  .deck-box__stickers { left: 6px; right: 6px; bottom: 8px; gap: 4px 3px; }
  .deck-box__stickers .sticker { padding: 1px 4px; letter-spacing: 0.02em; }
  .deck-box__back { padding: 10px; }
  .deck-box__back .btn-secondary, .deck-box__back .btn-danger { min-height: 34px; padding: 0 8px; font-size: var(--fs-small); }
}
@media (prefers-reduced-motion: reduce) {
  .deck-box__box { transition: none; }
}

.decks-index__empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 64px 0; color: var(--chalk-muted); }

/* ── Forms (Devise etc.) ──────────────────────────────────────────────────── */
input[type="email"],
input[type="password"],
input[type="text"]:not(.db-name-input):not(.db-search-input),
.auth-page select,
.auth-page input[type="number"],
.auth-page input[type="datetime-local"],
.auth-page textarea {
  display: block;
  width: 100%;
  padding: 8px;
  background: var(--mat-raised);
  border: 1px solid var(--mat-edge);
  border-radius: 4px;
  color: var(--chalk);
  font-size: var(--fs-body);
  margin-bottom: 12px;
}



/* ── Match board (T10 — counter-window moment) ───────────────────────────────
 * Palette reused as-is from the rest of the app (Design review Pass 5):
 * background #1a1a1a, gold accent #f0c040, red #e53e3e. Contrast verified
 * during implementation (Design review Pass 6): #f0c040 on #1a1a1a clears
 * 4.5:1 easily; #e53e3e on #1a1a1a measures ~4.2:1 — comfortably over the
 * 3:1 minimum for large/bold text and borders, so red is only ever used
 * that way below (attack banner, glows), never for small body text.
 */

.match-waiting,
.match-join {
  max-width: 480px;
  margin: 48px auto;
  padding: 0 16px;
  text-align: center;
}

.match-waiting__link { display: flex; gap: 8px; align-items: stretch; }
/* (field and button the same height, side by side: the app's text fields
   carry a margin below them, which here made the button taller) */
.match-waiting__link input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
  height: 40px;
  text-align: center;
  font-size: var(--fs-small);
}
.match-waiting__link .btn-primary { flex: none; min-width: 110px; height: 40px; min-height: 0; padding-top: 0; padding-bottom: 0; }

.match-waiting__hint {
  color: var(--chalk-muted);
  font-size: var(--fs-small);
}


.match-join__form {
  text-align: left;
}

/* (no deck fits the match's format: each one, and why not) */
.match-join__not-legal {
  margin: 0 0 16px;
  padding-left: 20px;
  text-align: left;
  font-size: var(--fs-small);
  color: var(--chalk-muted);
}
.match-join__not-legal li + li { margin-top: 6px; }

/* Match and replay pages: the enlarged card in its own column on the left
   (same side as the deck builder's), the board on the right. The panel
   sticks to the viewport so the card stays in view while scrolling. */
.match-layout {
  display: grid;
  /* The board is only as wide as the table needs, so the pair is centred
     rather than the board floating in a wide column. */
  --side-w: clamp(300px, 24vw, 480px);
  grid-template-columns: var(--side-w) minmax(0, max-content);
  justify-content: center;
  gap: 16px;
  margin: 0 auto;
  padding: 0 16px;
  align-items: start;
}

/* The column beside the board: the enlarged card at a fixed size on top,
   and the opened trash filling what's left below it. */
.match-preview {
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto; /* only on short windows with a big hand */
}

.match-preview__panel,
.hand-panel,
.trash-panel {
  padding: 12px;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 8px;
}

/* The enlarged card takes whatever height the hands leave; an opened
   trash floats over it rather than taking room from it. */
.match-preview__stage {
  position: relative;
  flex: 1 1 0;
  min-height: 160px;
  display: flex;
}
.match-preview__panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* The effect being resolved, where the enlarged card goes (the side
   column has the room the bar below the table doesn't): its card, the
   question in full, the card's text, and "Choose one" options as wide
   buttons. A hovered card covers it (the preview has a background then);
   once the pointer leaves, it's back. */
.question-panel {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--mat-sunken);
  border: 1px solid var(--don);
  border-radius: 8px;
}
.question-panel:empty { display: none; }
.question-panel--waiting { border-color: var(--mat-edge); }
.match-preview__panel { position: relative; z-index: 2; }
.question-panel:not(:empty) ~ .match-preview__panel:not(:has(img)) { visibility: hidden; } /* (no "Hover a card" over it) */
.match-preview__panel:has(img) { background: var(--mat-sunken); }
/* (a board card with what changed it: the sentences under it, the card taking the rest) */
.match-preview__panel:has(.card-preview__details), .db-preview:has(.card-preview__details) { flex-direction: column; align-items: stretch; gap: 8px; overflow-y: auto; }
.match-preview__panel:has(.card-preview__details) .db-preview__image, .db-preview:has(.card-preview__details) .db-preview__image { flex: 1 1 auto; min-height: 140px; height: auto; }
.match-preview__panel .card-preview__details, .db-preview .card-preview__details { margin: 0; flex: none; }
.question-panel__body { display: flex; flex-direction: column; gap: 10px; }
/* The resolving card's picture beside whose card it is and the question —
   an Event's too, in the trash by now (a click shows it big). */
.question-panel__head { display: flex; flex-direction: column; gap: 10px; }
.question-panel__head--card { flex-direction: row; align-items: flex-start; gap: 12px; }
.question-panel__ask { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.question-panel__card {
  flex: none; width: clamp(84px, 34%, 140px); padding: 0; border: 0; background: none;
  border-radius: 6px; cursor: zoom-in; line-height: 0;
}
.question-panel__card img { width: 100%; height: auto; aspect-ratio: 63 / 88; border-radius: 6px; display: block; }
.question-panel__card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.question-panel__source { margin: 0; font-size: var(--fs-small); color: var(--chalk-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.question-panel__prompt { margin: 0; font-size: var(--fs-large); line-height: 1.4; color: var(--chalk); font-weight: 600; text-wrap: pretty; }
.question-panel__text { margin: 0; padding-top: 10px; border-top: 1px solid var(--mat-edge); font-size: var(--fs-body); line-height: 1.5; color: var(--chalk-muted); }
.question-panel__options { display: flex; flex-direction: column; gap: 8px; }
.question-panel__options .btn-secondary { justify-content: flex-start; text-align: left; white-space: normal; min-height: 44px; padding: 8px 12px; line-height: 1.35; }

/* The hand, in the column: its own card size, as the column is outside
   .match-board (where the table's sizes are set). */
.hand-panel {
  flex: none;
  --hand-h: min(130px, 12vh);
  --hand-w: calc(var(--hand-h) * 0.716);
}
.hand-panel .match-board__hand-header { margin-bottom: 6px; }
.hand-panel:empty { visibility: hidden; } /* before the first render; still "shown" for sidePanel */

/* A face-down card in the opponent's hand: the size of one of yours. */
.hand-card--back .card-back { display: block; width: var(--hand-w); height: var(--hand-h); }

.trash-panel {
  position: absolute;
  z-index: 5;
  bottom: 8px; left: 8px; right: 8px; /* at the bottom: the card's cost and power stay in view */
  max-height: calc(100% - 16px);
  overflow-y: auto;
  background: color-mix(in srgb, var(--mat-raised) 96%, transparent);
  border-color: var(--stitch);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.7);
}
.trash-panel:empty { display: none; }
/* Hovering a card in the trash shows it in the preview, fitted into the
   room above the trash (--trash-h is set by lib/side_column.js). */
.match-preview__stage:has(.trash-panel__card:hover) .match-preview__panel {
  padding-bottom: calc(var(--trash-h, 0px) + 20px);
}
.trash-panel__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}
.trash-panel__card { width: 100%; height: auto; aspect-ratio: 63 / 88; }
.trash-panel__card > .card-face { width: 100%; height: 100%; position: relative; }
/* The trash opened in the column: one row the size of the hand's cards,
   overlapping just enough to fit (as the hand does — up to 90% of a
   card; past that, it scrolls sideways), so the enlarged card above keeps
   its room. Only the hovered card's picture comes to the front, letting
   the pointer through to the card under it: each card is still hovered
   by its own strip. */
.trash-panel .trash-panel__cards--row {
  --trash-card-h: min(130px, 12vh);
  --trash-card-w: calc(var(--trash-card-h) * 0.716);
  container-type: inline-size;
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  padding-top: 4px; /* room for the hover lift */
  overflow-x: auto;
}
.trash-panel .trash-panel__cards--row > .trash-panel__card { flex: none; width: var(--trash-card-w); height: var(--trash-card-h); aspect-ratio: auto; }
.trash-panel .trash-panel__cards--row > .trash-panel__card + .trash-panel__card {
  margin-left: clamp(calc(var(--trash-card-w) * -0.9),
                     calc((100cqw - var(--n) * var(--trash-card-w)) / (var(--n) - 1)),
                     6px);
}
.trash-panel .trash-panel__cards--row > .trash-panel__card:hover > .card-face { z-index: 2; pointer-events: none; transform: translateY(-4px); }
.trash-panel__empty { margin: 0; font-size: var(--fs-small); color: var(--chalk-faint); text-align: center; }

.trash-pile { cursor: pointer; border-radius: 6px; }
.trash-pile:hover .card-face,
.trash-pile:hover .card-slot-empty,
.trash-pile:focus-visible .card-face,
.trash-pile:focus-visible .card-slot-empty { outline: 2px solid var(--don); outline-offset: 2px; }

/* Too narrow for a side column: hide it, and the preview falls back to
   its overlay (card_preview_controller checks the panel's display). */
@media (max-width: 1100px) {
  .match-layout { grid-template-columns: minmax(0, 1fr); }
  .match-preview { display: none; }
  .match-preview__panel { display: none; }
  .trash-panel { display: none; }
  .hand-panel { display: none; }
}

.match-board {
  margin: 0 auto;
  padding: 6px 0 0;
}

.match-board__loading,
.match-board__error {
  text-align: center;
  color: var(--chalk-muted);
  padding: 48px 0;
}

/* The one bar below the table: the status, then the decision at hand
   (End Turn, attach DON!!, block, ...) or the result, then the links.
   It wraps only for the rare long decision (several blockers). */
.match-board__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: var(--fs-small);
  letter-spacing: 0.02em;
  color: var(--chalk);
  background: var(--mat-raised);
  border: 1px solid var(--mat-edge);
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 6px; /* (below the table) */
}
/* The status gives way first (the hint is cut short) so the decision and
   the links stay on the same line. */
.match-board__status-text { flex: 1 1 0; min-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ... except a card effect's question to this player: that's the decision
   itself (what's K.O.'d, what it costs), so it wraps — up to 2 lines, the
   height of the buttons beside it, so the table below doesn't shrink (the
   rest, rarely, on hover). */
.match-board__status--asking .match-board__status-text {
  min-width: 260px;
  white-space: normal;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.match-board__status-actions { display: flex; gap: 10px; align-items: center; }
.match-board__hint { color: var(--chalk-muted); font-size: var(--fs-small); }
/* Back to My Decks: on the replay, at the far left of its bar (the live
   board has it last of its links — see .match-board__back-link). */
.match-board__back {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--chalk); text-decoration: none; font-size: var(--fs-large);
  border: 1px solid var(--mat-edge);
}
.match-board__back:hover, .match-board__back:focus-visible { color: var(--chalk-strong); border-color: var(--chalk-faint); background: var(--hover); }
/* The live board's way back, last of the bar's links, on every screen: at
   the far left it sat right beside End Turn — a finger, or a trackpad's
   slip, away. */
/* (the underline under the words only, not the arrow) */
.match-board__back-link { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.match-board__back-label { text-decoration: underline; }
.match-board__back-link--next { color: var(--focus); font-weight: 700; } /* (a tournament's match over: back for the next round) */
.match-board__back-arrow { font-size: var(--fs-large); line-height: 1; }
/* A bar with no room for the words (a narrow desktop window — the status
   already cut short —, a tablet's, a phone's): the arrow alone, bigger.
   The bar is the container: what counts is its own width. */
.match-board__status { container: match-bar / inline-size; }
@container match-bar (max-width: 819px) {
  .match-board__back-label { display: none; }
  .match-board__back-arrow { font-size: 1.6rem; }
}
/* (a phone: a finger's size to tap — the margins keep the bar's line as it was) */
@media (max-width: 480px) {
  .match-board__back-link { justify-content: center; min-width: 36px; min-height: 36px; margin-block: -9px; }
  /* (there, the result has a line of its own: room for "Tournament" beside the arrow) */
  .match-board__back-link--next .match-board__back-label { display: inline; }
}

/* Concede, at the top right of the board (the opponent's header): away from the bar's links and End Turn. */
.match-board__concede { flex: none; margin-left: 4px; color: var(--danger-text); white-space: nowrap; }
.match-board__concede:hover, .match-board__concede:focus-visible { color: var(--danger-text); }

.match-board__end-turn { flex: none; min-height: 28px; padding: 3px 14px; font-size: var(--fs-small); }
.match-board__status .match-board__controls { padding-top: 0; gap: 6px 8px; }
.match-board__status .filter-select { max-width: 140px; }
.match-board__status .db-cost-input { width: 3.5em; }
.match-board__status .match-board__result { margin: 0; padding: 2px 10px; font-size: var(--fs-body); }

/* Positioned parent for the Phaser overlay (dim/arrow/counter ring) — the
 * arena is exactly what gets visually dimmed during an attack; the status
 * bar below (persistent chrome) is a sibling and is never touched. */
.match-board__arena {
  position: relative;
}

.match-board__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.match-board__overlay canvas {
  width: 100%;
  height: 100%;
}

.match-board__zone {
  position: relative;
  z-index: 1; /* sits above the dim overlay — opaque card backgrounds read as "not dimmed" */
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 8px;
  padding: 4px 8px 6px;
  margin-bottom: 4px;
}

.match-board__zone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  margin-bottom: 3px;
  min-height: 18px;
}

.don-track {
  display: inline-flex;
  gap: 3px;
}

/* Text only for screen readers (the board shows card images). */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Cards on the board — real OPTCG proportions (63×88mm ≈ 0.716) ─────── */
/* Card sizes follow the window, as big as it allows, so both halves of
   the table and the status bar always fit without scrolling (both hands
   are in the column beside it):
   - height: measured, the table is about 6 card heights (two card rows
     and a DON!! row per player) plus ~196px of fixed chrome (status bar,
     zone headers, labels) — 206px leaves a little slack;
   - width: the table (see `width` below: 5.72 card heights + 76px) must
     fit beside that column. */
.match-board {
  --card-h: max(48px, min(calc((100vh - 214px) / 6),
                          calc((100vw - var(--side-w, 0px) - 48px - 76px) / 5.72)));
  --card-w: calc(var(--card-h) * 0.716);
  --hand-h: calc(var(--card-h) * 0.9);
  --hand-w: calc(var(--hand-h) * 0.716);
  --don-h:  calc(var(--card-h) * 0.72);
  --don-w:  calc(var(--don-h) * 0.716);
  /* As wide as a full Character area needs: 5 Characters rested (each as
     wide as a card is tall, 6px apart) beside the Life column, plus the
     areas' and the zone's padding. The cost area, between two pile
     columns, is narrower: its DON!! overlap a little once there are many
     (.don-slot). Never so narrow that the status bar (status, decision,
     links) can't keep to one line, though. */
  width: max(860px, calc(var(--card-h) * 5 + var(--card-w) + 76px));
  max-width: 100%;
}
/* The replay keeps its scrubber below the table. */
.match-board[data-controller~="replay-board"] {
  --card-h: max(48px, min(calc((100vh - 266px) / 6),
                          calc((100vw - var(--side-w, 0px) - 48px - 76px) / 5.72)));
}
/* Narrow screens: no column beside the board, so the hand is back below
   the table and the cards are smaller. */
@media (max-width: 1100px) {
  .match-layout .match-board { --card-h: max(48px, min(calc((100vh - 270px) / 7.4), calc((100vw - 32px - 76px) / 5.72))); }
}
/* A tablet or a small laptop (a phone has its own, below): the hand, under
   the table, takes the height the table leaves — it sat at the table's
   card size (~83px on a 768×1024 tablet, under a phone's 128px) with room
   to spare; never smaller than that, at most 150px. And the opponent's
   hand says how many ("Hand: 5"): the backs in their header are too small
   to count. */
@media (min-width: 481px) and (max-width: 1100px) {
  .match-layout .match-board { --hand-h: clamp(calc(var(--card-h) * 0.9), calc(100vh - var(--card-h) * 7.4 - 190px), 150px); }
  .match-board__zone-header .hand-backs { display: none; }
  .match-board__zone-header .hand-count { display: inline-flex; }
}

.card-face {
  display: block;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  overflow: hidden;
  background: var(--mat-sunken);
  transition: transform 0.2s;
}
.card-face__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-face__text {
  display: flex; align-items: center; justify-content: center; height: 100%;
  padding: 6px; text-align: center; font-size: var(--fs-micro); font-weight: 600; color: var(--chalk);
  border: 1px solid var(--mat-edge); border-radius: 6px;
}

/* The official back of a deck card (the navy one; Leaders are red, DON!!
   white), from Bandai's rule manual. */
.card-back {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  background: url("/assets/card_back-b4fc156b.webp") center / 100% 100% no-repeat;
}
/* The opponent's hand, face down in their zone header, fanned. */
.card-back--hand { height: calc(var(--card-h) * 0.38); width: calc(var(--card-h) * 0.38 * 0.716); border-radius: 3px; flex: none; }
.card-back--hand + .card-back--hand { margin-left: calc(var(--card-h) * 0.38 * 0.716 * -0.45); }
.card-slot-empty {
  width: var(--card-w); height: var(--card-h);
  border: 1px dashed var(--mat-edge); border-radius: 6px;
}

/* ── The playmat — laid out like the official One Piece mat ─────────────
 * Your half, from the table's edge up: DON!! deck · cost area · trash;
 * Leader · Stage · Deck; the Character area (5 slots), with
 * Life in a tall column on the left. The opponent's half is the same mat
 * turned 180°, so both Character areas meet in the middle of the table. */
.playmat {
  display: grid;
  grid-template-columns: calc(var(--card-w) + 16px) repeat(2, minmax(0, 1fr)) calc(var(--card-w) + 16px);
  gap: 4px;
  grid-template-areas:
    "life    chars  chars  chars"
    "life    leader stage  deck"
    "dondeck cost   cost   trash";
}
.match-board__zone--opponent .playmat {
  grid-template-areas:
    "trash cost  cost   dondeck"
    "deck  stage leader life"
    "chars chars chars  life";
}

.mat-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--card-h) + 8px);
  padding: 4px;
  background: var(--mat-raised);
  border: 1px solid var(--mat-edge);
  border-radius: 8px;
}
.mat-area__label {
  position: absolute;
  top: 3px; left: 8px;
  z-index: 1;
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chalk-faint);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 16px);
}
/* The narrow pile areas only name themselves while empty — over a card
   the label just clutters it. */
.mat-area--trash:has(.card-face) .mat-area__label,
.mat-area--deck:has(.card-back) .mat-area__label,
.mat-area--life:has(.card-back) .mat-area__label,
.mat-area--dondeck:has(.don-card) .mat-area__label { display: none; }
.mat-area--cost { min-height: 0; }

.card-slot-empty--character { width: var(--card-w); height: var(--card-h); margin: 0 calc((var(--card-h) - var(--card-w)) / 2); }

/* Life: the top card whole, the rest peeking out beneath it. */
/* Life: whole cards stacked one on top of the other, each peeking out a
   little below the one before, like the pile on the table. */
.life-stack { position: relative; display: flex; flex-direction: column; align-items: center; }
.card-back--life { flex: none; box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.6); }
.card-back--life + .card-back--life { margin-top: calc(var(--card-h) * -0.8); }

/* DON!! cards: the official front (from Bandai's rule manual), standing
   when active, sideways and dimmed once rested. */
/* Each DON!! sits in a slot as wide as it shows (sideways when rested).
   With room to spare the slots are 6px apart; with less they overlap just
   enough to fit the row (--active / --rested are set by zoneHTML). */
.cost-area { container-type: inline-size; display: flex; align-items: center; width: 100%; min-height: var(--don-h); }
.don-slot { flex: none; width: var(--don-w); height: var(--don-h); display: flex; align-items: center; justify-content: center; }
.don-slot--rested { width: var(--don-h); }
.don-slot + .don-slot {
  margin-left: clamp(calc(var(--don-w) * -0.85),
                     calc((100cqw - var(--active) * var(--don-w) - var(--rested) * var(--don-h)) / (var(--active) + var(--rested) - 1)),
                     6px);
}
.don-card {
  width: var(--don-w); height: var(--don-h);
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  /* (the plain DON!!, unless the card's own style says the player's — board_view.js#donFace, #263) */
  --don-face: url("/assets/don_card-4d4d74d7.webp");
  background: var(--don-face) center / 100% 100% no-repeat;
  transition: transform 0.2s, filter 0.2s;
}
.don-card { flex: none; box-shadow: -1px 0 3px rgba(0, 0, 0, 0.5); }
.don-card--rested { transform: rotate(90deg); filter: brightness(0.55); }
.don-card--back { background-image: url("/assets/don_card_back-39251f13.webp"); }
.card-slot-empty--don { width: var(--don-w); height: var(--don-h); }

/* DON!! given to a Leader/Character: real DON!! cards tucked under it,
   fanned out to its right (the slot is wider than the card), each a
   little further out — with a count chip on top. */
.combatant__don { position: absolute; inset: 0; pointer-events: none; }
.combatant .card-face { position: relative; z-index: 1; }
.combatant__power { z-index: 2; }
.don-card--given {
  position: absolute; z-index: 0;
  width: var(--card-w); height: var(--card-h);
  left: 50%; top: 50%;
  transform: translate(calc(-50% + (var(--card-h) - var(--card-w)) * 0.3 + var(--i) * 5px), calc(-50% + var(--i) * 2px));
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}
.combatant__don-count {
  position: absolute; z-index: 2; right: 0; bottom: 18%;
  min-width: 20px; padding: 1px 5px; border-radius: 10px;
  background: var(--mat-raised); border: 1px solid var(--don); color: var(--focus);
  font-size: var(--fs-micro); font-weight: 700; text-align: center;
}

/* Dragging a DON!! from the cost area onto one of your cards. */
.don-card--draggable { cursor: grab; touch-action: none; }
.don-card--draggable:hover, .don-card--draggable:focus-visible { outline: 2px solid var(--don); outline-offset: 1px; }
.don-card--picked { outline: 2px solid var(--don); box-shadow: 0 0 10px rgba(240, 192, 64, 0.9); }
/* The order picked, when it matters ("place them back in any order"). */
.trash-panel__card { position: relative; }
.pick-order {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  min-width: 1.4em; padding: 1px 5px; border-radius: 999px;
  background: var(--target-strong); color: var(--on-don); font-weight: 700; font-size: var(--fs-small); text-align: center;
}

/* An effect's choice can pick DON!! too (same colours as a chosen card). */
.don-card--choosable { cursor: pointer; outline: 2px solid var(--target); box-shadow: 0 0 10px rgba(56, 178, 172, 0.7); }
.don-card--chosen    { cursor: pointer; outline: 2px solid var(--target-strong); box-shadow: 0 0 12px rgba(129, 230, 217, 0.9); }
.don-card--ghost {
  position: fixed; z-index: 1000; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-6deg) scale(1.15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}
/* Dragging several picked DON!!: how many go. */
.don-card--ghost[data-count]::after {
  content: attr(data-count);
  position: absolute; right: -8px; bottom: -8px;
  padding: 1px 6px; border-radius: 10px;
  background: var(--mat-raised); border: 1px solid var(--don); color: var(--focus);
  font-size: var(--fs-micro); font-weight: 700;
}
.match-board--don-dragging { cursor: grabbing; }
.match-board--don-dragging [data-don-target],
.combatant--don-target { border-color: var(--don); box-shadow: 0 0 10px rgba(240, 192, 64, 0.5); cursor: pointer; }
.combatant--don-hover { border-color: var(--chalk-strong); box-shadow: 0 0 16px rgba(240, 192, 64, 1); }

.pile__card { position: relative; }
.pile__count {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0, 0, 0, 0.8); color: var(--focus);
  font-size: var(--fs-micro); font-weight: 700; border-radius: 4px; padding: 0 5px;
}

.hand-backs { display: flex; }
/* (the opponent's hand on a phone: one back and how many — see the phone section) */
.hand-count { display: none; align-items: center; gap: 4px; flex: none; font-weight: 700; color: var(--chalk); white-space: nowrap; }
.hand-count .card-back { width: 12px; height: 17px; }

/* The Character area: its 5 places always in one row (on a phone, a
   Character takes the table's card size, not the Leader's minimum — see
   the 480px rules). */
.match-board__combatants {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.combatant {
  position: relative;
  /* Room for the card turned sideways when rested. */
  width: var(--card-h);
  height: var(--card-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.combatant__label { font-size: var(--fs-micro); color: var(--chalk-muted); text-transform: uppercase; }
.combatant__name  { font-size: var(--fs-body); font-weight: 600; }

/* Current power (with DON!! and counters) — not on the printed card. */
.combatant__power {
  position: absolute;
  left: 50%; bottom: 2px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  color: var(--don); /* (on the card: gold in both themes) */
  font-size: var(--fs-micro); font-weight: 700;
  border-radius: 4px; padding: 1px 6px;
  white-space: nowrap;
}

/* The two cards in a battle: their power big on them (the banner between
   the halves of the table went unseen), in the same dark-and-gold tag as
   any changed power, in its font — the attack line already says which
   is which. */
.combatant__power--battle {
  padding: 1px 8px 2px; border-radius: 6px; line-height: 1.1;
  font-size: clamp(0.8rem, calc(var(--card-h, 100px) * 0.2), 1.6rem);
}
/* (the opponent's side, above the table's middle: the attack line runs
   from the card's middle down — the power goes to the card's top, out of
   its way, and the chips of what changed it to the bottom) */
.match-board__zone--opponent .combatant__power--battle { top: 2px; bottom: auto; }
.match-board__zone--opponent .combatant:has(.combatant__power--battle) .combatant__changes { top: auto; bottom: 2px; }

/* Each change to its power, on top of the card (powerChangesHTML): the
   amount (green up, red down) and how long it lasts, in words — the tag's
   tint only backs the word up. */
.combatant__changes {
  position: absolute; z-index: 3;
  left: 50%; top: 2px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none;
}
.combatant:has(.combatant__negated) .combatant__changes { top: 22px; } /* (under the "Negated" badge) */
.power-change {
  display: inline-flex; align-items: baseline; gap: 4px;
  padding: 1px 5px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.85);
  font-size: var(--fs-micro); line-height: 1.2; white-space: nowrap;
  pointer-events: auto; cursor: help;
}
.power-change__amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.power-change__amount--up   { color: var(--success); }
.power-change__amount--down { color: var(--danger-text); }
.power-change__amount--set  { color: var(--chalk); }
/* (cost: its own color — a higher cost is neither good nor bad) */
.power-change--cost .power-change__amount,
.power-change--cost-total .power-change__amount { color: var(--focus); }
.power-change--cost-total { border: 1px solid var(--don); }
/* A keyword an effect gave it (#313): its name, as the cards print it. */
.power-change--keyword .power-change__amount { color: var(--on-card); letter-spacing: 0.02em; }
.power-change__tag { font-size: var(--fs-micro); color: var(--chalk); }
.power-change--battle .power-change__tag,
.power-change--counter .power-change__tag { color: var(--danger-text); }
.power-change--turn .power-change__tag    { color: var(--focus); }
.power-change--until .power-change__tag   { color: var(--playable-text); }
.power-change--always .power-change__tag  { color: var(--target-strong); }
.power-change--don .power-change__tag     { color: var(--focus); }

/* Its restrictions and protections (statusMarksHTML): a drawn icon each
   family (board_view.js FAMILIES) — green a protection or a permission,
   red a restriction — along its top, inside the card and never taking a
   tap (a tap on the card is the card's). At most 3 (2 on a smaller
   card: up to 1100px), then "+N". Their words are in the card's preview (changeDetails). */
.combatant__marks {
  position: absolute; z-index: 3;
  /* (the card's own top right corner: the combatant is a square with room
     for the card turned sideways, the card centered in it) */
  top: 3px; right: calc((100% - var(--card-h) * 0.716) / 2 + 2px);
  display: flex; gap: 2px; /* (side by side along its top: down its side they'd cover its power) */
  pointer-events: none;
}
.mark-icon {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px; border-radius: 4px; border: 1px solid var(--danger);
  background: rgba(0, 0, 0, 0.85); color: var(--danger-text);
}
.mark-icon svg { width: 14px; height: 14px; display: block; }
.mark-icon--protect { border-color: var(--target-strong); color: var(--target-strong); }
.mark-more {
  display: inline-flex; align-items: center; padding: 0 3px; border-radius: 4px; border: 1px solid var(--chalk-muted);
  background: rgba(0, 0, 0, 0.85); color: var(--on-card); font-size: var(--fs-micro); font-weight: 700; line-height: 16px;
}
.mark-icon--past-wide, .mark-more--narrow { display: none; }
/* An effect on all of a player's Characters: said once beside the area
   (sharedMarksHTML), each card showing only its own (--wide)... */
.combatant__marks--narrow { display: none; }
.area-marks {
  position: absolute; z-index: 4; left: 8px; top: 24px; width: 118px;
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.area-marks__line {
  display: flex; align-items: flex-start; gap: 4px;
  padding: 2px 5px; border-radius: 4px; border: 1px solid var(--danger);
  background: rgba(0, 0, 0, 0.85); color: var(--danger-text);
  font-size: var(--fs-micro); font-weight: 700; line-height: 1.25;
}
.area-marks__line--protect { border-color: var(--target-strong); color: var(--target-strong); }
.area-marks__line .mark-icon { border: 0; padding: 0; background: none; color: inherit; flex: none; }
.area-marks__when { font-weight: 400; color: var(--chalk); }
/* ...except where there's no room beside the area: each card counts them. */
@media (max-width: 1100px) {
  .area-marks, .combatant__marks--wide { display: none; }
  .combatant__marks--narrow { display: flex; }
}
/* (2 across a smaller card — no side panel, or a phone: the first, then "+N") */
@media (max-width: 1100px) {
  .mark-icon--past-wide, .mark-more--narrow { display: inline-flex; }
  .mark-icon--past-narrow, .mark-more--wide { display: none; }
}
@media (max-width: 480px) {
  .combatant__marks { top: 2px; right: calc((100% - var(--card-h) * 0.716) / 2 + 1px); gap: 1px; }
  .mark-icon { padding: 0; }
  .mark-icon svg { width: 11px; height: 11px; }
  .mark-more { line-height: 13px; padding: 0 1px; font-size: 9px; letter-spacing: -0.02em; }
}

/* The icons' legend (the bar's "Icons" — marksLegendHTML) */
.marks-legend {
  position: fixed; z-index: 60; right: 16px; bottom: 72px; width: min(320px, calc(100vw - 32px));
  padding: 12px 14px; background: var(--mat-raised); border: 1px solid var(--stitch); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); color: var(--chalk); font-size: var(--fs-small);
}
.marks-legend h4 { margin: 0 0 8px; font-size: var(--fs-body); }
.marks-legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.marks-legend li { display: flex; align-items: center; gap: 8px; }
.marks-legend .mark-icon svg { width: 16px; height: 16px; }
.marks-legend p { margin: 8px 0 0; color: var(--chalk-muted); }
.marks-legend__close { position: absolute; top: 4px; right: 8px; border: 0; background: none; color: var(--chalk-muted); font-size: 20px; cursor: pointer; }
@media (max-width: 480px) { .marks-legend { bottom: 110px; } }

/* "Negate the effect of ...": the printed text doesn't apply for now. */
.combatant__negated {
  position: absolute; z-index: 2;
  left: 50%; top: 2px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  color: var(--danger-text);
  font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: 4px; padding: 1px 6px;
  white-space: nowrap;
}

/* Rested: turned sideways, like on the table. */
.combatant--rested .card-face { transform: rotate(90deg); filter: brightness(0.8); }
/* (a Stage rested to pay for its [Activate: Main] — the same, with room for it sideways) */
.stage-card--rested { width: var(--card-h); display: flex; justify-content: center; }
.stage-card--rested .card-face { transform: rotate(90deg); filter: brightness(0.8); }


/* ⚡ — a card of yours with an [Activate: Main] ability usable now. */
.stage-card { position: relative; }
.card-activate {
  position: absolute; top: 2px; right: 2px; z-index: 2;
  width: 24px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-small); line-height: 1;
  color: var(--on-don); background: var(--don);
  border: 1px solid var(--mat-raised); border-radius: 50%;
  box-shadow: 0 0 8px rgba(240, 192, 64, 0.8);
  cursor: pointer;
}
.card-activate:hover, .card-activate:focus-visible { background: var(--don-hover); outline: 2px solid var(--chalk-strong); }
.card-face--selected { outline: 2px solid var(--don); }
/* An ability or an effect's option: the whole text, to read before
   choosing — wrapped, from the left. (A button is an inline flexbox, where
   an ellipsis doesn't apply: cut to one line, its centred text showed only
   its middle.) */
.match-board__activate,
.match-board__option {
  flex: 1 1 100%; justify-content: flex-start; text-align: left;
  white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
  height: auto; padding-top: 8px; padding-bottom: 8px;
}
/* "Which first?" on a phone: a line of each effect, its card's name first
   — the cards stay in view on the board (a tap there shows one big; the
   table's cards shrink for each option: --bar-extra below). */
@media (max-width: 480px) {
  .match-board__option--effect > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; }
}

/* Attacking, step by step: a ready attacker glows gold; the picked one is
   solid gold; valid targets glow red. */
.combatant--selectable,
.combatant--targetable,
.combatant--selected { cursor: pointer; }
.combatant--selectable { border-color: var(--don); box-shadow: 0 0 10px rgba(240, 192, 64, 0.6); }
.combatant--selected   { border-color: var(--don); background: rgba(240, 192, 64, 0.15); }
.combatant--targetable { border-color: var(--danger); box-shadow: 0 0 8px rgba(229, 62, 62, 0.6); }
/* Would be K.O.'d / removed unless its owner uses a replacement effect. */
.combatant--at-stake   { border-color: var(--danger); box-shadow: 0 0 8px rgba(229, 62, 62, 0.6); }
.combatant--selectable:focus-visible,
.combatant--targetable:focus-visible { outline: 2px solid var(--don-light); outline-offset: 2px; }



/* Card effects: cards a Choice lets you pick glow teal, picked ones are
   solid; the card whose effect is resolving pulses gold. */
.combatant--choosable,
.combatant--chosen,
.card-face--choosable,
.card-face--chosen { cursor: pointer; }
.combatant--choosable { border-color: var(--target); box-shadow: 0 0 10px rgba(56, 178, 172, 0.7); }
.combatant--chosen    { border-color: var(--target-strong); background: rgba(56, 178, 172, 0.25); box-shadow: 0 0 12px rgba(129, 230, 217, 0.9); }
.card-face--choosable { box-shadow: 0 0 0 2px var(--target), 0 0 10px rgba(56, 178, 172, 0.7); }
.card-face--dim       { filter: brightness(0.45); }
.card-face--chosen    { box-shadow: 0 0 0 3px var(--target-strong), 0 0 12px rgba(129, 230, 217, 0.9); }
.hand-card--choosable { cursor: pointer; }
.hand-card--chosen    { cursor: pointer; }
.hand-card--choosable .card-face { box-shadow: 0 0 0 2px var(--target), 0 0 8px rgba(56, 178, 172, 0.7); }
.hand-card--chosen .card-face    { box-shadow: 0 0 0 3px var(--target-strong), 0 0 12px rgba(129, 230, 217, 0.9); transform: translateY(-6px); }
.combatant--resolving, .stage-card--resolving .card-face { animation: effect-resolving 1.2s ease-in-out infinite; outline: 2px solid var(--don); outline-offset: 1px; }
.stage-card--resolving { position: relative; }
/* "Resolving" on the card whose effect is resolved (board_view's resolvingBadgeHTML):
   across its middle, gold like its edge; under the attack line's chips and power. */
.card-resolving {
  position: absolute; z-index: 2; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--don);
  background: rgba(0, 0, 0, 0.85); color: var(--don);
  font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap; pointer-events: none;
}
@keyframes effect-resolving {
  0%, 100% { box-shadow: 0 0 6px rgba(240, 192, 64, 0.5); }
  50%      { box-shadow: 0 0 16px rgba(240, 192, 64, 0.95); }
}
.match-board__pick-count { color: var(--target-strong); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }


.combatant--attacking {
  border-color: var(--danger);
  box-shadow: 0 0 10px rgba(229, 62, 62, 0.6);
}

.combatant--waiting {
  animation: match-board-pulse 1.2s ease-in-out infinite;
}

@keyframes match-board-pulse {
  0%, 100% { border-color: var(--danger); }
  50%      { border-color: var(--danger-border); }
}

/* Laid over the line between the two halves, at the top of your zone — not
   in your header's line, where a longer battle ("… (+1000 de Counter)")
   wrapped the header and moved the whole of your side down, then back up
   when the battle ended (every card sliding along: board_motion.js). Its
   slot, just before your zone in the arena, takes no height and sits over
   the attack line's overlay (z-index 5), which used to cross the text. */
.match-board__attack-slot {
  position: relative;
  z-index: 6;
  height: 0;
  top: 1px; margin: 0 1px; /* (inside your zone's border, where it was laid before) */
}
.match-board__attack-banner {
  position: absolute;
  top: -11px; left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 0 10px;
  overflow: hidden; text-overflow: ellipsis;
  text-align: center;
  font-weight: 700;
  font-size: var(--fs-small);
  line-height: 20px;
  color: var(--danger);
  white-space: nowrap;
  background: var(--mat-sunken);
  border: 1px solid var(--danger-border);
  border-radius: 999px;
  pointer-events: none;
}

/* Below the table: the hand, only on narrow screens (otherwise it's in the
   column beside the board), or the replay's scrubber. */
.match-board__dock {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.match-board__dock-side { flex: 1 1 auto; min-width: 0; } /* (the replay scrubber's one-line move is cut short, never widens it) */

.match-board__hand {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
}

.match-board__hand-header {
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  margin-bottom: 3px;
}

/* The hand is always one row — a second row would push the table off the
   screen. With room to spare the cards sit 6px apart; with less, they
   overlap just enough to fit (up to 90% of a card), like a hand held in
   fan, and the one under the pointer comes to the front. `--n` is the
   number of cards (set by handHTML); 100cqw is the row's width. */
.match-board__hand-cards {
  container-type: inline-size;
  display: flex;
  flex-wrap: nowrap;
  padding-top: 4px; /* room for the hover lift */
}
.match-board__hand-cards > .hand-card + .hand-card {
  margin-left: clamp(calc(var(--hand-w) * -0.9),
                     calc((100cqw - var(--n) * (var(--hand-w) + 4px)) / (var(--n) - 1)),
                     6px);
}
/* Only the hovered card's picture comes to the front — not its button,
   which stays where it is under the next card. The raised picture lets
   the pointer through, so each card is still hovered by its own visible
   strip, and moving onto the next card's strip moves the highlight. */
.match-board__hand-cards > .hand-card { position: relative; }
.match-board__hand-cards > .hand-card .card-face { position: relative; }
.match-board__hand-cards > .hand-card:hover .card-face,
.match-board__hand-cards > .hand-card:focus-visible .card-face { z-index: 2; pointer-events: none; }

.hand-card {
  padding: 0;
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--chalk);
  font-family: inherit;
  cursor: default;
  transition: border-color 0.3s, box-shadow 0.3s, opacity 0.3s, transform 0.15s;
}
.hand-card .card-face { width: var(--hand-w); height: var(--hand-h); }

/* Cards you can't use right now are dimmed; usable ones stay bright. */
/* Unusable cards look like any other (no dimming — they overlap, and a
   see-through or darkened hand reads badly); usable ones glow instead. */
.hand-card--playable:hover .card-face, .hand-card--counterable:hover .card-face { transform: translateY(-4px); }

.hand-card__name {
  font-size: var(--fs-small);
  font-weight: 600;
}

.hand-card__tag {
  font-size: var(--fs-micro);
  color: var(--chalk-muted);
}

.hand-card__counter {
  font-size: var(--fs-micro);
  color: var(--focus);
}

/* The glows are on the picture, not the button, so they come to the
   front with it. */
.hand-card:focus-visible .card-face { box-shadow: 0 0 0 2px var(--chalk-strong); }
.hand-card--counterable { cursor: pointer; }
/* (a card the defender can counter with: its own edge glows gold, pulsing) */
.hand-card--counterable .card-face { box-shadow: 0 0 0 2px var(--don), 0 0 8px rgba(240, 192, 64, 0.7); animation: counter-glow 1.4s ease-in-out infinite; }
@keyframes counter-glow { 50% { box-shadow: 0 0 0 3px var(--don-hover), 0 0 16px rgba(240, 192, 64, 0.95); } }
@media (prefers-reduced-motion: reduce) { .hand-card--counterable .card-face { animation: none; } }
.hand-card--counterable:hover .card-face,
.hand-card--counterable:focus-visible .card-face { box-shadow: 0 0 0 2px var(--don-light), 0 0 0 4px var(--don); }

.hand-card__cost {
  font-size: var(--fs-micro);
  color: var(--playable-text);
}

/* Clicked once to play: raised and ringed, waiting for Play (or a second click). */
.match-board__hand-cards > .hand-card--selected .card-face,
.hand-card--selected .card-face { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--don), 0 0 14px rgba(240, 192, 64, 0.8); z-index: 2; }
.play-sheet__actions { display: flex; gap: 10px; margin-top: 10px; }
.play-sheet__actions > * { flex: 1; min-height: 46px; }
.hand-card--playable { cursor: pointer; }
.hand-card--playable .card-face { box-shadow: 0 0 0 2px var(--playable); }
.hand-card--playable:hover .card-face,
.hand-card--playable:focus-visible .card-face { box-shadow: 0 0 0 2px var(--playable-text), 0 0 0 4px var(--playable); }
.hand-card:focus-visible { outline: none; }

.hand-card--fading .card-face { box-shadow: 0 0 0 2px var(--mat-edge); }
.hand-card--fading { opacity: 0.7; }

.match-board__result {
  position: relative;
  z-index: 1;
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: 6px;
  font-size: var(--fs-body);
}
.match-board__result--won  { background: var(--success-bg); color: var(--success); }
.match-board__result--lost { background: var(--danger-bg); color: var(--danger-text); }
.match-board__result--abandoned { background: var(--hover); color: var(--chalk-muted); }


.match-board__controls {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.match-board__controls .btn-primary,
.match-board__controls .btn-secondary {
  min-height: 44px; /* Design review Pass 6 — mobile touch target floor */
}
/* With a mouse, the touch floor isn't needed — and low buttons keep the
   status bar one line. */
@media (pointer: fine) {
  .match-board__controls .btn-primary,
  .match-board__controls .btn-secondary { min-height: 28px; padding: 3px 12px; font-size: var(--fs-small); }
}

/* A move on its way to the server (sendCommand): the board says so at
   once — the pointer waits, what was clicked dims and pulses, the bar's
   buttons can't be pressed again. */
.match-board--waiting, .match-board--waiting * { cursor: progress !important; }
.match-board--waiting .match-board__status button,
.match-board--waiting .match-board__status .btn-clear { pointer-events: none; opacity: 0.6; }
.is-pending { animation: move-pending 0.8s ease-in-out infinite; }
@keyframes move-pending { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .is-pending { animation: none; opacity: 0.6; } }

/* An effect's cards with a trash opened below them: a line between. */
.choice-cards:not(:only-child) { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--mat-edge); }

/* The connection dropped: said at the top of the board, moves held. */
/* No side column (a phone, a narrow window): the table is taller than the
   screen, so the bar with the decision at hand (End Turn, Play, Done
   countering, which Character leaves) stays at the bottom of the screen
   instead of below the table, out of sight. Messages show above it. */
@media (max-width: 1100px) {
  .match-board__status { position: sticky; bottom: 0; z-index: 30; box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.6); }
  .match-board__toast { bottom: auto; top: 12px; z-index: 1100; }
}

/* [Activate: Main]'s ⚡ on a touch screen: big enough for a finger, and
   its tap area bigger still. */
@media (hover: none) {
  /* (a tap leaves :hover stuck on the card: the card in front takes the
     tap where it shows, not the one under it) */
  .match-board__hand-cards > .hand-card:hover .card-face { pointer-events: auto; }
  .card-activate { width: 34px; height: 34px; top: -8px; right: -8px; font-size: 1rem; }
  .card-activate::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; }
}

.connection-banner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1100; /* (over the table: it takes no room) */
  padding: 6px 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  background: var(--danger-bg); border: 1px solid var(--danger); border-radius: 6px;
  color: var(--danger-text); font-weight: 700; text-align: center;
}
.match-board--offline .match-board__status button { pointer-events: none; opacity: 0.5; }

/* The tutorial (tutorial_guide.js, #189): the step's text over the top of
   the table (it takes no room), and what to click for it pulsing. */
.tutorial-box {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 1090;
  width: min(600px, calc(100vw - 32px)); box-sizing: border-box;
  padding: 8px 14px 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  background: var(--info-bg); border: 1px solid var(--don); border-radius: 8px; color: var(--chalk);
}
.tutorial-box:not(.tutorial-box--yours, .tutorial-box--intro, .tutorial-box--done) { border-color: var(--stitch); }
.tutorial-box__head {
  display: flex; justify-content: space-between; gap: 12px; margin-bottom: 2px;
  font-size: var(--fs-small); font-weight: 700; color: var(--focus);
}
.tutorial-box:not(.tutorial-box--yours, .tutorial-box--intro, .tutorial-box--done) .tutorial-box__head { color: var(--chalk-muted); }
.tutorial-box__text { margin: 0; font-size: var(--fs-body); line-height: 1.35; }
.tutorial-box__text b { color: var(--warning); }
.tutorial-box__actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.tutorial-box__actions button { min-height: 36px; min-width: 96px; }
.tutorial-box--nudge { animation: tutorial-nudge 0.35s ease-in-out; }
@keyframes tutorial-nudge {
  25% { transform: translateX(calc(-50% - 6px)); }
  75% { transform: translateX(calc(-50% + 6px)); }
}
.tutorial-target { outline: 3px solid var(--don); outline-offset: 2px; animation: tutorial-pulse 1.2s ease-in-out infinite; }
@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 192, 64, 0.75); }
  50% { box-shadow: 0 0 0 8px rgba(240, 192, 64, 0); }
}
/* (a card in the hand comes out whole from under the next one) */
.match-board__hand-cards > .hand-card.tutorial-target { z-index: 3; }
@media (prefers-reduced-motion: reduce) { .tutorial-target, .tutorial-box--nudge { animation: none; } }

/* A take-back asked (take_back_view.js): over the table, to answer or to
   cancel — it takes no room, like the banner above. */
.take-back-box {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1100;
  width: max-content; max-width: min(560px, calc(100vw - 32px));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px;
  padding: 10px 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  background: var(--don-tint); border: 1px solid var(--don); border-radius: 8px; color: var(--chalk);
}
.take-back-box__text { margin: 0; flex: 1 1 260px; min-width: 0; font-size: var(--fs-body); line-height: 1.35; }
.take-back-box__actions { display: flex; gap: 8px; flex: none; }
.take-back-box__actions button { min-height: 36px; }

/* The chess clock, in each zone's header: the one running stands out;
   extra time is red. */
.match-clock {
  margin-left: auto; margin-right: 12px; padding: 1px 8px; border-radius: 4px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: var(--fs-small);
  color: var(--chalk-muted); border: 1px solid var(--mat-edge);
}
.match-clock--running { color: var(--focus); border-color: var(--don); }
.match-clock--extra { color: var(--danger-text); border-color: var(--danger); }
.match-clock--extra.match-clock--running { background: var(--danger-bg); }

/* Whether the opponent's page is open: a word, with a dot. */
.presence { margin-right: 8px; font-size: var(--fs-small); font-weight: 600; }
.presence::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; vertical-align: middle; }
.presence--online { color: var(--success); }
.presence--online::before { background: var(--success); }
.presence--offline { color: var(--chalk-muted); }
.presence--offline::before { background: var(--stitch); }

/* Cards in flight (board_motion.js): copies over the whole page, so the
   board's areas don't clip them; the real card shows once one lands. */
.board-motion-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }
.board-motion-ghost {
  position: absolute;
  margin: 0;
  transition: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55);
  will-change: transform, opacity;
}

/* Floats over the table instead of taking room below it. */
.match-board__life-reveal {
  position: absolute;
  z-index: 3;
  right: 12px;
  bottom: 12px;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  animation: life-reveal-in 0.2s ease-out;
}
@keyframes life-reveal-in { from { opacity: 0; transform: translateY(6px); } }

.life-reveal__title {
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  text-transform: uppercase;
}

.life-reveal__name {
  font-weight: 600;
  margin: 2px 0;
}

.life-reveal__trigger {
  font-size: var(--fs-small);
  color: var(--chalk-faint); /* muted — Premise 3 caveat: a real trigger doesn't resolve yet, so it must never read as fully "live" */
  font-style: italic;
}

.match-board__toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--hover);
  border: 1px solid var(--stitch);
  color: var(--chalk);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: var(--fs-small);
  z-index: 10;
}

.match-board__toast--error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

@media (max-width: 480px) {
  /* The hand on a phone: big cards, fanned in one row as on a desktop —
     all in view; the one picked to play comes to the front. */
  .match-board, .hand-panel { --hand-h: 128px; }
  .match-board__hand-cards > .hand-card { flex: none; }
  .match-board__zone-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  /* (the mat's labels are background: on a phone's narrow mat, as small as they were, so they don't run into the cards) */
  .mat-area__label { font-size: 0.58rem; }
  .combatant { min-width: 80px; }
  .match-board__combatants { gap: 4px; }
  .match-board__combatants > .combatant { min-width: 0; }
}

/* ── Replay scrubber (T11) ────────────────────────────────────────────────── */

/* The buttons and the slider take what the move leaves them: the move a
   fixed share of the bar, one line (cut short — the whole of it on
   hover), so nothing moves as its words change. On a phone, the move
   under them. */
/* (the replay's parts redrawn on each move, round the scrubber that never is: boxes of their own the layout doesn't see) */
.replay-board__part { display: contents; }
/* (a phone's replay: the opponent's hand, face up, over their side of the table) */
.replay-board__opponent-hand { position: relative; z-index: 1; margin-bottom: 6px; }
.replay-scrubber {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 8px;
  padding: 8px 10px;
}

.replay-scrubber__controls { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.replay-scrubber__controls > button { flex: none; }

.replay-scrubber input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--don);
}

.replay-scrubber__label {
  flex: 0 0 38%;
  font-size: var(--fs-small);
  color: var(--chalk-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* No side column (≤ 1100px): the hand is in the dock — the scrubber under
   it, the whole width (beside it, the hand was squeezed to a sliver, and
   its size, changing every move, moved the buttons); the page ends above
   the "Report a bug" icon, so it covers no button. */
@media (max-width: 1100px) {
  .match-board__dock:has(.replay-scrubber) { flex-wrap: wrap; }
  .match-board__dock:has(.replay-scrubber) > .match-board__dock-side { flex-basis: 100%; }
  body:has(.bug-report-fab) .match-layout:has(.replay-scrubber) { padding-bottom: 56px; }
}
@media (max-width: 480px) {
  .replay-scrubber { flex-direction: column; align-items: stretch; }
  .replay-scrubber__label { flex: none; }
}

/* ── Landing page ─────────────────────────────────────────────────────────── */
.home { max-width: 1040px; margin: 0 auto; padding: 48px 24px; }
.home-hero { padding: clamp(40px, 8vw, 88px) clamp(24px, 6vw, 72px); }
.home-hero h1 { margin: 0; font-size: var(--fs-h1); line-height: 1; letter-spacing: -0.02em; }
.home-hero__tagline { max-width: 34ch; margin: 16px 0 32px; color: var(--chalk-muted); font-size: var(--fs-large); line-height: 1.4; }

/* The actions in a row (the primary first), wrapping; on a phone one a line, all as wide. */
.home-hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.home-hero__actions form { margin: 0; }
@media (max-width: 640px) {
  .home { padding: 16px; }
  .home-hero__actions { flex-direction: column; align-items: stretch; }
  .home-hero__actions > *,
  .home-hero__actions form > button { width: 100%; justify-content: center; }
}

/* ── The tutorial's way in (#190): the two Leaders side by side ────────── */
.tutorials { max-width: 720px; margin: 0 auto; padding: 48px 16px 64px; display: grid; gap: 24px; }
.tutorials__header h1 { margin: 0; }
.tutorials__intro { margin: 8px 0 0; color: var(--chalk-muted); line-height: 1.5; }
.tutorials__sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tutorial-side { display: grid; justify-items: center; gap: 6px; padding: 20px 16px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 10px; text-align: center; }
.tutorial-side h2 { margin: 6px 0 0; font-size: var(--fs-h3, 1.15rem); }
.tutorial-side__leader { display: block; border-radius: 8px; transition: transform .15s ease; }
.tutorial-side__leader:hover, .tutorial-side__leader:focus-visible { transform: translateY(-3px); }
.tutorial-side__leader img { display: block; width: 160px; height: auto; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
.tutorial-side__turn { margin: 0; color: var(--chalk-muted); font-size: var(--fs-small); }
.tutorial-side__open { margin: 0; color: var(--focus); font-size: var(--fs-small); font-weight: 600; }
.tutorial-side__actions { display: grid; gap: 8px; width: min(220px, 100%); margin-top: 8px; }
.tutorial-side__actions > *, .tutorial-side__form button { width: 100%; justify-content: center; }
.tutorial-side__form { margin: 0; }
.tutorials__note { margin: 0; color: var(--chalk-muted); font-size: var(--fs-small); }
.tutorials__back { color: var(--focus); }
@media (prefers-reduced-motion: reduce) { .tutorial-side__leader { transition: none; } }

/* A tutorial's deck in the builder, only looked at (tutorials/deck): no
   filters and no card browser — the deck takes the space below the bar. */
.deck-builder--readonly .db-workspace { grid-template-rows: auto minmax(0, 1fr); }
.deck-builder--readonly .db-deckstrip { grid-row: 2; overflow-y: auto; margin-bottom: 12px; }
.deck-builder--readonly .db-display__inner { height: auto; overflow: visible; scroll-snap-type: none; }
.deck-builder--readonly .deck-stack { cursor: default; }
.db-name-input--readonly { flex: 1 1 auto; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: none; border: 0; box-shadow: none; padding-left: 0; }
.db-topbar__form { margin: 0; }

/* ── Tournaments (#103): the list, each one's page and its form ─────────── */
.tournaments, .tournament { max-width: 820px; margin: 0 auto; padding: 32px 16px 64px; display: grid; gap: 24px; }
.tournaments__header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
/* (the title and its line shrink — the line wraps — so the buttons stay up beside the title; under it only on a phone) */
.tournaments__header > div:first-child { flex: 1 1 280px; min-width: 0; }
.tournaments__header h1, .tournament__header h1 { margin: 0; }
.tournaments__intro { margin: 4px 0 0; color: var(--chalk-muted); }
.tournaments__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; flex: none; }
/* Phone: the buttons on a line of their own under the title, as wide as the page (as on My Decks). */
@media (max-width: 640px) {
  .tournaments__actions { width: 100%; margin-left: 0; }
  .tournaments__actions > * { flex: 1 1 calc(50% - 4px); }
}
/* "Only with the link": in the list (its players and organizer only) and on its page. */
.tournament-link-only {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; vertical-align: middle;
  border: 1px solid var(--don-tint-edge); color: var(--focus); font-size: var(--fs-micro); font-weight: 600; white-space: nowrap;
}
.tournament__share { display: grid; gap: 6px; margin: 12px 0; padding: 12px 14px; background: var(--don-tint); border: 1px solid var(--don-tint-edge); border-radius: 8px; }
.tournament__share .tournament__hint { margin: 0; }
.tournament__share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tournament__share-url { flex: 1 1 220px; min-width: 0; font: inherit; color: var(--chalk); background: var(--mat-sunken); border: 1px solid var(--mat-edge); border-radius: 4px; padding: 6px 8px; }
.tournament-form__visibility { border: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.tournament-form__visibility legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
/* (over the form pages' ".auth-page .field label": a block, above its field) */
.auth-page .field .tournament-form__choice, .tournament-form .tournament-form__choice {
  display: flex; flex-direction: row; align-items: flex-start; gap: 10px; margin: 0; cursor: pointer; color: var(--chalk); font-size: var(--fs-body);
}
.tournament-form .tournament-form__choice input { flex: none; width: auto; min-height: 0; margin: 4px 0 0; }
.tournament-form__choice span { display: grid; gap: 2px; }
.tournament-form__choice em { color: var(--chalk-muted); font-size: var(--fs-small); }
.tournaments__group h2, .tournament__manage h2 { margin: 0 0 10px; font-size: var(--fs-large); }
.tournaments__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tournament-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "meta status"; gap: 2px 12px; align-items: center;
  padding: 12px 14px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 8px; color: inherit;
}
.tournament-row:hover, .tournament-row:focus-visible { border-color: var(--don); }
.tournament-row__name { grid-area: name; font-weight: 700; overflow-wrap: anywhere; }
.tournament-row__meta { grid-area: meta; color: var(--chalk-muted); font-size: var(--fs-small); }
.tournament-row .tournament-status { grid-area: status; }
.tournament-status { padding: 2px 8px; border: 1px solid var(--stitch); border-radius: 999px; font-size: var(--fs-small); color: var(--chalk); white-space: nowrap; }
.tournament-status--registration { border-color: var(--success); color: var(--success); }
.tournament-status--running { border-color: var(--don); color: var(--focus); }
.tournament-status--draft, .tournament-status--cancelled { color: var(--chalk-muted); }
.tournament__back { margin: 0; }
.tournament__header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.tournament__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 0; }
.tournament__facts div { padding: 10px 12px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 8px; }
.tournament__facts dt { color: var(--chalk-muted); font-size: var(--fs-small); }
.tournament__facts dd { margin: 2px 0 0; }
.tournament__description { line-height: 1.55; color: var(--chalk); }
.tournament__description p { margin: 0 0 10px; }
.tournament__manage { padding: 14px; border: 1px solid var(--stitch); border-radius: 8px; }
.tournament__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tournament__actions form { margin: 0; }
.tournament__hint { margin: 10px 0 0; color: var(--chalk-muted); font-size: var(--fs-small); }
.tournament__registration h2 { margin: 0 0 10px; font-size: var(--fs-large); }
.tournament-entry { display: grid; gap: 8px; margin-bottom: 14px; }
.tournament-entry__status { margin: 0; }
.tournament-entry__form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.tournament-entry .tournament__actions { flex-direction: column; align-items: flex-start; }
.tournament-entry .tournament-entry__form { width: 100%; margin: 0; }
.tournament-entry__form select { flex: 1 1 200px; min-width: 0; max-width: 360px; padding: 8px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 4px; color: var(--chalk); font-size: var(--fs-body); }
.tournament-players { margin: 14px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; counter-reset: player; }
.tournament-players li { counter-increment: player; padding: 8px 10px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 6px; overflow-wrap: anywhere; }
.tournament-players li::before { content: counter(player) ". "; color: var(--chalk-muted); }
.tournament-players__me { border-color: var(--don) !important; }
.tournament-players__dropped { color: var(--chalk-muted); font-size: var(--fs-small); }
.tournament__round h2 { margin: 0 0 10px; font-size: var(--fs-large); }
.tournament-mine { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; padding: 12px 14px; border: 1px solid var(--don); border-radius: 8px; background: var(--don-tint); }
.tournament-mine p { margin: 0; }
.tournament-tables { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tournament-tables li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 12px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 6px; }
.tournament-tables__mine { border-color: var(--don) !important; }
.tournament-tables__number { color: var(--chalk-muted); font-size: var(--fs-small); min-width: 4.5em; }
.tournament-tables__players { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tournament-tables__watch { font-size: var(--fs-small); }
.tournament-tables__result { font-size: var(--fs-small); color: var(--success); }
.tournament-mine__result { font-weight: 600; }
/* (the organizer's correction, on each table: a word until opened, then the buttons on a line of their own) */
.tournament-tables__correct { font-size: var(--fs-small); color: var(--chalk-muted); }
.tournament-tables__correct summary { cursor: pointer; }
.tournament-tables__correct[open] { flex-basis: 100%; }
.tournament-tables__correct form { display: inline-block; margin: 6px 8px 0 0; }
/* (#108) the rounds' tabs, the standings, the champion */
.tournament-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tournament-tabs__tab { padding: 4px 12px; border: 1px solid var(--stitch); border-radius: 999px; color: var(--chalk); font-size: var(--fs-small); text-decoration: none; }
.tournament-tabs__tab:hover, .tournament-tabs__tab:focus-visible { border-color: var(--don); color: var(--focus); }
.tournament-tabs__tab[aria-current="page"] { border-color: var(--don); background: var(--don-tint); color: var(--focus); font-weight: 700; }
.tournament__standings h2 { margin: 0 0 10px; font-size: var(--fs-large); }
.tournament-champion { margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--don); border-radius: 8px; background: var(--don-tint); color: var(--focus); font-size: var(--fs-large); }
.tournament-champion strong { color: var(--chalk-strong); }
.tournament-standings__scroll { overflow-x: auto; }
.tournament-standings { width: 100%; border-collapse: separate; border-spacing: 0 4px; font-variant-numeric: tabular-nums; }
.tournament-standings th { padding: 0 10px 2px; color: var(--chalk-muted); font-size: var(--fs-small); font-weight: 400; text-align: right; white-space: nowrap; }
.tournament-standings th abbr { text-decoration: none; cursor: help; }
.tournament-standings td { padding: 6px 10px; background: var(--mat-raised); border-block: 1px solid var(--mat-edge); text-align: right; white-space: nowrap; }
.tournament-standings td:first-child { border-left: 1px solid var(--mat-edge); border-radius: 6px 0 0 6px; }
.tournament-standings td:last-child { border-right: 1px solid var(--mat-edge); border-radius: 0 6px 6px 0; }
.tournament-standings .tournament-standings__rank { width: 2em; color: var(--chalk-muted); text-align: center; }
.tournament-standings .tournament-standings__player { width: 100%; text-align: left; white-space: normal; }
.tournament-standings__art { display: inline-block; flex: none; width: 32px; height: 32px; margin-right: 10px; vertical-align: middle; border-radius: 5px; overflow: hidden; background: var(--mat-sunken); }
.tournament-standings__art img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.tournament-standings__name { vertical-align: middle; overflow-wrap: anywhere; }
.tournament-standings__drawn { margin-left: 1px; color: var(--focus); text-decoration: none; cursor: help; }
.tournament-standings__note { margin: 8px 0 0; color: var(--chalk-muted); font-size: var(--fs-small); }
.tournament-standings td.tournament-standings__points { font-weight: 700; color: var(--focus); }
.tournament-standings__label { display: none; }
.tournament-standings__me td { border-color: var(--don); }
@media (max-width: 640px) {
  /* (compact rows: rank, player, points, W-L — byes and the tiebreaks on a smaller second line) */
  .tournament-standings thead { display: none; }
  .tournament-standings, .tournament-standings tbody { display: block; }
  .tournament-standings tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-bottom: 4px; padding: 6px 10px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 6px; }
  .tournament-standings tr::after { content: ""; order: 1; flex-basis: 100%; } /* (the line break) */
  .tournament-standings__me { border-color: var(--don) !important; }
  .tournament-standings td { padding: 0; background: none; border: 0 !important; border-radius: 0 !important; }
  .tournament-standings td.tournament-standings__player { flex: 1 1 0; min-width: 0; }
  .tournament-standings td.tournament-standings__byes, .tournament-standings td.tournament-standings__rate { order: 2; color: var(--chalk-muted); font-size: var(--fs-small); text-align: left; }
  .tournament-standings td.tournament-standings__byes { margin-left: calc(2em + 10px); }
  .tournament-standings__label { display: inline; }
}
.tournament-edit input[type="datetime-local"] { color-scheme: dark; }
/* (#109) a player's published decklist */
/* The Pre-release tab (#258): pools of 6 boosters, each a row of its 12 cards;
   the Rares and higher marked (a chip), the hits outlined in gold. */
.pre-release { max-width: 1100px; margin: 0 auto; padding: 32px 16px 64px; display: grid; gap: 24px; }
.pre-release h1 { margin: 0; }
.pre-release h2 { margin: 0 0 10px; font-size: var(--fs-large); }
.pre-release__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.pre-release__pool { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr) auto; gap: 12px 16px; align-items: center; padding: 12px; background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 8px; }
.pre-release__pool-head { min-width: 0; }
.pre-release__pool-head h3 { margin: 0; font-size: var(--fs-body); }
.pre-release__pool-head h3 a { color: inherit; }
.pre-release__pool-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.pre-release__pool-actions form { margin: 0; }
.pre-release__deck-status { margin: 4px 0 0; color: var(--chalk); font-size: var(--fs-small); }
.card-thumb__pool-copies { position: absolute; right: 4px; bottom: 4px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--mat-sunken) 88%, transparent); border: 1px solid var(--don); color: var(--focus); font-size: var(--fs-small); font-weight: 700; pointer-events: none; }
.pre-release__hits { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 64px)); gap: 6px; }
.pre-release__pool-header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 24px; }
.pre-release__leader { list-style: none; margin: 0; padding: 0; width: 150px; flex: none; }
.pre-release__who { flex: 1 1 320px; min-width: 0; display: grid; gap: 8px; justify-items: start; }
.pre-release__who .tournament__hint, .pre-release__who form { margin: 0; }
.pre-release__cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.pre-release-card .card-thumb__image-wrap { position: relative; }
.pre-release-card__mark { position: absolute; left: 3px; top: 3px; padding: 1px 5px; border-radius: 3px; background: color-mix(in srgb, var(--mat-sunken) 88%, transparent); color: var(--on-card); font-size: var(--fs-micro); font-weight: 700; pointer-events: none; }
.pre-release-card--super_rare .card-thumb__image-wrap, .pre-release-card--alternate_art .card-thumb__image-wrap,
.pre-release-card--secret_rare .card-thumb__image-wrap, .pre-release-card--special .card-thumb__image-wrap,
.pre-release-card--manga .card-thumb__image-wrap, .pre-release-card--treasure_rare .card-thumb__image-wrap { outline: 2px solid var(--don); outline-offset: -1px; border-radius: 6px; }
.pre-release-card--super_rare .pre-release-card__mark, .pre-release-card--alternate_art .pre-release-card__mark,
.pre-release-card--secret_rare .pre-release-card__mark, .pre-release-card--special .pre-release-card__mark,
.pre-release-card--manga .pre-release-card__mark, .pre-release-card--treasure_rare .pre-release-card__mark { color: var(--focus); }
@media (max-width: 900px) {
  .pre-release__cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .pre-release__pool { grid-template-columns: 1fr; }
  .pre-release__pool-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .pre-release__cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pre-release__leader { width: 110px; }
  .pre-release__hits { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.tournament-decklist { max-width: 1100px; margin: 0 auto; padding: 32px 16px 64px; display: grid; gap: 24px; }
.tournament-decklist__header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 24px; }
.tournament-decklist__leader { flex: none; width: 180px; aspect-ratio: 63 / 88; }
.tournament-decklist__who { flex: 1 1 320px; min-width: 0; display: grid; gap: 8px; }
.tournament-decklist__who h1 { margin: 0; overflow-wrap: anywhere; }
.tournament-decklist__meta { margin: 0; color: var(--chalk); }
.tournament-decklist__who .tournament__hint { margin: 0; }
.tournament-decklist__copy { display: grid; gap: 8px; justify-items: start; margin-top: 4px; }
.tournament-decklist__text { width: 100%; max-width: 420px; padding: 8px; background: var(--mat-sunken); border: 1px solid var(--mat-edge); border-radius: 4px; color: var(--chalk); font: var(--fs-small) / 1.4 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
.tournament-decklist__group h2 { margin: 0 0 10px; font-size: var(--fs-large); }
.tournament-decklist__group-count { color: var(--chalk-muted); font-weight: 400; }
.tournament-decklist__cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tournament-decklist__copies { position: absolute; right: 4px; bottom: 4px; padding: 1px 8px; border-radius: 4px; background: color-mix(in srgb, var(--mat-sunken) 88%, transparent); border: 1px solid var(--don); color: var(--focus); font-weight: 700; pointer-events: none; }
.tournament-decklist__cost { color: var(--chalk-muted); font-weight: 400; }
@media (max-width: 640px) {
  .tournament-decklist__leader { width: 120px; }
  .tournament-decklist__cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
}
.tournament-standings__name a, .tournament-players a { color: inherit; text-decoration: underline; text-decoration-color: var(--chalk-faint); text-underline-offset: 3px; }
.tournament-standings__name a:hover, .tournament-players a:hover { color: var(--focus); text-decoration-color: currentColor; }
.tournament-edit textarea { font: inherit; resize: vertical; }

/* ── "Novidades": each release, what it changed for players (release_notes/index) ── */
.release-notes { max-width: 720px; margin: 0 auto; padding: 32px 16px 64px; display: grid; gap: 22px; }
.release-notes__header h1 { margin: 0 0 4px; }
.release-notes__intro { margin: 0; color: var(--chalk-muted); }
.release-notes__release { display: grid; gap: 6px; padding-top: 18px; border-top: 1px solid var(--mat-edge); }
.release-notes__version { margin: 0; font-size: var(--fs-large); color: var(--focus); font-variant-numeric: tabular-nums; }
.release-notes__date { color: var(--chalk-muted); font-size: var(--fs-small); }
.release-notes__items { margin: 4px 0 0; padding-left: 1.2em; display: grid; gap: 6px; line-height: 1.5; color: var(--chalk); }
.release-notes__back { margin: 0; }

/* ── Card hover preview ───────────────────────────────────────────────────────
 * Deliberately no interactive chrome (no close button, no dimmed backdrop) —
 * this is a transient hover glance, not a deliberate look-closer click.
 * `pointer-events: none` is load-bearing: without it, this full-viewport
 * overlay would sit on top of the card being hovered and immediately steal
 * the mouseleave event that's supposed to make it disappear. */
.card-preview-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  z-index: 25;
}

.card-preview {
  max-width: 460px;
  width: 100%;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.card-preview__image {
  width: 100%;
  border-radius: 6px;
  display: block;
}
/* (a board card held on a phone: what changed it, under it) */
.card-preview__details {
  margin: 8px 0 0; padding: 8px 12px; list-style: none; display: grid; gap: 4px;
  background: var(--mat-raised); border: 1px solid var(--stitch); border-radius: 8px;
  color: var(--chalk); font-size: var(--fs-small); line-height: 1.35;
}
.card-preview__details li:first-child { color: var(--focus); font-weight: 700; }
/* (hovered on a screen without the side panel: the sentences fit under it,
   clear of the match's status bar at the bottom) */
.card-preview-overlay:not(.card-preview-overlay--lightbox):has(.card-preview__details) { align-items: flex-start; padding-bottom: 96px; }
.card-preview-overlay:not(.card-preview-overlay--lightbox) .card-preview:has(.card-preview__details) { width: auto; }
.card-preview-overlay:not(.card-preview-overlay--lightbox) .card-preview:has(.card-preview__details) .card-preview__image { max-height: calc(100vh - 140px - 12em); width: auto; max-width: 100%; margin: 0 auto; }

/* Held on purpose (a finger on a touch screen): a lightbox — dimmed,
   tappable anywhere to close, with a close button to say so. */
.card-preview-overlay--lightbox { pointer-events: auto; background: rgba(0, 0, 0, 0.7); z-index: 1000; } /* (over the trash sheet, under the messages) */
.card-preview-overlay--lightbox .card-preview { position: relative; max-height: 100%; width: auto; max-width: min(460px, 100%); }
.card-preview-overlay--lightbox .card-preview__image { max-height: calc(100vh - 140px); width: auto; max-width: 100%; margin: 0 auto; }
.card-preview-overlay--lightbox .card-preview:has(.card-preview__details) .card-preview__image { max-height: calc(100vh - 140px - 9em); }
/* (card_preview_image.js: the card's space, kept from the first instant — as
   big as the window lets it be at a card's proportions — the small picture
   in it at once, the full one over it once loaded) */
.card-preview-overlay--lightbox .card-preview__frame {
  --preview-room: calc(100vh - 140px);
  position: relative; aspect-ratio: 63 / 88; margin: 0 auto; max-width: 100%;
  width: min(440px, calc(100vw - 70px), calc(var(--preview-room) * 0.716));
}
.card-preview-overlay--lightbox .card-preview:has(.card-preview__details) .card-preview__frame { --preview-room: calc(100vh - 140px - 9em); }
.card-preview-overlay--lightbox .card-preview__frame > img,
.card-preview-overlay--lightbox .card-preview__frame > canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; margin: 0; object-fit: contain; border-radius: 6px;
}
.card-preview__close {
  position: absolute; top: -14px; right: -14px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--stitch); background: var(--hover); color: var(--chalk);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}
/* The trash on a phone (no column beside the board — TrashPanel): a sheet
   over the bottom of the screen, its cards in a grid (a trash can hold 30:
   in one row they'd be slivers), scrolling past 60% of the screen. */
.trash-sheet { position: fixed; inset: 0; z-index: 950; background: rgba(0, 0, 0, 0.5); display: flex; align-items: flex-end; }
.trash-sheet__panel {
  width: 100%; max-height: 60vh; overflow-y: auto; box-sizing: border-box;
  background: var(--mat-sunken); border-top: 1px solid var(--mat-edge); border-radius: 12px 12px 0 0;
  padding: 8px 12px 16px; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.6);
}
.trash-sheet__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: var(--fs-small); }
.trash-sheet__close { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--stitch); background: var(--hover); color: var(--chalk); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.trash-sheet .trash-panel__cards { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }

/* (holding a card mustn't open the phone's own image menu, select its text
   or drag its picture: on Android those cancel the hold — any card that
   shows big when held, the board's, the log's names, the builder's) */
@media (hover: none) {
  .card-face, .card-face img, .combatant, .hand-card, .deck-stack, .card-grid img,
  [data-card-preview-image-param], [data-card-preview-image-param] * {
    -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
  }
}

/* ── Right-click "Copy image" (card_copy_controller.js) — above the hover
 * preview (z-index 25), which can still be showing when the menu opens. ── */
.card-copy-menu {
  position: fixed;
  z-index: 30;
  min-width: 140px;
  padding: 4px;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.card-copy-menu__item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--chalk);
  font-size: var(--fs-small);
  text-align: left;
  cursor: pointer;
}
.card-copy-menu__item:hover,
.card-copy-menu__item:focus-visible { background: var(--hover); outline: none; }

.card-copy-toast {
  position: fixed;
  z-index: 30;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 6px;
  background: var(--success-bg);
  color: var(--success);
  font-size: var(--fs-small);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.card-copy-toast--error { background: var(--danger-bg); color: var(--danger-text); }


/* ── Report a bug (bug_report_controller.js) ──────────────────────────────── */
.bug-report {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  background: var(--mat-raised);
  color: var(--chalk);
  border: 1px solid var(--stitch);
  border-radius: 8px;
}
.bug-report::backdrop { background: rgba(0, 0, 0, 0.6); }
.bug-report__form { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.bug-report__title { margin: 0; font-size: var(--fs-large); }
.bug-report__hint { margin: 0; font-size: var(--fs-small); color: var(--chalk-muted); }
.bug-report__text {
  width: 100%;
  resize: vertical;
  padding: 8px 10px;
  font: inherit;
  font-size: var(--fs-body);
  color: var(--chalk);
  background: var(--mat-sunken);
  border: 1px solid var(--stitch);
  border-radius: 4px;
}
.bug-report__text:focus { outline: 2px solid var(--don); outline-offset: -1px; }
.bug-report__status { margin: 0; min-height: 1.2em; font-size: var(--fs-small); color: var(--focus); }
.bug-report__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Game log (game_log_view.js): a drawer over the right of the board ───── */
.match-board { position: relative; }
.game-log {
  position: absolute;
  top: 6px;
  right: 0;
  bottom: 48px; /* (above the status bar) */
  z-index: 30;
  width: min(340px, 90%);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--mat-raised) 96%, transparent);
  border: 1px solid var(--mat-edge);
  border-radius: 6px 0 0 6px;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.5);
}
.game-log[hidden] { display: none; }
.game-log__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--chalk);
  border-bottom: 1px solid var(--mat-edge);
}
.game-log__close { background: none; border: none; color: var(--chalk-muted); font-size: var(--fs-large); line-height: 1; cursor: pointer; }
.game-log__close:hover { color: var(--chalk-strong); }
.game-log__list { flex: 1; overflow-y: auto; margin: 0; padding: 6px 12px 10px; list-style: none; font-size: var(--fs-small); line-height: 1.35; }
.game-log__entry { padding: 4px 0; color: var(--chalk); }
.game-log__entry--turn { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--mat-edge); color: var(--focus); font-weight: 600; }
.game-log__moves { margin: 2px 0 0; padding-left: 14px; list-style: "· "; color: var(--chalk-muted); font-weight: normal; }
.game-log__card { color: var(--chalk-strong); text-decoration: underline dotted var(--chalk-faint); text-underline-offset: 2px; cursor: default; }
.game-log__empty { color: var(--chalk-faint); font-size: var(--fs-small); padding: 8px 0; }
/* "Undo to here" (MatchTakeBack, #85): on each line the player may take back to */
.game-log__undo {
  margin-left: 6px; padding: 0 8px; min-height: 24px; border-radius: 4px; vertical-align: baseline;
  background: transparent; border: 1px solid var(--don-tint-edge); color: var(--focus); font-size: var(--fs-small); cursor: pointer;
}
.game-log__undo:hover, .game-log__undo:focus-visible { background: var(--don-tint); border-color: var(--don); }
.match-board__status-actions [aria-pressed="true"] { color: var(--focus); }

/* ── The log and chat column (game_board_controller#layoutColumn): on a
   wide window, beside the table — two tabs, the log open from the start.
   The same log and chat as the drawers, standing in it. ─────────────────── */
.match-layout--column { grid-template-columns: var(--side-w) minmax(0, max-content) var(--column-w, 320px); }
.match-column {
  position: sticky; top: 12px; height: calc(100vh - 24px); min-width: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--mat-sunken); border: 1px solid var(--mat-edge); border-radius: 8px;
}
.match-column[hidden] { display: none; }
.match-column__tabs { display: flex; flex: none; border-bottom: 1px solid var(--mat-edge); }
.match-column__tab {
  flex: 1; min-height: 40px; padding: 8px 12px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--chalk-muted); font: inherit; font-size: var(--fs-small); font-weight: 600; cursor: pointer;
}
.match-column__tab:hover { color: var(--chalk); }
.match-column__tab[aria-selected="true"] { color: var(--focus); border-bottom-color: var(--don); }
.match-column__tab:focus-visible { outline: 2px solid var(--don); outline-offset: -2px; }
.match-column__body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.match-column .game-log {
  position: static; width: auto; flex: 1; min-height: 0;
  background: transparent; border: none; border-radius: 0; box-shadow: none;
}
.match-column .game-log[hidden] { display: none; }
.match-column .game-log__header { display: none; } /* (the tabs say which it is) */
/* (in the column, not in the bar) */
.match-layout--column .match-board__status [data-cmd="toggle_log"],
.match-layout--column .match-board__status [data-cmd="toggle_chat"] { display: none; }

/* ── Chat (match_chat.js): the game log's drawer, with a box to write in ─── */
.match-chat__list { flex: 1; overflow-y: auto; margin: 0; padding: 6px 12px 10px; list-style: none; font-size: var(--fs-small); line-height: 1.35; }
.match-chat__message { padding: 4px 0; color: var(--chalk); }
.match-chat__who { font-weight: 600; color: var(--playable-text); }
.match-chat__message--mine .match-chat__who { color: var(--focus); }
.match-chat__time { margin-left: 6px; color: var(--chalk-faint); font-size: var(--fs-micro); }
.match-chat__body { margin: 1px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.match-chat__form { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px 4px; border-top: 1px solid var(--mat-edge); }
/* (grows with what's typed — match_chat.js#fitInput — up to 4 lines, then scrolls) */
.match-chat__input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; /* (16px: iOS doesn't zoom the page in on focus) */
  line-height: 1.35; resize: none; overflow-y: hidden; box-sizing: border-box;
  color: var(--chalk); background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 4px; padding: 6px 8px;
}
.match-chat__input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-chat__input:focus { outline: 2px solid var(--don); outline-offset: -1px; }
.match-chat__send { flex: none; }
/* The 😊 and its emojis (match_chat.js EMOJIS): a grid over the messages, right above the box */
.match-chat__form { position: relative; }
.match-chat__emoji { flex: none; min-width: 40px; padding: 4px 8px; font-size: 18px; line-height: 1.2; }
.match-chat__emojis {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 4px); z-index: 2;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; padding: 6px;
  background: var(--mat-raised); border: 1px solid var(--mat-edge); border-radius: 6px; box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.5);
}
.match-chat__emojis[hidden] { display: none; }
.match-chat__emoji-pick {
  min-height: 40px; padding: 0; background: none; border: 0; border-radius: 4px;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.match-chat__emoji-pick--pair { font-size: 15px; white-space: nowrap; letter-spacing: -1px; }
.match-chat__emoji-pick:hover, .match-chat__emoji-pick:focus-visible { background: var(--hover); outline: none; }
.match-chat__error { margin: 0; padding: 0 10px 6px; min-height: 1.2em; font-size: var(--fs-micro); color: var(--focus); }
.match-chat__toggle--unread { color: var(--chalk-strong); }
/* On a touch screen: the whole screen above the keyboard (match_chat.js#sheet
   sets --chat-top and --chat-h from the visual viewport), the page behind still. */
.game-log.match-chat--sheet {
  position: fixed; top: var(--chat-top, 0); left: 0; right: 0; bottom: auto;
  width: auto; height: var(--chat-h, 100dvh); z-index: 1000;
  border: none; border-radius: 0; background: var(--mat-sunken);
  /* (past its edges too: while it catches up with a keyboard coming or going, no board shows around it) */
  box-shadow: 0 0 0 100vmax var(--mat-sunken);
}
/* (and a touch there lands on the sheet, not on the board under its colour) */
.game-log.match-chat--sheet::before { content: ""; position: fixed; inset: -100vmax; z-index: -1; }
.match-chat--sheet .match-chat__error { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
html.match-chat-sheet-open, html.match-chat-sheet-open body { overflow: hidden; overscroll-behavior: none; }
.match-chat__badge {
  display: inline-block; min-width: 1.4em; margin-left: 2px; padding: 0 4px; border-radius: 999px;
  background: var(--danger); color: var(--chalk-strong); font-size: var(--fs-micro); font-weight: 700; line-height: 1.4; text-align: center;
}

/* ── The decision panel (game_board_controller#renderDecision): the bar's
   controls, right above the hand in the column ─────────────────────────── */
.decision-panel { flex: none; }
.decision-panel:empty { display: none; }
.decision-panel .match-board__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 6px;
  font-size: var(--fs-body);
}
.decision-panel--mine .match-board__controls { border-color: var(--don); }
.decision-panel .match-board__controls > strong,
.decision-panel .match-board__controls > em,
.decision-panel .match-board__pick-count { flex: 1 0 100%; }
/* "Don't ask again this turn" (an effect asked on every attack): its own line, under the buttons */
.match-board__mute { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: var(--fs-small); cursor: pointer; }
.match-board__mute input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.decision-panel .match-board__mute { flex: 1 0 100%; }
.decision-panel .match-board__controls .btn-primary,
.decision-panel .match-board__controls .btn-secondary { min-height: 40px; padding: 8px 14px; }
.decision-panel .match-board__option { flex: 1 1 100%; justify-content: flex-start; text-align: left; white-space: normal; }

/* ── Devise's pages (log in, sign up, password): a card in the middle ───── */
.auth-page {
  width: min(400px, calc(100vw - 32px));
  margin: 8vh auto 32px;
  padding: 28px 28px 20px;
  background: var(--mat-sunken);
  border: 1px solid var(--mat-edge);
  border-radius: 10px;
}
.auth-page h2 { margin: 0 0 20px; font-size: var(--fs-large); }
.auth-page .field { margin-bottom: 14px; }
.auth-page .field p { margin: 0; }
.auth-page .field label { display: block; margin-bottom: 6px; font-size: var(--fs-small); color: var(--chalk-muted); }
.auth-page .field em { display: block; margin: -2px 0 6px; font-size: var(--fs-small); color: var(--chalk-muted); font-style: normal; }
/* "Remember me": the box and its label on one line */
.auth-page .field:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; }
.auth-page .field:has(input[type="checkbox"]) label { margin: 0; color: var(--chalk); font-size: var(--fs-body); }
.auth-page input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--don); }
/* (a checkbox with a hint under it — the Account page: the box and its label on one line, the hint below) */
.auth-page .field--check:has(input[type="checkbox"]) { display: block; } /* (over the rule above: as specific, and later) */
.auth-page .field--check p:first-child { display: flex; align-items: center; gap: 8px; }
.auth-page .actions { margin: 20px 0 16px; }
.auth-page .actions input[type="submit"] { width: 100%; padding: 10px; }
.auth-page > p, .auth-page form + p, .auth-page p:has(> a) { margin: 8px 0; text-align: center; font-size: var(--fs-small); }
.auth-page a:not(.btn-primary) { color: var(--focus); }
.auth-page a:not(.btn-primary):hover { text-decoration: underline; }
.auth-page form.button_to { display: block; margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--mat-edge); }
.auth-page__provider { width: 100%; padding: 10px; font-size: var(--fs-body); }
.auth-page #error_explanation { margin-bottom: 16px; padding: 10px 12px; background: var(--danger-bg); color: var(--danger-text); border-radius: 6px; font-size: var(--fs-small); }
.auth-page #error_explanation h2 { margin: 0 0 6px; font-size: var(--fs-small); }
.auth-page #error_explanation ul { margin: 0; padding-left: 18px; }

/* ── The deck builder on a phone: one column that scrolls as a page — the
   top bar (stuck at the top: Save always at hand), the deck, the filters,
   then the cards (a tap adds one). No hover there: no preview panel, and
   no sidebar to resize. ───────────────────────────────────────────────── */
@media (max-width: 760px) {
  .deck-builder { display: flex; flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .db-workspace { display: contents; }
  .db-resize-handle, .db-preview { display: none; }

  .db-topbar { order: 1; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; height: auto; gap: 8px 12px; padding: 10px 12px; }
  .db-name-input { flex: 1 1 60%; max-width: none; }
  .db-count { margin-left: auto; }
  .db-topbar__actions { flex: 1 1 100%; flex-wrap: wrap; gap: 6px; }
  .db-topbar__actions > * { flex: 1 1 auto; }
  .db-topbar__actions .btn-primary,
  .db-topbar__actions .btn-secondary { min-height: 36px; padding: 0 10px; }
  .db-topbar__form { display: flex; }
  .db-topbar__form button { flex: 1 1 auto; }

  .db-errors { top: 12px; }
  .db-invite { order: 2; }
  .db-deckstrip { order: 3; margin: 8px 8px 0; padding: 14px 14px; }
  .db-summary-toggle { display: block; width: 100%; min-height: 32px; margin-bottom: 8px; }
  .db-summary--strip { display: flex; }
  .db-summary-side { display: none; }
  .deck-builder:not(.deck-builder--summary-open) .db-summary { display: none; }
  .db-summary__costs { justify-content: space-between; width: 100%; }
  .db-sidebar { order: 4; overflow: visible; padding: 12px; border-bottom: 1px solid var(--mat-edge); }
  .db-main { order: 5; overflow: visible; padding: 8px 12px 24px; }
}

/* Watching a match (MatchesController#watch): said in the bar. */
.match-board__watching { color: var(--focus); font-size: var(--fs-small); font-weight: 600; }
/* (#111: how many watch through the link) */
.match-board__spectators { color: var(--chalk-muted); font-size: var(--fs-small); white-space: nowrap; }

/* An invite opened signed out (matches/join_guest): who challenged, and the way in. */
.invite-page h2 { margin-bottom: 6px; }
.invite-page__what { margin: 0 0 16px; color: var(--chalk); }
.invite-page__steps { margin: 0 0 12px; padding-left: 20px; color: var(--chalk); line-height: 1.7; }
.invite-page__note { margin: 0 0 18px; color: var(--chalk-muted); font-size: var(--fs-small); text-align: left; }
.invite-page__main { width: 100%; }
.decks-index__invite { margin: 0 0 16px; border-radius: 6px; }
.decks-index__invite a { text-decoration: underline; }

/* My Matches (matches/index): a list per group — your turn first. */
.matches-index__group { margin-bottom: 28px; }
.matches-index__group h2 { font-size: var(--fs-h3, 1.1rem); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.matches-index__count { background: var(--don); color: var(--on-don); border-radius: 999px; padding: 0 9px; font-size: var(--fs-small); font-weight: 700; }
.matches-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.matches-list__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px 16px;
  background: var(--mat-sunken); border: 1px solid var(--mat-edge); border-radius: 8px; padding: 10px 14px;
}
.matches-list__who { display: flex; flex-direction: column; min-width: 0; }
.matches-list__leaders { color: var(--chalk-muted); font-size: var(--fs-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matches-list__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; color: var(--chalk-muted); font-size: var(--fs-small); }
.matches-list__time-control { color: var(--chalk); }
.matches-list__time-control--none { color: var(--playable-text); }
.matches-list__result--won { color: var(--success); font-weight: 700; }
.matches-list__result--lost { color: var(--danger-text); font-weight: 700; }
.matches-list__result--abandoned { color: var(--chalk-muted); font-weight: 700; }
.matches-index__hint { font-size: var(--fs-small); font-weight: normal; color: var(--chalk-muted); }
@media (max-width: 560px) {
  .matches-list__row { grid-template-columns: minmax(0, 1fr) auto; }
  .matches-list__meta { grid-column: 1 / -1; grid-row: 2; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 4px 12px; }
}

/* Challenge a Friend / Find a match (decks/_play_dialog): the deck, the
   format and the time, picked before the invite or the search. On a
   phone it takes the whole screen. */
.play-dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0;
  background: var(--mat-raised); color: var(--chalk); border: 1px solid var(--stitch); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}
.play-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.play-dialog__form { display: flex; flex-direction: column; max-height: inherit; }
.play-dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--mat-edge); }
.play-dialog__header h2 { margin: 0; font-size: var(--fs-large); }
.play-dialog__close { font-size: 1.5rem; line-height: 1; padding: 0 6px; text-decoration: none; }
/* (the groups scroll between the title and the buttons, which stay put) */
.play-dialog__body { display: flex; flex-direction: column; gap: 18px; padding: 16px 18px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.play-dialog__group { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
/* (floated: a plain block in the group, not drawn into a border) */
.play-dialog__group legend { float: left; width: 100%; padding: 0; font-size: var(--fs-small); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--focus); }
.play-dialog__decks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.play-dialog__options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
/* (the formats: all on one line — on a phone, one a line) */
.play-dialog__options--formats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.play-dialog__note { margin: 0; color: var(--chalk-muted); font-size: var(--fs-small); }
.play-dialog__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--mat-edge); }

/* A deck or an option to pick: the radio hidden, the whole box the target. */
.play-deck, .play-option {
  position: relative; display: flex; gap: 10px; align-items: center; min-width: 0;
  padding: 8px; background: var(--hover); border: 1px solid var(--mat-edge); border-radius: 8px; cursor: pointer;
}
.play-deck input, .play-option input { position: absolute; opacity: 0; pointer-events: none; }
.play-deck:has(input:checked), .play-option:has(input:checked) { border-color: var(--don); box-shadow: 0 0 0 1px var(--don); background: var(--don-tint); }
.play-deck:has(input:focus-visible), .play-option:has(input:focus-visible) { outline: 2px solid var(--don); outline-offset: 2px; }
.play-option:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.play-deck__art { flex: none; width: 44px; height: 44px; border-radius: 6px; overflow: hidden; background: var(--mat-sunken); }
.play-deck__art img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; }
.play-deck__text, .play-option__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.play-deck__name { font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-deck__leader, .play-option__text span { color: var(--chalk-muted); font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-option__text span { white-space: normal; }
/* The deck: the one picked in a button, the decks in a list that opens
   under it (deck_picker_controller.js) — a few at a time, scrolling; one a
   line. On a computer the list floats over the dialog, placed by the
   controller (fixed: the dialog's scrolling body would cut it off); on a
   phone, where the dialog is the whole screen, it opens in its flow. */
.deck-picker__current { width: 100%; text-align: left; font: inherit; color: inherit; border-color: var(--don); }
.deck-picker__current:hover, .deck-picker__current:focus-visible { background: var(--don-tint); }
.deck-picker__current:focus-visible { outline: 2px solid var(--don); outline-offset: 2px; }
.deck-picker__current .play-deck__text { flex: 1 1 auto; }
.deck-picker__chevron { flex: none; color: var(--focus); font-size: 1.1rem; transition: transform 0.15s ease; }
.deck-picker__current[aria-expanded="true"] .deck-picker__chevron { transform: rotate(180deg); }
.deck-picker__panel {
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
  background: var(--mat-sunken); border: 1px solid var(--stitch); border-radius: 10px;
}
.deck-picker__panel[hidden] { display: none; }
.deck-picker__panel .play-dialog__decks { grid-template-columns: minmax(0, 1fr); gap: 6px; max-height: min(372px, 52dvh); overflow-y: auto; overscroll-behavior: contain; }
.deck-picker__panel .play-deck[hidden] { display: none; }
/* (a computer: over the dialog; the window's room, set by the controller, may make the list shorter) */
@media (min-width: 561px) {
  .deck-picker__panel { position: fixed; z-index: 10; margin: 0; box-sizing: border-box; background: var(--mat-raised); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7); }
  .deck-picker__panel .play-dialog__decks { max-height: 372px; flex: 0 1 auto; min-height: 0; }
}
.deck-picker__search {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; color: var(--chalk);
  background: var(--mat-sunken); border: 1px solid var(--stitch); border-radius: 6px;
}
.deck-picker__search:focus { outline: 2px solid var(--don); outline-offset: 0; border-color: transparent; }
@media (max-width: 560px) {
  .play-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .play-dialog__form { height: 100%; }
  .play-dialog__decks { grid-template-columns: minmax(0, 1fr); }
  .play-dialog__options--formats { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
}
/* The DON!! picker (#263 — don_cards/_picker, don_picker_controller.js): a
   button with the DON!! in use, a dialog to search one by name. */
.don-picker { display: inline-flex; min-width: 0; }
.don-picker__trigger { display: inline-flex; align-items: center; gap: 8px; max-width: 260px; padding-top: 4px; padding-bottom: 4px; }
.don-picker__thumb { flex: none; width: 24px; height: 34px; object-fit: cover; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.don-picker__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.don-picker__what { color: var(--chalk-muted); font-weight: 700; }
.don-picker__dialog { width: min(640px, calc(100vw - 32px)); }
.don-picker__options { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.don-picker__options .don-picker__thumb { width: 32px; height: 45px; }
.don-picker__search { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-small); font-weight: 700; color: var(--focus); }
.don-picker__search input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; font-weight: 400; font-size: 16px; color: var(--chalk);
  background: var(--mat-sunken); border: 1px solid var(--stitch); border-radius: 6px;
}
.don-picker__search input:focus { outline: 2px solid var(--don); outline-offset: 0; border-color: transparent; }
.don-picker__results { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.don-picker__results:empty { display: none; }
.don-pick {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 6px; font: inherit; color: var(--chalk); text-align: left;
  background: var(--hover); border: 1px solid var(--mat-edge); border-radius: 8px; cursor: pointer;
}
.don-pick img { width: 100%; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 4px; }
.don-pick__name { font-size: var(--fs-small); line-height: 1.25; overflow-wrap: anywhere; }
.don-pick__set { font-size: var(--fs-micro); color: var(--chalk-muted); }
.don-pick:hover { border-color: var(--stitch); }
.don-pick:focus-visible { outline: 2px solid var(--don); outline-offset: 2px; }
.don-pick--chosen { border-color: var(--don); box-shadow: 0 0 0 1px var(--don); background: var(--don-tint); }
@media (max-width: 560px) { .don-picker__trigger { max-width: 200px; } }

/* A match's format (My Matches; stickers there with rollout step 3). */
.matches-list__regulation {
  padding: 1px 6px; border: 1px solid var(--stitch); border-radius: 4px; color: var(--chalk); font-size: var(--fs-small); white-space: nowrap;
}
.matches-list__regulation--extra { border-color: var(--extra); color: var(--extra-text); }
.matches-list__regulation--unreleased { border-color: var(--warning); color: var(--warning); }

/* "Report a bug", in the bottom-left corner of every page (the layout):
   out of the way of each page's own buttons. On a narrow screen just its
   icon; the board's bar, stuck to the bottom there, leaves it room. */
.bug-report-fab {
  position: fixed; left: 12px; bottom: 12px; z-index: 900;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 12px;
  background: var(--mat-raised); color: var(--chalk-muted); border: 1px solid var(--stitch); border-radius: 999px;
  font: inherit; font-size: var(--fs-small); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); opacity: 0.85;
}
.bug-report-fab:hover, .bug-report-fab:focus-visible { opacity: 1; color: var(--focus); border-color: var(--don); }
/* Where a page has a card preview in a column (the board and the replay
   with their side column, the deck builder on a wide screen), it's in the
   page's own bar instead — the corner's room goes to the card. */
.match-board__bug-link, .db-topbar__bug { display: none; }
@media (min-width: 1101px) {
  .match-board__bug-link { display: inline; }
  body:has(.match-board__bug-link) .bug-report-fab { display: none; }
}
@media (min-width: 761px) {
  .db-topbar__bug { display: inline-flex; align-items: center; justify-content: center; }
  body:has(.db-topbar__bug) .bug-report-fab { display: none; }
}
@media (max-width: 1100px) {
  .bug-report-fab { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .bug-report-fab__label { display: none; }
  body:has(.bug-report-fab) .match-board__status { padding-left: 60px; }
}

/* An effect's cards (searched, revealed, to pick) with no column beside
   the board: first in the decision bar, a row above its buttons — one row,
   never wrapped: each card shrinks from 62px as far as it takes to fit. */
/* The cards looked at, where the hand is (no column beside the board): a
   tab beside the hand's — "The effect's cards (3)" | "Your hand (5)" — the
   hand's size, in one row (game_board_controller#renderChoiceCardsInline).
   The tabs take the hand title's line: nothing moves. */
.match-board__dock--choosing { flex-direction: column; align-items: stretch; gap: 0; }
.match-board__dock--choosing .match-board__hand-header { display: none; }
.choice-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--mat-edge); margin-bottom: 1px; }
.choice-tabs__tab {
  font: inherit; font-size: var(--fs-micro); line-height: 1.25; padding: 0 10px; margin-bottom: -1px; cursor: pointer;
  color: var(--chalk-muted); background: var(--mat-raised); border: 1px solid var(--mat-edge); border-bottom: 0; border-radius: 6px 6px 0 0;
}
.choice-tabs__tab[aria-selected="true"] { color: var(--focus); background: var(--hover); border-color: var(--don); font-weight: 700; }
.choice-tabs__tab:focus-visible { outline: 2px solid var(--don); outline-offset: 1px; }
.match-board__dock .choice-cards--dock { margin: 0; padding: 0; border: 0; } /* (over .choice-cards:not(:only-child)) */
.choice-cards--dock .trash-panel__cards { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; }
.choice-cards--dock .trash-panel__card { flex: none; height: var(--hand-h); width: calc(var(--hand-h) * 0.716); aspect-ratio: auto; box-sizing: border-box; }

/* ── The board on a phone: all of it on one screen ─────────────────────────
   Both zones, the hand and the decision bar fit the screen's height, so
   nothing needs scrolling — and the bar, stuck to the bottom only when the
   page is taller than the screen, never covers the hand. Each zone's header
   is one line; the attack's banner is laid over it rather than pushing the
   table down (which also made every card on it count as moved). */
@media (max-width: 480px) {
  .match-layout { padding: 0 8px; }
  .match-board { padding-top: 2px; }
  .match-board__zone { padding: 2px 6px 3px; margin-bottom: 3px; }
  .match-board__zone-header {
    flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 6px;
    font-size: var(--fs-micro); min-height: 16px; margin-bottom: 2px;
  }
  .match-board__zone-header > span:first-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .match-board__zone-header .match-clock { margin: 0; font-size: var(--fs-micro); padding: 0 6px; }
  .match-board__zone-header .don-track,
  .match-board__zone-header .hand-backs { flex: none; }
  /* (the opponent's hand, face down: a small stack, not a row taking the line) */
  .match-board__zone-header .hand-backs .card-back--hand + .card-back--hand { margin-left: -9px; }
  .match-board__attack-banner {
    position: absolute; top: 2px; left: 6px; right: 6px;
    transform: none; max-width: none; padding: 0; border: 0; border-radius: 0;
    background: var(--mat-sunken); font-size: var(--fs-micro); line-height: 16px;
    overflow: hidden; text-overflow: ellipsis;
  }
  /* The table's cards as big as the screen lets them — and only the
     screen: the same size all match long, an effect's question aside
     (below). Its height: the two
     halves (6 rows of cards), the hand (1.9x a card) and the rest — 7.9
     cards and 303px; its width: the 5 Character slots. (iPhone 14, 390x664:
     46px; 393x720: 53px; 430x830: 65px.) */
  .match-board, .match-layout .match-board { --card-h: clamp(var(--card-min, 40px), min(calc((100svh - 303px - var(--home-edge) - var(--bar-extra, 0px)) / 7.9), calc((100vw - 72px) / 5.5)), 72px); }
  /* (an effect's question in the bar, two lines — and "Don't ask again
     this turn" under it — makes the bar taller: the cards give it room
     while it's there, a little smaller, so the page still fits the screen) */
  .match-board:has(.question-inline) { --bar-extra: 14px; }
  .match-board:has(.question-inline):has(.match-board__mute) { --bar-extra: 54px; --card-min: 38px; }
  .match-board:has(.match-board__option--effect) { --bar-extra: 24px; }
  .match-board:has(.match-board__option--effect + .match-board__option--effect + .match-board__option--effect) { --bar-extra: 60px; --card-min: 36px; }
  .match-board:has(.match-board__option--effect + .match-board__option--effect + .match-board__option--effect + .match-board__option--effect) { --bar-extra: 96px; --card-min: 32px; }
  .match-board, .hand-panel { --hand-h: calc(var(--card-h) * 1.9); }
  .match-board__hand-header { font-size: var(--fs-micro); margin-bottom: 1px; }
  .match-board__status { padding: 3px 8px; gap: 2px 8px; margin-top: 3px; }
  /* A card's power and cost changes: the chips saying why don't fit on a
     phone's small cards (they ran over the next ones) — only its power now,
     green above the printed one and red below, and its cost now when that
     changed; holding a finger on it shows each change in words. */
  .combatant__changes .power-change:not(.power-change--cost-total) { display: none; }
  .power-change--cost-total { padding: 0 3px; }
  .power-change__label, .combatant__power-unit { display: none; }
  .combatant__power { padding: 0 3px; max-width: 100%; overflow: hidden; }
  .card-resolving { display: none; } /* (the word didn't fit a phone's card: its gold edge says it) */
  .combatant__power--battle { padding: 0 4px; }
  .combatant__power--up   { color: var(--success); }
  .combatant__power--down { color: var(--danger-text); }
  /* The opponent's header: "Hand: 5" instead of backs too small to count,
     and only their name and Life — the deck and the trash show theirs on
     the piles, and the line ran out of room ("Life: 4 · Dec…"). */
  .match-board__zone-header .hand-backs { display: none; }
  .match-board__zone-header .hand-count { display: inline-flex; }
  .match-board__zone--opponent .zone-counts { display: none; }
  /* (one line when they fit — a link never breaks inside; the end of a match has more: a second line) */
  .match-board__status-actions { font-size: var(--fs-micro); flex-wrap: wrap; gap: 2px 6px; }
  .match-board__status-actions > * { white-space: nowrap; }
  /* [Activate: Main]'s ⚡ on a phone's small cards: up in the corner, so a
     tap on the card itself (to attack with it) isn't taken by it. */
  .card-activate { width: 28px; height: 28px; top: -14px; right: -12px; font-size: 0.85rem; }
  .card-activate::after { inset: -4px; }
}

/* Messages that come and go (signed in, an error): over the page at the
   top, whatever the page — never pushing it down, nor pulling it back up
   when gone. */
.toasts {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1200;
  width: min(560px, calc(100vw - 24px));
  display: grid; gap: 8px; pointer-events: none;
}
.toasts:empty { display: none; }
.top-bar ~ .toasts { top: 76px; } /* (under the top bar, not over its menus) */
@media (max-width: 640px) { .top-bar ~ .toasts { top: 68px; } }
.toasts .flash { pointer-events: auto; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); }

/* A decision in a phone's bar (turn order, mulligan, block, Play / Cancel,
   Confirm / None): its question on a line of its own, its buttons side by
   side under it, the same width — not one beside the question and the
   next wrapped under it. (An ability's or an option's long text keeps its
   own full line.) */
@media (max-width: 480px) {
  .match-board__status > .match-board__controls { flex: 1 1 100%; gap: 8px; }
  .match-board__status > .match-board__controls > strong,
  .match-board__status > .match-board__controls > em,
  .match-board__status > .match-board__controls > .match-board__pick-count { flex: 1 1 100%; }
  /* (two to a row at most, the same width — three, like two Blockers and "Don't block": two, then one the whole width; a long name wraps inside its button) */
  .match-board__status > .match-board__controls > .btn-primary:not(.match-board__activate):not(.match-board__option),
  .match-board__status > .match-board__controls > .btn-secondary:not(.match-board__option) { flex: 1 1 calc(50% - 4px); min-width: 0; white-space: normal; height: auto; }
}

/* An effect's question on a phone (no column beside the board — the
   board's renderQuestion): first in the decision bar, compact, so the
   table and the hand (where a card is often picked) stay in view; the
   status line, which would repeat the question, gives way to it. */
.match-board__status > .question-inline { flex: 1 1 100%; min-width: 0; overflow: hidden; order: -2; font-size: var(--fs-micro); line-height: 1.3; }
.match-board__status > .question-inline .question-panel__body { padding: 0; border: 0; gap: 0; }
.match-board__status > .question-inline .question-panel__body p { margin: 0 0 2px; padding: 0; border: 0; font-size: var(--fs-micro); line-height: 1.3; }
.match-board__status > .question-inline .question-panel__source { color: var(--chalk-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.match-board__status > .question-inline .question-panel__prompt { font-size: var(--fs-small); font-weight: 700; color: var(--chalk); }
.match-board__status > .question-inline .question-panel__text { color: var(--chalk); max-height: calc(2 * 1.3em); overflow-y: auto; }
.match-board__status:has(.question-inline) > .match-board__status-text,
.match-board__status:has(.question-inline) > .match-board__back { display: none; }
/* ... in two lines at most: the card's picture, small, then whose card
   ("UxBob's"; nothing for yours: the picture says which) and what it asks
   — cut short with "…" past two lines; a tap on any of it shows the card
   big with the question and the effect in full
   (game_board_controller#bindQuestionCard). */
.match-board__status > .question-inline .question-panel__text { display: none; }
.match-board__status > .question-inline .question-panel__head { flex-direction: row; align-items: center; gap: 6px; min-width: 0; }
.match-board__status > .question-inline .question-panel__head[data-question-card] { cursor: pointer; }
.match-board__status > .question-inline .question-panel__ask {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; min-width: 0; line-height: 1.3;
}
.match-board__status > .question-inline .question-panel__ask > p { display: inline; margin: 0; }
.match-board__status > .question-inline .question-panel__source + .question-panel__prompt { margin-left: 6px; }
/* (the picture no taller than the two lines) */
.match-board__status > .question-inline .question-panel__card { flex: none; width: auto; border-radius: 2px; }
.match-board__status > .question-inline .question-panel__card img { display: block; height: 2.2em; width: auto; border-radius: 2px; }
/* (the question above: "tap a card" and None / Confirm share one line under it) */
@media (max-width: 480px) {
  .match-board__status:has(.question-inline) > .match-board__controls > .match-board__pick-count { flex: 1 1 auto; }
  .match-board__status:has(.question-inline) > .match-board__controls > .btn-secondary:not(.match-board__option),
  .match-board__status:has(.question-inline) > .match-board__controls > .btn-primary:not(.match-board__option):not(.match-board__activate) { flex: 0 0 auto; }
}

/* Sorting the hand / an opened trash (board_view's sortSelectHTML): a
   small select beside the hand's title, at the top of the trash. */
.match-board__hand-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-sort {
  font: inherit; font-size: var(--fs-micro); color: var(--chalk); background: var(--mat-raised);
  border: 1px solid var(--mat-edge); border-radius: 4px; padding: 1px 4px; cursor: pointer;
}
.trash-panel__tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.trash-sheet__header { gap: 8px; }
.trash-sheet__header > strong { margin-right: auto; }

/* ── Cards left (board_view's endRevealHTML): the game log's drawer, once
   the match is over — each player's hand, Life and next card ──────────── */
.match-reveal__body { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.match-reveal__player + .match-reveal__player { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--mat-edge); }
.match-reveal__name { margin: 0 0 4px; font-size: var(--fs-body); color: var(--focus); }
.match-reveal__label { margin: 8px 0 4px; font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--chalk-muted); }
.match-reveal .trash-panel__cards { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
/* (inside the board a card takes the table's --card-w: here, its grid cell) */
.match-reveal .trash-panel__card { width: 100%; height: auto; aspect-ratio: 63 / 88; margin: 0; }
.match-reveal__none { margin: 0; color: var(--chalk-faint); font-size: var(--fs-small); }

/* Keyboard shortcuts (#181, lib/board_shortcuts.js): the key on its
   button, small, where there's a keyboard to press it (not on a touch
   screen) and only once they're turned on (.board-shortcuts-on, on <html>);
   the list behind the "?" key or the bar's "?" (not on a touch screen). */
@media (hover: hover) {
  .board-shortcuts-on .match-layout .match-board__controls,
  .board-shortcuts-on .match-layout .question-panel__options { counter-reset: shortcut; }
  .board-shortcuts-on .match-layout button:is([data-cmd="end_turn"], [data-cmd="choice_yes"], [data-cmd="choice_confirm"], [data-cmd="confirm_play"],
    [data-cmd="mulligan"], [data-cmd="choose_turn_order"], [data-cmd="end_counter"], [data-cmd="all_don"],
    [data-cmd="cancel_select"], [data-cmd="cancel_play"], [data-cmd="cancel_attack"], [data-cmd="cancel_activate"], [data-cmd="cancel_don"], [data-cmd="choice_no"], [data-cmd="choice_none"], [data-cmd="skip_block"],
    [data-cmd="choice_option"], [data-cmd="declare_block"], .match-board__controls [data-cmd="activate_ability"])::after {
    display: inline-block; margin-left: 6px; padding: 0 4px; border: 1px solid currentColor; border-radius: 3px;
    font-size: 0.75em; font-weight: 400; line-height: 1.3; opacity: 0.6; vertical-align: 1px;
  }
  .board-shortcuts-on .match-layout button[data-cmd="end_turn"]::after { content: "E"; }
  .board-shortcuts-on .match-layout button:is([data-cmd="choice_yes"], [data-cmd="choice_confirm"], [data-cmd="confirm_play"], [data-cmd="mulligan"][data-redraw="false"],
    [data-cmd="choose_turn_order"][data-go-first="true"], [data-cmd="end_counter"])::after { content: "Enter"; }
  .board-shortcuts-on .match-layout button:is([data-cmd="cancel_select"], [data-cmd="cancel_play"], [data-cmd="cancel_attack"], [data-cmd="cancel_activate"], [data-cmd="cancel_don"], [data-cmd="choice_no"], [data-cmd="choice_none"], [data-cmd="skip_block"])::after { content: "Esc"; }
  .board-shortcuts-on .match-layout button[data-cmd="mulligan"][data-redraw="true"]::after { content: "M"; }
  .board-shortcuts-on .match-layout button[data-cmd="choose_turn_order"][data-go-first="false"]::after { content: "S"; }
  .board-shortcuts-on .match-layout button[data-cmd="all_don"]::after { content: "D"; }
  .board-shortcuts-on .match-layout button:is([data-cmd="choice_option"], [data-cmd="declare_block"], .match-board__controls [data-cmd="activate_ability"]) { counter-increment: shortcut; }
  .board-shortcuts-on .match-layout button:is([data-cmd="choice_option"], [data-cmd="declare_block"], .match-board__controls [data-cmd="activate_ability"])::after { content: counter(shortcut); }
}
@media (hover: none) {
  .match-board__shortcuts { display: none; }
}
.match-board__shortcuts { text-decoration: none; font-weight: 700; }

.shortcuts-help {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 16px 18px;
  background: var(--mat-raised); color: var(--chalk); border: 1px solid var(--stitch); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}
.shortcuts-help::backdrop { background: rgba(0, 0, 0, 0.6); }
.shortcuts-help h2 { margin: 0 0 12px; font-size: var(--fs-large); }
.shortcuts-help__list { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.shortcuts-help__list th { width: 1%; padding: 6px 12px 6px 0; text-align: left; white-space: nowrap; vertical-align: top; }
.shortcuts-help__list td { padding: 6px 0; border-top: 1px solid var(--mat-edge); }
.shortcuts-help__list tr:first-child td { border-top: 0; }
.shortcuts-help kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; text-align: center;
  font: inherit; font-weight: 700; color: var(--focus); border: 1px solid var(--stitch); border-radius: 4px; background: var(--hover);
}
.shortcuts-help__toggle { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-weight: 700; cursor: pointer; }
.shortcuts-help__toggle input { width: 18px; height: 18px; accent-color: var(--don); }
.shortcuts-help__off { margin: 0 0 10px; font-size: var(--fs-small); color: var(--chalk-muted); }
.shortcuts-help:has([data-shortcuts-toggle]:checked) .shortcuts-help__off { display: none; }
.shortcuts-help:has([data-shortcuts-toggle]:not(:checked)) .shortcuts-help__list { opacity: 0.5; }
.shortcuts-help__note { margin: 12px 0; font-size: var(--fs-small); color: var(--chalk-muted); }
.shortcuts-help form { display: flex; justify-content: flex-end; margin: 0; }
