:root {
  color-scheme: dark;
  font: 1rem/1.5 system-ui, sans-serif;
  color: #f5f4ec;
  background: #191714;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: clamp(.5rem, 2vw, 1.75rem);
}

h1 {
  margin: 0 0 1.5rem;
  font: bold clamp(2.5rem, 10vw, 4rem)/1 Georgia, serif;
}

form {
  margin-top: 1.5rem;
}

label {
  display: block;
  margin-bottom: .4rem;
}

.join-controls, .deal-options {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.deal-options {
  column-gap: 1.25rem;
  margin-bottom: .9rem;
}

input, select, button {
  box-sizing: border-box;
  padding: .55rem .85rem;
  border: 1px solid #87a89b;
  border-radius: .4rem;
  font: inherit;
}

input, select {
  width: 9rem;
  background: #153b31;
  color: inherit;
}

#code {
  text-transform: uppercase;
}

select {
  width: auto;
  max-width: 100%;
}

.profiles {
  margin-bottom: .9rem;
}

.profiles summary {
  cursor: pointer;
}

.profile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 2.25rem;
  gap: .4rem;
  align-items: center;
  margin-top: .6rem;
}

.profile-row input {
  width: 100%;
}

.profile-row .avatar {
  width: 2.25rem;
}

#discard-options {
  padding-inline-start: .9rem;
  border-inline-start: 1px solid #64877b;
}

input[type="number"] {
  width: 5.25rem;
}

button {
  background: #e9d399;
  color: #1c2e24;
  font-weight: 650;
  cursor: pointer;
}

button:disabled {
  opacity: .65;
  cursor: default;
}

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.lobby-code {
  margin-block: .25rem;
  font: bold 2.25rem ui-monospace, monospace;
  letter-spacing: .12em;
}

#status:empty {
  margin: 0;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.cards .card {
  display: block;
  touch-action: none;
  user-select: none;
}

.card {
  position: relative;
  box-sizing: border-box;
  width: var(--card-width);
  aspect-ratio: 5 / 7;
  padding: 0;
  border: 1px solid #c4b897;
  border-radius: .32rem;
  background: #f3efdf;
  color: #192421;
  font: bold .95rem/.9 Georgia, serif;
  box-shadow: 1px 3px 4px #061d15a0;
}

.card-corner,
.card-center {
  position: absolute;
  white-space: pre-line;
  text-align: center;
}

.card-corner {
  inset: .23rem auto auto .22rem;
}

.card-center {
  inset: 50% auto auto 58%;
  translate: -50% -50%;
  font-size: clamp(1.15rem, 3vw, 2rem);
}

.card-center.court {
  padding: .22rem .17rem;
  border: 1px solid #a48a59;
  border-radius: .23rem;
  background: #eee0bd;
  font-size: clamp(.9rem, 2.5vw, 1.35rem);
}

.card.red {
  color: #a52033;
}

button.card:enabled:hover,
button.card:focus-visible {
  outline: 2px solid #e9d399;
  translate: 0 -.3rem;
}

button.card:disabled {
  opacity: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#app {
  --gold: #e9d399;
  --wood: repeating-linear-gradient(174deg, #ad714333 0 2px, #2a160f30 2px 4px, transparent 4px 9px),
         linear-gradient(125deg, #58301e, #754527 32%, #402216 75%, #663a22);
  --card-width: clamp(2.8rem, 5.5vw, 4rem);
  max-width: 74rem;
  margin: auto;
}

.table-header,
.table-frame {
  border: 1px solid #96603a;
  background: var(--wood);
  box-shadow: inset 0 0 0 3px #3c2115, inset 0 0 0 5px #a5774c65, 0 4px 12px #0006;
}

.table-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: .65rem;
  margin-bottom: .85rem;
  padding: .45rem .8rem;
  border-radius: .8rem;
}

.table-header h1 {
  grid-column: 2;
  margin: 0;
  padding: .22rem clamp(.85rem, 4vw, 2.6rem) .32rem;
  border: 1px solid #997544;
  border-radius: .65rem;
  color: #f6e4bd;
  background: #282719;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: .015em;
  text-shadow: 0 2px #17140c;
}

.table-header h1::before,
.table-header h1::after {
  display: inline-block;
  margin-inline: .6em;
  color: #d8b573;
  font-size: .5em;
  vertical-align: middle;
}

.table-header h1::before { content: "♣"; }
.table-header h1::after { content: "♠"; }

#open-scores {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  margin-inline-end: .35rem;
}

#open-scores,
.score-actions button,
#archive-actions button,
#game-record-actions button,
.record-panel button,
.welcome-felt button,
#setup-list-games {
  border-color: #ae8750;
  color: #f4dc9d;
  background: #173a2e;
  box-shadow: inset 0 0 0 2px #10291f, 0 2px 3px #041a1380;
}

#app[data-screen="welcome"] #archive-actions {
  display: contents;
}

#list-scores { grid-area: 1 / 1; justify-self: end; }
#list-games { grid-area: 1 / 3; justify-self: start; }

#app:is([data-screen="setup"], [data-screen="join"]) :is(#archive-actions, #game-record-actions, #open-scores, #table-code) {
  display: none;
}

.felt.welcome-felt {
  grid-template-rows: auto auto;
  place-content: center;
  gap: .7rem;
}

.welcome-felt button {
  width: min(14rem, calc(100vw - 4rem));
}

#new-game-entry {
  min-height: 3.2rem;
}

.setup-panel,
#lobby-view {
  box-sizing: border-box;
  width: min(100%, 51rem);
  margin: clamp(1.2rem, 10vh, 5.5rem) auto 0;
  padding: clamp(1rem, 3vw, 1.9rem);
  border: 1px solid #4c796a;
  border-radius: 1rem;
  background: #174639;
  box-shadow: 0 5px 10px #0004;
}

.setup-panel h2,
#lobby-view h2 {
  margin: 0 0 1.2rem;
  font: bold clamp(1.55rem, 5vw, 2.15rem)/1.2 Georgia, serif;
}

.setup-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.6rem, 3vw, 1.7rem);
}

.setup-group {
  min-width: 0;
  padding: clamp(.65rem, 2vw, 1rem);
  border-radius: .7rem;
  background: #10382e;
}

.setup-group h3 {
  margin: 0 0 .8rem;
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 600;
}

.setup-row, .setup-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .55rem;
  margin-bottom: .65rem;
}

.setup-row label { margin: 0; }

.stepper {
  display: flex;
  flex: none;
  align-items: center;
  gap: .2rem;
}

.stepper button {
  width: 2rem;
  height: 2.3rem;
  padding: 0;
  font-weight: 500;
}

.stepper :is(select, input) {
  appearance: textfield;
  width: 2.6rem;
  padding: .25rem;
  border-color: transparent;
  text-align: center;
  background: transparent;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { appearance: none; }

.setup-toggle { position: relative; cursor: pointer; }

.setup-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .4rem;
  margin-bottom: .65rem;
}

.setup-option .setup-toggle { margin: 0; }

.setup-help {
  padding: .1rem .15rem;
  border-color: transparent;
  background: transparent;
  color: #c1d1c2;
  line-height: 1.3;
}

.setup-help[aria-expanded="true"] { color: var(--gold); }

#setup-option-help {
  margin: 0;
  padding: .5rem;
  border-radius: .4rem;
  background: #092a20;
  color: #f5f4ec;
  font-size: .88rem;
}

.setup-toggle input {
  position: absolute;
  inset: 0 0 0 auto;
  width: 3.3rem;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-face {
  flex: 0 0 3.3rem;
  padding-block: .3rem;
  border: 1px solid #c6a66f;
  border-radius: .4rem;
  color: #281d12;
  background: #d8bb84;
  text-align: center;
}

.toggle-face::after { content: "Nei"; }
.setup-toggle input:checked + .toggle-face::after { content: "Já"; }
.setup-toggle input:focus-visible + .toggle-face { outline: 2px solid white; outline-offset: 2px; }

.setup-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .7rem;
  margin-top: 1rem;
}

.setup-footer p { margin: 0; color: #c1d1c2; }
.setup-footer > div { display: flex; flex-wrap: wrap; gap: .5rem; }
.join-panel, #lobby-view { width: min(100%, 28rem); }
#cancel-join { margin-top: .8rem; }

#archive-actions,
#game-record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

#game-record-actions {
  grid-area: 1 / 3;
  justify-self: end;
  justify-content: flex-end;
}

.score-paper {
  box-sizing: border-box;
  width: min(46rem, calc(100% - 1.5rem));
  height: min(36rem, calc(100svh - 1.5rem));
  max-width: none;
  max-height: none;
  padding: clamp(1rem, 4vw, 1.9rem);
  border: 2px solid #ac8650;
  border-radius: .65rem;
  color-scheme: light;
  color: #4a2e1c;
  background: #ecdbb1;
  box-shadow: inset 0 0 0 4px #f3e7c8, inset 0 0 0 5px #b99664, 0 8px 28px #0007;
}

.score-paper[open] {
  display: flex;
  flex-direction: column;
  gap: .8rem;
}

.score-paper::backdrop {
  background: #080c09b5;
}

.score-paper h2 {
  margin: 0;
  font: bold clamp(1.55rem, 5vw, 2.15rem)/1.2 Georgia, serif;
}

.scores-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#scores-grid, #archive-grid {
  width: 100%;
  min-width: calc(var(--score-columns, 1) * 6rem);
  table-layout: fixed;
  border-spacing: .25rem;
}

#scores-grid th, #archive-grid th {
  position: sticky;
  top: 0;
  padding: .3rem .15rem;
  background: #ecdbb1;
  font-weight: 600;
  overflow-wrap: anywhere;
}

#archive-grid td {
  padding: .45rem .25rem;
  border: 1px solid #c5aa76;
  border-radius: .35rem;
  background: #f2e4bd;
  text-align: center;
}

.record-panel:not(.score-paper) {
  box-sizing: border-box;
  width: min(32rem, calc(100% - 1.5rem));
  max-width: none;
  padding: clamp(1.15rem, 4vw, 2rem);
  border: 1px solid #4c796a;
  border-radius: 1rem;
  color: #f5f4ec;
  background: #174639;
  box-shadow: 0 6px 22px #0008;
}

.record-panel::backdrop {
  background: #080c09b5;
}

.record-panel:not(.score-paper) h2 {
  margin: 0 0 .9rem;
  font: bold clamp(1.5rem, 5vw, 2.1rem)/1.2 Georgia, serif;
}

.record-panel:is(.score-paper) > #record-back {
  align-self: end;
}

#record-date {
  margin: 0 0 .5rem;
}

#record-list-view {
  max-height: min(50svh, 20rem);
  overflow: auto;
}

#record-list {
  display: grid;
  gap: .5rem;
  margin: .3rem 0 .8rem;
  padding: 0;
  list-style: none;
}

#record-list button {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .4rem;
  width: 100%;
  text-align: start;
  overflow-wrap: anywhere;
}

#record-list time {
  color: #bfd1c7;
  font-size: .85rem;
  font-weight: normal;
}

#record-name-view {
  margin-top: 0;
}

#record-name {
  width: 100%;
}

.record-footer,
.end-game-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin-top: 1rem;
}

#record-status:empty {
  display: none;
}

.unsaved-note {
  color: var(--gold);
  font-weight: 650;
}

#scores-grid input {
  width: 100%;
  padding: .45rem .25rem;
  border-color: #c5aa76;
  color: #34251a;
  background: #f2e4bd;
  text-align: center;
}

#scores-grid input:focus {
  outline: 2px solid #8b653c;
  outline-offset: -2px;
  background: #fff1cc;
}

#scores-status {
  margin: 0;
}

#scores-status:empty {
  display: none;
}

.score-actions {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
}

.score-actions form {
  margin: 0;
}

.score-actions button:focus-visible {
  outline-color: #73522b;
}

.table-code {
  grid-area: 1 / 3;
  justify-self: end;
  margin: 0;
  padding-inline: .4rem;
  color: #f6e4bd;
  font: 600 .85rem ui-monospace, monospace;
}

.table-header:has(#game-record-actions:not([hidden])) .table-code {
  grid-row: 2;
}

#status:not(:empty) {
  color: #f6e4bd;
  text-align: center;
}

.table-frame {
  padding: clamp(.45rem, 1.3vw, .95rem);
  border-radius: clamp(1.5rem, 5vw, 4.7rem);
}

.felt {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: clamp(1.15rem, 3vh, 2.25rem);
  min-height: clamp(31rem, calc(100svh - 8rem), 47rem);
  padding: clamp(.9rem, 3vh, 1.65rem) clamp(.65rem, 3vw, 2.25rem);
  border: 1px solid #30231a;
  border-radius: clamp(1.2rem, 4.3vw, 3.9rem);
  background: radial-gradient(circle at 30% 27%, #ffffff0b 0 .55px, transparent 1.25px) 0 0 / 5px 7px,
              radial-gradient(circle at 63% 71%, #071e1736 0 .45px, transparent 1.3px) 1px 1px / 7px 5px,
              radial-gradient(ellipse at 50% 46%, #19543e, #104332 60%, #0b3025);
  box-shadow: inset 0 2px 10px #041a13c0;
}

.game-history {
  box-sizing: border-box;
  width: min(100%, 40rem);
  padding: .55rem .7rem;
  border: 1px solid #a0c0a44d;
  border-radius: .7rem;
  background: #092a20d2;
}

.game-history h2 {
  margin: 0;
  padding-bottom: .25rem;
  border-bottom: 1px solid #a0c0a44d;
  color: var(--gold);
  font-size: .95rem;
}

.history-scroll {
  max-height: 8rem;
  overflow: auto;
  scrollbar-gutter: stable;
}

#history-entries {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .88rem;
  overflow-wrap: anywhere;
}

#history-entries li {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: .4rem;
  padding-block: .22rem;
}

#undo {
  padding: .12rem .5rem;
  border-color: #c9a463;
  border-radius: .55rem;
  font-size: .82rem;
}

.seat,
.shared-zone {
  width: min(100%, 40rem);
  box-sizing: border-box;
}

.seat {
  display: grid;
  justify-items: center;
  gap: .55rem;
  text-align: center;
}

.seat-badge,
.seat-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .5rem;
}

.seat-badge h2,
#board-heading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.seat-badge {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.seat-count,
#stock-count,
#play-hint,
#empty-board,
#empty-hand {
  color: #c1d1c2;
  font-size: .9rem;
}

.avatar {
  width: 2.65rem;
  aspect-ratio: 1;
  background: url("avatars.png") 0 0 / 200% 200% no-repeat;
}

.avatar[data-avatar="0"] {
  visibility: hidden;
}

.seat-badge .avatar[data-avatar="0"] {
  display: none;
}

.avatar[data-avatar="2"] {
  background-position: 100% 0;
}

.avatar[data-avatar="3"] {
  background-position: 0 100%;
}

.avatar[data-avatar="4"] {
  background-position: 100% 100%;
}

.card-backs {
  display: flex;
  min-height: calc(var(--card-width) * 1.4);
}

.card-backs .card-back + .card-back {
  margin-inline-start: calc(var(--card-width) * -.56);
}

.card-back {
  display: block;
  box-sizing: border-box;
  width: var(--card-width);
  aspect-ratio: 5 / 7;
  border: 3px solid #eee7d7;
  border-radius: .32rem;
  background: repeating-conic-gradient(from 45deg, #6e87a544 0 25%, transparent 0 50%) 0 0 / 7px 7px,
              #233a5b;
  box-shadow: inset 0 0 0 1px #a8a28e, inset 0 0 0 3px #223551, 1px 2px 3px #041a13b0;
}

.shared-zone {
  display: grid;
  align-self: center;
  gap: .75rem;
  min-height: 11.5rem;
  padding: .85rem clamp(.6rem, 2.5vw, 1.2rem);
  border: 1px solid #a0c0a44d;
  border-radius: 1.2rem;
  background: #092f23ba;
  text-align: center;
}

.shared-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.board-cards.drop-zone {
  display: grid;
  align-content: center;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.shared-zone:has(.board-cards.drop-highlight) {
  border-color: var(--gold);
  background: #665c2b88;
  box-shadow: inset 0 0 0 1px var(--gold);
}

.board-cards .cards {
  justify-content: center;
}

.drop-zone {
  position: relative;
  min-height: calc(var(--card-width) * 1.4 + .9rem);
  padding: .5rem;
  border: 1px solid #a0c0a44d;
  border-radius: .85rem;
}

.seat-zone {
  box-sizing: border-box;
  width: min(95%, 34rem);
  background: #092f237a;
}

.drop-zone.drop-highlight {
  border-color: var(--gold);
  background: #b99c4529;
  box-shadow: inset 0 0 0 1px var(--gold);
}

.placed {
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: calc(-1 * var(--x)) calc(-1 * var(--y));
}

.card.landing-outline {
  z-index: 1;
  pointer-events: none;
  border: 2px solid var(--gold);
  background: #e9d39930;
  box-shadow: none;
}

.card.held-card {
  position: fixed;
  z-index: 10;
  pointer-events: none;
}

.drop-button:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.drop-button:focus {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.piles {
  display: flex;
  align-items: center;
  gap: clamp(.2rem, 1vw, .75rem);
  padding-inline-start: clamp(.2rem, 1vw, .85rem);
  border-inline-start: 1px solid #a0c0a44d;
}

.stock {
  display: grid;
  justify-items: center;
  gap: .2rem;
}

.discard-zone {
  min-height: 0;
  padding: .25rem;
  border-color: transparent;
}

.empty-pile {
  border: 1px dashed #a0c0a4;
  background: transparent;
  box-shadow: none;
}

#table[data-players="1"] .felt {
  grid-template-rows: 1fr auto;
}

#table:is([data-players="3"], [data-players="4"]) .felt {
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) minmax(0, 1fr);
  column-gap: clamp(.45rem, 2vw, 1.5rem);
}

#table:is([data-players="3"], [data-players="4"]) :is(.opponent-top, .shared-zone, .your-seat) {
  grid-column: 2;
}

#table:is([data-players="3"], [data-players="4"]) .shared-zone {
  grid-row: 2;
}

#table:is([data-players="3"], [data-players="4"]) .your-seat {
  grid-row: 3;
}

#table:is([data-players="3"], [data-players="4"]) .game-history {
  grid-column: 1 / -1;
}

@media (min-width: 68rem) {
  .game-history {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: min(15rem, calc((100% - 42rem) / 2));
  }
}

.opponent-left, .opponent-right {
  grid-row: 2;
  align-self: center;
}

.opponent-left { grid-column: 1; }
.opponent-right { grid-column: 3; }

.opponent-left .card-backs, .opponent-right .card-backs {
  --card-width: clamp(2.4rem, 4vw, 3rem);
}

:is(.opponent-left, .opponent-right) .card-backs .card-back + .card-back {
  margin-inline-start: calc(var(--card-width) * -.79);
}

#draw {
  display: grid;
  justify-items: center;
  gap: .6rem;
  padding: .2rem .35rem;
  border-color: transparent;
  color: var(--gold);
  background: transparent;
}

.stock-back {
  box-shadow: inset 0 0 0 1px #a8a28e, inset 0 0 0 3px #223551,
              0 3px #ae9e7e, 0 5px #6e5740, 0 7px #b2a181, 1px 9px 3px #041a13b0;
}

#draw:enabled:hover .stock-back {
  outline: 2px solid var(--gold);
}

#draw.empty-stock .stock-back {
  border: 1px dashed #a0c0a4;
  background: transparent;
  box-shadow: none;
}

#hand {
  justify-content: center;
  padding: .45rem .25rem .7rem;
}

#hand-area {
  box-sizing: border-box;
  width: 100%;
  min-height: calc(var(--card-width) * 1.4 + 1rem);
  padding: 0;
}

.hand-marker {
  position: absolute;
  z-index: 2;
  width: 3px;
  border-radius: 2px;
  background: var(--gold);
  pointer-events: none;
}

#hand.fanned {
  flex-wrap: nowrap;
  gap: 0;
}

#hand.fanned li + li {
  margin-inline-start: calc(var(--card-width) * -.33);
}

#hand.fanned li {
  transform: translateY(var(--drop)) rotate(var(--tilt));
  transform-origin: center 90%;
}

#hand.fanned li:focus-within {
  z-index: 1;
}

.cards .card:enabled {
  cursor: grab;
}

.cards .card.picked-up {
  opacity: 0;
}

#hand li.raised {
  position: relative;
  z-index: 1;
  translate: 0 calc(var(--card-width) * -.22);
}

.holding-card,
.holding-card .drop-zone {
  cursor: grabbing;
}

#empty-hand,
#play-hint,
#turn {
  margin: 0;
}

.seat-controls {
  column-gap: 1rem;
}

#turn {
  color: #f1dfaf;
}

.turn-action {
  position: relative;
}

#confirm-turn {
  position: absolute;
  z-index: 3;
  inset: auto 0 calc(100% + .25rem);
  border-color: #b28a4e;
  animation: reveal-turn-confirmation .16s ease-out;
}

@keyframes reveal-turn-confirmation {
  from { opacity: 0; transform: translateY(.65rem); }
}

@media (prefers-reduced-motion: reduce) {
  #confirm-turn { animation: none; }
}

#end-turn {
  border: 1px solid #b28a4e;
  color: #f4dc9d;
  background: #173a2e;
  box-shadow: inset 0 0 0 2px #10291f, 0 2px 3px #041a1380;
}

#end-turn:enabled:hover {
  background: #25523f;
}

@media (max-width: 54rem) {
  #table:is([data-players="3"], [data-players="4"]) .felt {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto 1fr auto;
  }

  #table:is([data-players="3"], [data-players="4"]) :is(.opponent-top, .shared-zone, .your-seat) {
    grid-column: 1 / -1;
  }

  #table:is([data-players="3"], [data-players="4"]) .shared-zone { grid-row: 3; }
  #table:is([data-players="3"], [data-players="4"]) .your-seat { grid-row: 4; }
  .opponent-right { grid-column: 2; }
  #table[data-players="3"] .opponent-left { grid-column: 1 / -1; }
}

@media (max-width: 36rem) {
  .table-header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: .35rem;
  }

  .table-header h1 {
    grid-column: 1;
  }

  #open-scores,
  #game-record-actions,
  .table-header:has(#game-record-actions:not([hidden])) .table-code,
  .table-code {
    grid-column: 1;
    grid-row: auto;
    justify-self: center;
    margin: 0;
  }

  #app[data-screen="welcome"] #archive-actions {
    display: flex;
    justify-content: center;
  }

  #game-record-actions { justify-content: center; }
  .setup-columns { grid-template-columns: 1fr; }
  .record-panel .end-game-options { grid-template-columns: 1fr; }

  .table-code {
    justify-self: center;
  }

  #stock-count {
    max-width: 6rem;
  }

  #hand.fanned li + li {
    margin-inline-start: calc(var(--card-width) * -.47);
  }
}
