@font-face {
  font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/fonts/bricolage-grotesque-latin-ext.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("/fonts/bricolage-grotesque-latin.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;
}

:root {
  --bg: #0a1238;
  --hover: #111e50;
  --line: #223070;
  --text: #ffffff;
  --dim: #aab8e6;
  --faint: #6c7cb8;
  --n: 3;          /* number of players, set by the page */
  --name: 240px;   /* room for the variant name in list view */
  --col: clamp(40px, calc((min(980px, 100vw) - 2 * var(--gutter) - var(--name)) / var(--n)), 92px); /* one player column; shrinks with more players */
  --vw: calc(min(980px, 100vw) - 2 * var(--gutter)); /* visible content width, used to pin bars while a wide list scrolls sideways */
  --yellow: #ffe500;
  --edge: #ff9d00; /* orange drop edge on yellow buttons */
  --card: #0d1744;
  --deep: #070d2a;
  --slab: #16256a;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); color-scheme: dark; scrollbar-color: #2c3d86 var(--bg); }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font: 400 15px/1.5 "Bricolage Grotesque", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--yellow); color: var(--bg); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
h1, h2, p { margin: 0; }
input { caret-color: var(--text); }

/* the interface is not text: no accidental selecting while clicking around. Only the search box and the QR code stay selectable. */
button, .foot, .fx, .act-row, .sw, .chip, .sprite, .pic, .tabs, .views, .dd, .cols, .cell, .marks, .tl, .badge, .live, .lang, .top h1, .login h1, .qr-card h2, .solid, .pp { user-select: none; -webkit-user-select: none; }
* { -webkit-user-drag: none; } /* nothing on the site can be dragged */
button, .cell, .mark { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body { -webkit-font-smoothing: antialiased; }

/* heavy slanted caps, narrowed */
.top h1, .login h1, .sprite h2, .pl b, .tabs button, .views button, .solid, .dd-btn, .dd-list button, .badge, .tl, .jump {
  text-transform: uppercase; font-style: italic; font-weight: 800; font-stretch: 80%;
}
.top h1, .login h1, .sprite h2, .pl b, .tabs button, .views button, .solid, .dd-btn, .dd-list button { letter-spacing: .01em; }

/* shared bits */
.lang { display: flex; gap: 6px; color: var(--faint); }
.lang button { color: var(--dim); }
.lang button.on { color: var(--text); font-weight: 700; }
.link { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.link:hover { color: var(--text); }
.solid { background: var(--yellow); color: var(--bg); padding: 10px 22px; transform: skewX(-8deg); box-shadow: 3px 3px 0 var(--edge); }
.solid:hover { background: #fff; }
.err { color: #f0907f; font-size: 14px; }
input[type=password], input[type=search] {
  background: var(--card); border: 2px solid var(--line); border-radius: 3px; padding: 7px 10px; min-height: 36px;
}
input::placeholder { color: var(--faint); }
input:hover { border-color: var(--faint); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(340px, 100%); display: grid; gap: 10px; }
.login h1 { font-size: 26px; color: var(--yellow); margin-bottom: 4px; }
.login label { color: var(--dim); font-size: 14px; }
.login .solid { margin-top: 6px; }
.login .lang { margin-top: 18px; }

/* page frame */
#app { max-width: 980px; margin: 0 auto; padding: 0 var(--gutter); }
/* with many players the list gets wider than the screen and the page scrolls sideways; these stay in view */
#app:has(.ledger:not(.grid)) { min-width: calc(var(--name) + var(--n) * var(--col) + 2 * var(--gutter)); }
.top, .bar, .done, .foot, .head { position: sticky; left: var(--gutter); width: min(var(--vw), 100%); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 28px 0 18px; gap: 16px; } /* one row, never wraps: the actions stay beside the title, not between it and the tabs */
.top h1 { min-width: 0; }
.top-actions { flex: none; }
.top h1 { font-size: 26px; letter-spacing: .02em; color: var(--yellow); }
.top-actions { display: flex; gap: 22px; align-items: center; }
.live { color: var(--dim); font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live.on::before { background: var(--yellow); }

/* pinned bar: tabs, then view switch + search + filter */
.bar { top: 0; z-index: 3; background: var(--bg); box-shadow: 0 3px 0 var(--yellow); padding-top: 12px; }
.tabs { display: flex; gap: 10px; padding-bottom: 2px; }
.tabs button { padding: 8px 18px; margin-bottom: 8px; background: var(--slab); transform: skewX(-8deg); font-size: 15px; letter-spacing: .03em; }
.tabs button:hover { background: #1f3290; }
.tabs button.on { background: var(--yellow); color: var(--bg); font-weight: 700; box-shadow: 3px 3px 0 var(--edge); }
.tabs small { opacity: .65; font-size: 13px; margin-left: 4px; font-weight: 400; }
.find { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 0 12px; }
.find input[type=search] { flex: 1 1 160px; width: auto; min-width: 0; }
.find .dd { flex: 0 0 240px; }
.views { display: flex; gap: 14px; align-items: center; margin-right: 4px; }
.views button { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); padding: 4px 0; border-bottom: 2px solid transparent; }
.views svg { flex: none; opacity: .75; }
.views button.on svg { opacity: 1; color: var(--yellow); }
.views button:hover { color: var(--text); }
.views button.on { color: var(--text); font-weight: 700; border-bottom-color: var(--yellow); }

/* dropdown */
.dd { position: relative; min-width: 200px; }
.dd-btn { position: relative; width: 100%; min-height: 36px; padding: 6px 34px 6px 12px; text-align: left; background: var(--card); border: 2px solid var(--line); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-btn:hover { border-color: var(--faint); }
.dd-btn[aria-expanded="true"] { border-color: var(--yellow); }
.dd-btn::after { content: ""; position: absolute; right: 12px; top: 50%; width: 0; height: 0; margin-top: -3px; border: 5px solid transparent; border-top-color: var(--yellow); border-bottom: 0; }
.dd-btn[aria-expanded="true"]::after { border-top-color: transparent; border-bottom: 5px solid var(--yellow); border-top: 0; }
.dd-list { position: absolute; z-index: 20; right: 0; top: calc(100% + 4px); min-width: 100%; width: max-content; max-width: calc(100vw - 32px); max-height: min(60vh, 420px); overflow-y: auto; background: var(--card); border: 2px solid var(--yellow); box-shadow: 4px 4px 0 var(--edge); display: grid; padding: 4px; }
.dd-list button { text-align: left; padding: 9px 12px; font-size: 13px; color: var(--text); white-space: nowrap; }
.dd-list button:hover, .dd-list button:focus-visible { background: #1f3290; outline: 0; }
.dd-list button.on { background: var(--yellow); color: var(--bg); }

/* ledger: one grid shared by the pinned header and every row */
.row, .cols { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--n), var(--col)); min-width: calc(var(--name) + var(--n) * var(--col)); align-items: center; }
.cols { position: sticky; top: var(--barh, 56px); z-index: 2; background: var(--bg); padding: 10px 0 9px; }
.pl { min-width: 0; text-align: center; padding: 0 6px; display: flex; flex-direction: column; align-self: stretch; }
.pl b { display: block; color: var(--c); font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.ppl-open { display: inline-flex; align-items: center; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 3px; max-width: 100%; }
.tags em { font-style: italic; font-weight: 800; font-stretch: 80%; text-transform: uppercase; letter-spacing: .03em; font-size: 10px; line-height: 1.15; padding: 3px 7px 2px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: center; background: var(--c); color: var(--bg); transform: skewX(-8deg); box-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }
.pl span { display: block; color: var(--dim); font-size: 12px; margin: 1px 0 5px; }
.pl i { display: block; height: 6px; background: var(--slab); margin-top: auto; transform: skewX(-20deg); }
.pl i::after { content: ""; display: block; height: 100%; width: var(--w); background: var(--c); }

/* sprite block: rarity colour in --r */
#board { isolation: isolate; } /* nothing in the list can paint over the pinned bar */
.sprite { --r: #3d7bff; border-bottom: 2px solid var(--slab); padding: 26px 0 10px; }
.sprite:last-child { border-bottom: 0; }
.sprite.rare { --r: #36a8ff; } .sprite.epic { --r: #c25cff; } .sprite.legendary { --r: #ff9d2e; } .sprite.mythic { --r: #ffd84d; }
.head { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px; padding-bottom: 12px; }
.pic { position: relative; overflow: hidden; }
.pic img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pic:not(.ok) img { opacity: 0; } /* a picture only shows once it is fully loaded; the wheel covers the wait */
.pic .ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 26px; font-weight: 700; color: var(--faint); }
.head .pic { width: 84px; height: 84px; background: color-mix(in srgb, var(--r) 38%, var(--bg)); clip-path: polygon(0 0, 100% 0, 100% 86%, 88% 100%, 0 100%); }
.sprite h2 { font-size: 28px; letter-spacing: .02em; line-height: 1; color: var(--r); }
.sprite h2 span { color: var(--dim); font-size: 15px; letter-spacing: 0; margin-left: 8px; font-weight: 400; font-style: normal; text-transform: none; }
.sprite.complete h2 { color: var(--yellow); }
.meta { display: flex; flex-wrap: wrap; gap: 0 14px; color: var(--dim); font-size: 13px; margin-top: 2px; }
.meta .no { color: var(--r); font-style: italic; font-weight: 800; }
.meta .rar { color: var(--r); font-weight: 700; }
.ability { color: var(--dim); margin-top: 6px; max-width: 62ch; }
.how { color: var(--faint); font-size: 13px; margin-top: 4px; max-width: 62ch; }
.how b { font-weight: 600; color: var(--dim); }
.badge { display: inline-block; vertical-align: middle; font-family: inherit; font-size: 13px; background: var(--yellow); color: var(--bg); padding: 3px 12px; margin-left: 12px; transform: skewX(-8deg); box-shadow: 2px 2px 0 var(--edge); }

/* list view rows */
.row { padding: 5px 0; border-radius: 2px; }
.row:hover { background: var(--hover); }
.vname { display: flex; align-items: center; gap: 12px; min-width: 0; position: sticky; left: var(--gutter); z-index: 1; background: var(--bg); }
.row:hover .vname { background: var(--hover); }
.vname .pic { width: 36px; height: 36px; flex: none; background: color-mix(in srgb, var(--r) 30%, var(--bg)); }
.vname .pic .ph { font-size: 14px; }
.vname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.all .vname span { color: var(--yellow); }

/* checkboxes: flat squares, filled in the player's colour */
.cell, .mark { position: relative; }
.cell { display: grid; place-items: center; height: 40px; cursor: pointer; }
.cell input, .mark input { appearance: none; margin: 0; width: 22px; height: 22px; border: 1.5px solid var(--faint); border-radius: 3px; background: transparent; cursor: pointer; display: grid; place-items: center; }
.cell input:hover, .mark input:hover { border-color: var(--c); }
.cell input:checked, .mark input:checked { background: var(--c); border-color: var(--c); }
.cell input:checked::after, .mark input:checked::after { content: ""; width: 5px; height: 10px; border: solid var(--bg); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.cell::before, .mark::before { content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 3px solid var(--c, var(--yellow)); border-radius: 50%; opacity: 0; pointer-events: none; }

/* grid view: shop-style cards, rarity-coloured with a dark name bar */
.ledger.grid .cols { grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); gap: 10px 0; min-width: 0; } /* many players stack onto several lines */
.ledger.many.grid .cols { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.ledger.tall .cols { position: static; } /* a header taller than a third of the screen (many players, long labels) scrolls away instead of staying pinned */
.ledger.grid .cols > div:first-child { display: none; }
.sprite.g { padding-bottom: 22px; }
.sprite.g h2 { font-size: 20px; font-weight: 700; line-height: 1.2; }
.sprite.g h2 span { font-size: 14px; }
.sprite.g .ability, .sprite.g .how { margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; }
.tile { display: grid; border-radius: 4px; background: color-mix(in srgb, var(--r) 34%, var(--bg)); }
.tile:hover { transform: translateY(-4px); }
.tile .pic { width: 100%; height: auto; aspect-ratio: 1; padding: 6px 6px 0; }
.tile .pic .ph { font-size: 34px; }
.tile .pic img { filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .18)); }
.tl { background: var(--deep); padding: 9px 12px 4px; font-size: 15px; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marks { display: flex; justify-content: space-between; background: var(--deep); padding: 4px 12px 14px; }
.many .marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 8px 4px; justify-items: center; }
.ledger.dense:not(.grid) .pl b { writing-mode: vertical-rl; transform: rotate(180deg); max-height: 120px; margin: 0 auto; font-size: 12px; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.ledger.dense:not(.grid) .pl span { font-size: 9px; white-space: nowrap; }
.mark { display: grid; justify-items: center; gap: 3px; cursor: pointer; }
.mark::before { top: 12px; margin-top: -11px; }
.mark span { font-size: 11px; color: var(--c); font-weight: 700; line-height: 1; }
.mark input { width: 24px; height: 24px; background: rgba(255, 255, 255, .06); }
.tile.all { outline: 3px solid var(--yellow); outline-offset: -3px; } /* drawn inside, so it never pokes out beside the pinned bar */
.tile.all .tl { color: var(--yellow); }

.empty { color: var(--dim); padding: 40px 0; }
.foot { color: var(--faint); font-size: 13px; padding: 28px 0 48px; max-width: 70ch; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) skewX(-6deg); background: #ff5a5a; color: #fff; font-weight: 700; padding: 10px 18px; z-index: 10; max-width: calc(100vw - 32px); }

/* view-only visitors */
.ro { font-style: italic; font-weight: 800; font-stretch: 80%; text-transform: uppercase; letter-spacing: .03em; font-size: 11px; line-height: 1; padding: 4px 8px 3px; border: 2px solid var(--yellow); color: var(--yellow); transform: skewX(-8deg); user-select: none; }
.view-only .cell input, .view-only .mark input { pointer-events: none; opacity: .7; }
.view-only .cell, .view-only .mark { cursor: default; }

/* QR login */
.act-open, .qr-open, .help-open, .out-btn { display: inline-flex; align-items: center; gap: 6px; }
.solid svg { margin-right: 7px; vertical-align: -2px; flex: none; }
.solid { display: inline-flex; align-items: center; justify-content: center; }
.tr-row .solid svg { margin-right: 6px; }
.qr { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(7, 13, 42, .86); }
.qr-card { width: min(360px, 100%); display: grid; justify-items: center; gap: 16px; padding: 22px 22px 24px; background: var(--card); border: 2px solid var(--yellow); box-shadow: 6px 6px 0 var(--edge); }
.qr-card h2 { font-size: 24px; line-height: 1.1; text-align: center; color: var(--yellow); text-transform: uppercase; font-style: italic; font-weight: 800; font-stretch: 80%; letter-spacing: .02em; }
.qr-code { width: min(264px, 70vw); aspect-ratio: 1; display: grid; place-items: center; background: var(--yellow); box-shadow: 5px 5px 0 var(--edge); color: var(--bg); font-weight: 700; text-align: center; }
.qr-code img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.qr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.solid:disabled { opacity: .5; cursor: default; }
.qr-code .spin { border-color: rgba(10, 18, 56, .2); border-top-color: var(--bg); }
.ppl-list { width: 100%; max-height: min(50vh, 360px); overflow-y: auto; display: grid; gap: 6px; }
.pp { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; text-align: left; font: inherit; font-weight: 700; color: var(--text); background: var(--bg); border: 2px solid var(--edge); }
.pp i { width: 14px; height: 14px; flex: none; border: 2px solid var(--c); }
.pp[aria-pressed=true] { border-color: var(--c); }
.pp[aria-pressed=true] i { background: var(--c); }
.pp[aria-pressed=false] { opacity: .55; }
.pp:disabled { cursor: not-allowed; }
.qr-note { color: var(--dim); font-size: 14px; text-align: center; max-width: 30ch; }

/* back to top */
.jump { position: fixed; right: 28px; bottom: 22px; z-index: 40; height: 46px; padding: 0 18px; display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: .03em; background: var(--yellow); color: var(--bg); box-shadow: 3px 3px 0 var(--edge); transform: translateY(14px) skewX(-8deg); opacity: 0; pointer-events: none; }
.jump svg, .jump .lbl { transform: skewX(8deg); }
.jump.show { opacity: 1; transform: translateY(0) skewX(-8deg); pointer-events: auto; }
.jump:hover { background: #fff; }
.jump:active { transform: translate(2px, 2px) skewX(-8deg); box-shadow: 1px 1px 0 var(--edge); }

/* loading wheels */
.spin { display: inline-block; width: 22px; height: 22px; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--yellow); border-radius: 50%; animation: spin .8s linear infinite; }
.spin.sm { width: 14px; height: 14px; border-width: 2px; align-self: center; }
.spin.lg { width: 56px; height: 56px; border-width: 5px; }
.boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--bg); }
.solid.busy { position: relative; color: transparent; }
.solid.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 3px solid rgba(10, 18, 56, .25); border-top-color: var(--bg); border-radius: 50%; animation: spin .7s linear infinite; }
/* the picture spinner only shows if loading takes a moment, so cached pictures never flash it */
.pic:not(.ok):has(img)::before { content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 3px solid rgba(255, 255, 255, .15); border-top-color: var(--yellow); border-radius: 50%; z-index: 1; opacity: 0; animation: spin .8s linear infinite, show 0s linear .35s forwards; }
.vname .pic:not(.ok):has(img)::before { width: 14px; height: 14px; margin: -7px 0 0 -7px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes show { to { opacity: 1; } }

/* motion: small and quick, off for reduced-motion */
@media (prefers-reduced-motion: no-preference) {
  .tabs button, .solid, .link, .views button { transition: background-color .15s, color .15s; }
  .cell input, .mark input { transition: background-color .12s, border-color .12s; }
  .tile { transition: transform .15s ease-out, border-color .15s; }
  .pic img { transition: transform .2s ease-out, opacity .2s ease-out; }
  .tile:hover .pic img, .row:hover .pic img, .head .pic:hover img { transform: scale(1.08); }
  .jump { transition: opacity .25s ease, transform .25s ease, background-color .15s; }
  .enter .sprite { animation: rise .32s ease-out both; }
  .qr-card { animation: rise .22s ease-out; }
  .enter .sprite:nth-child(2) { animation-delay: .04s; } .enter .sprite:nth-child(3) { animation-delay: .08s; }
  .enter .sprite:nth-child(4) { animation-delay: .12s; } .enter .sprite:nth-child(n+5) { animation-delay: .16s; }
  input.pop { animation: pop .22s ease-out; }
  .live.on::before { animation: pulse 2.4s ease-in-out infinite; }
  .cell:has(input.pop)::before, .mark:has(input.pop)::before { animation: burst .38s ease-out; }
  .tabs button:active { transform: skewX(-8deg) scale(.93); }
  .views button:active { transform: scale(.93); }
  .solid:active { transform: skewX(-8deg) translate(2px, 2px); box-shadow: 1px 1px 0 var(--edge); }
  .tabs button.slam { animation: slam .22s ease-out; }
  .dd-list { animation: drop .16s ease-out; transform-origin: top; }
  .sprite.cheer .badge { animation: badge .5s cubic-bezier(.2, 1.6, .4, 1); }
  .sprite.cheer { animation: flash .7s ease-out; }
  .pl.fresh { animation: rise .45s ease-out both; }
  .pl.fresh .tags em, .chip.new { animation: badge .5s cubic-bezier(.2, 1.6, .4, 1) both; }
  .pr.new { animation: rise .28s ease-out both; }
  .done:not([hidden]) { animation: rise .4s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
  @keyframes pop { 40% { transform: scale(1.3); } }
  @keyframes pulse { 50% { opacity: .35; } }
  @keyframes burst { 0% { opacity: .95; transform: scale(.5); } 100% { opacity: 0; transform: scale(2.4); } }
  @keyframes slam { 0% { transform: skewX(-8deg) scale(.9); } 60% { transform: skewX(-8deg) scale(1.06); } 100% { transform: skewX(-8deg) scale(1); } }
  @keyframes drop { from { opacity: 0; transform: scaleY(.85); } }
  @keyframes badge { from { transform: skewX(-8deg) scale(0); } }
  @keyframes flash { 0% { background: rgba(255, 229, 0, .22); } 100% { background: transparent; } }
}

/* phones */
@media (max-width: 560px) {
  :root { --name: 79px; --col: clamp(44px, calc((100vw - 2 * var(--gutter) - var(--name)) / var(--n)), 68px); }
  .top { padding: 18px 0 12px; }
  .top h1 { font-size: 22px; }
  .top-actions { gap: 14px; }
  .bar { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: end; gap: 6px; padding-top: 6px; }
  .tabs { gap: 6px; padding-bottom: 0; }
  .tabs button { padding: 6px 12px; margin-bottom: 0; }
  .find { align-items: stretch; gap: 6px; padding: 0 0 6px; }
  .find .views { margin-right: 0; gap: 10px; font-size: 13px; }
  .find input[type=search] { flex: 1.2; min-height: 34px; padding: 4px 8px; font-size: 14px; }
  .find .dd { flex: 1; min-width: 0; }
  .dd-btn { min-height: 34px; padding: 4px 28px 4px 8px; font-size: 12px; }
  .pl { padding: 0 2px; }
  .pl b { font-size: 11px; letter-spacing: 0; overflow: visible; text-overflow: clip; }
  .tags { gap: 3px; } .tags em { font-size: 9px; padding: 2px 5px 1px; }
  .head { gap: 12px; }
  .head .pic { width: 64px; height: 64px; }
  .sprite h2 { font-size: 23px; }
  .vname { gap: 8px; }
  .vname .pic { width: 30px; height: 30px; }
  .jump { padding: 0 14px; }
  .live { font-size: 0; gap: 0; } /* just the dot on phones */
  .out-btn .lbl, .help-open .lbl, .ppl-open .lbl, .act-open .lbl, .qr-open .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .jump .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } /* phones: icon only, text stays for screen readers */
}
/* very narrow phones: keep the tabs inside the screen */
@media (max-width: 360px) {
  .top-actions { gap: 9px; }
  .top h1 { font-size: 18px; }
  .tabs { gap: 4px; }
  .tabs button { padding: 6px 9px; font-size: 11px; }
  .tabs small { margin-left: 2px; }
  .find input[type=search] { flex: .8; }
  .find .dd { flex: 1.2; }
  .dd-btn { padding-right: 22px; }
  .dd-btn::after { right: 8px; }
}

/* keyboard use: skip link, help window */
.skip { position: fixed; left: 12px; top: -60px; z-index: 80; padding: 10px 16px; background: var(--yellow); color: var(--bg); font-weight: 800; text-decoration: none; }
.skip:focus { top: 12px; }
#board:focus { outline: 0; }
.keys { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.keys dt { display: flex; gap: 4px; justify-content: flex-end; }
.keys dd { margin: 0; color: var(--dim); font-size: 14px; }
.keys kbd { font: inherit; font-size: 12px; font-weight: 800; padding: 2px 7px; color: var(--yellow); background: var(--bg); border: 2px solid var(--edge); }
@media (pointer: coarse) { .help-open { display: none; } }

/* people management: editor, colour picker, trash */
.pr { display: flex; gap: 6px; align-items: stretch; }
.pe-edit { flex: none; width: 40px; display: grid; place-items: center; color: var(--dim); background: var(--bg); border: 2px solid var(--edge); }
.pe-edit:hover { color: var(--yellow); border-color: var(--yellow); }
.pe-card { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; justify-items: stretch; }
.pe-card h2 { text-align: center; }
.pe-f { display: grid; gap: 6px; }
.pe-f > span { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.pe-card input:not([type=color]) { font: inherit; color: var(--text); background: var(--bg); border: 2px solid var(--edge); padding: 9px 11px; min-width: 0; }
.pe-card input:not([type=color]):focus-visible { border-color: var(--yellow); outline: 0; }
.pe-note { color: var(--faint); font-size: 12px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sw { position: relative; height: 34px; padding: 0; background: var(--c); border: 0; clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%); transition: transform .12s; }
.sw:hover { transform: translateY(-2px); }
.sw[aria-checked=true] { outline: 0; box-shadow: none; transform: translateY(-3px) scale(1.08); filter: drop-shadow(0 3px 0 var(--yellow)); }
.sw[aria-checked=true]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 5px; margin: -5px 0 0 -5px; border: solid var(--bg); border-width: 0 0 3px 3px; transform: rotate(-45deg); }
.sw.auto { grid-column: span 2; background: #1f3290; color: var(--text); font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sw.auto[aria-checked=true]::after { display: none; }
.sw.auto[aria-checked=true] { background: var(--yellow); color: var(--bg); }
.sw:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; clip-path: none; }
.pe-custom { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
.pe-pick { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.pe-pick input { width: 44px; height: 34px; padding: 0; border: 2px solid var(--edge); background: var(--bg); cursor: pointer; }
.pe-hex.bad { border-color: #f0907f; }
.pe-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: stretch; background: var(--c, var(--yellow)); color: var(--bg); max-width: 100%; }
.pe-card .chip { --c: var(--yellow); }
.chip em { font-style: italic; font-weight: 800; font-stretch: 80%; text-transform: uppercase; letter-spacing: .03em; font-size: 11px; padding: 4px 7px; overflow-wrap: anywhere; }
.chip button { padding: 0 7px; font-size: 15px; line-height: 1; color: var(--bg); background: rgba(0, 0, 0, .18); border: 0; }
.chip button:hover { background: rgba(0, 0, 0, .35); }
.pe-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pe-prev { text-align: center; padding: 10px; border: 2px dashed var(--edge); }
.pe-prev b { color: var(--c); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 18px; overflow-wrap: anywhere; }
.pe-sure { display: grid; gap: 14px; justify-items: center; text-align: center; }
.pe-card.sure > :not(h2):not(.pe-sure) { display: none; }
.solid.danger { background: #ff5a5f; color: var(--bg); }
.tr-card { width: min(480px, 100%); justify-items: stretch; }
.tr-card h2 { text-align: center; }
.tr-find { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.tr-find input, .tr-find select { font: inherit; color: var(--text); background: var(--bg); border: 2px solid var(--edge); padding: 9px 11px; min-width: 0; }
.tr-row { align-items: center; justify-content: space-between; padding: 8px 10px; border: 2px solid var(--edge); background: var(--bg); }
.tr-who { display: grid; gap: 4px; min-width: 0; }
.tr-who b { display: flex; align-items: center; gap: 8px; font-style: italic; text-transform: uppercase; color: var(--c); overflow-wrap: anywhere; }
.tr-who b i { width: 12px; height: 12px; flex: none; background: var(--c); }
.tr-who .tags { justify-content: flex-start; margin: 0; }
.tr-who small { color: var(--faint); font-size: 12px; }
.tr-row .solid { flex: none; font-size: 13px; padding: 8px 12px; }

.chip { touch-action: none; cursor: grab; }
.chip.drag { position: relative; z-index: 5; opacity: .85; cursor: grabbing; box-shadow: 3px 3px 0 var(--edge); transition: none; pointer-events: none; }
.chip.over { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* everyone has every sprite */
.done { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 18px; background: var(--yellow); color: var(--bg); box-shadow: 4px 4px 0 var(--edge); }
.done[hidden] { display: none; }
.done div { display: grid; line-height: 1.15; }
.done b { font-size: 18px; font-style: italic; font-weight: 800; font-stretch: 80%; text-transform: uppercase; letter-spacing: .03em; }
.done span { font-size: 13px; font-weight: 600; opacity: .8; }
.party { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.party[hidden] { display: none; }
.party-t { position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%) skewX(-8deg); max-width: 92vw; padding: 18px 34px; text-align: center; background: var(--yellow); color: var(--bg); box-shadow: 8px 8px 0 var(--edge); display: grid; gap: 4px; }
.party-t b { font-size: clamp(26px, 7vw, 60px); line-height: 1; font-style: italic; font-weight: 800; font-stretch: 80%; text-transform: uppercase; letter-spacing: .02em; }
.party-t span { font-size: clamp(14px, 2.6vw, 20px); font-weight: 700; }
.party i { display: none; position: absolute; top: -24px; left: var(--x); width: var(--s); height: calc(var(--s) * 1.7); background: var(--c); }
@media (prefers-reduced-motion: no-preference) {
  .party { animation: partyOut .5s 4.2s forwards; }
  .party-t { animation: stamp .55s cubic-bezier(.2, 1.5, .4, 1) both; }
  .party i { display: block; animation: confetti 2.8s var(--d) cubic-bezier(.3, .4, .6, 1) forwards; }
  @keyframes confetti { to { transform: translateY(112vh) rotate(var(--r)); } }
  @keyframes stamp { from { opacity: 0; transform: translate(-50%, -50%) skewX(-8deg) scale(2.4); } }
  @keyframes partyOut { to { opacity: 0; } }
}

/* activity: small live toasts and the log window */
.act-open { display: inline-flex; align-items: center; gap: 6px; }
.feed { position: fixed; left: 18px; bottom: 18px; z-index: 55; display: grid; gap: 8px; justify-items: start; pointer-events: none; max-width: min(360px, calc(100vw - 36px)); }
.fx { display: flex; align-items: center; gap: 9px; padding: 8px 12px; font-size: 13px; font-weight: 600; background: var(--card); border: 2px solid var(--c, var(--yellow)); box-shadow: 3px 3px 0 var(--edge); overflow-wrap: anywhere; }
.fx i, .act-row i { flex: none; width: 9px; height: 9px; background: var(--c, var(--yellow)); transform: skewX(-12deg); }
.fx.out { opacity: 0; transform: translateX(-12px); transition: opacity .3s, transform .3s; }
.act-card { width: min(520px, 100%); justify-items: stretch; text-align: center; }
.act-card h2 { display: flex; align-items: center; justify-content: center; gap: 10px; }
.act-card .qr-note { max-width: none; justify-self: center; }
.act-list { list-style: none; margin: 0; padding: 0 6px 0 0; width: 100%; max-height: min(54vh, 440px); overflow-y: auto; display: grid; gap: 6px; text-align: left; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.act-day { position: sticky; top: 0; z-index: 1; padding: 6px 2px 4px; background: var(--card); color: var(--dim); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.act-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; padding: 9px 12px; background: var(--bg); border-left: 3px solid var(--c, var(--yellow)); font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.act-row svg { color: var(--c, var(--yellow)); }
.act-row em { color: var(--faint); font-style: normal; }
.act-row time { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.act-empty { padding: 28px 0; text-align: center; color: var(--dim); }
.qr-link { display: grid; grid-template-columns: 1fr auto; gap: 8px; width: 100%; }
.qr-link input { min-width: 0; font: inherit; font-size: 12px; color: var(--text); background: var(--bg); border: 2px solid var(--edge); padding: 8px 10px; text-overflow: ellipsis; }
.qr-link input:focus-visible { border-color: var(--yellow); outline: 0; }
.qr-link .solid { font-size: 13px; padding: 8px 14px; }
@media (prefers-reduced-motion: no-preference) {
  .fx { animation: rise .25s ease-out; }
  .act-row.new { animation: rise .25s ease-out both; }
}
@media (max-width: 560px) { .feed { left: 10px; bottom: 76px; } }

.act-more { display: grid; justify-items: center; padding: 8px 0 4px; }

/* touch phones */
html { -webkit-tap-highlight-color: transparent; }
button, select, input, label, a { touch-action: manipulation; } /* no double-tap zoom delay */
.qr { padding: 12px; }
.qr-card { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; } /* a short screen scrolls inside the window instead of cutting it off */
.jump { bottom: calc(22px + env(safe-area-inset-bottom)); right: calc(28px + env(safe-area-inset-right)); }
.feed { bottom: calc(18px + env(safe-area-inset-bottom)); }
.swatches { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); }
.sw { height: 38px; }
@media (pointer: coarse), (max-width: 560px) {
  input, select, textarea { font-size: 16px !important; } /* iPhones zoom into anything smaller */
  .top h1 { font-size: 16px; line-height: 1.15; }
  .top-actions { gap: 2px; }
  .top-actions .link, .top-actions .lang button { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 36px; padding: 0 6px; }
  .top-actions .lang { display: flex; align-items: center; margin: 0 4px 0 2px; }
  .tabs button, .views button, .dd-btn { min-height: 38px; }
  .qr-link .solid, .pe-add .solid { min-height: 40px; }
  .pe-edit { width: 44px; } .pp { min-height: 42px; }
  .chip button { padding: 0 11px; min-height: 30px; }
}
@media (max-width: 340px) { /* the narrowest phones: the title gets its own line, the actions spread under it */
  .top { flex-wrap: wrap; }
  .top-actions { width: 100%; justify-content: space-between; }
}

@media (pointer: coarse), (max-width: 560px) {
  .top-actions .help-open { display: none; }
  .has-kbd .top-actions .help-open { display: inline-flex; }
}

.foot[data-i=foot] { padding-bottom: 6px; }
.foot.src { padding: 0 0 48px; }
.foot.src a { color: var(--muted, inherit); text-decoration: underline; text-underline-offset: 3px; }
.foot.src a:hover, .foot.src a:focus-visible { color: var(--yellow); }
