/* Pexeso: status and the line under it on top, the players' plates, the grid
   of cards in the room that is left. A card is two faces back to back that
   turn in 3D: the back a pattern on the cloth's colours, the face ivory with a
   large picture. A pair taken stays face up, framed in its owner's colour. */
.pex{
  --pex-c0:#ffc65c;--pex-c1:#6fc3df;--pex-c2:#ef7d8f;--pex-c3:#9fd47a;
  position:absolute;inset:0;
  display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr);
  overflow:hidden;
}
.pex.still .pex-in,.pex.still .pex-card{transition:none!important}
.pex-top{position:relative;display:grid;justify-items:center;gap:2px;padding:6px 10px 2px}
.pex-status{padding:.4em .9em;font-size:.93rem}
.pex-say{margin:0;min-height:1.3em;max-width:24rem;font-size:.86rem;line-height:1.3;text-align:center;color:var(--mist)}
/* the look after a miss runs out under the status */
.pex-look{position:absolute;left:50%;bottom:0;width:7rem;height:2px;margin-left:-3.5rem;border-radius:2px;background:var(--gold);opacity:.8;transform-origin:left}
.pex-look.run{animation:pex-look var(--ms,1500ms) linear forwards}
@keyframes pex-look{to{transform:scaleX(0)}}

/* ── plates ──────────────────────────────────────────────────────────── */
.pex-plates{display:flex;justify-content:center;gap:6px;padding:4px 8px}
.pex-plate{
  --pc:var(--pex-c0);
  display:flex;align-items:center;gap:6px;
  flex:0 1 200px;min-width:0;min-height:44px;padding:3px 8px 3px 4px;
  border:1.5px solid var(--line);border-radius:999px;
  background:rgba(13,18,10,.3);
  transition:border-color .2s,background-color .2s;
}
.pex-plate.c1{--pc:var(--pex-c1)}.pex-plate.c2{--pc:var(--pex-c2)}.pex-plate.c3{--pc:var(--pex-c3)}
.pex-plate .ava{width:32px;height:32px;font-size:.95rem;flex:none}
.pex-who{display:grid;line-height:1.15;min-width:0;flex:1}
.pex-who .nm{font-weight:600;font-size:.88rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pex-who .sub{font-size:.7rem;color:var(--mist);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pex-count{
  flex:none;min-width:1.9em;height:1.9em;padding:0 .3em;border-radius:999px;
  display:grid;place-items:center;font-size:.95rem;font-variant-numeric:tabular-nums;
  background:var(--pc);color:#241a2d;
}
.pex-plate.turn{border-color:var(--pc);background:rgba(255,255,255,.08)}
.pex-plate.turn .ava{box-shadow:0 0 0 2.5px var(--pc)}
.pex-plate.best .pex-count{box-shadow:0 0 0 2.5px var(--ivory)}
/* four at the table on a phone: the name gives way to the count */
.pex-plates[data-n="3"] .pex-plate,.pex-plates[data-n="4"] .pex-plate{flex:1 1 0;padding-right:5px}
/* …and on a phone the count sits on the avatar's corner, so that the name keeps some room */
@media (max-width:440px){
  .pex-plates[data-n="3"] .pex-plate,.pex-plates[data-n="4"] .pex-plate{position:relative;gap:4px;padding-left:3px}
  .pex-plates[data-n="3"] .pex-count,.pex-plates[data-n="4"] .pex-count{
    position:absolute;left:19px;bottom:-3px;min-width:1.45em;height:1.45em;font-size:.72rem;
    box-shadow:0 0 0 2px rgba(13,18,10,.75);
  }
  .pex-plates[data-n="4"] .pex-who .nm{font-size:.74rem}
  .pex-plates[data-n="4"] .pex-who .sub{display:none}
  .pex-plates[data-n="4"] .pex-plate .ava{width:26px;height:26px;font-size:.8rem}
}

/* ── the grid ────────────────────────────────────────────────────────── */
.pex-main{display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden;padding:4px}
.pex-grid{
  --cols:6;--w:52px;--h:64px;--gap:6px;
  display:grid;grid-template-columns:repeat(var(--cols),var(--w));grid-auto-rows:var(--h);gap:var(--gap);
}
.pex-card{
  position:relative;width:var(--w);height:var(--h);padding:0;border:0;background:none;
  perspective:600px;cursor:default;-webkit-tap-highlight-color:transparent;
  transition:transform .25s var(--ease,ease),opacity .3s;
}
.pex-card.can{cursor:pointer}
.pex-card:focus-visible{outline:2px solid var(--gold);outline-offset:2px;border-radius:9px}
.pex-in{
  position:absolute;inset:0;display:block;
  transform-style:preserve-3d;transition:transform .42s cubic-bezier(.3,.7,.35,1.15);
}
.pex-card.up .pex-in{transform:rotateY(180deg)}
.pex-back,.pex-face{
  position:absolute;inset:0;display:grid;place-items:center;border-radius:clamp(5px,calc(var(--w)*.14),10px);
  -webkit-backface-visibility:hidden;backface-visibility:hidden;
}
.pex-back{
  background:
    radial-gradient(circle at 50% 50%,rgba(255,255,255,.18) 0 18%,transparent 19%),
    repeating-linear-gradient(45deg,rgba(255,255,255,.09) 0 4px,transparent 4px 9px),
    linear-gradient(160deg,#7b2a5c,#3c1131);
  box-shadow:inset 0 0 0 2px rgba(255,198,92,.55),0 3px 8px -4px rgba(0,0,0,.7);
}
.pex-face{
  transform:rotateY(180deg);
  background:var(--ivory);color:#241a2d;
  font-size:calc(var(--w)*.6);line-height:1;
  box-shadow:inset 0 -3px 0 rgba(36,26,45,.12),0 3px 8px -4px rgba(0,0,0,.7);
}
.pex-card.can:hover .pex-back{box-shadow:inset 0 0 0 2px var(--gold),0 5px 12px -4px rgba(0,0,0,.8)}
.pex-card.can:active{transform:scale(.95)}
/* a pair taken: framed in its owner's colour, gently out of the way */
.pex-card.own{--pc:var(--pex-c0);opacity:.62;transform:scale(.9)}
.pex-card.own.c1{--pc:var(--pex-c1)}.pex-card.own.c2{--pc:var(--pex-c2)}.pex-card.own.c3{--pc:var(--pex-c3)}
.pex-card.own .pex-face{box-shadow:inset 0 0 0 3px var(--pc)}
.pex-card.pop{animation:pex-pop .55s var(--ease,ease) .35s both}
@keyframes pex-pop{0%{transform:scale(1);opacity:1}45%{transform:scale(1.12);opacity:1}100%{transform:scale(.9);opacity:.62}}
.pex-card.miss .pex-face{box-shadow:inset 0 0 0 3px var(--cherry)}
.pex-card.now .pex-face{box-shadow:inset 0 0 0 3px var(--gold)}
/* the hint: the cards to turn glow gold; with nothing sure, the unseen cards are dotted */
.pex-card.hn-sure .pex-back{box-shadow:inset 0 0 0 3px var(--gold),0 0 14px 2px rgba(255,198,92,.75);animation:pex-glow 1.2s ease-in-out infinite}
.pex-card.hn-maybe .pex-back{box-shadow:inset 0 0 0 2px rgba(255,198,92,.9)}
.pex-card.hn-maybe .pex-back::after{content:"?";color:rgba(255,198,92,.85);font-weight:700;font-size:calc(var(--w)*.34)}
@keyframes pex-glow{50%{box-shadow:inset 0 0 0 3px var(--gold),0 0 4px 0 rgba(255,198,92,.4)}}

.pex-sum{margin:.2em 0 .6em;font-size:.9rem;opacity:.75;text-align:center}

/* a short screen: everything a little tighter */
@media (max-height:600px){
  .pex-top{padding-top:3px;gap:0}
  .pex-status{padding:.3em .8em;font-size:.86rem}
  .pex-say{font-size:.78rem;min-height:1.1em}
  .pex-plates{padding:2px 6px}
  .pex-plate{min-height:36px}
  .pex-plate .ava{width:26px;height:26px;font-size:.8rem}
}
@media (prefers-reduced-motion:reduce){
  .pex-in,.pex-card{transition:none}
  .pex-card.pop,.pex-card.hn-sure .pex-back,.pex-look.run{animation:none}
}
