/* The four-seat table, your hand, the pass bar, the cards-played memory aid, the score table, the scores panel, the last
   trick and the rules a new game is set up with. Colors come from the page's --sw-* roles, so a theme restyles all of it. */
.tricks-table {
  --trick-card: 4rem;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(4.4rem, 1fr) minmax(0, 3.2fr) minmax(4.4rem, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: ". top ." "left trick right" "bottom bottom bottom" "hand hand hand";
  gap: .35rem;
}
.tricks-table .seat { justify-self: center; width: min(100%, 11rem); }
/* The side seats sit next to the trick, not out at the edge of a wide table. */
.tricks-table .seat[data-place="left"] { justify-self: end; }
.tricks-table .seat[data-place="right"] { justify-self: start; }
.tricks-table .seat[data-place="bottom"] { width: 100%; }
.tricks-table .seat[data-place="top"] { grid-area: top; }
.tricks-table .seat[data-place="left"] { grid-area: left; align-self: center; }
.tricks-table .seat[data-place="right"] { grid-area: right; align-self: center; }
.tricks-table .seat[data-place="bottom"] { grid-area: bottom; }
.tricks-table .trick { grid-area: trick; position: relative; min-height: 0; }
.tricks-table .hand-slot { grid-area: hand; min-width: 0; }

.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .18rem;
  min-width: 0;
  padding: .3rem .5rem;
  border: 2px solid transparent;
  border-radius: calc(var(--sw-radius) / 1.6);
  background: color-mix(in srgb, var(--sw-raised) 80%, transparent);
  color: var(--sw-on-raised);
  font-size: .86rem;
  line-height: 1.15;
  text-align: center;
}
/* Your partner's panel and your own carry a quiet rule in the team's color, and the partner a link mark, so a side is
   never told by color alone. */
.seat[data-ally="true"], .tricks-table:has(.seat[data-ally="true"]) .seat[data-you="true"] {
  border-color: color-mix(in srgb, var(--sw-accent) 38%, transparent);
}
/* Whose turn it is, seen from across the table without reading: the panel glows in the accent color and the player's
   mark lights up inside it. The mark and the words stay for a reader and for a screen with no color. */
.seat[data-turn="true"] {
  border-color: var(--sw-accent);
  border-style: solid;
  background: color-mix(in srgb, var(--sw-accent) 22%, var(--sw-raised));
  box-shadow: 0 0 0 2px var(--sw-accent), 0 0 14px 4px color-mix(in srgb, var(--sw-accent) 55%, transparent);
  animation: seat-turn 1.6s ease-in-out infinite;
}
@keyframes seat-turn { 50% { box-shadow: 0 0 0 2px var(--sw-accent), 0 0 24px 9px color-mix(in srgb, var(--sw-accent) 30%, transparent); } }
.seat[data-turn="true"] .seat-icon:not([data-icon="ally"]) {
  box-sizing: content-box;
  padding: .12rem;
  border-radius: 50%;
  background: var(--sw-accent);
  color: var(--sw-surface);
  box-shadow: 0 0 8px 2px color-mix(in srgb, var(--sw-accent) 70%, transparent);
}
/* A seat's avatar sits before the name. On the seat whose turn it is, it is ringed in the accent and glows. */
.seat-avatar { --avatar-size: 1.75rem; }
.seat[data-turn="true"] .seat-avatar {
  box-shadow: 0 0 0 2px var(--sw-raised), 0 0 0 4px var(--sw-accent), 0 0 12px 5px color-mix(in srgb, var(--sw-accent) 70%, transparent);
}
.seat[data-away="true"] .seat-avatar { filter: grayscale(.8); opacity: .7; }
.seat-avatar-button { flex: none; padding: 0; border: 0; border-radius: 50%; background: none; line-height: 0; cursor: pointer; }
.seat-avatar-button:focus-visible { outline: 3px solid var(--sw-focus, var(--sw-accent)); outline-offset: 2px; }
@media (hover: hover) { .seat-avatar-button:hover .seat-avatar { box-shadow: 0 0 0 2px var(--sw-raised), 0 0 0 4px var(--sw-accent); } }
@media (max-width: 32rem), (max-height: 28rem) { .seat-avatar { --avatar-size: 1.45rem; } }
.seat-head { display: flex; align-items: center; justify-content: center; gap: .3rem; min-width: 0; max-width: 100%; }
.seat-turn { display: inline-flex; color: var(--sw-accent); font-size: .7em; flex: none; }
.seat-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 720; unicode-bidi: isolate; }
.seat[data-away="true"] .seat-name { font-style: italic; }
/* A name that opens the player's profile reads as the name, and underlines under the pointer or focus. */
a.seat-name { color: inherit; text-decoration: none; }
a.seat-name:hover, a.seat-name:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
/* The dealer's disc, as on a card table. */
.seat-dealer {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: var(--sw-on-raised);
  color: var(--sw-raised);
  font-size: .62rem;
  font-weight: 850;
  line-height: 1;
}
.seat-icon { flex: none; display: inline-flex; width: 1rem; height: 1rem; color: var(--sw-muted); }
.seat-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.seat-icon svg .fill { fill: currentColor; stroke: none; }
.seat-icon[data-icon="ally"] { color: var(--sw-accent); width: .95rem; }
/* A level: an icon, then four rising bars filled to the computer strength it plays like. */
.seat-level { flex: none; display: inline-flex; align-items: center; gap: .15rem; }
.seat-bars { display: inline-flex; align-items: flex-end; gap: 1.5px; height: .8rem; }
.seat-bar { width: 3px; border-radius: 1px; background: color-mix(in srgb, var(--sw-muted) 38%, transparent); }
.seat-bar:nth-child(1) { height: 35%; }
.seat-bar:nth-child(2) { height: 57%; }
.seat-bar:nth-child(3) { height: 79%; }
.seat-bar:nth-child(4) { height: 100%; }
.seat-bar[data-on="true"] { background: var(--sw-on-raised); }
.seat-level[data-provisional="true"] .seat-bar[data-on="true"] { background: color-mix(in srgb, var(--sw-on-raised) 60%, transparent); }
.seat-level-new { font-size: .62rem; font-weight: 750; letter-spacing: .03em; color: var(--sw-muted); text-transform: uppercase; }
.seat-note { color: var(--sw-muted); font-size: .72rem; }
.seat-numbers { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .15rem .5rem; }
.seat-numbers strong { font-variant-numeric: tabular-nums; }
.seat-label { color: var(--sw-muted); font-size: .68rem; margin-inline: .12rem; }
.seat-taken { display: inline-flex; align-items: baseline; gap: .12rem; }
.seat-taken strong { color: var(--sw-caution); }
.seat-taken-icon { color: var(--sw-caution); font-size: .8em; }
/* A bid against tricks taken: open rings still wanted, filled ones taken, smaller marks for any over the bid. Rows wrap
   at five, so a count reads at a glance. */
.seat-pips { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px; max-width: calc(5 * .62rem + 4 * 3px + 1.2rem); }
.pip { width: .62rem; height: .62rem; border-radius: 50%; border: 1.5px solid var(--sw-on-raised); box-sizing: border-box; }
.pip[data-state="taken"] { background: var(--sw-on-raised); }
.pip[data-state="wanted"] { opacity: .75; }
.pip[data-state="zero"] { border-style: dashed; opacity: .6; }
.pip-over { display: inline-flex; gap: 2px; margin-inline-start: 2px; }
.pip[data-state="over"] { width: .42rem; height: .42rem; border: 0; background: var(--sw-caution); border-radius: 1px; transform: rotate(45deg); }
.pip-nil {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: .9rem;
  height: .9rem;
  border-radius: 50%;
  border: 1.5px solid var(--sw-on-raised);
  box-sizing: border-box;
  font-size: .5rem;
  font-weight: 850;
}
.pip-nil::after { content: ""; position: absolute; inset: 45% -15% auto; height: 1.5px; background: currentColor; transform: rotate(-45deg); }
.pip-nil[data-blind="true"] { background: var(--sw-on-raised); color: var(--sw-raised); }
.pip-nil[data-blind="true"]::after { background: var(--sw-raised); }
.pip-nil[data-broken="true"] { border-color: var(--sw-caution); color: var(--sw-caution); }
.seat-dealer, .seat-tag { flex: none; }
.seat-tag { padding: 0 .4rem; border: 1px solid var(--sw-caution); border-radius: 999px; font-size: .7rem; font-weight: 700; }
/* The seat that took the trick is outlined, and says so. */
.seat[data-won="true"] { outline: 3px solid var(--sw-action); outline-offset: 2px; background: color-mix(in srgb, var(--sw-action) 18%, var(--sw-raised)); }
.seat[data-won="true"]::after {
  content: "Took the trick";
  position: absolute;
  inset: auto 0 -.7rem;
  margin-inline: auto;
  width: fit-content;
  padding: 0 .5rem;
  border-radius: 999px;
  background: var(--sw-action);
  color: var(--sw-on-action);
  font-size: .68rem;
  font-weight: 800;
  white-space: nowrap;
  z-index: 2;
}
.seat[data-place="bottom"] { flex-direction: row; justify-content: center; flex-wrap: wrap; gap: .2rem .9rem; padding-block: .2rem; }
.seat-status { color: var(--sw-accent); font-size: .74rem; }
.seat-action { min-height: 2.25rem; padding: .2rem .5rem; font-size: .78rem; }

.trick-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--trick-card);
  box-shadow: 0 .15rem .5rem color-mix(in srgb, var(--sw-surface) 70%, transparent);
  border-radius: 8% / 5.7%;
  --reach: calc(var(--trick-card) * .64);
  --side: calc(var(--trick-card) * .62);
}
.trick-opens { cursor: pointer; }
.trick-card[data-winning="true"] { box-shadow: 0 0 0 3px var(--sw-action), 0 .2rem .8rem color-mix(in srgb, var(--sw-surface) 70%, transparent); z-index: 2; }
.deal-card { position: absolute; width: 2.6rem; translate: -50% -50%; z-index: 30; pointer-events: none; }
.deal-card .card { width: 100%; }
.trick-card[data-place="bottom"] { translate: calc(-50% + var(--trick-card) * .08) calc(-50% + var(--reach) * .78); rotate: 3deg; }
.trick-card[data-place="top"] { translate: calc(-50% - var(--trick-card) * .08) calc(-50% - var(--reach) * .78); rotate: -2deg; }
.trick-card[data-place="left"] { translate: calc(-50% - var(--side)) calc(-50% - var(--reach) * .1); rotate: -4deg; }
.trick-card[data-place="right"] { translate: calc(-50% + var(--side)) calc(-50% + var(--reach) * .05); rotate: 4deg; }

.hand { position: relative; width: 100%; isolation: isolate; }
.hand-card {
  position: absolute;
  width: var(--hand-card);
  padding: 0;
  border: 0;
  background: none;
  border-radius: 8% / 5.7%;
  min-height: 0;
  transition: translate var(--sw-quick), opacity var(--sw-quick);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hand-card .card { pointer-events: none; }
.hand-card[data-state="legal"], .hand-card[data-state="open"] { translate: 0 -4px; }
.hand-card[data-state="legal"] { box-shadow: 0 0 0 2px var(--sw-accent); }
/* Cards that cannot be played are only a little quieter, and a filter rather than opacity keeps a card that overlaps
   another from showing it through. The playable ones are outlined and lifted instead, so the index stays readable. */
.hand-card[data-state="illegal"] .card, .hand-card[data-state="blocked"] .card { filter: brightness(.94); }
.hand-card[data-state="illegal"], .hand-card[data-state="blocked"] { translate: 0 3px; }
@media (prefers-contrast: more), (forced-colors: active) {
  .hand-card[data-state="illegal"] .card, .hand-card[data-state="blocked"] .card { filter: none; }
}
/* The index of a card in the hand is its rank with the suit under it, in the top left corner, which is the part of
   a card that stays uncovered in both rows. */
.hand-card .card-index:not(.opposite) { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0; inset: 3cqi auto auto 5cqi; width: auto; font-size: 30cqi; line-height: 1.05; letter-spacing: -.06em; }
.hand-card .card-index:not(.opposite) .suit-mark { font-size: 27cqi; }
/* A queued card rises but keeps its place in the stack, so it never covers the index of a card in front of it. Its
   tag sits above its own top edge, where no card in its row covers it. */
.hand-card[data-state="queued"] { translate: 0 -12px; box-shadow: 0 0 0 3px var(--sw-action), 0 .2rem .6rem color-mix(in srgb, var(--sw-surface) 70%, transparent); }
.hand-card[data-state="queued"]::after {
  content: "Next";
  position: absolute;
  inset: -1.15rem auto auto 0;
  width: fit-content;
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--sw-action);
  color: var(--sw-on-action);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.3;
  pointer-events: none;
}
.hand-card[aria-pressed] { cursor: pointer; }
.auto-toggle-wrap { display: flex; justify-content: center; flex: 0 0 auto; }
.auto-toggle { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.75rem; padding: .2rem .25rem .2rem .7rem; border: 1px solid var(--sw-border); border-radius: calc(var(--sw-radius) / 2); background: var(--sw-raised); color: var(--sw-on-raised); font-size: .8rem; font-weight: 720; cursor: pointer; }
.auto-toggle[data-on="true"] { border-color: var(--sw-accent); }
.auto-toggle-select { min-height: 2.2rem; padding: .15rem .4rem; border: 0; border-radius: calc(var(--sw-radius) / 3); background: color-mix(in srgb, var(--sw-surface) 40%, var(--sw-raised)); color: inherit; font: inherit; cursor: pointer; }
.auto-toggle[data-on="true"] .auto-toggle-select { background: var(--sw-accent); color: var(--sw-surface); }
/* Playing out is for this hand only, so it stands out while it lasts. */
.auto-toggle[data-mode="playout"] { box-shadow: 0 0 0 2px color-mix(in srgb, var(--sw-accent) 45%, transparent); }
.auto-toggle:has(select:focus-visible) { outline: 3px solid var(--sw-focus); outline-offset: 2px; }
.hand-card[data-state="selected"] { translate: 0 -14px; box-shadow: 0 0 0 3px var(--sw-action), 0 .2rem .6rem color-mix(in srgb, var(--sw-surface) 70%, transparent); }
.hand-card[data-received="true"] { box-shadow: 0 0 0 3px var(--sw-caution); }
.hand-card[data-received="true"][data-state="legal"] { box-shadow: 0 0 0 3px var(--sw-caution), 0 0 0 5px var(--sw-accent); }
.hand-card:focus-visible { outline: 3px solid var(--sw-focus); outline-offset: 2px; z-index: 40 !important; }
@media (hover: hover) {
  .hand-card[data-state="legal"]:hover, .hand-card[data-state="open"]:hover, .hand-card[data-state="queueable"]:hover { translate: 0 -9px; z-index: 30 !important; }
  /* Off turn a card lifts and is outlined under the pointer just as on your turn, so it reads as one to choose. */
  .hand-card[data-state="queueable"]:hover { box-shadow: 0 0 0 2px var(--sw-accent); }
}

.pass-bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .4rem .9rem; padding: .25rem .5rem; }
.pass-bar[hidden] { display: none; }
.pass-prompt { margin: 0; font-weight: 720; }
.pass-confirm { min-width: 9rem; }

.played-panel { display: grid; gap: .2rem; font-size: .78rem; }
.played-row { display: flex; align-items: center; gap: .15rem; }
.played-suit { width: 1.1rem; height: 1.1rem; flex: none; fill: currentColor; margin-inline-end: .25rem; }
.played-row[data-suit="hearts"] .played-suit, .played-row[data-suit="diamonds"] .played-suit { color: var(--sw-danger); }
.played-cell { flex: 1 1 0; min-width: 0; text-align: center; padding: .12rem 0; border-radius: 3px; border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.played-cell[data-state="played"] { color: var(--sw-muted); opacity: .45; text-decoration: line-through; }
.played-cell[data-state="mine"] { border-color: var(--sw-accent); color: var(--sw-accent); font-weight: 720; }
.played-cell[data-state="out"] { color: var(--sw-on-raised); font-weight: 600; }

.score-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; }
.score-table th, .score-table td { padding: .3rem .45rem; text-align: center; border-bottom: 1px solid color-mix(in srgb, var(--sw-border) 55%, transparent); }
.score-table thead th { color: var(--sw-muted); font-weight: 720; }
.score-table th[data-winner="true"] { color: var(--sw-accent); }
.score-table tbody th { color: var(--sw-muted); font-weight: 500; }
.score-table .score-total th, .score-table .score-total td { color: inherit; font-weight: 800; border-bottom: 2px solid var(--sw-border); }
.score-table [data-lowest="true"] { color: var(--sw-accent); }
.score-table [data-moon="true"] { color: var(--sw-caution); }
.score-moon { font-size: .7rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A wide screen gives the trick more room, keeps the seats beside it, and lays the scores panel to one side. */
@media (min-width: 64rem) {
  .tricks-table { grid-template-columns: minmax(8rem, 1fr) minmax(0, 38rem) minmax(8rem, 1fr); }
}
@media (min-width: 48rem) and (min-height: 38rem) {
  .tricks-table .seat[data-place="top"] { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: .1rem .8rem; width: auto; min-width: 11rem; max-width: 100%; }
  .seat { font-size: .92rem; }
}
.tricks-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; min-height: 0; }
.tricks-stage > .scores-panel { display: none; }
@media (min-width: 62rem) and (min-height: 40rem) {
  .tricks-stage:has(> .scores-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr) 15rem; }
  .tricks-stage > .scores-panel:not([hidden]) { display: grid; }
}

.scores-panel {
  align-self: start;
  align-content: start;
  gap: .5rem;
  padding: .7rem .8rem;
  border: 1px solid color-mix(in srgb, var(--sw-border) 60%, transparent);
  border-radius: calc(var(--sw-radius) / 1.6);
  background: color-mix(in srgb, var(--sw-raised) 85%, transparent);
  color: var(--sw-on-raised);
}
.scores-panel-heading { font: 700 1rem/1.2 var(--sw-display); }
.scores-panel-hand { color: var(--sw-muted); font-size: .86rem; }
.scores-panel-entries { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.scores-panel-entry { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 .5rem; padding: .3rem .5rem; border: 1px solid transparent; border-radius: calc(var(--sw-radius) / 2.4); }
.scores-panel-entry[data-you="true"] { border-color: color-mix(in srgb, var(--sw-border) 70%, transparent); }
.scores-panel-entry[data-leading="true"] { border-color: var(--sw-accent); }
.scores-panel-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores-panel-total { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.scores-panel-tag { grid-column: 1 / -1; color: var(--sw-accent); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.scores-panel-detail { grid-column: 1 / -1; color: var(--sw-muted); font-size: .8rem; }
.scores-panel-rows { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; font-size: .84rem; }
.scores-panel-rows dt { color: var(--sw-muted); }
.scores-panel-rows dd { margin: 0; font-variant-numeric: tabular-nums; text-align: end; }
.scores-panel-rows:empty { display: none; }

/* The last trick, over the table where the trick is. */
.last-trick-button {
  grid-area: trick;
  align-self: start;
  justify-self: end;
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 2.75rem;
  padding: .3rem .7rem;
  font-size: .8rem;
}
.last-trick-button kbd, .last-trick kbd { font: inherit; font-size: .72rem; padding: 0 .3rem; border: 1px solid var(--sw-border); border-radius: 4px; color: var(--sw-muted); }
.last-trick {
  position: fixed;
  inset: 0;
  z-index: 20;
  margin: auto;
  width: min(30rem, calc(100vw - 1.5rem));
  height: fit-content;
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  padding: .8rem 1rem 1rem;
  border: 2px solid var(--sw-border);
  border-radius: var(--sw-radius);
  background: var(--sw-raised);
  color: var(--sw-on-raised);
  box-shadow: 0 .6rem 2.4rem color-mix(in srgb, var(--sw-surface) 75%, transparent);
}
.last-trick[hidden] { display: none; }
.last-trick-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.last-trick-head h3 { font: 700 1.1rem/1.2 var(--sw-display); margin: 0; }
.last-trick-close { min-height: 2.75rem; min-width: 2.75rem; }
.last-trick-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.last-trick-play { display: grid; justify-items: center; gap: .2rem; padding: .4rem .2rem; border: 2px solid transparent; border-radius: calc(var(--sw-radius) / 1.6); text-align: center; font-size: .86rem; }
.last-trick-play[data-won="true"] { border-color: var(--sw-action); background: color-mix(in srgb, var(--sw-action) 14%, transparent); }
.last-trick-face { width: min(100%, 5.2rem); }
.last-trick-who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.last-trick-tag { color: var(--sw-muted); font-size: .76rem; min-height: 1.1em; }
.last-trick-play[data-won="true"] .last-trick-tag { color: var(--sw-on-raised); font-weight: 700; }
.last-trick-none { grid-column: 1 / -1; color: var(--sw-muted); }

/* A new game's rules: the usual ones in a line, and the house rules a click away. */
.rules-builder .rules-standard { margin: 0 0 .5rem; padding: .5rem .7rem; border-radius: calc(var(--sw-radius) / 2); background: color-mix(in srgb, var(--sw-surface) 55%, transparent); font-size: .9rem; }
.rules-builder .rules-standard strong { margin-inline-end: .3rem; }
.rules-builder .rules-house { margin-block: 0 1rem; }
.rules-builder .rules-state { color: var(--sw-muted); font-weight: 500; font-size: .86rem; }
.rules-builder .rules-body { display: grid; gap: .2rem; margin-top: .5rem; }
.rules-builder .rules-note { margin: .2rem 0 .5rem; }
.rules-builder .rules-reset { min-height: 2.75rem; }
.rules-builder .rules-select { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; font-weight: 720; font-size: .9rem; }
.rules-builder .rules-select select { width: auto; background: var(--sw-raised); color: var(--sw-on-raised); }
.rules-builder .sizes-three { grid-template-columns: repeat(3, 1fr); }
.rules-line { color: var(--sw-muted); font-size: .9rem; }
.rules-line[data-standard="false"] { color: var(--sw-on-surface); }

/* Why a hand scored what it did. */
.hand-lines-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.hand-lines-list > li { padding: .35rem .5rem; border: 1px solid color-mix(in srgb, var(--sw-border) 55%, transparent); border-radius: calc(var(--sw-radius) / 2.4); }
.hand-lines-list > li[data-you="true"] { border-color: var(--sw-accent); }
.hand-lines-head { display: flex; justify-content: space-between; gap: .5rem; margin: 0 0 .15rem; }
.hand-lines-total { font-weight: 800; font-variant-numeric: tabular-nums; }
.hand-lines-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .05rem; font-size: .86rem; color: var(--sw-muted); }
.hand-lines-list ul li { display: flex; justify-content: space-between; gap: .5rem; }
.hand-lines-points { font-variant-numeric: tabular-nums; color: var(--sw-on-raised); }

/* A portrait phone puts the three other seats in one row across the top, so the trick has the whole width. Their cards
   still land on the side they sit, left, across and right. */
@media (max-width: 40rem) and (min-height: 30.01rem) {
  .tricks-table {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "left top right" "trick trick trick" "bottom bottom bottom" "hand hand hand";
    gap: .3rem;
  }
  .tricks-table .seat[data-place="left"], .tricks-table .seat[data-place="right"], .tricks-table .seat[data-place="top"] {
    justify-self: stretch; align-self: stretch; width: auto;
  }
  .seat { font-size: .8rem; padding: .25rem .3rem; }
  .seat-label { font-size: .62rem; }
}

@media (max-height: 30rem) {
  .last-trick-button { min-height: 2.25rem; padding-block: .1rem; }
  .auto-toggle { min-height: 2.25rem; padding-block: .1rem; font-size: .78rem; }
  .last-trick-cards { gap: .3rem; }
  .last-trick-face { width: min(100%, 3.4rem); }
  /* A phone on its side has little height, so the seats go to the corners round the trick, in the order of play: you at
     the lower left by your hand, then the upper left, the upper right and the lower right. The trick has the full height. */
  .tricks-table {
    grid-template-columns: minmax(7.5rem, 1fr) minmax(0, 3fr) minmax(7.5rem, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto;
    grid-template-areas: "left trick top" "bottom trick right" "hand hand hand";
  }
  .tricks-table .seat[data-place] { width: 100%; justify-self: stretch; }
  .tricks-table .seat[data-place="left"], .tricks-table .seat[data-place="top"] { align-self: start; }
  .tricks-table .seat[data-place="bottom"], .tricks-table .seat[data-place="right"] { align-self: end; }
  .seat[data-place="bottom"] { flex-direction: column; gap: .2rem; }
  .seat { padding: .2rem .3rem; }
}
@media (prefers-reduced-motion: reduce) {
  .hand-card { transition: none; }
  .seat[data-turn="true"] { animation: none; }
}
@media (forced-colors: active) {
  .hand-card[data-state="legal"], .hand-card[data-state="selected"], .seat[data-turn="true"], .seat[data-won="true"], .trick-card[data-winning="true"] { outline: 2px solid Highlight; }
  .pip, .pip-nil { border-color: CanvasText; }
  .pip[data-state="taken"], .pip[data-state="over"], .seat-bar[data-on="true"], .seat-dealer { background: CanvasText; color: Canvas; }
}
