:root {
  --felt: #0c3d2e;
  --felt-mid: #0f4a38;
  --felt-deep: #07261c;
  --gold: #e8c36a;
  --cream: #f4ead7;
  --ink: #14110e;
  --surface: #221e19;
  --muted: #9a8f7a;
  --playable: #3ecf8e;
  --danger: #e05a4f;
  --unplayable: #d0574d;
  --phone-w: 390px;
  --phone-h: 844px;
  --base-card-w: 58px;
  --base-card-h: 87px;
  --card-w: var(--base-card-w);
  --card-h: var(--base-card-h);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #0c0a08;
  color: var(--cream);
  font-family: system-ui, sans-serif;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.frame {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.phone {
  width: min(100%, var(--phone-w));
  height: var(--phone-h);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  border-radius: 32px;
  overflow: hidden;
  position: relative;
  background: var(--felt-deep);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  container-type: inline-size;
  container-name: phone;
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  padding: 16px 0;
  flex-direction: column;
}

.screen.is-on {
  display: flex;
}

.screen.felt.is-on {
  padding: 4px 0 12px;
}

.meta {
  background: linear-gradient(180deg, #1a1612, #12100d);
}

.felt {
  background:
    radial-gradient(circle at 50% 8%, rgba(232, 195, 106, 0.1), transparent 36%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 2px, transparent 2px 4px),
    var(--felt-image, none) center / cover no-repeat,
    linear-gradient(180deg, var(--felt-mid), var(--felt-deep));
  padding-top: 8px;
}

.topbar,
.pad,
.table-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
}

.scroll {
  overflow: auto;
  padding: 12px 16px 8px;
  flex: 1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack[hidden] {
  display: none;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  text-align: left;
}

.btn {
  border-radius: 999px;
  padding: 10px 14px;
  background: #2c261f;
}

.btn.primary {
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
}

.btn.danger {
  background: var(--danger);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(232, 195, 106, 0.25);
}

.table-chrome,
.table-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 0;
  flex-shrink: 0;
}

.table-rivals {
  display: flex;
  justify-content: space-evenly;
  gap: 28px;
  /* The bottom clears the downward arch of a fan that faces you. */
  padding: 8px 12px 14px;
  flex-shrink: 0;
}

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 128px;
  padding: 6px 8px;
  border-radius: 16px;
}

.seat .who {
  font-size: 12px;
}

.role {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-role {
  align-self: center;
  margin: 6px 0 0;
  min-height: 1.3em;
  flex-shrink: 0;
}

/* One line under the cards, kept when empty, so the seat does not grow and shrink. */
.seat-said {
  min-height: 1.4em;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-align: center;
}

.table-statements {
  align-self: center;
  max-width: min(92%, 520px);
  margin: 6px 0 0;
  text-align: center;
  flex-shrink: 0;
}

.table-statements[hidden] {
  display: none;
}

.statement-line {
  margin: 2px 0;
  padding: 6px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 14px;
}

.statement-line.is-new {
  animation: statement-in 320ms ease-out;
}

@keyframes statement-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .statement-line.is-new {
    animation: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pcard.is-flying {
  z-index: 80;
  pointer-events: none;
}

/* One layer above the table for the cards in flight; the message box stays above it. */
.flight-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.flight-layer > .pcard.flight-copy {
  position: fixed;
  margin: 0;
  transform: none;
}

/* Both faces of a card that turns over in flight lie on the copy's box. */
.flight-copy > img.flight-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pcard.is-flying-away {
  visibility: hidden;
}

/* The one row that gives up height. Its cards stay the chosen size; extra cards scroll. */
.table-mid {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 8px;
  min-height: 0;
  /* A backstop. The fit keeps the cards inside this band; the bar is not the method. */
  overflow: hidden;
}

.table-screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.screen-split {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.screen-split[data-axis="row"] {
  flex-direction: row;
}

.screen.felt.is-on.has-screen {
  display: flex;
  flex-direction: column;
}

.table-messages {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.area-part {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex: 0 0 auto;
}

.area-part.is-grow {
  flex: 1 1 auto;
}

.area-board {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  --card-h: calc(var(--base-card-h) * var(--card-scale, 1));
  --card-w: calc(var(--card-h) * 2 / 3);
}

.area-board.is-grid,
.area-part.is-grid {
  align-items: stretch;
  justify-content: flex-start;
}

.area-board.is-stock,
.area-part.is-stock {
  padding-left: calc(var(--card-h) * 0.12);
  overflow: visible;
}

/* While the fit measures the screen, the grid's decs are out of the flow and
   clipped, so neither their old places nor their lines change the screen's size. */
.area-board.is-measuring,
.area-part.is-measuring {
  overflow: hidden;
}

.is-measuring > .grid-line,
.is-measuring > .placed-dec {
  position: absolute;
  left: 0;
  top: 0;
}

.grid-line {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.hand-row.is-line {
  justify-content: center;
  align-items: center;
}

.hand-row.is-line.at-right {
  justify-content: flex-end;
}

.hand-row.is-line.at-left {
  justify-content: flex-start;
}

.table-mid > .board,
.table-mid > .piles,
.table-mid > .area-part {
  --card-h: calc(var(--base-card-h) * var(--card-scale, 1));
  --card-w: calc(var(--card-h) * 2 / 3);
}

.piles {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  /* The turned stock hangs out of its box, to the left. A small inset keeps
     that edge inside the table. */
  padding-left: calc(var(--card-h) * 0.12);
  overflow: visible;
}

.piles:empty {
  display: none;
}

.dec {
  display: flex;
  align-items: center;
  justify-content: center;
}

.talon {
  position: relative;
  width: calc(var(--card-h) + 16px);
  height: calc(var(--card-h) + 16px);
}

.talon[data-style="cross"] {
  transform: rotate(var(--turn, 0deg));
}

.talon-open {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
}

.talon-lid {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: calc(var(--card-h) * var(--cover, 0.5) * 0.5);
  transform: translate(-50%, -50%) rotate(var(--lid-rot, 90deg));
}

.talon[data-style="parallel"] .talon-lid {
  transform: translate(-50%, -50%) rotate(var(--lid-rot, 0deg));
}

.talon[data-style="parallel"][data-facing="east"] {
  width: calc(var(--card-w) * (1 + var(--cover, 0.5)) + 10px);
  height: var(--card-h);
}

.talon[data-style="parallel"][data-facing="east"] .talon-open {
  left: auto;
  right: 0;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

.talon[data-style="parallel"][data-facing="east"] .talon-lid {
  left: 0;
  top: 50%;
  transform: translate(0, -50%) rotate(var(--lid-rot, 0deg));
}

.deck {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.deck.is-playable {
  cursor: pointer;
  filter: drop-shadow(0 3px 10px rgba(240, 200, 80, 0.45));
}

.deck-edge {
  position: absolute;
  top: 3px;
  left: 4px;
  right: calc(-1 * var(--thick, 4px));
  bottom: calc(-1 * var(--thick, 4px));
  border-radius: 6px;
  background: #2c3548;
  box-shadow:
    2px 1px 0 #1b2230,
    4px 2px 0 #252d3e,
    6px 3px 0 #1b2230;
}

.deck-face {
  position: relative;
  z-index: 1;
}

.board {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto;
  gap: 8px 6px;
  align-items: start;
  align-content: start;
  justify-items: center;
  min-width: 0;
  min-height: 0;
}

/* A screen part places its own decs. The grid above is only the table with no screen. */
.board.is-line,
.board.is-stack,
.piles.is-line,
.piles.is-stack {
  display: flex;
  flex-wrap: nowrap;
  grid-template-columns: none;
  grid-template-rows: none;
}

.board.is-anchor,
.piles.is-anchor {
  position: relative;
  min-height: var(--card-h);
}

.placed-dec {
  transform: translateX(var(--dx, 0px));
}

/* A grid gap cannot be negative. An overlap is a pull: the lower row moves
   up (--row-pull) and a wide row moves inward (--dx). The board's height is
   the stack. The lower row stays in front, so its top edge still reads as a row. */
.board-set {
  transform: translate(var(--dx, 0px), var(--row-y, 0px));
}

.board-set:nth-child(n + 4) {
  --row-y: var(--row-pull, 0px);
  position: relative;
  z-index: 1;
}

.arrange.is-cascade {
  position: relative;
  width: calc(var(--card-w) + (var(--n, 2) - 1) * var(--step-x, 14px));
  height: calc(var(--card-h) + (var(--n, 2) - 1) * var(--step-y, 12px));
}

.arrange.is-cascade .pcard {
  position: absolute;
  left: calc(var(--i, 0) * var(--step-x, 14px));
  top: calc(var(--i, 0) * var(--step-y, 12px));
  z-index: calc(var(--i, 0) + 1);
}

.arrange.is-cascade .pcard.is-playable {
  z-index: calc(var(--i, 0) + 1);
}

.arrange.is-cascade .pcard.is-cover {
  transform: rotate(14deg);
}

/* Put down one by one: every card on the centre, shifted and turned by its own
   --heap-x, --heap-y (shares of a card) and --heap-turn. The box keeps room for
   the farthest shift and turn, and does not grow with the cards. */
.arrange.is-heap {
  position: relative;
  width: calc(var(--card-w) * 1.35);
  height: calc(var(--card-h) * 1.25);
}

.arrange.is-heap .pcard {
  position: absolute;
  left: calc(50% - var(--card-w) / 2);
  top: calc(50% - var(--card-h) / 2);
  transform: translate(calc(var(--card-w) * var(--heap-x, 0)), calc(var(--card-h) * var(--heap-y, 0)))
    rotate(var(--heap-turn, 0deg));
}

/* Side by side, slightly overlapping: --seen of each card stays in view. */
.arrange.is-row {
  display: flex;
  flex-direction: row;
}

.arrange.is-row .pcard + .pcard {
  margin-left: calc(var(--card-w) * (var(--seen, 0.75) - 1));
}

/* stack: every dec in one cell, the same box; each later one offset by its margin. */
.area-part.is-stack,
.area-board.is-stack {
  display: grid;
  grid-template-columns: auto;
  grid-template-rows: auto;
}

.area-part.is-stack > .placed-dec,
.area-board.is-stack > .placed-dec {
  grid-area: 1 / 1;
  justify-self: start;
  align-self: start;
}

.table-calls,
.hand-row,
.seat-fan,
.table-actions {
  flex-shrink: 0;
}

/* The call buttons sit on their own layer, above any card that is lifted or flying past. */
.table-calls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 4px 12px;
  position: relative;
  z-index: 30;
  min-height: 46px;
}

/* An empty button row keeps its height, like the messages band above it. */
.table-calls:empty {
  visibility: hidden;
}

.is-room {
  visibility: hidden;
}

.hand-row,
.seat-fan,
.arrange.is-fan {
  display: flex;
  justify-content: center;
  overflow: visible;
}

/* The top padding is the room a hand card rises into: the fan's arc (26px), the hover
   lift (18px) and a playable card's step up (12px). A lifted card stays in this band.
   --card-scale is the applied size, shared with the open cards. */
.hand-row {
  --rise: 56px;
  --card-h: calc(var(--base-card-h) * var(--card-scale, 1));
  --card-w: calc(var(--card-h) * 2 / 3);
  /* The outer cards' tilted corners dip below the row; bigger cards dip further. */
  --dip: max(14px, calc(var(--card-h) * 0.16));
  padding: var(--rise) 12px var(--dip);
  min-height: calc(var(--card-h) + var(--rise) + var(--dip));
  align-items: flex-end;
}

.hand-row.fan-stack {
  flex-direction: column-reverse;
  align-items: center;
}

/* A second row of a big hand sits half behind the first, as a hand is held. */
.hand-row.fan-stack > .arrange + .arrange {
  margin-bottom: calc(var(--card-h) * -0.5);
}

.seat-fan {
  width: 128px;
  min-height: calc(var(--card-h) + 40px);
  padding: 4px 0 0;
}

/* A face-up card in another player's seat is an open card: the size of the
   open cards on the table, not of his small face-down fan. */
.seat-shown {
  --card-h: calc(var(--base-card-h) * var(--card-scale, 1));
  --card-w: calc(var(--card-h) * 2 / 3);
}

.seat-fan.fan-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 128px;
}

.arrange.is-fan[data-style="turn"] {
  align-items: flex-end;
  transform: rotate(var(--turn, 180deg));
}

.arrange.is-fan .pcard {
  margin-left: calc(-1 * var(--overlap, 28px));
  --mid: calc((var(--n, 1) - 1) / 2);
  --d: calc(var(--i, 0) - var(--mid));
  --maxd: max(0.5, calc((var(--n, 1) - 1) / 2));
  --u: calc(1 - (var(--d) / var(--maxd)) * (var(--d) / var(--maxd)));
}

.arrange.is-fan .pcard:first-child {
  margin-left: 0;
}

.arrange.is-fan[data-style="arch"][data-facing="south"],
.arrange.is-fan[data-style="turn"] {
  align-items: flex-end;
}

.arrange.is-fan[data-style="arch"][data-facing="north"] {
  align-items: flex-start;
}

.arrange.is-fan[data-style="arch"][data-facing="west"] {
  flex-direction: column;
  align-items: flex-start;
}

.arrange.is-fan[data-style="arch"][data-facing="west"] .pcard {
  margin-left: 0;
  margin-top: calc(-1 * var(--overlap, 28px));
}

.arrange.is-fan[data-style="arch"][data-facing="west"] .pcard:first-child {
  margin-top: 0;
}

.arrange.is-fan[data-style="arch"][data-facing="east"] {
  flex-direction: column;
  align-items: flex-end;
}

.arrange.is-fan[data-style="arch"][data-facing="east"] .pcard {
  margin-left: 0;
  margin-top: calc(-1 * var(--overlap, 28px));
}

.arrange.is-fan[data-style="arch"][data-facing="east"] .pcard:first-child {
  margin-top: 0;
}

.arrange.is-fan[data-style="arch"] .pcard,
.arrange.is-fan[data-style="turn"] .pcard {
  transform-origin: var(--origin-x, 50%) var(--origin-y, 100%);
  transform: translate(
      calc((var(--u) * var(--arc, 26px) + var(--lift, 0px)) * var(--away-x, 0)),
      calc((var(--u) * var(--arc, 26px) + var(--lift, 0px)) * var(--away-y, -1))
    )
    rotate(calc(var(--d) * var(--tilt, 10deg) * var(--tilt-sign, 1)));
}

.arrange.is-fan[data-facing="south"] .pcard:hover,
.arrange.is-fan[data-facing="south"] .pcard:focus-visible {
  transform: translate(
      calc((var(--u) * var(--arc, 26px) + var(--lift, 0px) + var(--hover-lift, 18px)) * var(--away-x, 0)),
      calc((var(--u) * var(--arc, 26px) + var(--lift, 0px) + var(--hover-lift, 18px)) * var(--away-y, -1))
    )
    rotate(calc(var(--d) * var(--tilt, 10deg) * var(--tilt-sign, 1)));
  z-index: 20;
}

/* Touch screens keep :hover after a tap: no hover lift there, or a tapped card stays up. */
@media (hover: none) {
  .arrange.is-fan[data-facing="south"] .pcard:hover {
    transform: translate(
        calc((var(--u) * var(--arc, 26px) + var(--lift, 0px)) * var(--away-x, 0)),
        calc((var(--u) * var(--arc, 26px) + var(--lift, 0px)) * var(--away-y, -1))
      )
      rotate(calc(var(--d) * var(--tilt, 10deg) * var(--tilt-sign, 1)));
    z-index: auto;
  }

  .hand-row {
    --rise: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arrange.is-fan .pcard,
  .arrange.is-fan .pcard:hover,
  .arrange.is-fan .pcard:focus-visible {
    transform: none;
  }
}

.card.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pcard {
  width: var(--card-w);
  height: var(--card-h);
  padding: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  flex: 0 0 auto;
  position: relative;
  overflow: visible;
}

.pcard img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: transparent;
  border-radius: 7px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.38);
}

.pcard .lbl {
  display: none;
}

.pcard.is-playable,
.pcard.slot {
  box-shadow:
    0 0 0 3px var(--playable),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

/* Your own hand: the frame follows the "Card frames" setting (none while you wait,
   none when off); a playable card is lifted either way. */
.pcard.in-hand.is-playable {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.pcard.in-hand.is-frame-ok {
  box-shadow:
    0 0 0 3px var(--playable),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

.pcard.in-hand.is-frame-no {
  box-shadow:
    0 0 0 3px var(--unplayable),
    0 4px 10px rgba(0, 0, 0, 0.4);
}

.hand-row .pcard.is-playable,
.seat-fan .pcard.is-playable {
  z-index: 3;
}

.hand-row .pcard.is-playable {
  --lift: 12px;
  transform: translateY(calc(-1 * var(--lift)));
}

.pcard.is-drag {
  touch-action: none;
  cursor: grab;
}

.pcard.is-ghosted {
  opacity: 0.35;
}

.pcard.is-dropped {
  visibility: hidden;
}

/* A dropped card waits at the drop point for the core's answer. */
.pcard.drop-ghost {
  position: fixed;
  z-index: 80;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

.pcard.drag-ghost {
  position: fixed;
  z-index: 80;
  margin: 0;
  pointer-events: none;
  transform: scale(1.08) rotate(-8deg);
  box-shadow:
    0 0 0 3px var(--playable),
    0 12px 24px rgba(0, 0, 0, 0.45);
}

.board-set.is-drop {
  border-radius: 10px;
  padding: 4px;
  min-height: var(--card-h);
}

.screen.felt.is-dragging .board-set.is-drop {
  box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.35);
}

.board-set.is-hot {
  box-shadow: 0 0 0 3px var(--playable);
  background: rgba(62, 207, 142, 0.12);
}

.pcard.slot {
  background: rgba(62, 207, 142, 0.18);
  border: 2px dashed rgba(62, 207, 142, 0.7);
}

.pcard.slot:not(.is-playable) {
  background: rgba(244, 234, 215, 0.06);
  border: 2px dashed rgba(244, 234, 215, 0.28);
  box-shadow: none;
}

/* A steady part's empty dec: its place is kept, nothing is drawn there. */
.pcard.slot.is-held {
  visibility: hidden;
}

.card-stack {
  position: relative;
  width: calc(var(--card-w) + (var(--shown, 1) - 1) * var(--step, 3px));
  height: var(--card-h);
}

.card-stack .stack-layer {
  position: absolute;
  left: calc(var(--s, 0) * var(--step, 3px));
  top: calc(var(--s, 0) * 1px);
}

.pcard.is-inert {
  cursor: default;
}

.pcard.is-inert.is-drag {
  cursor: grab;
}

.pcard.drag-ghost.is-arrange-only {
  box-shadow:
    0 0 0 3px rgba(244, 234, 215, 0.7),
    0 12px 24px rgba(0, 0, 0, 0.45);
}

.pcard.mini {
  width: var(--card-w);
  height: var(--card-h);
}

.pcard {
  transition: transform 180ms ease;
}

.seat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: #1b2838;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.version {
  margin-top: auto;
  font-size: 11px;
  opacity: 0.6;
  text-align: center;
}

/* Above every card layer, a flight included, and away from the hand band. */
.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 12px;
  background: #2c261f;
  padding: 12px;
  border-radius: 10px;
  z-index: 100;
  pointer-events: none;
}

.zoom {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
}

.zoom[hidden] {
  display: none;
}

.zoom img {
  max-width: 70%;
  border-radius: 12px;
}

.zoom #zoom-label {
  display: none;
}

.curtain {
  margin: auto;
  padding: 24px;
  text-align: center;
}

code {
  display: block;
  word-break: break-all;
  background: #2c261f;
  padding: 12px;
  border-radius: 8px;
}


/* sign-in (card-player) */
.field { display: flex; flex-direction: column; gap: 4px; }
.field input {
  font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.06); color: inherit;
}
.stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; }
.stats .num { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.recent { display: flex; flex-direction: column; gap: 4px; }
.recent .won { color: #9be59b; }
.recent .lost { color: #ff9c9c; }

.small { font-size: 0.8rem; line-height: 1.3; }

.setting {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 14px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.setting legend {
  padding: 0 6px;
  font-weight: 600;
}

.setting label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.setting p {
  flex-basis: 100%;
  margin: 0;
}

.pack-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex-basis: 100%;
}

.setting .pack-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pack-choice:has(input:checked) {
  border-color: var(--gold);
  background: rgba(232, 195, 106, 0.1);
}

.pack-faces {
  display: flex;
}

.pack-faces img {
  width: 40px;
  height: 60px;
  border-radius: 4px;
  margin-right: -12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.avatar-face {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
}

/* The phone frame is 390px wide on a wide window too. Compact seats, so the
   chosen card size — Normal, Large, or Larger — still has a middle. */
@container phone (max-width: 520px) {
  .table-rivals {
    --card-w: 36px;
    --card-h: 54px;
    gap: 12px;
    padding-top: 4px;
  }

  .seat-fan {
    min-height: calc(var(--card-h) + 22px);
  }

  .seat {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: center;
    align-items: center;
    column-gap: 6px;
    row-gap: 2px;
    min-width: 0;
    padding: 4px 6px;
  }

  .seat > .avatar {
    grid-row: 1 / span 2;
    width: 28px;
    height: 28px;
  }

  .seat > .who {
    grid-column: 2;
    align-self: end;
  }

  .seat > .role {
    grid-column: 2;
    align-self: start;
  }

  .seat > :not(.avatar):not(.who):not(.role) {
    grid-column: 1 / -1;
    justify-self: center;
  }
}

/* Phone-sized screens: the app is the screen. 100dvh is the visible height (100vh
   includes the area under a phone browser's address bar). */
@media (max-width: 520px) {
  .frame {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .phone {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  /* The table is a fixed column of rows; only the board (.table-mid) gives up height. */
  .screen.felt.is-on {
    padding: 0 0 max(8px, env(safe-area-inset-bottom));
  }

  .table-chrome {
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .table-rivals {
    gap: 12px;
    padding-top: 4px;
  }

  .seat {
    min-width: 0;
    padding: 4px 6px;
  }

  .table-actions {
    padding-top: 2px;
  }

}

/* Short screens: smaller cards and rival fans, so every row fits without scrolling. */
@media (max-width: 520px) and (max-height: 760px) {
  :root {
    --base-card-w: 48px;
    --base-card-h: 72px;
  }

  .table-rivals {
    --card-w: 36px;
    --card-h: 54px;
  }

  .seat-fan {
    min-height: calc(var(--card-h) + 36px);
  }

  /* Avatar beside the name and role; the fan and anything after it span the seat. */
  .seat {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: center;
    align-items: center;
    column-gap: 6px;
    row-gap: 2px;
  }

  .seat > .avatar {
    grid-row: 1 / span 2;
    width: 28px;
    height: 28px;
  }

  .seat > .who {
    grid-column: 2;
    align-self: end;
  }

  .seat > .role {
    grid-column: 2;
    align-self: start;
  }

  .seat > :not(.avatar):not(.who):not(.role) {
    grid-column: 1 / -1;
    justify-self: center;
  }

  .table-role,
  .table-statements {
    margin-top: 3px;
  }

  .statement-line {
    padding: 4px 10px;
    font-size: 13px;
  }

  .board {
    gap: 4px;
  }
}

/* A phone turned sideways: short and wide. The app is the screen, and the table becomes
   a grid: the rivals in a narrow column on the left, the board in the middle, the calls
   and Leave on the right, the hand along the bottom (one row, see app.js). */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --base-card-w: 44px;
    --base-card-h: 66px;
  }

  .frame {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .phone {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .screen.felt.is-on {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "chrome chrome chrome"
      "rivals role calls"
      "rivals statements calls"
      "rivals mid calls"
      "rivals hand actions";
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .table-chrome {
    grid-area: chrome;
    padding: 4px 12px 0;
  }

  .table-chrome .btn {
    padding: 5px 12px;
  }

  .table-rivals {
    grid-area: rivals;
    flex-direction: column;
    justify-content: space-evenly;
    gap: 4px;
    padding: 2px 4px;
    min-height: 0;
    overflow: hidden;
    --card-w: 30px;
    --card-h: 45px;
  }

  .seat {
    min-width: 0;
    padding: 4px;
    display: grid;
    grid-template-columns: auto auto;
    justify-content: center;
    align-items: center;
    column-gap: 6px;
    row-gap: 2px;
  }

  .seat > .avatar {
    grid-row: 1 / span 2;
    width: 26px;
    height: 26px;
  }

  .seat > .who {
    grid-column: 2;
    align-self: end;
  }

  .seat > .role {
    grid-column: 2;
    align-self: start;
  }

  .seat > :not(.avatar):not(.who):not(.role) {
    grid-column: 1 / -1;
    justify-self: center;
  }

  .seat-fan {
    min-height: calc(var(--card-h) + 22px);
  }

  .table-role {
    grid-area: role;
    justify-self: center;
    margin-top: 2px;
  }

  .table-statements {
    grid-area: statements;
    justify-self: center;
    margin-top: 2px;
  }

  .statement-line {
    padding: 3px 10px;
    font-size: 12px;
  }

  .table-mid {
    grid-area: mid;
    padding: 2px 6px;
  }

  .board {
    gap: 4px;
  }

  .table-calls {
    grid-area: calls;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
    padding: 4px 10px;
  }

  .hand-row {
    grid-area: hand;
    --rise: 40px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .table-actions {
    grid-area: actions;
    align-self: end;
    padding: 0 10px 8px;
  }
}
