Playing Cards That Stay Readable at 31 Pixels Wide
A card face drawn for a desktop table turns to noise once the card is only 31 pixels wide. Play5s draws a second, compact layer inside every face: the rank and suit sit in the strip that always stays visible, the standard pip layout shrinks into the body, and court figures are drawn once and reused. Duplicate SVG ids were the one trap.
This note covers the French-suited faces shared by 30 Play5s card games.
Why does a normal card face fail at 31 pixels?
Our smallest cards are small. In our own layout measurements on 25 November 2026, the cards in a Spider Solitaire column on a 360 by 640 phone are 31 pixels wide. Klondike gets 45 pixels on the same screen and 50 on a 390 by 844 one, and the computer's hand in Crazy Eights drops to 27.
A full face carries a lot. Wikipedia's article on the standard 52-card deck describes it: a pip card shows as many suit symbols as its number, plus a numeral in at least two corners, and the king, queen and jack carry reversible figures. Shrink that to 31 pixels and the pips become dots, a figure becomes a smear, and the rank is about the size of a full stop.
Our first phone face avoided the mess by dropping almost everything: one big letter, one small suit in the corner and one big suit in the middle. It was legible, but a seven and an eight differed only by a letter, and a jack, queen and king were three letters on a blank card. Players could read them. They could not feel the cards.
How much of a card does the player actually see?
Cards are rarely seen whole. Two situations decide what a compact face must show.
In a solitaire column each card is covered by the next, so only a top strip stays visible. Depending on the game that strip is 26 to 36 percent of the card height, which on our 140-unit face is everything above about y 50. In a hand fanned sideways, such as Hearts at 390 pixels, about 44 percent of the width shows: the left edge.
So the strip holds the rank on the left and the suit on the right, and nothing else is allowed to reach into it. No half-cut pip, no frame edge peeking out under the rank. The fanned hand needs its own answer: the suit is printed a second time on the left edge, under the rank, because nothing of the right corner shows there.
Printed packs went through the same change. Wikipedia's playing card article says packs with corner and edge indices let players hold their cards close together in a fan with one hand, instead of the two hands used before. A phone screen is that one-handed fan again, with fewer pixels.
What does the compact face contain?
We made two mock-ups and reviewed them at phone size. Design A put a double index on the left; design B was a symmetrical, compact face. In a hand of cards B was hard to tell apart, so A won, and a second round of polish produced the face described here. All numbers below are in the 100 by 140 units of the SVG view box.
- The rank is set at x 6 with its baseline at y 34, in the strip.
- The suit pip sits at (82, 19), size 20, also in the strip.
- The suit repeats at (17, 59), size 18, just below the strip, for fanned hands.
- The body is the normal face, drawn smaller and centred at x 60.
The body reuses the same pip table as the large face rather than a second set of positions. Only a few constants change:
const SM = { suitY: 59, cx: 60, px: 0.95, pipY: 98.5, py: 0.8,
pip: 16, artY: 94, court: 0.79 };
// the same standard layout, squeezed 5% sideways and 20% vertically
body = PIPS[rank].map(([x, y, flip]) =>
pip(suit, SM.cx + (x - 50) * SM.px, SM.pipY + (y - 70) * SM.py, SM.pip, flip));
The court figures are the double-ended artwork of the large face, scaled to 0.79 and kept below the strip. The first row of pips starts lower than the edge suit on purpose. When both sat at the same height the edge suit lined up with the first row and read as one more pip, which is how a seven of clubs looked like an eight in an early build and a ten of diamonds like an eleven.
How does one SVG hold two faces?
Each face is one SVG with two groups inside it, kl-big for the large drawing and kl-small for the compact one. CSS shows exactly one of them:
.kl-small { display: none; }
.kl-board.is-small .kl-big { display: none; }
.kl-board.is-small .kl-small { display: inline; }
Every game measures its card width after layout and puts is-small on the board when the width is under 66 pixels (62 in Briscola and Durak). Italian and Spanish decks have a single drawing that works at every size, so they were left alone. One class on one element flips every card at once, so a resize never redraws a face.
The cost is markup. The strings for all 52 faces grew from 264,391 to 302,376 characters, 14 percent, because the compact layer repeats the pips. Court figures cost only about one percent more, thanks to the next trick.
What went wrong with duplicate ids?
A court figure carries gradients, a pattern and a clip path, all referenced by id. To avoid doubling the markup, a figure is drawn once inside <defs> and placed with <use> in both layers. Mozilla's reference for <use> describes how it clones an element by reference.
The trap is that an id has to be unique. The HTML Standard says the value of an id attribute must be unique amongst all the IDs in the element's tree, and a card page breaks that easily: Spider can deal two decks, Rummy 500 draws melds, and one card can appear twice.
On Chromium 156, on 25 November 2026, two SVGs on one page used the same gradient id and the first was display:none. The second drew nothing: its <use> and its fill="url(#...)" resolved to the hidden copy. Face-down cards keep a hidden face, so this happens in ordinary play.
The fix is boring on purpose. Every time a court figure is drawn it gets a new id made from the card and a counter in base 36, such as k37-1a. We also stopped caching a face string and reusing it for a second card, which Spider had been doing. The same bug had been hiding in the large face for a while, with fixed ids per card, whenever a card showed up twice.
What did we check before shipping it?
Thirty games share this face. We captured every one at 360 by 640, 390 by 844, 768 by 1024 and 1440 by 900, 120 screenshots in all, and looked at them: no sideways scroll, no script errors, and no duplicate id on the pages that mix decks, namely Spider, Klondike, Buraco, Pinochle, Rummy 500 and Tarot. Twelve per-game fit tests passed, and a page-level test visited every page in every language at 320, 390 and 1440 pixels. Finally, a side-by-side of seven games, the old face on top and the new one below, was reviewed by eye.
You can see the result in the card games on Play5s, on any phone narrow enough to trigger it.