/* Material Design 3 layer, on the existing stack: design tokens (colour roles, shape, elevation, state layers, type scale),
   48px touch targets, pill buttons, tonal surfaces and ripple. Loaded last, so it refines the other sheets.
   The N26 identity (sodium yellow on steel, Saira Stencil / Barlow Condensed / Source Serif) is kept: these are Material's
   mechanics in the app's own colours. */

:root {
  /* colour roles (primary = sodium) */
  --md-primary: var(--sodium);
  --md-on-primary: var(--on-sodium);
  --md-surface: var(--bg);
  --md-surface-1: color-mix(in srgb, var(--sodium) 2%, var(--panel));    /* tonal elevation: the higher the surface, the more primary tint */
  --md-surface-2: color-mix(in srgb, var(--sodium) 3%, var(--panel));
  --md-surface-3: color-mix(in srgb, var(--sodium) 3%, var(--panel-2));
  --md-outline: var(--line);
  --md-on-surface: var(--ink);
  --md-on-surface-variant: var(--muted);
  --md-error: #f59a7a;
  --md-error-container: #7a1f1f;
  /* shape */
  --md-shape-xs: 4px; --md-shape-sm: 8px; --md-shape-md: 12px; --md-shape-lg: 16px; --md-shape-xl: 28px; --md-shape-full: 999px;
  /* elevation (shadows; dark themes lean on the tonal surfaces above) */
  --md-elev-1: 0 1px 2px rgb(0 0 0 / .30), 0 1px 3px 1px rgb(0 0 0 / .15);
  --md-elev-2: 0 1px 2px rgb(0 0 0 / .30), 0 2px 6px 2px rgb(0 0 0 / .15);
  --md-elev-3: 0 1px 3px rgb(0 0 0 / .30), 0 4px 8px 3px rgb(0 0 0 / .15);
  /* state layers */
  --md-hover: 8%; --md-focus: 10%; --md-press: 10%;
  /* motion */
  --md-ease: cubic-bezier(.2, 0, 0, 1); --md-fast: 120ms; --md-medium: 250ms;
  /* touch targets: 48px */
  --tap: 3rem;
}

/* ---- type scale: nothing under 12px, body 16px */
.asc-pill small, .app-badge, .tab-n, .c span { font-size: max(.75rem, 12px); }
.pe-note, .pe-hint, .pe-msg { font-size: max(.875rem, 14px); line-height: 1.45; }

/* ---- state layers: hover, keyboard focus and press tint any interactive surface by the current text colour */
.pe button, .pe .app-btnlink, .app-tile, .tr-tile, .app-gangtile, .app-ftile, .app-segopt span, .app-tabs a, .app-linkrow, .app-picklist button, summary, .fname, .xp-btn, .app-herohome, .app-herouser, .app-close {
  transition: background-color var(--md-fast) var(--md-ease), box-shadow var(--md-fast) var(--md-ease), transform var(--md-fast) var(--md-ease);
  --_s: 0%;
  background-image: linear-gradient(color-mix(in srgb, currentColor var(--_s), transparent), color-mix(in srgb, currentColor var(--_s), transparent));
}
@media (hover: hover) { .pe button:hover, .pe .app-btnlink:hover, .app-tile:hover, .tr-tile:hover, .app-gangtile:hover, .app-ftile:hover, .app-segopt:hover span, .app-tabs a:hover, .app-linkrow:hover, .app-picklist button:hover, summary:hover, .xp-btn:hover { --_s: var(--md-hover); } }
.pe button:focus-visible, .pe .app-btnlink:focus-visible, .app-tile:focus-visible, .tr-tile:focus-visible, .app-gangtile:focus-visible, .app-ftile:focus-visible, .app-tabs a:focus-visible, .app-linkrow:focus-visible, summary:focus-visible { --_s: var(--md-focus); }
.pe button:active, .pe .app-btnlink:active, .app-tile:active, .tr-tile:active, .app-gangtile:active, .app-ftile:active, .app-tabs a:active, .app-linkrow:active, summary:active { --_s: var(--md-press); }
.pe button:disabled { --_s: 0%; opacity: .38; }       /* Material's disabled: 38% */

/* ---- ripple (see js/shared/ripple.js): a circle that grows from the touch point */
.has-ripple { position: relative; overflow: hidden; isolation: isolate; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .16; transform: scale(0); animation: ripple 450ms var(--md-ease) forwards; z-index: -1; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ripple { animation: none; opacity: 0; } }

/* ---- buttons: pill-shaped, 48px touch target (Material 3) */
.pe button:not(.fname):not(.xp-btn):not(.fc-close):not(.tr-tile):not(.app-ftile):not(.pe-x):not(.app-close):not(.app-gangpicbtn), .pe .app-btnlink, .pe-crop button {
  border-radius: var(--md-shape-full); min-height: var(--tap); padding-inline: 1.5rem; letter-spacing: .01em;
}
.pe button:not(.fname):not(.xp-btn):not(.fc-close):not(.tr-tile):not(.app-ftile):not(.pe-add):not(.danger):not(.pe-x):not(.app-close):not(.app-gangpicbtn):not(:disabled) { box-shadow: var(--md-elev-1); }   /* filled buttons rest at elevation 1 */
.pe button.pe-x:not(.fname):not(.xp-btn):not(.fc-close) { border-radius: var(--md-shape-full); min-width: var(--tap); }
.app-close { min-width: var(--tap); min-height: var(--tap); }

/* ---- text fields: outlined, 56px, 4px corners, a 2px primary outline on focus */
.pe input:not([type=checkbox]):not([type=radio]):not([type=color]):not(.st):not(.sm):not(.app-num), .pe select, .app-dialog input:not([type=checkbox]):not([type=radio]) { min-height: 3.5rem; border-radius: var(--md-shape-xs); }
.pe-t input, .pe-t select, .tr-stats input, .pe input.st { min-height: var(--tap); }     /* in tables and stat grids the fields stay compact */
.pe textarea { border-radius: var(--md-shape-xs); }
.pe input:focus, .pe select:focus, .pe textarea:focus { border-color: var(--md-primary); box-shadow: 0 0 0 1px var(--md-primary); outline: none; }

/* ---- surfaces: cards sit on tonal surfaces, with a shadow only when they float */
.fighter, .app-side, .app-tcard, .app-tile, .tr-gang, .tr-battle, .pe-gang, .app-rewcard, .app-linkrow, .app-card2 { border-radius: var(--md-shape-md); }
.fighter, .app-side, .app-tcard { background-color: var(--md-surface-1); }
.app-tile, .app-gangtile { background-color: var(--md-surface-1); }
.app-tile:hover, .app-gangtile:hover { box-shadow: var(--md-elev-1); }
.app-dialog { border-radius: var(--md-shape-xl); box-shadow: var(--md-elev-3); background: var(--md-surface-3); }
.app-dialog::backdrop { background: rgb(0 0 0 / .55); }
.fc-pop { border-radius: var(--md-shape-xl); }
.jump.app-topnav { box-shadow: var(--md-elev-1); }                       /* the pinned tab bar sits at elevation 1 */
.app-fbox .fighter { box-shadow: none; }

/* ---- touch targets: 48px minimum for everything tappable */
.app-ftile, .app-picklist button, .tr-fighter summary, .app-tabs a, .app-segopt span, .app-fpick, .pe-check { min-height: var(--tap); }
.xp-btn, .pe button.xp-btn { min-height: var(--tap); min-width: var(--tap); }
.fname, h2.app-gangname[role=button], h1 .fname, .app-vs h2 .fname, h4 .fname { min-height: var(--tap); display: inline-flex; align-items: center; }
.fh h4 { display: flex; align-items: center; }
.app-herohome, .app-herouser { width: var(--tap); height: var(--tap); }
@media (max-width: 44rem) { .app-topnav .app-tabs a { min-height: var(--tap); } }

/* the rules above are beaten by a few older, more specific ones: restate them where those live */
.pe button.app-ftile { min-height: var(--tap); padding-block: .5rem; align-items: center; }
.app-battletitle, .app-vs h2 .app-gname, h2 a.app-gname, h3 a.app-gname, h4 a.app-gname { display: inline-flex; align-items: center; min-height: var(--tap); }
.app-chat #msgform textarea { height: var(--tap); min-height: var(--tap); }
/* standalone links (not inside a sentence) get a full touch target */
.pe a[href^="http"]:not(.app-btnlink):not(p a):not(li a):not(small a):not(td a) { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ---- snackbar (js/shared/snackbar.js): inverse surface, 4px corners, elevation 3, above the chat composer when there is one */
.snackstack[popover] { position: fixed; inset: auto 0 calc(var(--snack-lift, 0px) + 1rem + env(safe-area-inset-bottom, 0px)) 0; margin: 0 auto; width: fit-content; max-width: min(34rem, calc(100vw - 2rem)); padding: 0; border: 0; background: none; overflow: visible;
  display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.snackbar { display: flex; align-items: center; gap: .25rem; min-height: 3rem; padding: .25rem .5rem .25rem 1rem; border: 0; border-radius: var(--md-shape-xs);
  background: var(--ink); color: var(--on-sodium); box-shadow: var(--md-elev-3); font-family: var(--label); font-size: 1.05rem; line-height: 1.3;
  opacity: 0; transform: translateY(.75rem); transition: opacity var(--md-medium) var(--md-ease), transform var(--md-medium) var(--md-ease); }
.snackbar.in { opacity: 1; transform: none; }
.snackbar.err { background: var(--md-error-container); color: #fff; }
.snackbar .sb-text { white-space: pre-line; flex: 1; min-width: 0; padding-block: .5rem; overflow-wrap: anywhere; }
.snackbar .sb-act { flex: none; min-height: var(--tap); min-width: var(--tap); padding: 0 .75rem; border: 0; border-radius: var(--md-shape-full); background: none; color: #7a5800;
  font: 700 .95rem var(--label); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.snackbar.err .sb-act { color: #ffd9cc; }
.snackbar .sb-act:hover, .snackbar .sb-act:focus-visible { background: color-mix(in srgb, currentColor 10%, transparent); }
@media (prefers-reduced-motion: reduce) { .snackbar { transition: none; } }

/* ================= Bottom navigation bar (phones) ================= */
.app-bottomnav { display: none; }
@media (max-width: 44rem) {
  :root { --bnav-h: calc(5rem + env(safe-area-inset-bottom, 0px)); }
  .app-bottomnav { display: block; position: fixed; inset: auto 0 0 0; z-index: 9; height: var(--bnav-h); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--md-surface-2); box-shadow: 0 -1px 0 var(--md-outline), var(--md-elev-2); }
  .app-bottomnav ul { display: flex; height: 5rem; margin: 0; padding: 0; list-style: none; }
  .app-bottomnav li { flex: 1 1 0; min-width: 0; }
  .app-bottomnav a, .app-bottomnav button { width: 100%; height: 100%; display: grid; justify-items: center; align-content: center; gap: .25rem; padding: 0; border: 0; background: none; color: var(--md-on-surface-variant);
    font: 600 .75rem/1 var(--label); letter-spacing: .05em; text-transform: uppercase; text-decoration: none; cursor: pointer; }
  .bn-ind { position: relative; width: 4rem; height: 2rem; display: grid; place-items: center; border-radius: var(--md-shape-full); transition: background-color var(--md-medium) var(--md-ease); }
  .bn-ind svg { width: 1.5rem; height: 1.5rem; }
  /* the current tab: a gold icon and label and a short gold bar above it (no pill behind the icon) */
  .app-bottomnav a, .app-bottomnav button { position: relative; }
  .app-bottomnav [aria-current="page"], .app-bottomnav .bn-more.on { color: var(--sodium); }
  .app-bottomnav [aria-current="page"]::before, .app-bottomnav .bn-more.on::before { content: ''; position: absolute; top: 0; left: 50%; width: 2.75rem; height: 3px; transform: translateX(-50%); background: var(--sodium); border-radius: 0 0 3px 3px; }
  .app-bottomnav a:active .bn-ind, .app-bottomnav button:active .bn-ind { background: color-mix(in srgb, currentColor 14%, transparent); }
  .bn-badge { position: absolute; top: -.1rem; right: .55rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem; border-radius: var(--md-shape-full); background: var(--md-error-container); color: #fff; font: 700 .7rem/1.1rem var(--label); text-align: center; }
  /* the top tab bar gives way to it, and the page clears it */
  body:has(.app-bottomnav) .jump.app-topnav { display: none; }
  body:has(.app-bottomnav) main { padding-bottom: calc(var(--bnav-h) + 1.5rem); }
  body.kbd .app-bottomnav { display: none; }                             /* out of the way while a field has the keyboard */
  /* the chat composer sits just above the bar */
  .app-chat #msgform { bottom: var(--bnav-h); }
  body.kbd .app-chat #msgform { bottom: 0; }
  .app-chat { padding-bottom: calc(var(--bnav-h) + 7rem); }
  body.kbd .app-chat { padding-bottom: 7rem; }
}
/* the More sheet */
.bn-sheet ul { list-style: none; margin: 0; padding: 0; display: grid; }
.bn-sheet a { display: flex; align-items: center; min-height: var(--tap); padding: 0 1rem; border-radius: var(--md-shape-md); color: var(--md-on-surface); text-decoration: none; font-family: var(--label); font-size: 1.15rem; font-weight: 600; }
.bn-sheet a[aria-current="page"] { background: color-mix(in srgb, var(--sodium) 20%, transparent); color: var(--sodium); }
.bn-sheet a:hover, .bn-sheet a:focus-visible { background: color-mix(in srgb, currentColor 8%, transparent); }

/* ---- top tabs (desktop, and tablets): one scrolling row, with a Material indicator under the active tab */
.app-topnav .app-tabs { flex-wrap: nowrap; justify-content: safe center; overflow-x: auto; scrollbar-width: none; }
.app-topnav .app-tabs::-webkit-scrollbar { display: none; }
.app-topnav .app-tabs a { flex: none; position: relative; }
.app-tabs a, .app-tabs a[aria-current="page"] { border-bottom-color: transparent; }
.app-tabs a[aria-current="page"]::after { content: ''; position: absolute; inset: auto .5rem 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--md-primary); }

/* ================= Account: avatar button and menu ================= */
.avatar { display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--sodium); color: var(--on-sodium); font-family: var(--display); font-size: 1.05rem; line-height: 1; }
.app-herouser .avatar { background: var(--on-sodium); color: var(--sodium); }     /* on the yellow hero: a dark disc */
.app-topnav #userbtn { gap: .6rem; }
.app-topnav #userbtn:hover .avatar, .app-topnav #userbtn:focus-visible .avatar { box-shadow: 0 0 0 3px color-mix(in srgb, var(--sodium) 30%, transparent); }
.acct-menu[popover] { position: fixed; inset: auto; margin: 0; min-width: 16rem; max-width: calc(100vw - 1rem); padding: .5rem 0; border: 0; border-radius: var(--md-shape-md); background: var(--md-surface-3); color: var(--ink); box-shadow: var(--md-elev-3); }
.acct-menu .acct-who { display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem .75rem; }
.acct-menu .acct-who div { display: grid; gap: .05rem; min-width: 0; }
.acct-menu .acct-who b { font: 700 1.2rem/1.15 var(--label); overflow-wrap: anywhere; }
.acct-menu .acct-who small { color: var(--md-on-surface-variant); font: 500 .95rem var(--label); }
.acct-menu button, .acct-menu a { display: flex; align-items: center; width: 100%; min-height: var(--tap); padding: 0 1rem; border: 0; border-radius: 0; background: none; color: inherit; text-align: left; text-decoration: none; font: 600 1.05rem var(--label); cursor: pointer; }
.acct-menu button:hover, .acct-menu a:hover, .acct-menu button:focus-visible, .acct-menu a:focus-visible { background: color-mix(in srgb, currentColor 8%, transparent); outline: none; }
.acct-menu hr { margin: .25rem 0; border: 0; border-top: 1px solid var(--md-outline); }

/* ================= Linear progress (js/api.js) and selected chips ================= */
.linear-progress { position: fixed; inset: 0 0 auto 0; z-index: 40; height: 4px; overflow: hidden; background: rgb(0 0 0 / .4); opacity: 0; pointer-events: none; transition: opacity var(--md-fast) linear; }
.linear-progress.on { opacity: 1; }
.linear-progress span { position: absolute; inset: 0 auto 0 0; width: 40%; background: #fff; border-radius: 0 2px 2px 0; animation: linear-progress 1.3s var(--md-ease) infinite; }
@keyframes linear-progress { from { left: -40%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .linear-progress span { animation: none; left: 0; width: 100%; opacity: .7; } }

/* the result / side-job / option pickers as Material filter chips: a tonal fill and a check when selected */
.app-segopt span { display: flex; align-items: center; justify-content: center; gap: .4rem; border-radius: var(--md-shape-sm); border-color: var(--md-outline); }
.app-segopt:has(input:checked) span { background: color-mix(in srgb, var(--sodium) 22%, var(--panel)); border-color: transparent; box-shadow: none; color: var(--md-on-surface); }
.app-segopt:has(input:checked) span::before { content: '✓'; font-weight: 700; color: var(--md-primary); }
.app-segopt:has(input:focus-visible) span { outline: 2px solid var(--md-primary); outline-offset: 2px; }

/* ================= Switches: on/off settings (label.sw > input[type=checkbox]) ================= */
.pe-check.sw { justify-content: space-between; flex-direction: row-reverse; gap: .75rem; }
.pe .sw input[type=checkbox], .sw input[type=checkbox] { appearance: none; box-sizing: border-box; min-height: 0; min-width: 0; padding: 0; flex: none; position: relative; width: 3.25rem; height: 2rem; margin: 0; border-radius: 1rem; border: 2px solid var(--md-outline); background: var(--md-surface-2); cursor: pointer; transition: background var(--md-fast), border-color var(--md-fast); }
.sw input[type=checkbox]::before { content: ''; position: absolute; top: 50%; left: .4rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--md-outline); transform: translateY(-50%); transition: left var(--md-fast) var(--md-ease), width var(--md-fast), height var(--md-fast), background var(--md-fast); }
.sw input[type=checkbox]:checked { background: var(--md-primary); border-color: var(--md-primary); }
.sw input[type=checkbox]:checked::before { left: 1.45rem; width: 1.5rem; height: 1.5rem; background: var(--on-sodium); }
.sw input[type=checkbox]:disabled { opacity: .5; cursor: default; }
.sw input[type=checkbox]:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 3px; }
.sw:active input[type=checkbox]:not(:disabled)::before { width: 1.75rem; }
@media (prefers-reduced-motion: reduce) { .sw input[type=checkbox], .sw input[type=checkbox]::before { transition: none; } }

/* ================= Navigation rail (wide screens): the campaign tabs, down the left with their icons ================= */
.tab-ic { display: none; }
@media (min-width: 44.01rem) {
  .app-topnav .app-tabs { position: fixed; z-index: 20; left: 0; top: 0; bottom: 0; width: 5.25rem; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-items: stretch; gap: .4rem; padding: 1rem .25rem; overflow-y: auto; background: var(--md-surface-1); border-right: 1px solid var(--md-outline); }
  .app-topnav .app-tabs a { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-height: 0; padding: .1rem 0; border-radius: var(--md-shape-md); text-align: center; font-size: .8rem; letter-spacing: .04em; line-height: 1.1; }
  .app-topnav .app-tabs .tab-ic { display: grid; place-items: center; width: 3.5rem; height: 2rem; border-radius: 1rem; transition: background var(--md-fast); }
  .app-topnav .app-tabs .tab-ic svg { width: 1.5rem; height: 1.5rem; }
  .app-topnav .app-tabs a:hover .tab-ic { background: color-mix(in srgb, currentColor 10%, transparent); }
  .app-topnav .app-tabs a[aria-current="page"] { color: var(--ink); }
  .app-topnav .app-tabs a[aria-current="page"] .tab-ic { background: color-mix(in srgb, var(--sodium) 28%, transparent); color: var(--sodium); }
  .app-topnav .app-tabs a[aria-current="page"]::after { display: none; }
  body:has(.app-tabs) .app-topnav { min-height: 0; height: 0; padding: 0; border: 0; overflow: visible; }
  body:has(.app-tabs) .app-topnav > ul { height: 0; padding: 0; min-height: 0; }
  .app-topnav .app-tabs .app-badge { position: absolute; top: 0; left: 50%; margin: 0 0 0 .5rem; }
}

/* ================= Sign-in style screens (login, setup, join): a narrow card, notes spaced below the action ================= */
.app-card > form#f ~ .pe-note { margin-top: 1rem; }
@media (min-width: 44.01rem) { .app-card:has(> form#f.app-form) { max-width: 28rem; margin-inline: auto; padding: 1.5rem; background: var(--md-surface-1); border-radius: var(--md-shape-lg, 1rem); } }

/* rail extras: Campaigns on top, the Arbitrator menu, the account at the foot (hidden below the rail's width) */
.rail-only, .app-topnav .app-tabs .rail-only { display: none; }
@media (min-width: 44.01rem) {
  .app-topnav .app-tabs .rail-only { display: flex; }
  .app-topnav .app-tabs > * { flex: none; }
  .app-topnav .app-tabs a[data-arb] { display: none; }
  body:has(.app-tabs) .app-topnav a.home, body:has(.app-tabs) .app-topnav li.app-user { display: none; }
  .app-topnav .app-tabs .rail-home { padding-bottom: .6rem; margin-bottom: .2rem; border-bottom: 1px solid var(--md-outline); border-radius: var(--md-shape-md) var(--md-shape-md) 0 0; }
  .app-topnav .app-tabs .rail-arb, .app-topnav .app-tabs .rail-user { flex-direction: column; align-items: center; gap: .2rem; min-height: 0; padding: .1rem 0; border: 0; border-radius: var(--md-shape-md); background: none; color: var(--muted); font: 600 .8rem/1.1 var(--label); letter-spacing: .04em; text-transform: uppercase; text-align: center; cursor: pointer; }
  .app-topnav .app-tabs .rail-arb:hover { color: var(--ink); }
  .app-topnav .app-tabs .rail-arb.on { color: var(--ink); }
  .app-topnav .app-tabs .rail-arb.on .tab-ic { background: color-mix(in srgb, var(--sodium) 28%, transparent); color: var(--sodium); }
  .app-topnav .app-tabs .rail-user { margin-top: auto; padding: .75rem 0 .25rem; border-top: 1px solid var(--md-outline); border-radius: 0; color: var(--ink); }
  .app-topnav .app-tabs .rail-user .tab-l { max-width: 4.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; font-size: .85rem; }
}

/* the More sheet: icons on every row, the Arbitrator's pages grouped under a heading */
.bn-sheet a { gap: 1rem; }
.bn-sheet a svg, .bn-sheet .bn-group svg { flex: none; width: 1.5rem; height: 1.5rem; }
.bn-sheet .bn-group { display: flex; align-items: center; gap: 1rem; margin-top: .5rem; padding: .75rem 1rem .25rem; border-top: 1px solid var(--md-outline); color: var(--md-on-surface-variant); font: 700 .9rem var(--label); letter-spacing: .08em; text-transform: uppercase; }
.bn-sheet .bn-group ~ li a { padding-left: 3.5rem; }
.acct-menu button, .acct-menu a { gap: 1rem; }
.acct-menu button svg, .acct-menu a svg { flex: none; width: 1.4rem; height: 1.4rem; }

/* the account dialog's Log out: an outlined, transparent button on the dialog's own surface */
.pe .app-dlg-foot, .app-dlg-foot.pe-row { background: none; padding: 0; }
.pe .app-dlg-foot .app-btnlink.app-logout { background-color: transparent; border: 1px solid #c0432e; color: #f59a7a; box-shadow: none; }

/* ================= Profile pictures ================= */
.avatar.pic { overflow: hidden; background: var(--panel-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-chat .app-msgs li, .app-msgs li { display: flex; gap: .65rem; align-items: flex-start; }
.app-msgs li .avatar { width: 2.25rem; height: 2.25rem; margin-top: .1rem; }
.app-msgs li.mine { flex-direction: row-reverse; }
.app-msgs .app-msgbody { min-width: 0; }
.app-ident .app-avatar { overflow: hidden; }
.app-ident .app-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* the player's avatar: a small circle at the top left of the gang picture */
.app-gpic { position: relative; flex: none; display: block; width: 3rem; height: 3rem; }
.app-gangtile .app-gpic > img, .app-gangtile .app-gpic > .app-dot { width: 3rem; height: 3rem; }
.app-gangtile .avatar img { width: 100%; height: 100%; border: 0; border-radius: 0; }
.app-gpic > .avatar, .app-gangpicwrap > .app-owneravatar { position: absolute; z-index: 2; top: -.35rem; left: -.35rem; width: 1.5rem; height: 1.5rem; border: 2px solid var(--panel); box-sizing: content-box; font-size: .8rem; }
.app-gangpicwrap > .app-owneravatar { width: 1.75rem; height: 1.75rem; top: -.5rem; left: -.5rem; }
.app-gangpicwrap > .app-owneravatar img { border: 0; border-radius: 0; width: 100%; height: 100%; }

/* ================= Site admin on a phone: a card per invite and per user, two-up fields ================= */
@media (max-width: 40rem) {
  #newinv.app-inline { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
  #newinv > :first-child, #newinv > .pe-row, #newinv > .app-msg { grid-column: 1 / -1; }
  .app-users thead { display: none; }
  .app-users, .app-users tbody { display: grid; gap: .75rem; }
  .app-users tr { display: grid; gap: 0; padding: .75rem 1rem; border: 0; border-radius: var(--md-shape-md); background: var(--md-surface-1); }
  .app-users tr.app-off { opacity: .75; }
  .app-users td { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--md-outline) 50%, transparent); text-align: right; }
  .app-users td[data-l]::before, .app-users td[data-l]:not([data-l="Username"])::before { content: attr(data-l); flex: none; color: var(--muted); text-align: left; }
  .app-users td.app-head { display: block; padding: 0 0 .5rem; border-bottom: 1px solid var(--md-outline); text-align: left; font-size: 1.2rem; }
  .app-users td.app-head::before { content: none !important; }
  .app-users td.app-acts { display: flex; justify-content: stretch; gap: .5rem; padding: .75rem 0 0; border: 0; }
  .app-users td.app-acts:empty { display: none; }
  .app-users td.app-acts > button { flex: 1; margin: 0; }
}

/* the option cards: the radio / checkbox is only a hit area over the card, never drawn */
.app-typecard input, .app-segopt input { appearance: none; -webkit-appearance: none; opacity: 0; background: none; border: 0; box-shadow: none; outline: 0; }

/* the account picture: tap it to change it */
.app-ident .app-avatarbtn { position: relative; flex: none; padding: 0; border: 0; border-radius: 50%; background: none; min-height: 0; cursor: pointer; line-height: 0; }
.pe .app-ident button.app-avatarbtn { padding: 0; min-height: 0; background: none; border-radius: 50%; }
.pe .app-ident button.app-textbtn { display: block; min-height: 0; padding: .2rem 0 0; border: 0; background: none; color: var(--sodium); font: 600 .9rem var(--label); text-decoration: underline; border-radius: 0; box-shadow: none; }
.pe .app-ident button.app-textbtn[hidden] { display: none; }

/* ================= Rolled or set by hand: a die in front of dice that were rolled, a pencil in front of values typed in ================= */
.app-dice::before, .app-set::before { content: ''; display: inline-block; width: .95em; height: .95em; margin-right: .3em; vertical-align: -.12em; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.app-dice { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='3'/%3E%3Cg fill='black' stroke='none'%3E%3Ccircle cx='8.5' cy='8.5' r='1.6'/%3E%3Ccircle cx='15.5' cy='15.5' r='1.6'/%3E%3Ccircle cx='15.5' cy='8.5' r='1.6'/%3E%3Ccircle cx='8.5' cy='15.5' r='1.6'/%3E%3C/g%3E%3C/svg%3E"); }
.app-set { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20l1-4L16.5 4.5a2.1 2.1 0 0 1 3 3L8 19z'/%3E%3C/svg%3E"); font-family: ui-monospace, Menlo, monospace; background: var(--panel-2); padding: 0 .35rem; border-radius: 3px; white-space: nowrap; }
.app-dice:empty::before { margin-right: 0; }
.app-ident button.app-avatarbtn, .pe .app-ident button.app-avatarbtn { width: auto; min-width: 0; min-height: 0 !important; padding: 0 !important; border-radius: 50% !important; background: none !important; background-image: none !important; box-shadow: none; border: 0; }

/* ================= The rail, icon and name on one row (Material navigation drawer rows) ================= */
@media (min-width: 44.01rem) {
  body:has(.app-tabs .rail-only) { padding-left: 11.5rem; }
  .app-topnav .app-tabs { width: 11.5rem; gap: .15rem; padding: .75rem .5rem; }
  .app-topnav .app-tabs a, .app-topnav .app-tabs .rail-arb, .app-topnav .app-tabs .rail-user { flex-direction: row; justify-content: flex-start; align-items: center; gap: .85rem; min-height: 3rem; padding: 0 1rem; border-radius: 1.5rem; text-align: left; font: 600 1rem/1.1 var(--label); letter-spacing: .04em; }
  .app-topnav .app-tabs .tab-ic, .app-topnav .app-tabs .rail-arb .tab-ic { width: 1.5rem; height: 1.5rem; border-radius: 0; background: none !important; }
  .app-topnav .app-tabs a:hover .tab-ic, .app-topnav .app-tabs a[aria-current="page"] .tab-ic, .app-topnav .app-tabs .rail-arb.on .tab-ic { background: none !important; }
  /* hover and selection show once, on the whole row */
  .app-topnav .app-tabs a[aria-current="page"], .app-topnav .app-tabs .rail-arb.on { background-color: color-mix(in srgb, var(--sodium) 24%, transparent); color: var(--sodium); }
  .app-topnav .app-tabs a[aria-current="page"] .tab-ic { color: var(--sodium); }
  .app-topnav .app-tabs .rail-home { border-bottom: 0; border-radius: 1.5rem; margin-bottom: 0; padding-bottom: 0; }
  .app-topnav .app-tabs .rail-home + a { margin-top: .5rem; }
  .app-topnav .app-tabs .rail-user { margin-top: auto; border-top: 0; border-radius: 1.5rem; padding: 0 1rem; text-transform: none; font-size: 1rem; color: var(--ink); }
  .app-topnav .app-tabs .rail-user .avatar { width: 1.75rem; height: 1.75rem; font-size: .95rem; }
  .app-topnav .app-tabs .rail-user .tab-l { max-width: 6.5rem; }
  .app-topnav .app-tabs .app-badge { position: static; margin-left: auto; }
}
@media (min-width: 44.01rem) { .app-topnav .app-tabs .rail-user .tab-l { font-size: 1rem; } }

/* ================= Messages: who it is for is typed as @tags, with a suggestion list ================= */
.app-chat #msgform { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; }
.app-chat #msgform .app-toline { grid-column: 1 / -1; grid-row: 1; color: var(--muted); font: 500 .9rem var(--label); }
.app-chat #msgform .app-toline b { color: var(--sodium); font-weight: 700; }
.app-chat #msgform .app-body { grid-column: 1; grid-row: 2; }
.app-chat #msgform .pe-row button { grid-column: 2; grid-row: 2; align-self: end; }
.app-chat #msgform .app-msg { grid-column: 1 / -1; grid-row: 3; }
.mention-pop { position: absolute; z-index: 30; left: .5rem; right: .5rem; bottom: 100%; margin: 0 0 .25rem; padding: .25rem 0; list-style: none; max-height: 40vh; overflow-y: auto; border-radius: var(--md-shape-md); background: var(--md-surface-3); box-shadow: var(--md-elev-3); }
.mention-pop[hidden] { display: none; }
.mention-pop li { display: flex; align-items: baseline; gap: .75rem; min-height: var(--tap); padding: .5rem 1rem; align-items: center; cursor: pointer; }
.mention-pop li b { color: var(--sodium); font: 700 1.05rem var(--label); }
.mention-pop li small { color: var(--md-on-surface-variant); font: 500 .95rem var(--label); }
.mention-pop li[aria-selected="true"], .mention-pop li:hover { background: color-mix(in srgb, var(--sodium) 18%, transparent); }

/* ================= The rail collapses to icons and opens over the page on hover or focus ================= */
@media (min-width: 44.01rem) {
  body:has(.app-tabs .rail-only) { padding-left: 4.5rem; }
  .app-topnav .app-tabs { width: 4.5rem; overflow-x: hidden; transition: width var(--md-fast) var(--md-ease), box-shadow var(--md-fast); }
  .app-topnav .app-tabs:hover, .app-topnav .app-tabs:focus-within, .app-topnav .app-tabs.open { width: 11.5rem; box-shadow: var(--md-elev-3); }
  .app-topnav .app-tabs a, .app-topnav .app-tabs .rail-arb, .app-topnav .app-tabs .rail-user { padding: 0 .75rem; overflow: hidden; white-space: nowrap; }
  .app-topnav .app-tabs .tab-l { opacity: 0; transition: opacity var(--md-fast); }
  .app-topnav .app-tabs:hover .tab-l, .app-topnav .app-tabs:focus-within .tab-l, .app-topnav .app-tabs.open .tab-l { opacity: 1; }
  .app-topnav .app-tabs .tab-ic { flex: none; }
  .app-topnav .app-tabs a { position: relative; }
  .app-topnav .app-tabs .app-badge { position: absolute; top: .45rem; left: 1.7rem; margin: 0; min-width: 1rem; height: 1rem; padding: 0 .25rem; font-size: .7rem; line-height: 1rem; }
  .app-topnav .app-tabs:hover .app-badge, .app-topnav .app-tabs:focus-within .app-badge { position: static; margin-left: auto; height: auto; line-height: inherit; font-size: inherit; }
}
@media (prefers-reduced-motion: reduce) { .app-topnav .app-tabs, .app-topnav .app-tabs .tab-l { transition: none; } }

/* ================= Site admin, wider screens: the invite form on one tidy row ================= */
@media (min-width: 40.01rem) {
  #newinv.app-inline { display: grid; grid-template-columns: minmax(12rem, 2fr) 9rem 7rem auto; gap: 1rem; align-items: end; max-width: 52rem; }
  #newinv .pe-f { margin: 0; }
  #newinv input, #newinv input.sm { width: 100%; box-sizing: border-box; min-height: 3.5rem; }
  #newinv .pe-row { grid-column: auto; margin: 0; }
  #newinv .pe-row button { min-height: 3.5rem; white-space: nowrap; }
  #newinv .app-msg { grid-column: 1 / -1; margin: 0; }
  #invlist h3 { margin-top: 1.5rem; }
  .app-invs td.app-acts { text-align: right; color: var(--muted); }
}

/* the site admin pop-up: wide on a desktop, a full sheet on a phone */
.app-admindlg { width: min(64rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); overflow-y: auto; }
.app-admindlg section + section { margin-top: 1.5rem; }
.app-admindlg h2 { margin-top: 0; }
.app-admindlg .pe-row, .app-admindlg .app-form { background: none; }

/* ================= Triumphs: a card each, the leader up front, the field as bars ================= */
.app-triumphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.tri-card { display: grid; align-content: start; gap: .9rem; padding: 1.1rem 1.25rem 1.25rem; border-radius: var(--md-shape-lg, 1rem); background: var(--md-surface-1); border-top: 4px solid var(--tone, var(--sodium)); box-shadow: var(--md-elev-1); }
.tri-card header { display: flex; gap: .85rem; align-items: center; }
.tri-ic { flex: none; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: color-mix(in srgb, var(--tone, var(--sodium)) 22%, transparent); color: var(--tone, var(--sodium)); }
.tri-ic svg { width: 1.5rem; height: 1.5rem; }
.tri-card .tri-name { margin: 0; font: 700 1.15rem/1.15 var(--label); letter-spacing: .06em; text-transform: uppercase; }
.tri-card header small { display: block; margin-top: .15rem; color: var(--muted); font-size: .95rem; }
.tri-card.none { opacity: .85; }
.tri-card.none .tri-ic { background: var(--panel-2); color: var(--muted); }
.tri-lead { display: flex; align-items: center; gap: .85rem; padding: .75rem .9rem; border-radius: var(--md-shape-md); background: color-mix(in srgb, var(--tone, var(--sodium)) 14%, var(--panel)); }
.tri-pics { display: flex; flex: none; }
.tri-pic { display: block; width: 3rem; height: 3rem; margin-left: -.6rem; border: 2px solid var(--tone); border-radius: 50%; overflow: hidden; background: var(--tone); }
.tri-pic:first-child { margin-left: 0; }
.tri-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tri-pic .tri-dot { display: block; width: 100%; height: 100%; opacity: .6; }
.tri-lead > div { min-width: 0; display: grid; gap: .1rem; flex: 1; }
.tri-who { font: 700 1.2rem/1.15 var(--label); overflow-wrap: anywhere; }
.tri-lead small { color: var(--muted); font: 500 .9rem var(--label); text-transform: uppercase; letter-spacing: .06em; }
.tri-val { font: 700 2.2rem/1 var(--display); color: var(--ink); }
.tri-none { margin: 0; padding: .75rem .9rem; border-radius: var(--md-shape-md); background: var(--panel-2); color: var(--muted); font-family: var(--label); }
.tri-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.tri-bars li { display: grid; grid-template-columns: minmax(6rem, 38%) 1fr 2.5rem; align-items: center; gap: .6rem; }
.tri-bn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.tri-bar { height: .6rem; border-radius: .3rem; background: var(--panel-2); overflow: hidden; }
.tri-bar i { display: block; height: 100%; border-radius: .3rem; background: var(--tone, var(--sodium)); }
.tri-bars b { text-align: right; font-family: var(--label); }

/* the Territories page: each holder's gang picture (and the player's avatar) beside its name */
.app-tgh { display: flex; align-items: center; gap: .9rem; }
.app-tgh .app-tpic { width: 2.75rem; height: 2.75rem; margin-left: .4rem; }
.app-tgh .app-tpic > img, .app-tgh .app-tpic > .app-dot { width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; border: 2px solid var(--tone); box-sizing: border-box; }
.app-tgh .app-tpic > .app-dot { display: block; background: var(--tone); opacity: .6; }
.app-tgh .app-tpic > .avatar { background: var(--panel-2); }

/* gang pictures in lists and headings (shared/holders.js): small beside names, larger in the battle heading */
.app-gpic-sm, .app-gpic-md { position: relative; display: inline-block; flex: none; vertical-align: middle; margin-right: .5rem; }
.app-gpic-sm { width: 1.75rem; height: 1.75rem; margin-left: .35rem; }
.app-gpic-md { width: 2.75rem; height: 2.75rem; margin-left: .45rem; }
.app-gpic-sm > img, .app-gpic-sm > .app-dot, .app-gpic-md > img, .app-gpic-md > .app-dot { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--tone, var(--line)); box-sizing: border-box; }
.app-gpic-sm > .app-dot, .app-gpic-md > .app-dot { background: var(--tone); opacity: .6; }
.app-gpic-sm > .avatar { top: -.3rem; left: -.35rem; width: .95rem; height: .95rem; border-width: 1px; font-size: .5rem; }
.app-gpic-md > .avatar { top: -.35rem; left: -.4rem; width: 1.35rem; height: 1.35rem; border-width: 2px; font-size: .7rem; }
.app-gpic > .avatar img { border: 0; border-radius: 0; width: 100%; height: 100%; }
.app-withpic { display: inline-flex; align-items: center; }
/* a gang named with its picture: a pill with the picture inside at the start */
.app-withpic { gap: .1rem; padding: .15rem .8rem .15rem .15rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--tone, var(--line)) 55%, transparent); background: color-mix(in srgb, var(--tone, var(--line)) 14%, var(--panel)); text-decoration: none; }
a.app-withpic:hover { text-decoration: none; background: color-mix(in srgb, var(--tone, var(--line)) 24%, var(--panel)); }
.app-withpic > .app-gpic { margin-left: .2rem; margin-right: .45rem; }
.app-withpic > .app-gpic-md { margin-left: .2rem; }
.app-vsh { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem 0; }
.app-vsh small { margin: 0 .6rem; }
td.app-pname .pn { display: flex; align-items: center; gap: .75rem; }
td.app-pname .avatar { width: 2.25rem; height: 2.25rem; }
td.app-pname > span { min-width: 0; }
td.app-pname::before { content: none !important; }
td.app-pname { text-align: left !important; }

/* the chat composer starts beside the rail, and the rail (open or not) stays above it */
@media (min-width: 44.01rem) {
  body:has(.app-tabs .rail-only) .jump.app-topnav { z-index: 35; }
  body:has(.app-tabs .rail-only) .app-chat #msgform { left: 4.5rem; }
}


/* the account picture: a small trash circle at its bottom right removes it */
.app-avatarwrap { position: relative; flex: none; display: inline-block; line-height: 0; }
.pe .app-ident button.app-trashbtn, .app-ident button.app-trashbtn { position: absolute; right: -.25rem; bottom: -.25rem; width: 1.6rem; height: 1.6rem; min-height: 0 !important; min-width: 0; padding: 0 !important; display: grid; place-items: center; border: 2px solid var(--panel); border-radius: 50% !important; background: var(--panel-2) !important; background-image: none !important; color: #f59a7a; box-shadow: none; cursor: pointer; box-sizing: content-box; }
.app-trashbtn[hidden] { display: none !important; }
.app-trashbtn svg { width: .95rem; height: .95rem; }
.app-trashbtn:hover, .app-trashbtn:focus-visible { background: #7a1f1f !important; color: #fff; }
.app-btnic { width: 1.1em; height: 1.1em; margin-right: .4em; vertical-align: -.15em; }
.pe button#editmode { display: inline-flex; align-items: center; }

/* a fighter's tool row: the actions and the reorder arrows stay on one line */
.pe .app-ftools { flex-wrap: nowrap; gap: .15rem; align-items: center; }
.pe .app-ftools > button { padding-inline: .55rem !important; font-size: .95rem; white-space: nowrap; }
.pe .app-ftools .app-fmove { flex: none; gap: .1rem; }
.pe .app-ftools .app-fmove button { min-width: 2.25rem; padding-inline: 0 !important; }
.pe .app-ftools .app-fmove .pe-x { min-width: 2.25rem; }
@media (max-width: 21rem) { .pe .app-ftools { flex-wrap: wrap; } }   /* (only a very narrow phone wraps) */
.app-reply { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; width: 2rem; height: 2rem; padding: 0 !important; min-height: 2rem !important; min-width: 0 !important; border: 0 !important; background: none !important; color: var(--sodium) !important; box-shadow: none !important; font: 600 .9rem var(--label); cursor: pointer; border-radius: 1rem !important; }
.app-reply svg { width: 1.15rem; height: 1.15rem; }
.app-reply:hover, .app-reply:focus-visible { background: color-mix(in srgb, var(--sodium) 16%, transparent) !important; }
.app-msghead { width: 100%; }
.app-fold > summary small { margin-left: .5rem; color: var(--muted); font-weight: 500; }
.app-fold .app-newmelee { margin-top: .75rem; }
.app-fold .app-newmelee:not(:first-child) { padding-top: .75rem; border-top: 1px solid var(--line); }
.app-customfold > summary .app-foldh, #meleesec > summary .app-foldh { font-size: 1.6rem; }
.app-customfold, #meleesec { margin-bottom: 1.25rem; }
.app-sidepill { margin-left: .5rem; vertical-align: middle; align-self: center; font: 700 .8rem/1 var(--label); letter-spacing: .06em; text-transform: uppercase; padding: .25rem .55rem; border-radius: .8rem; }

/* campaign cards on the home page */
.app-ctile { display: grid; gap: .5rem; align-content: start; }
.app-ctile strong { font-size: 1.35rem; }
.ct-gang { display: flex; align-items: center; gap: .6rem; }
.ct-pic { flex: none; width: 2rem; height: 2rem; border-radius: 50%; overflow: hidden; border: 2px solid var(--tone, var(--line)); background: color-mix(in srgb, var(--tone, var(--line)) 55%, transparent); box-sizing: border-box; }
.ct-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ct-pic i { display: block; width: 100%; height: 100%; }
.ct-foot { display: flex; align-items: center; gap: .6rem; color: var(--muted); font: 600 .95rem var(--label); }
.ct-role { background: color-mix(in srgb, var(--sodium) 22%, transparent) !important; color: var(--sodium) !important; border: 0; text-transform: uppercase; letter-spacing: .06em; padding: .2rem .6rem; border-radius: .8rem; }

/* Order and Chaos: two equal, fixed-width pills; "Ascendant" on the side that has it, "Next cycle" on the side that will (post-cycle) */
.app-ascend { display: grid !important; grid-template-columns: repeat(2, minmax(0, 13rem)); gap: .6rem; justify-content: start; align-items: stretch; }
.asc-pill { display: grid !important; grid-template-columns: auto 1fr; grid-template-areas: "n name" "tags tags"; align-items: baseline; column-gap: .5rem; row-gap: .3rem; min-height: 4.4rem; width: auto; box-sizing: border-box; }
.asc-pill b { grid-area: n; }
.asc-pill > span:not(.asc-tags) { grid-area: name; }
.asc-pill .asc-tags { grid-area: tags; display: flex; flex-wrap: wrap; gap: .25rem; min-height: 1.1rem; }
.asc-pill .asc-tags small { flex-basis: auto; padding: .1rem .45rem; border-radius: .6rem; font-size: .68rem; line-height: 1.1; }
.asc-pill .asc-tags .is-now { background: var(--tone); color: #0d1417; }
.asc-pill .asc-tags .is-next { border: 1px solid var(--tone); color: var(--tone); }
.asc-pill.next:not(.now) { border-color: color-mix(in srgb, var(--tone) 55%, transparent); border-style: dashed; }
@media (max-width: 44rem) { .app-ascend { grid-template-columns: 1fr 1fr; } }
.asc-pill.now { border-style: solid !important; }
.app-actdet { padding: .75rem 1rem 1rem; margin-bottom: .6rem; border-radius: var(--md-shape-md); background: var(--md-surface-1); display: grid; gap: .5rem; }
.app-actdet h3 { margin: 0; }

/* fold headings on the battle page are headings, not billboards */
.app-fold > summary .app-foldh { font-size: 1.6rem; }
.app-gamefold > summary small { color: var(--muted); }
.app-wrapup { margin: 1rem 0; }
.app-wrapup h3 { margin: 0 0 .25rem; }
.app-needs { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .6rem .8rem; border-radius: var(--md-shape-md); background: color-mix(in srgb, #c0432e 18%, var(--panel)); border-left: 4px solid #c0432e; }

/* equipment locked to a fighter type: marked in the pick list */
.app-picklist li.is-locked button { border-left: 4px solid var(--sodium); background: color-mix(in srgb, var(--sodium) 10%, var(--panel)); }
.app-lockbadge { display: inline-block; margin-left: .5rem; padding: .05rem .5rem; border-radius: .6rem; background: var(--sodium); color: var(--on-sodium); font: 700 .75rem var(--label); letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }
.app-builtin { color: var(--muted); font: 600 .75rem var(--label); text-transform: uppercase; letter-spacing: .06em; margin-left: auto; padding-right: .5rem; }

/* rolled or set by hand, on Starting Territories and Gang Tactics: set by hand is red, so the Arbitrator sees it when approving */
.app-set.hand { color: #f59a7a; background: color-mix(in srgb, #c0432e 22%, var(--panel)); border: 1px solid #c0432e; font-family: var(--label); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.tac-ic { background: none !important; border: 0 !important; padding: 0 !important; }
.tac-ic:empty::before { margin-right: 0; }
.app-pill.by-hand { border-color: #c0432e; color: #f59a7a; }
.app-terrcard header .app-dice, .app-terrcard header .app-set { margin-left: .75rem; align-self: center; }
.app-xpextras { display: grid; gap: .25rem; padding: .5rem .75rem; border-radius: var(--md-shape-md); background: color-mix(in srgb, var(--sodium) 10%, var(--panel)); }
.app-xpextras small { color: var(--muted); font: 600 .85rem var(--label); }
.app-needlist.ok { border-left-color: #4a8; background: color-mix(in srgb, #4a8 10%, var(--panel)); }
.app-ransomrow, .app-escaperow { margin: .25rem 0; }
.app-escaperow.done { background: none; border-left-color: transparent; padding-left: 0; }
.app-needlist { display: grid; gap: .5rem; margin: .75rem 0; padding: .75rem 1rem; border-radius: var(--md-shape-md); background: color-mix(in srgb, #c0432e 14%, var(--panel)); border-left: 4px solid #c0432e; }
.app-needlist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.app-needlist .app-linkbtn { background: none !important; border: 0 !important; padding: 0 !important; min-height: 0 !important; color: var(--sodium); font: 700 1rem var(--label); text-decoration: underline; cursor: pointer; box-shadow: none !important; }
.app-needlist .app-needs { background: none; border-left: 0; padding: .25rem 0; }
.app-needlist .app-ransomrow { margin-left: 1rem; padding: .5rem .75rem; background: color-mix(in srgb, #c0432e 14%, var(--panel)); border-left: 4px solid #c0432e; border-radius: var(--md-shape-md); }
.app-cyc-d small { font-size: .55em; color: var(--muted); font-family: var(--label); letter-spacing: .06em; text-transform: uppercase; margin-left: .5rem; }
.app-ransomrow { flex-wrap: wrap; justify-content: flex-start; gap: .5rem .75rem; }
.app-ransomrow > span:first-of-type { flex-basis: 100%; }
.app-ransomrow .app-ransomamt { margin-right: auto; }
/* one box, not boxes in boxes: the rows inside the "Captured fighters" block carry no box of their own */
.app-needlist .app-ransomrow, .app-needlist .app-escaperow { margin: .25rem 0 0; padding: 0; background: none; border: 0; border-radius: 0; }
.app-needlist li + li { border-top: 1px solid color-mix(in srgb, #c0432e 35%, transparent); padding-top: .5rem; }
.app-needlist .app-ransomrow.done { opacity: .85; }
.app-ransomrow .app-ransomnote { flex-basis: 100%; color: var(--muted); }
.app-bstate { margin-left: .5rem; color: var(--muted); }
.app-battlelink { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .1rem 0; }
.app-battlelink small { margin: 0 .5rem; }
.app-ransomrow.done { align-items: center; }
.app-ransomrow.done .pe-add { margin-left: auto; }
/* a Territory chip opens its details */
.app-terrbtn { display: inline; padding: 0 !important; min-height: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; color: inherit; font: inherit; text-decoration: underline dotted; cursor: pointer; border-radius: 0 !important; }
.app-terrinfo .app-tags { display: flex; gap: .5rem; align-items: center; margin: .25rem 0 .75rem; }
.app-terrinfo .app-tline { margin: .4rem 0; }
/* Credits, Meat and Scavenging: three equal columns */
.app-incsum.app-3col { table-layout: fixed; width: 100%; }
.app-incsum.app-3col th.app-num, .app-incsum.app-3col td.app-num { width: 7.5rem; text-align: right; white-space: nowrap; }
@media (max-width: 40rem) { .app-incsum.app-3col th.app-num, .app-incsum.app-3col td.app-num { width: 4.75rem; } }
.app-battlelink .app-gname, .app-battlelink .app-gname:hover { text-decoration: none; }
.app-battlelink .app-withpic:first-child { margin-left: .3rem; }
/* a Territory chip: the name in white, its tags (Ruined, Hideout) in grey */
.app-pill .app-terrbtn { color: var(--ink) !important; }
.app-pill > small { color: var(--muted); font-weight: 500; }
.app-pill.app-ruined .app-terrbtn { color: var(--ink) !important; }
/* Venator Skill Access: the four ranks side by side */
.app-ranks { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .5rem .8rem; }
.app-ranks > legend, .app-ranks > p { grid-column: 1 / -1; }
/* the pop-ups for equipment and skills: the title, the close button and what's chosen stay at the top while the list scrolls */
.app-sticktop { position: sticky; top: -1.25rem; z-index: 5; margin: -1.25rem -1.25rem .6rem; padding: 1.25rem 1.25rem .5rem; background: var(--panel); border-bottom: 1px solid var(--line); max-height: 45vh; overflow-y: auto; }
.app-sticktop .app-headrow { margin-bottom: .25rem; }
/* a skill or item in the pick list: its tooltip term stays inline with the number */
.app-picklist button > span { display: grid; gap: .1rem; }
.app-picklist span.sk { display: inline; }
/* the equipment, skill and other pick-list pills: rounded, but not fully */
.pe .app-picklist button:not(.fname), .app-dialog .app-picklist button { border-radius: 12px !important; }
/* a price (and Trade Points) never wraps its digits */
.app-picklist button > em, .app-pickcols em { white-space: nowrap; flex: none; }
.app-pickcols { flex: none; }
/* a compact top for the equipment and skill pop-ups: it stays on screen while the list scrolls, so it must not take the screen */
.app-sticktop { padding: .5rem 1.25rem .35rem; max-height: 30vh; }
.app-sticktop .app-headrow { align-items: center; margin: 0 0 .15rem; gap: .5rem; }
.app-sticktop .app-headrow h2 { font-size: 1.15rem !important; line-height: 1.1; margin: 0; }
.app-sticktop .app-headrow .pe-x, .pe .app-sticktop .app-headrow button.pe-x { width: 2.25rem; height: 2.25rem; min-width: 2.25rem !important; min-height: 2.25rem !important; padding: 0 !important; }
.app-sticktop h3 { font-size: .75rem; margin: .25rem 0 .15rem; letter-spacing: .06em; }
.app-sticktop .app-gear { margin: 0 0 .15rem; gap: .2rem; }
.app-sticktop .app-gear li { font-size: .8rem; }
.pe .app-sticktop .app-gear li button.pe-x { min-width: 1.7rem !important; min-height: 1.7rem !important; width: 1.7rem; height: 1.7rem; }
.app-sticktop .pe-note { margin: .1rem 0; font-size: .8rem; }
.app-sticktop .app-gear li button svg { width: 1rem !important; min-width: 1rem; height: 1rem; flex: none; }
/* the gang's action row stays on one line on a phone: Delete gang becomes a trash button, and the Rating line goes underneath */
.app-sticky #delete svg, .app-sticky #mmtoggle svg { width: 1.15rem; height: 1.15rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pe .app-sticky #delete, .pe .app-sticky #mmtoggle { display: inline-flex; align-items: center; gap: .4rem; }
/* the Arbitrator's review row: Delete is just the icon */
.pe .app-sticky #delete.icononly { padding-inline: 0; width: var(--tap); min-width: var(--tap); justify-content: center; }
.app-sticky #delete.icononly .lbl { display: none; }
@media (max-width: 44rem) {
  .pe .app-sticky { flex-wrap: wrap; gap: .4rem; justify-content: space-between; align-items: center; }   /* the buttons share the row, the trash button at the right */
  .pe .app-sticky > button, .pe .app-sticky > a { flex: none; padding-inline: 1rem; }
  .pe .app-sticky #delete.icononly { padding-inline: 0; }
  .app-sticky .pe-sum { flex: 1 0 100%; margin: 0; }
}
#savest:empty + .app-sep { display: none; }
/* the import button on the gang's action row: an icon, like the trash one */

.app-import[hidden] { display: none !important; }
.app-importhead { margin: 0 0 .5rem; }
/* a fighter's tool row stays on one line on a phone: compact text buttons and arrows */
@media (max-width: 44rem) {
  .pe .app-ftools > button { padding-inline: .4rem !important; font-size: .9rem; }
  .pe .app-ftools .app-fmove button { min-width: 2rem; }
  .pe .app-ftools .app-fmove .pe-x { min-width: 2.25rem; width: 2.25rem; height: 2.25rem; }
}
/* the Arbitrator's review row on a phone: Import, Delete (icon), Send back and Approve share one line */
.app-brk { display: none; }
@media (max-width: 44rem) {
  .pe .app-sticky:has(#approve) { flex-wrap: wrap; gap: .25rem; }
  .pe .app-sticky:has(#approve) > button { padding-inline: .7rem !important; }
  .pe .app-sticky:has(#approve) #delete.icononly { padding-inline: 0 !important; }
  .app-sticky #editbtns { order: 0; }
  .app-sticky #mmtoggle { order: 1; }
  .app-sticky #withdraw, .app-sticky #submit { order: 2; }
  .app-sticky #back { order: 3; }
  .app-sticky #approve { order: 4; }
  .app-sticky #delete { order: 6; }
  .app-sticky .pe-sum { order: 7; }
}

/* sticky bars inside dialogs take the dialog's own surface (not the older panel colour) */
.app-dialog .pe-row, .app-dialog .app-sticktop, dialog.app-equipdlg .app-sticktop { background: var(--md-surface-3) !important; }
.app-dialog .app-card2 .pe-row { background: none !important; }

/* the campaign's details: one card, rows divided by hairlines, little space under it */
.app-factcard { background: var(--md-surface-2, var(--panel)); border-radius: 12px; padding: .15rem 1rem; margin-bottom: .75rem; }
.app-factcard .app-facts { margin: 0 !important; }
.app-factcard .app-facts tr { background: none !important; border-radius: 0 !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; padding: .6rem 0 !important; }
.app-factcard .app-facts tr:last-child { border-bottom: 0 !important; }

/* the search box in a pop-up's fixed header is compact */
.pe .app-sticktop input[type=search] { min-height: 2.5rem !important; padding-block: 0 !important; margin: .2rem 0 .1rem; }

/* a Territory's own Roll button is part of its card, not the dialog's pinned action row */
.app-dialog .app-terrcard .pe-row { position: static !important; background: none !important; padding-block: 0 !important; }

/* a Territory's or Hideout's name: click to rename */
.pe .app-terrname { cursor: pointer; text-decoration: underline dotted; text-underline-offset: .25em; }
.pe .app-terrname:focus-visible { outline: 2px solid var(--sodium); outline-offset: 3px; }
.pe .app-terrrename { width: 100%; font: inherit; text-transform: none; }

/* the gang card's actions: Add fighter on its own line, then Tactics / Territories / Stash as three equal tiles */
.pe .app-gangbar { display: grid; gap: .75rem; margin-top: .5rem; }
.pe button.app-addfighter { width: 100%; min-height: 3.25rem; }
.pe .app-gtiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.pe button.app-gtile { display: grid !important; gap: .1rem; align-content: center; justify-items: start; text-align: left; min-height: 4rem !important; padding: .6rem .75rem !important; border: 1px solid var(--line) !important; border-radius: 12px !important; background: var(--md-surface-2, var(--panel-2)) !important; color: var(--ink) !important; box-shadow: none !important; }
.pe button.app-gtile small { font: 600 .78rem var(--label); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pe button.app-gtile b { font: 700 1.5rem/1.1 var(--label); color: var(--sodium); }
.pe button.app-gtile b i { font: 600 .9rem var(--label); font-style: normal; color: var(--muted); }
.pe button.app-gtile:hover, .pe button.app-gtile:focus-visible { border-color: var(--sodium) !important; }
@media (max-width: 21rem) { .pe .app-gtiles { grid-template-columns: 1fr 1fr; } }
.pe button.app-gtile b.app-over { color: var(--md-error, #ff8a7a); }

/* the Challenge order: a numbered card per gang, its name with the move arrows beside it, its state under it, and its actions in a row */
.app-order li { display: grid !important; grid-template-columns: 2rem minmax(0, 1fr) !important; gap: .15rem .6rem !important; padding: .7rem .8rem !important; border-radius: 12px; }
.app-order li::before { grid-row: 1 / span 3 !important; align-self: start; padding-top: .15rem; }
.app-order .app-ohead { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-width: 0; }
.app-order .app-oname { min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: .1rem .5rem; }
.app-order .app-omove { display: flex; gap: .25rem; flex: none; }
.app-order .app-omove button { min-width: 2.75rem; min-height: 2.5rem; padding: 0 .5rem; }
.app-order .app-ostate { grid-column: 2; }
.app-order .app-oacts { grid-column: 2 !important; grid-row: auto !important; display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; justify-content: flex-start !important; }
.app-order .app-oacts button { min-height: 2.5rem; padding: 0 .9rem; }

.pe .app-order .app-omove button, .pe .app-order .app-oacts button { min-width: 0 !important; border: 1px solid var(--line) !important; border-radius: 999px !important; background: var(--md-surface-2, var(--panel-2)) !important; }
.pe .app-order .app-omove button { width: 2.5rem; padding: 0 !important; }
.pe .app-order .app-oacts button { padding: 0 1rem !important; }

/* no divider line above the new-multiplayer-battle form when there is nothing listed before it */
#melees:empty + .app-newmelee { border-top: 0 !important; padding-top: 0 !important; }

/* Skip / Challenge / Pass on one line, across the whole card */
.app-order .app-oacts { grid-column: 1 / -1 !important; flex-wrap: nowrap !important; }
.pe .app-order .app-oacts button { flex: 1 1 0; padding: 0 .5rem !important; white-space: nowrap; }
.pe .app-order .app-oacts button { max-width: 9rem; }
.pe .app-order .app-omove button, .pe .app-order .app-oacts button { border: 0 !important; }

/* the Arbitrator adding a Territory to a running gang */
.pe .app-addterr { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }
.pe .app-addterr input { flex: 1 1 auto; min-width: 0; }
.pe .app-fpick { gap: .4rem; } .pe .app-fpick button { flex: 1 1 auto; padding: 0 .6rem; }

/* the player's avatar on a gang tile sits at the same place on the picture as it does on the gang sheet (same proportions) */
.app-gangtile .app-gpic > .avatar { top: -.36rem; left: -.36rem; width: 1.1rem; height: 1.1rem; font-size: .6rem; }

.app-next a .app-gname, .app-next .app-gname { text-decoration: none; }
.app-next .app-gname.app-withpic { display: inline-flex; align-items: center; }

/* a next step: the gang pill(s) on a line of their own, then the context */
.app-next .app-npills { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .1rem; margin-bottom: .3rem; }
.app-next .app-nv { color: var(--muted); font-family: var(--label); padding: 0 .3rem; }
.app-next .app-nyour { font: 700 1.05rem var(--label); color: var(--sodium); padding: .15rem .3rem; }
.app-next a.app-gname { color: var(--tone, var(--ink)); }

/* Accept and Decline side by side */
.pe .app-answer { flex-wrap: nowrap; }
.pe .app-answer button { flex: 1 1 0; min-width: 0; }
.pe .app-answer button.app-cancelch { flex: none; width: 3rem; min-width: 0; padding: 0; }

/* a challenge card with a battle opens it; pills are links to their gang */
.app-list li[data-go] { cursor: pointer; }
.app-list li[data-go]:hover { background: color-mix(in srgb, var(--panel) 92%, var(--ink)); }
a.app-gname { text-decoration: none; }

/* past battles: the side pill lines up with the gang pills */
.app-list li > p.app-hist { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .4rem; }
.app-hist .app-sidepill { align-self: center; margin: 0; }

/* the Resources report */
.app-rstats { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.app-rstat { display: grid; gap: .05rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--md-surface-2, var(--panel)); }
.app-rstat small { font: 600 .78rem var(--label); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.app-rstat b { font: 700 1.6rem/1.1 var(--label); color: var(--sodium); }
.app-rstat span { color: var(--muted); font-size: .85rem; min-height: 1em; }
.app-rblock { margin: .75rem 0; }
.app-rblock h4 { margin: 0 0 .3rem; }
.app-rblock .pe-t { width: 100%; }
.app-rblock .app-rhead th { text-align: left; color: var(--muted); font: 600 .78rem var(--label); letter-spacing: .06em; text-transform: uppercase; }
.app-rblock td:last-child { text-align: right; font-family: var(--label); font-weight: 700; }
.app-rblock .app-rtot td { border-top: 1px solid var(--line); font-weight: 700; }
.app-rvals { list-style: none; margin: .3rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem .8rem; }
.app-rlist { list-style: none; margin: 0; padding: 0; display: grid; }
.app-rlist li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.app-rlist li b { font-family: var(--label); font-weight: 700; }
.app-rlist .app-rhead { color: var(--muted); font: 600 .78rem var(--label); letter-spacing: .06em; text-transform: uppercase; border-bottom: 0; padding-bottom: 0; }
.app-rlist .app-rtot { font-size: 1rem; border-top: 2px solid var(--line); border-bottom: 0; font-weight: 700; }

/* a recruit on the phone is a card, not a row of a wide table */
@media (max-width: 44rem) {
  .app-reccards, .app-reccards tbody { display: block; width: 100%; }
  .app-reccards thead { display: none; }
  .app-reccards tr:has(> td[data-label]) { display: grid; gap: .6rem; position: relative; margin: 0 0 .8rem; padding: .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--md-surface-2, var(--panel)); }
  .app-reccards td { display: block; padding: 0 !important; border: 0 !important; }
  .app-reccards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: .2rem; color: var(--muted); font: 600 .78rem var(--label); letter-spacing: .06em; text-transform: uppercase; }
  .app-reccards td.app-recx { position: absolute; top: .5rem; right: .5rem; }
  .app-reccards td select, .app-reccards td input { width: 100%; }
}
@media (max-width: 44rem) { .app-reccards td[data-label]:first-child { padding-right: 3.6rem !important; } .app-reccards td.app-recx { top: 1.9rem; right: .8rem; } }
/* the Resources lists: plain rows, a straight rule above the total, label and figure on one line */
.app-rlist li, .app-rlist li.app-rtot { border-radius: 0 !important; align-items: center; }
.app-rlist li.app-rtot { margin-top: .35rem; padding: .5rem 0 0 !important; border-top: 2px solid var(--line) !important; border-bottom: 0 !important; font: 700 .85rem var(--label); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.app-rlist li.app-rtot b { font-size: 1.25rem !important; color: var(--sodium); letter-spacing: 0; }
.app-rlist li.pe-note { display: block; border-bottom: 0; margin: 0; }
/* Resources: tighter gaps between the tiles, the lists and the gangs */
.app-rgang > summary { margin-bottom: .4rem; min-height: 0; }
.app-rgang .app-rstats { margin: .3rem 0 .5rem; gap: .4rem; }
.app-rblock { margin: .4rem 0 !important; }
.app-rblock h4 { margin: 0 0 .15rem; }
.app-rlist li { padding: .25rem 0; }
.app-rlist li.pe-note { padding: 0 !important; }
/* the Mutations (and other options) in the Add fighter pop-up: one tidy row each, the box beside its name */
#addfdlg .app-skillpick { display: grid; gap: .25rem; margin: .5rem 0; }
#addfdlg .app-skillpick > .app-badge, #addfdlg .app-skillpick > small { justify-self: start; }
#addfdlg .app-skillpick .pe-check { display: flex !important; align-items: center; gap: .7rem; width: 100%; margin: 0; padding: .35rem 0; min-height: 2.5rem; white-space: normal; }
#addfdlg .app-skillpick .pe-check input[type=checkbox] { flex: none; margin: 0; }
#addfdlg .app-skillpick .pe-check > span { flex: 1; min-width: 0; }
