/* =============================================================================
 * Stash — pixel.css   (owner: Art)
 * Fonts, palette variables, the pixel base reset, and the UI kit components.
 * NO page layout here (that's css/layout.css).
 *
 * The 9-slice images come from Art.init() as CSS variables (--img-panel, …).
 * Before Art.init() runs, or if it fails, every component falls back to flat
 * palette colours and still reads correctly.
 *
 * Sizes follow the art doc: 1 HUD art px = 2 CSS px; fonts only at
 * 16 / 24 / 32 / 48 px; spacing on an 8 px grid; no border-radius, no blur.
 *
 * Components and their markup
 *   .px-panel            any block. .px-well = sunken variant. .px-eyebrow = label on top.
 *   .px-btn              <button class="px-btn [primary|danger] [icon] [block]">
 *                        states: :hover (hover devices) / .is-hover, :active / .is-pressed /
 *                        [aria-pressed=true], :disabled / [aria-disabled=true]
 *                        icon: <span class="px-icon i-menu"></span> inside the button
 *                        height: --px-btn-h (40px; 48px under 600px wide or data-layout=phone*)
 *   .px-pill             <span class="px-pill raid|used|gain|loss|info|amber">
 *   .px-chip             <span class="px-chip p1"></span>  player chip (22, .lg 44, .xl 66)
 *   .px-toggle           <button class="px-toggle" role="switch" aria-checked="false">Label</button>
 *                        draws the track + knob + ON/OFF word after the label
 *   .px-slider           <input type="range" class="px-slider" min="0" max="10" step="1">
 *                        fill follows --fill (Art keeps it in sync on input; call
 *                        Art.syncSlider(el) after setting .value from code)
 *   .px-scrim            full-screen dim behind a modal (.solid = 100% ink for pass-and-play)
 *   .px-modal            dialog box: .px-modal-title, .px-modal-body, .px-modal-actions
 *   .px-toast            .good | .bad | .info (default) ; .from-top to slide down instead of up
 *   .px-tooltip          .below puts the notch on top; --notch-x moves the notch (default 16px)
 *   .px-tabs > .px-tab   <button class="px-tab" role="tab" aria-selected="true">
 *   .px-card             parchment stash card; .px-card.back = hidden card back
 *   .px-progress > i     bot-thinking segments; i.on = lit
 *   .px-icon.i-<name>    18x18 icon (.x2 = 36x36): raid raid-red card menu sound-on sound-off
 *                        music music-off settings help close back play pause eye
 *                        eye-off check star dawn
 *   fonts                .px-display .px-ui .px-body  +  .px-16 .px-24 .px-32 .px-48
 *   colour               .px-muted .px-strong .px-amber .px-ok .px-warn .px-off
 *   misc                 .px-sprite (pixelated img/canvas), .px-sr (visually hidden),
 *                        .px-noselect
 * Root switches (on <html>):
 *   data-plain-text      body font becomes the system UI font (accessibility option)
 *   data-motion="reduced" kills component animations (also follows the OS setting)
 * ========================================================================== */

/* ------------------------------------------------------------------ fonts -- */
/* Google Fonts are linked from index.html. Offline: a system monospace,
   shrunk so line lengths stay close to Tiny5; labels are uppercase so the
   fallback looks like Silkscreen. */
@font-face {
  font-family: "Stash Fallback";
  src: local("Menlo"), local("Consolas"), local("DejaVu Sans Mono"), local("Roboto Mono"), local("Courier New");
  size-adjust: 82%;
}

:root {
  --font-display: "Press Start 2P", "Silkscreen", "Stash Fallback", ui-monospace, monospace;
  --font-ui: "Silkscreen", "Stash Fallback", ui-monospace, monospace;
  --font-body: "Tiny5", "Stash Fallback", ui-monospace, monospace;

  /* Endesga 32 — every colour on screen is one of these */
  --c-ink: #181425;          --c-quay: #262b44;        --c-slate: #3a4466;
  --c-steel: #5a6988;        --c-fog: #8b9bb4;         --c-mist: #c0cbdc;
  --c-white: #ffffff;
  --c-copper-dark: #733e39;  --c-copper: #b86f50;      --c-copper-light: #e4a672;
  --c-parchment: #ead4aa;
  --c-gold-dark: #f77622;    --c-gold: #feae34;        --c-gold-light: #fee761;
  --c-amber: #feae34;
  --c-uranium-dark: #265c42; --c-uranium: #3e8948;     --c-uranium-light: #63c74d;
  --c-ok: #63c74d;
  --c-danger-dark: #a22633;  --c-danger: #e43b44;      --c-alarm: #ff0044;
  --c-p1-dark: #124e89;      --c-p1: #0099db;          --c-p2: #f6757a;
  --c-p3: #2ce8f5;           --c-p4: #b55088;          --c-p4-dark: #68386c;
  --c-pink: #f6757a;
  --c-crate: #3e2731;        --c-rust: #be4a2f;        --c-rust-light: #d77643;
  --c-skin: #e8b796;         --c-skin-dark: #c28569;   --c-teal: #193c3e;
  --c-scrim: rgba(24, 20, 37, 0.8);

  --u: 2px;                 /* one HUD art px */
  --px-btn-h: 40px;
}
@media (max-width: 599px) { :root { --px-btn-h: 48px; } }
:root[data-layout="phone"], :root[data-layout="phone-land"] { --px-btn-h: 48px; }
:root[data-layout="desk"], :root[data-layout="tablet"] { --px-btn-h: 40px; }

:root[data-plain-text] {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html { color-scheme: dark; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-ink);
  color: var(--c-mist);
  font: 16px/24px var(--font-body);
  -webkit-font-smoothing: none;      /* macOS: hard-edged pixel fonts */
  -moz-osx-font-smoothing: unset;
  font-smooth: never;
  text-rendering: optimizeSpeed;
  font-synthesis: none;
  font-kerning: none;
  -webkit-tap-highlight-color: transparent;
}
:root[data-plain-text] body { -webkit-font-smoothing: auto; }

canvas, img, .px-sprite {
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -webkit-user-drag: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
input[type="text"], textarea { font-size: 16px; }   /* no iOS focus zoom */

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--c-white); outline-offset: 2px; }

.px-noselect, .px-btn, .px-tab, .px-pill, .px-chip, .px-toggle, .px-eyebrow, .px-progress {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.px-sr {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------- font utilities -- */
.px-display {
  font-family: var(--font-display); font-weight: 400;
  font-size: 16px; line-height: 24px; letter-spacing: 0;
  text-transform: uppercase; color: var(--c-white);
  text-shadow: 0 2px 0 var(--c-ink);
}
.px-ui {
  font-family: var(--font-ui); font-weight: 400;
  font-size: 16px; line-height: 16px; letter-spacing: 0;
  text-transform: uppercase;
}
.px-body {
  font-family: var(--font-body); font-weight: 400;
  font-size: 16px; line-height: 24px; letter-spacing: 0;
}
.px-16 { font-size: 16px; }
.px-24 { font-size: 24px; }
.px-32 { font-size: 32px; }
.px-48 { font-size: 48px; }
.px-display.px-16 { line-height: 24px; text-shadow: 0 2px 0 var(--c-ink); }
.px-display.px-24 { line-height: 32px; text-shadow: 0 3px 0 var(--c-ink); }
.px-display.px-32 { line-height: 40px; text-shadow: 0 4px 0 var(--c-ink); }
.px-display.px-48 { line-height: 56px; text-shadow: 0 6px 0 var(--c-ink); }
.px-ui.px-16 { line-height: 16px; }
.px-ui.px-24 { line-height: 24px; }
.px-ui.px-32 { line-height: 32px; }
.px-ui.px-48 { line-height: 48px; }
.px-body.px-16 { line-height: 24px; }
.px-body.px-24 { line-height: 32px; }
.px-body.px-32 { line-height: 40px; }
.px-body.px-48 { line-height: 56px; }
.px-bold { font-weight: 700; }

.px-muted  { color: var(--c-fog); }
.px-strong { color: var(--c-white); }
.px-amber  { color: var(--c-amber); }
.px-ok     { color: var(--c-ok); }
.px-warn   { color: var(--c-pink); }     /* danger TEXT (red fails contrast as small text) */
.px-off    { color: var(--c-steel); }    /* disabled / decoration only */

/* ------------------------------------------------------------------ icons -- */
.px-icon {
  display: inline-block; flex: none;
  width: 18px; height: 18px;
  background: var(--icon) 0 0 / 100% 100% no-repeat;
  image-rendering: crisp-edges; image-rendering: pixelated;
  vertical-align: middle;
}
.px-icon.x2 { width: 36px; height: 36px; }
.px-icon.i-raid      { --icon: var(--icon-raid); }
.px-icon.i-raid-red  { --icon: var(--icon-raid-red); }
.px-icon.i-card      { --icon: var(--icon-card); }
.px-icon.i-menu      { --icon: var(--icon-menu); }
.px-icon.i-sound-on  { --icon: var(--icon-sound-on); }
.px-icon.i-sound-off { --icon: var(--icon-sound-off); }
.px-icon.i-music     { --icon: var(--icon-music); }
.px-icon.i-music-off { --icon: var(--icon-music-off); }
.px-icon.i-settings  { --icon: var(--icon-settings); }
.px-icon.i-help      { --icon: var(--icon-help); }
.px-icon.i-close     { --icon: var(--icon-close); }
.px-icon.i-back      { --icon: var(--icon-back); }
.px-icon.i-play      { --icon: var(--icon-play); }
.px-icon.i-pause     { --icon: var(--icon-pause); }
.px-icon.i-eye       { --icon: var(--icon-eye); }
.px-icon.i-eye-off   { --icon: var(--icon-eye-off); }
.px-icon.i-check     { --icon: var(--icon-check); }
.px-icon.i-star      { --icon: var(--icon-star); }
.px-icon.i-dawn      { --icon: var(--icon-dawn); }

/* ---------------------------------------------------------------- panels -- */
.px-panel, .px-well {
  display: block;
  border: 8px solid var(--c-quay);
  border-image-source: var(--img-panel);
  border-image-slice: var(--px-slice) fill;
  border-image-width: 8px;
  border-image-repeat: stretch;
  background: var(--c-quay) padding-box;
  padding: 8px;
  box-shadow: 0 4px 0 var(--c-ink);
  color: var(--c-mist);
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-well {
  border-color: var(--c-ink);
  border-image-source: var(--img-well);
  box-shadow: none;
}
.px-eyebrow {
  display: block;
  margin: 0 0 8px;
  font: 16px/16px var(--font-ui);
  text-transform: uppercase;
  color: var(--c-fog);
}

/* --------------------------------------------------------------- buttons -- */
.px-btn, .px-tab {
  -webkit-appearance: none; appearance: none;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 96px; height: var(--px-btn-h);
  margin: 0;
  padding: 0 8px 4px;             /* + 8px border = 16px side padding; 4px bottom = the lip */
  border: 8px solid var(--c-slate);
  border-bottom-color: var(--c-quay);
  border-image-source: var(--img-btn);
  border-image-slice: var(--px-slice) fill;
  border-image-width: 8px;
  border-image-repeat: stretch;
  background: var(--c-slate) padding-box;
  box-shadow: 0 4px 0 var(--c-ink);
  color: var(--c-white);
  font: 16px/16px var(--font-ui);
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-btn > *, .px-tab > * { pointer-events: none; }
/* .is-hover = the same look on demand (keyboard/board cursor, demos) */
.px-btn.is-hover:not(:disabled), .px-tab.is-hover:not([aria-selected="true"]) {
  border-image-source: var(--img-btn-hover); border-color: var(--c-steel); background-color: var(--c-steel);
}
@media (hover: hover) {
  .px-btn:hover:not(:disabled):not([aria-disabled="true"]),
  .px-tab:hover:not([aria-selected="true"]):not(:disabled) {
    border-image-source: var(--img-btn-hover);
    border-color: var(--c-steel);
    background-color: var(--c-steel);
  }
}
.px-btn:active:not(:disabled):not([aria-disabled="true"]),
.px-btn.is-pressed, .px-btn[aria-pressed="true"],
.px-tab:active:not(:disabled) {
  border-image-source: var(--img-btn-pressed);
  padding-top: 4px; padding-bottom: 0;       /* the label drops with the face */
  box-shadow: none;
}
.px-btn:disabled, .px-btn[aria-disabled="true"], .px-tab:disabled {
  border-image-source: var(--img-btn-disabled);
  border-color: var(--c-quay);
  background-color: var(--c-quay);
  color: var(--c-steel);
  box-shadow: none;
  cursor: default;
}

/* primary (amber) */
.px-btn.primary {
  border-color: var(--c-amber);
  border-bottom-color: var(--c-gold-dark);
  border-image-source: var(--img-btn-primary);
  background-color: var(--c-amber);
  color: var(--c-ink);
  font-weight: 700;
}
.px-btn.primary.is-hover:not(:disabled) { border-image-source: var(--img-btn-primary-hover); border-color: var(--c-gold-light); background-color: var(--c-gold-light); }
@media (hover: hover) {
  .px-btn.primary:hover:not(:disabled):not([aria-disabled="true"]) {
    border-image-source: var(--img-btn-primary-hover);
    border-color: var(--c-gold-light);
    background-color: var(--c-gold-light);
  }
}
.px-btn.primary:active:not(:disabled):not([aria-disabled="true"]),
.px-btn.primary.is-pressed, .px-btn.primary[aria-pressed="true"] {
  border-image-source: var(--img-btn-primary-pressed);
}

/* danger (raid) */
.px-btn.danger {
  border-color: var(--c-danger);
  border-bottom-color: var(--c-danger-dark);
  border-image-source: var(--img-btn-danger);
  background-color: var(--c-danger);
  color: var(--c-white);
  text-shadow: 0 2px 0 var(--c-danger-dark);
}
.px-btn.danger.is-hover:not(:disabled) { border-image-source: var(--img-btn-danger-hover); border-color: var(--c-pink); background-color: var(--c-pink); }
@media (hover: hover) {
  .px-btn.danger:hover:not(:disabled):not([aria-disabled="true"]) {
    border-image-source: var(--img-btn-danger-hover);
    border-color: var(--c-pink);
    background-color: var(--c-pink);
  }
}
.px-btn.danger:active:not(:disabled):not([aria-disabled="true"]),
.px-btn.danger.is-pressed, .px-btn.danger[aria-pressed="true"] {
  border-image-source: var(--img-btn-danger-pressed);
}
.px-btn.primary:disabled, .px-btn.primary[aria-disabled="true"],
.px-btn.danger:disabled, .px-btn.danger[aria-disabled="true"] {
  border-image-source: var(--img-btn-disabled);
  border-color: var(--c-quay);
  background-color: var(--c-quay);
  color: var(--c-steel);
  text-shadow: none;
  font-weight: 400;
}

/* shapes */
.px-btn.icon { min-width: var(--px-btn-h); width: var(--px-btn-h); padding-left: 0; padding-right: 0; }
.px-btn.block { display: flex; width: 100%; }
.px-btn.tall { height: auto; min-height: var(--px-btn-h); padding-top: 4px; padding-bottom: 8px; white-space: normal; flex-direction: column; }
.px-btn.tall:active:not(:disabled), .px-btn.tall.is-pressed { padding-top: 8px; padding-bottom: 4px; }

/* ------------------------------------------------------------------ tabs -- */
.px-tabs { display: flex; gap: 8px; }
.px-tabs > .px-tab { flex: 1 1 0; min-width: 0; }
.px-tab[aria-selected="true"] {
  border-color: var(--c-amber);
  border-image-source: var(--img-tab-on);
  background-color: var(--c-amber);
  color: var(--c-ink);
  padding-top: 4px; padding-bottom: 0;
  box-shadow: none;
  cursor: default;
}

/* ----------------------------------------------------------------- pills -- */
.px-pill {
  --pill-bg: var(--c-slate);
  --pill-fg: var(--c-mist);
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px;
  padding: 0 6px;                     /* + 2px border = 8px */
  border: 2px solid var(--c-ink);
  border-image-source: var(--img-pill);
  border-image-slice: var(--px-slice1);
  border-image-width: 2px;
  border-image-repeat: stretch;
  background: var(--pill-bg) padding-box;
  color: var(--pill-fg);
  font: 16px/16px var(--font-ui);
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-pill .px-icon { width: 18px; height: 18px; margin-left: -4px; }
.px-pill.raid  { --pill-bg: var(--c-danger); --pill-fg: var(--c-white); }
.px-pill.used  { --pill-bg: var(--c-slate);  --pill-fg: var(--c-fog); }
.px-pill.gain  { --pill-bg: var(--c-ok);     --pill-fg: var(--c-ink); }
.px-pill.loss  { --pill-bg: var(--c-pink);   --pill-fg: var(--c-ink); }
.px-pill.info  { --pill-bg: var(--c-slate);  --pill-fg: var(--c-mist); }
.px-pill.amber { --pill-bg: var(--c-amber);  --pill-fg: var(--c-ink); }
.px-pill.bot   { --pill-bg: var(--c-p4);     --pill-fg: var(--c-white); }
.px-pill.x2 { height: 48px; padding: 0 12px; border-width: 4px; border-image-width: 4px; font-size: 32px; line-height: 32px; }

/* player chip: colour + ink emblem (never colour alone) */
.px-chip {
  display: inline-block; flex: none;
  width: 22px; height: 22px;
  background: var(--chip) 0 0 / 100% 100% no-repeat;
  vertical-align: middle;
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-chip.p1 { --chip: var(--img-pchip-p1); }
.px-chip.p2 { --chip: var(--img-pchip-p2); }
.px-chip.p3 { --chip: var(--img-pchip-p3); }
.px-chip.p4 { --chip: var(--img-pchip-p4); }
.px-chip.lg { width: 44px; height: 44px; }
.px-chip.xl { width: 66px; height: 66px; }

/* ---------------------------------------------------------------- toggle -- */
.px-toggle {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px;
  margin: 0; padding: 0;
  border: 0; background: none;
  color: var(--c-mist);
  font: 16px/16px var(--font-ui);
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}
.px-toggle::before {
  content: "";
  order: 2;
  flex: none;
  width: 40px; height: 20px;
  background:
    var(--img-knob-off) 2px 2px / 16px 16px no-repeat,
    var(--img-toggle-off) 0 0 / 100% 100% no-repeat;
  box-shadow: inset 0 0 0 2px var(--c-steel);
  transition: background-position 80ms steps(2, end);
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-toggle::after {
  content: "OFF";
  order: 3;
  min-width: 32px;
  color: var(--c-fog);
}
.px-toggle[aria-checked="true"]::before {
  background:
    var(--img-knob-on) 22px 2px / 16px 16px no-repeat,
    var(--img-toggle-on) 0 0 / 100% 100% no-repeat;
  box-shadow: inset 0 0 0 2px var(--c-ok);
}
.px-toggle[aria-checked="true"]::after { content: "ON"; color: var(--c-white); }
.px-toggle:disabled { cursor: default; color: var(--c-steel); }
.px-toggle:disabled::before { filter: none; box-shadow: inset 0 0 0 2px var(--c-slate); background: var(--c-quay); }
.px-toggle:disabled::after { color: var(--c-steel); }
.px-toggle.label-right::before { order: 0; }
.px-toggle.label-right::after { order: 1; }

/* ---------------------------------------------------------------- slider -- */
.px-slider {
  --fill: 0.5;
  -webkit-appearance: none; appearance: none;
  display: block;
  width: 100%; min-width: 120px;
  height: 48px;
  margin: 0; padding: 0;
  background:
    repeating-linear-gradient(to right, var(--c-steel) 0 2px, transparent 2px calc((100% - 16px) / 10))
    7px 36px / calc(100% - 14px) 4px no-repeat;
  cursor: pointer;
  touch-action: pan-y;
}
.px-slider::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(to right,
    var(--c-amber) 0 calc(8px + var(--fill) * (100% - 16px)),
    var(--c-ink) 0);
  box-shadow: 0 0 0 2px var(--c-ink);
}
.px-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 24px;
  margin-top: -8px;
  border: 0;
  background: var(--c-slate) var(--img-thumb) 0 0 / 100% 100% no-repeat;
  box-shadow: 0 2px 0 var(--c-ink);
  image-rendering: pixelated;
}
.px-slider:active::-webkit-slider-thumb { background-image: var(--img-thumb-active); }
.px-slider::-moz-range-track {
  height: 8px;
  background: var(--c-ink);
  box-shadow: 0 0 0 2px var(--c-ink);
}
.px-slider::-moz-range-progress { height: 8px; background: var(--c-amber); }
.px-slider::-moz-range-thumb {
  width: 16px; height: 24px;
  border: 0; border-radius: 0;
  background: var(--c-slate) var(--img-thumb) 0 0 / 100% 100% no-repeat;
  image-rendering: pixelated;
}
.px-slider:focus-visible { outline: 2px solid var(--c-white); outline-offset: 2px; }
.px-slider:disabled { cursor: default; filter: none; opacity: 1; }
.px-slider:disabled::-webkit-slider-runnable-track { background: var(--c-quay); }

/* ----------------------------------------------------------------- modal -- */
.px-scrim {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
  background: var(--img-scrim) 0 0 / 4px 4px repeat, var(--c-scrim);
}
.px-scrim.solid { background: var(--c-ink); }
.px-modal {
  position: relative;
  width: 100%; max-width: 480px;
  max-height: 100%;
  overflow: auto;
  border: 8px solid var(--c-quay);
  border-image-source: var(--img-panel);
  border-image-slice: var(--px-slice) fill;
  border-image-width: 8px;
  background: var(--c-quay) padding-box;
  padding: 24px;
  outline: 2px solid var(--c-steel);
  outline-offset: -10px;                /* the second, inner 2px line */
  box-shadow: 0 4px 0 var(--c-ink);
  color: var(--c-mist);
  font: 16px/24px var(--font-body);
  animation: px-rise 80ms steps(2, end);
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-modal:focus-visible { outline: 2px solid var(--c-white); outline-offset: -10px; }
.px-modal-title {
  margin: 0 0 16px;
  font: 24px/32px var(--font-display);
  text-transform: uppercase;
  text-align: center;
  color: var(--c-white);
  text-shadow: 0 3px 0 var(--c-ink);
}
.px-modal-body { margin: 0; }
.px-modal-body p { margin: 0 0 8px; }
.px-modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
@media (max-width: 599px) {
  .px-modal { padding: 16px; max-width: calc(100vw - 16px); }
  .px-modal-title { font-size: 16px; line-height: 24px; text-shadow: 0 2px 0 var(--c-ink); }
  .px-modal-actions { flex-direction: column-reverse; align-items: stretch; }
  .px-modal-actions > .px-btn { width: 100%; }
}
:root[data-layout="phone"] .px-modal-actions,
:root[data-layout="phone-land"] .px-modal-actions { flex-direction: column-reverse; align-items: stretch; }

/* ----------------------------------------------------------------- toast -- */
.px-toast {
  display: block;
  max-width: 400px;
  padding: 8px 16px;
  border: 2px solid var(--c-steel);
  border-left: 8px solid var(--c-mist);
  background: var(--c-ink);
  box-shadow: 0 4px 0 var(--c-ink);
  color: var(--c-white);
  font: 16px/24px var(--font-body);
  animation: px-up 120ms steps(3, end);
}
.px-toast.info { border-left-color: var(--c-mist); }
.px-toast.good { border-left-color: var(--c-ok); }
.px-toast.bad  { border-left-color: var(--c-danger); }
.px-toast.from-top { animation-name: px-down; }

/* --------------------------------------------------------------- tooltip -- */
.px-tooltip {
  --notch-x: 16px;
  position: absolute;
  z-index: 90;
  max-width: 240px;
  padding: 6px;                     /* + 2px border = 8px */
  border: 2px solid var(--c-mist);
  background: var(--c-ink);
  color: var(--c-white);
  font: 16px/24px var(--font-body);
  pointer-events: none;
  animation: px-up-small 80ms steps(2, end);
}
.px-tooltip::after {
  content: "";
  position: absolute;
  left: var(--notch-x); top: 100%;
  width: 10px; height: 6px;
  margin-top: -2px;
  background: var(--img-notch-down) 0 0 / 100% 100% no-repeat;
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-tooltip.below::after { top: auto; bottom: 100%; margin: 0 0 -2px; background-image: var(--img-notch-up); }
.px-tooltip.static { position: relative; display: inline-block; animation: none; }

/* ------------------------------------------------------------------ card -- */
.px-card {
  display: block;
  border: 8px solid var(--c-parchment);
  border-image-source: var(--img-card);
  border-image-slice: var(--px-slice) fill;
  border-image-width: 8px;
  background: var(--c-parchment) padding-box;
  padding: 8px;
  box-shadow: 0 4px 0 var(--c-ink);
  color: var(--c-ink);
  image-rendering: crisp-edges; image-rendering: pixelated;
}
.px-card.back {
  border-color: var(--c-slate);
  border-image-source: var(--img-card-back);
  border-image-slice: var(--px-slice);           /* no fill: the pattern shows through */
  background: var(--img-card-back-tile) 0 0 / 16px 16px repeat padding-box, var(--c-slate) padding-box;
  color: var(--c-mist);
}

/* -------------------------------------------------------------- progress -- */
.px-progress { display: inline-flex; gap: 4px; vertical-align: middle; }
.px-progress > i {
  display: block;
  width: 12px; height: 16px;
  background: var(--c-ink);
  box-shadow: 0 2px 0 var(--c-slate);          /* an ink well with a lit bottom edge */
}
.px-progress > i.on { background: var(--c-p4); box-shadow: inset 0 -2px 0 var(--c-p4-dark), 0 2px 0 var(--c-slate); }

/* ------------------------------------------------------------- animation -- */
@keyframes px-rise     { from { transform: translateY(8px); }  to { transform: none; } }
@keyframes px-up       { from { transform: translateY(24px); } to { transform: none; } }
@keyframes px-down     { from { transform: translateY(-24px); } to { transform: none; } }
@keyframes px-up-small { from { transform: translateY(4px); }  to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .px-modal, .px-toast, .px-tooltip { animation: none; }
  .px-toggle::before { transition: none; }
}
:root[data-motion="reduced"] .px-modal,
:root[data-motion="reduced"] .px-toast,
:root[data-motion="reduced"] .px-tooltip { animation: none; }
:root[data-motion="reduced"] .px-toggle::before { transition: none; }
