/* The card face itself: corner index, real pip layouts, and face cards you can
   read across a kitchen table. Loaded after app.css, which still owns the card
   BOX (size, shadow, selection, the backs) and the themes. */

.card {
  background: linear-gradient(180deg, #fffefa 0%, #f7f5ec 100%);
  border-radius: calc(var(--cw) * 0.09);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 3px 8px rgba(0, 0, 0, 0.22),
              inset 0 0 0 1px rgba(15, 23, 42, 0.16);
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.card:not(.back) { color: #16213d; }
.card.red:not(.back) { color: #c3123a; }

/* ---- the corner index: rank with its suit underneath, twice, as on a real card */
.card .cnr {
  position: absolute; display: grid; justify-items: center; line-height: 0.92;
  font-weight: 800; letter-spacing: -0.03em;
}
.card .cnr.tl { left: 5.5%; top: 4%; }
/* A real card repeats the index upside down in the far corner. In a fanned
   hand on a phone that corner is never the one you can see, and it crowds the
   pips -- so it only appears on the big cards. */
.card .cnr.br { display: none; right: 5.5%; bottom: 8%; transform: rotate(180deg); }
.card.big .cnr.br, .area.found .card .cnr.br { display: grid; }
.card .cnr .cx { font-size: calc(var(--cw) * 0.25); }
.card .cnr .cs { font-size: calc(var(--cw) * 0.185); font-style: normal; margin-top: calc(var(--cw) * 0.01); }

/* ---- the middle of the card */
.card .pips {
  position: absolute; left: 19%; right: 19%; top: 22%; bottom: 20%;
  /* minmax(0,...) or the pips (taller than a thirteenth of the card) stretch
     the rows and the whole layout walks off the bottom edge. */
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(13, minmax(0, 1fr));
}
.card .pip {
  font-style: normal; place-self: center; line-height: 1;
  font-size: calc(var(--cw) * 0.19);
}
.card .pip.flip { transform: rotate(180deg); }
.card .pip[data-col="1"] { grid-column: 1; }
.card .pip[data-col="2"] { grid-column: 2; }
.card .pip[data-col="3"] { grid-column: 3; }
.card .pip[data-row="1"] { grid-row: 1; }
.card .pip[data-row="3"] { grid-row: 3; }
.card .pip[data-row="4"] { grid-row: 4; }
.card .pip[data-row="5"] { grid-row: 5; }
.card .pip[data-row="7"] { grid-row: 7; }
.card .pip[data-row="9"] { grid-row: 9; }
.card .pip[data-row="10"] { grid-row: 10; }
.card .pip[data-row="11"] { grid-row: 11; }
.card .pip[data-row="13"] { grid-row: 13; }

.card .ace {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: calc(var(--cw) * 0.62); line-height: 1;
}

/* Jack, Queen, King: a framed letter. Court art turns to mud at this size --
   a big clear letter is what an older player can actually read. */
.card .court {
  position: absolute; inset: 18% 12% 16%;
  display: grid; place-content: center; justify-items: center; gap: calc(var(--cw) * 0.02);
}
.card .court-x { font-size: calc(var(--cw) * 0.52); font-weight: 800; line-height: 0.9; letter-spacing: -0.04em; }
.card .court-s { font-size: calc(var(--cw) * 0.26); font-style: normal; line-height: 1; }

/* whose card it is: with the deck art on, a coloured frame round the card --
   a band across the foot would sit on top of the artwork */
.card::after {
  left: 8%; right: 8%; bottom: calc(var(--cw) * 0.035);
  height: max(3px, calc(var(--ch) * 0.045));
  border-radius: 999px; opacity: 0.95;
}
/* Whose card it is: a ring OUTSIDE the card, not a border drawn over it.
   (2026-09-20: as a border it ate the card's own edge and index.) */
.card[data-r]::after { display: none; }
.card[data-r]:not(.plain) {
  box-shadow: 0 0 0 2px var(--seat), 0 1px 2px rgba(0, 0, 0, 0.45), 0 3px 8px rgba(0, 0, 0, 0.22),
              inset 0 0 0 1px rgba(15, 23, 42, 0.16);
}

/* Small cards (other people's hands, the crib, a trick): the pips would be
   specks, so those cards show the index and one clear suit instead. */
.card.small .pips, .card.tiny .pips, .mini .card .pips { display: none; }
.card.small .court, .card.tiny .court, .mini .card .court { border: 0; background: none; inset: 0; }
.card.small .cnr.br, .card.tiny .cnr.br, .mini .card .cnr.br { display: none; }
.card.small .cnr.tl, .card.tiny .cnr.tl, .mini .card .cnr.tl { left: 0; right: 0; top: 8%; }
.card.small .cnr .cx, .card.tiny .cnr .cx, .mini .card .cnr .cx { font-size: calc(var(--cw) * 0.44); }
.card.small .cnr .cs, .card.tiny .cnr .cs, .mini .card .cnr .cs { font-size: calc(var(--cw) * 0.36); }
.card.small .ace, .card.tiny .ace, .mini .card .ace { display: none; }

/* ============ THE DECK ==========================================================
   Ian's deck (one sheet, 13 ranks across x 4 suits down, cut from the artwork he
   sent). The drawn face underneath stays in the markup for screen readers and is
   what you get in the places the art is too small to read. */
.card[data-r] {
  background-image: url("/static/deck.webp?v=5");
  background-repeat: no-repeat;
  background-color: #f4e9cf;
  background-size: calc(var(--cw) * 13) calc(var(--ch) * 4);
}
.card[data-r] .cnr, .card[data-r] .pips, .card[data-r] .ace, .card[data-r] .court,
.card.big[data-r] .cnr.br, .area.found .card[data-r] .cnr.br { display: none; }
.card[data-r="1"] { background-position-x: calc(var(--cw) * -0); }
.card[data-r="2"] { background-position-x: calc(var(--cw) * -1); }
.card[data-r="3"] { background-position-x: calc(var(--cw) * -2); }
.card[data-r="4"] { background-position-x: calc(var(--cw) * -3); }
.card[data-r="5"] { background-position-x: calc(var(--cw) * -4); }
.card[data-r="6"] { background-position-x: calc(var(--cw) * -5); }
.card[data-r="7"] { background-position-x: calc(var(--cw) * -6); }
.card[data-r="8"] { background-position-x: calc(var(--cw) * -7); }
.card[data-r="9"] { background-position-x: calc(var(--cw) * -8); }
.card[data-r="10"] { background-position-x: calc(var(--cw) * -9); }
.card[data-r="11"] { background-position-x: calc(var(--cw) * -10); }
.card[data-r="12"] { background-position-x: calc(var(--cw) * -11); }
.card[data-r="13"] { background-position-x: calc(var(--cw) * -12); }
.card[data-s="S"] { background-position-y: calc(var(--ch) * -0); }
.card[data-s="H"] { background-position-y: calc(var(--ch) * -1); }
.card[data-s="D"] { background-position-y: calc(var(--ch) * -2); }
.card[data-s="C"] { background-position-y: calc(var(--ch) * -3); }

/* The backs: one per seat colour, from Ian's sheet (blue, pink, green,
   violet, amber, cyan -- the same six the chips and names use), so you can
   tell whose pile is whose without a ring painted round the artwork. */
.card.back {
  background-image: url("/static/backs.webp?v=2");
  background-repeat: no-repeat;
  background-color: #1e293b;
  background-size: calc(var(--cw) * 6) 100%;
  background-position-x: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.card.back.p0 { background-position-x: 0; }
.card.back.p1 { background-position-x: calc(var(--cw) * -1); }
.card.back.p2 { background-position-x: calc(var(--cw) * -2); }
.card.back.p3 { background-position-x: calc(var(--cw) * -3); }
.card.back.p4 { background-position-x: calc(var(--cw) * -4); }
.card.back.p5 { background-position-x: calc(var(--cw) * -5); }
.card.back.p6 { background-position-x: 0; }             /* seats 7 and 8 share */
.card.back.p7 { background-position-x: calc(var(--cw) * -1); }

/* ============ UNO =============================================================
   A complete deck from Wikimedia Commons, drawn by Dmitry Fomin and released
   CC0 (public domain): rasterised from its SVG, so it is sharp at any size.
   13 across (0-9, skip, reverse, +2) by 5 down (red, yellow, green, blue, then
   wild / +4 / the back). Uno cards are narrower than playing cards -- 300x480
   in the sheet -- so the box follows the art rather than stretching it. */
.uno-card, .uno-back {
  --uh: calc(var(--cw) * 1.6);
  height: var(--uh);
  background-image: url("/static/uno.webp?v=3");
  background-repeat: no-repeat;
  background-size: calc(var(--cw) * 13) calc(var(--uh) * 5);
  background-color: transparent;
  border: 0; border-radius: calc(var(--cw) * 0.085);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.uno-card > * { display: none; }   /* the drawn face stays for screen readers */
.uno-card[data-v="0"] { background-position-x: calc(var(--cw) * -0); }
.uno-card[data-v="1"] { background-position-x: calc(var(--cw) * -1); }
.uno-card[data-v="2"] { background-position-x: calc(var(--cw) * -2); }
.uno-card[data-v="3"] { background-position-x: calc(var(--cw) * -3); }
.uno-card[data-v="4"] { background-position-x: calc(var(--cw) * -4); }
.uno-card[data-v="5"] { background-position-x: calc(var(--cw) * -5); }
.uno-card[data-v="6"] { background-position-x: calc(var(--cw) * -6); }
.uno-card[data-v="7"] { background-position-x: calc(var(--cw) * -7); }
.uno-card[data-v="8"] { background-position-x: calc(var(--cw) * -8); }
.uno-card[data-v="9"] { background-position-x: calc(var(--cw) * -9); }
.uno-card[data-v="S"] { background-position-x: calc(var(--cw) * -10); }
.uno-card[data-v="R"] { background-position-x: calc(var(--cw) * -11); }
.uno-card[data-v="D2"] { background-position-x: calc(var(--cw) * -12); }
.uno-card[data-c="R"] { background-position-y: calc(var(--uh) * -0); }
.uno-card[data-c="Y"] { background-position-y: calc(var(--uh) * -1); }
.uno-card[data-c="G"] { background-position-y: calc(var(--uh) * -2); }
.uno-card[data-c="B"] { background-position-y: calc(var(--uh) * -3); }
.uno-card[data-c="W"][data-v="W"] { background-position: 0 calc(var(--uh) * -4); }
.uno-card[data-c="W"][data-v="W4"] { background-position: calc(var(--cw) * -1) calc(var(--uh) * -4); }
.uno-back { width: var(--cw); background-position: calc(var(--cw) * -2) calc(var(--uh) * -4); }
/* bright cards on a dark table: they need less shade than the cream deck */
.hand-card.no:has(.uno-card)::after { background: rgba(15, 23, 42, 0.22); }

/* ============ PLAY NINE ========================================================
   Ian's golf deck: -5 then 0-7 across the top row, 8-12 and the back below.
   ONE sprite, placed in PIXELS from a measured card width (--cw): as a
   percentage-sized sheet, Safari rounded each cell to whole pixels and the
   art crept off its card; as fifteen separate files it crashed WebKit
   outright (both 2026-09-20). --cw is set on each grid by a ResizeObserver
   in golf.js and on the piles below. */
.nine-grid { --cw: 60px; }
.pile-btn .nine-card, .held .nine-card { --cw: clamp(64px, 18vw, 96px); width: var(--cw); }
.nine-card[data-v], .nine-card.down {
  background-image: url("/static/nine.webp?v=2");
  background-repeat: no-repeat;
  background-size: calc(var(--cw) * 9) calc(var(--cw) * 1.4 * 2);
  border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.nine-card[data-v] .nv, .nine-card[data-v] .nsub { display: none; }
.nine-card[data-v]::before, .nine-card[data-v]::after { display: none; }
.nine-card[data-v="-5"] { background-position: 0 0; }
.nine-card[data-v="0"] { background-position: calc(var(--cw) * -1) 0; }
.nine-card[data-v="1"] { background-position: calc(var(--cw) * -2) 0; }
.nine-card[data-v="2"] { background-position: calc(var(--cw) * -3) 0; }
.nine-card[data-v="3"] { background-position: calc(var(--cw) * -4) 0; }
.nine-card[data-v="4"] { background-position: calc(var(--cw) * -5) 0; }
.nine-card[data-v="5"] { background-position: calc(var(--cw) * -6) 0; }
.nine-card[data-v="6"] { background-position: calc(var(--cw) * -7) 0; }
.nine-card[data-v="7"] { background-position: calc(var(--cw) * -8) 0; }
.nine-card[data-v="8"] { background-position: 0 calc(var(--cw) * -1.4); }
.nine-card[data-v="9"] { background-position: calc(var(--cw) * -1) calc(var(--cw) * -1.4); }
.nine-card[data-v="10"] { background-position: calc(var(--cw) * -2) calc(var(--cw) * -1.4); }
.nine-card[data-v="11"] { background-position: calc(var(--cw) * -3) calc(var(--cw) * -1.4); }
.nine-card[data-v="12"] { background-position: calc(var(--cw) * -4) calc(var(--cw) * -1.4); }
.nine-card.down { background-position: calc(var(--cw) * -5) calc(var(--cw) * -1.4); }
.nine-card.down::before, .nine-card.down::after { display: none; }

/* ============ PIECES ===========================================================
   Real chips (Ian's sheet: blue, pink, green, violet, amber, cyan -- the seat
   colours in that order). A chip is round, so the element has to be square:
   filling a board space that is a little taller than it is wide turned them
   into ovals. */
.chipdot[data-seat] {
  background-image: url("/static/chips.webp?v=2");
  background-size: 600% 100%;
  background-repeat: no-repeat;
  background-color: transparent;
  border: 0; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45); opacity: 1;
}
.sq .chipdot[data-seat] {
  inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 84%; height: auto; aspect-ratio: 1 / 1;
}
.chipdot[data-seat="0"] { background-position: calc(100% * 0 / 5) center; }
.chipdot[data-seat="1"] { background-position: calc(100% * 1 / 5) center; }
.chipdot[data-seat="2"] { background-position: calc(100% * 2 / 5) center; }
.chipdot[data-seat="3"] { background-position: calc(100% * 3 / 5) center; }
.chipdot[data-seat="4"] { background-position: calc(100% * 4 / 5) center; }
.chipdot[data-seat="5"] { background-position: calc(100% * 5 / 5) center; }
.sq .chipdot.locked[data-seat] { box-shadow: 0 0 0 3px var(--accent), 0 2px 4px rgba(0, 0, 0, 0.45); border-radius: 50%; }

/* ============ THE SEQUENCE BOARD ===============================================
   Tried the real card art in these squares (2026-09-20) and it was a mess:
   at 70-90px you get the rank plus a random slice of the pip field, and the
   court cards show a smear of the portrait. The board is 100 spaces you scan
   at a glance -- a clean label beats a cropped photograph. Cream card stock
   and the deck's colours keep it of a piece with the cards in your hand. */
.sq {
  background: linear-gradient(180deg, #fffdf6 0%, #f4e9cf 100%);
  border: 1px solid rgba(15, 23, 42, 0.18);
  color: #16213d;
}
.sq.red { color: #c3123a; }
.sq .chipdot { inset: 16%; }

/* Uno's cards are already bright and flat: the heavy shade that suits the
   cream deck turns them to mud. */
.hand-card.no:has(.uno-card)::after { background: rgba(15, 23, 42, 0.26); }

/* ============ THE FELT =========================================================
   Ian's felt photographs, one per game, laid under the theme's own colour wash
   (which still tints the panels). A fixed cover rather than a tile: these are
   photographs, not seamless patterns, so a repeat would show its seams. */
body[data-kind]::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background-position: center; background-size: cover; background-repeat: no-repeat;
  opacity: 0.55;
}
body[data-kind="solitaire"]::before { background-image: url("/static/felt-emerald.webp?v=1"); }
body[data-kind="euchre"]::before    { background-image: url("/static/felt-forest.webp?v=1"); }
body[data-kind="cribbage"]::before  { background-image: url("/static/felt-forest.webp?v=1"); }
body[data-kind="golf"]::before      { background-image: url("/static/felt-fairway.webp?v=1"); opacity: 0.5; }
body[data-kind="eights"]::before    { background-image: url("/static/felt-plum.webp?v=1"); }
body[data-kind="thirtyone"]::before { background-image: url("/static/felt-crimson.webp?v=1"); }
body[data-kind="sequence"]::before  { background-image: url("/static/felt-royal.webp?v=1"); }
body[data-kind="tock"]::before      { background-image: url("/static/felt-slate.webp?v=1"); }
body[data-kind="uno"]::before       { background-image: url("/static/felt-teal.webp?v=1"); opacity: 0.45; }
