#identity {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  max-width: 1060px;
  margin: clamp(22px, 6vh, 66px) auto;
  border: 1px solid #b9b3a1;
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 12px 35px #33261513;
  overflow: hidden;
}
.welcome-table {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: end;
  min-height: clamp(410px, 58vh, 555px);
  padding: clamp(30px, 4vw, 62px);
  overflow: hidden;
  color: #fff4d6;
  background: #143c2b url('/felt-table.jpg') 52% 42% / auto 138% no-repeat;
}
.welcome-table::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg, #071a0fe8, #0b281635 46%, transparent 82%);
}
.welcome-title {
  position: relative;
}
.welcome-title h1 {
  margin: 0;
  font: 800 clamp(37px, 4.6vw, 66px) / 1.18 var(--serif);
  letter-spacing: -0.025em;
}
.welcome-title p {
  margin: 13px 0 0;
  color: #e5d6b0;
  font-size: 14px;
  letter-spacing: 0.1em;
}
.welcome-cards {
  position: absolute;
  left: 50%;
  top: 37%;
  width: 0;
  height: 0;
  transform: rotate(-5deg);
}
.souvenir {
  position: absolute;
  width: 106px;
  height: 151px;
  border-radius: 8px;
  border: 1px solid #d7c9a8;
  background: linear-gradient(125deg, #fffef7, #eee6d0);
  box-shadow: 4px 9px 12px #07140ccb;
  color: #1b3027;
  font-family: Georgia, serif;
}
.souvenir span {
  display: grid;
  width: 30px;
  text-align: center;
  margin: 8px 0 0 4px;
  font:
    28px/0.9 Georgia,
    serif;
}
.souvenir small {
  font:
    20px/1 Georgia,
    serif;
}
.souvenir b {
  position: absolute;
  left: 35%;
  top: 39%;
  font:
    66px/1 Georgia,
    serif;
}
.card-back,
.deck-backs i {
  border: 3px solid #f1e3c2;
  background-color: #712e29;
  background-image:
    repeating-linear-gradient(45deg, transparent 0 4px, #d9aa7955 4px 5px),
    repeating-linear-gradient(-45deg, transparent 0 4px, #d9aa7955 4px 5px);
  box-shadow:
    inset 0 0 0 2px #833a2f,
    inset 0 0 0 3px #dab991,
    2px 4px 7px #08180dc9;
}
.souvenir.card-back {
  transform: translate(-113%, -45%) rotate(-21deg);
}
.black-ace {
  transform: translate(-55%, -60%) rotate(-4deg);
}
.red-ace {
  transform: translate(1%, -39%) rotate(14deg);
  color: #ae3f2e;
}
#identityForm {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 21px;
  padding: clamp(26px, 4.6vw, 62px);
}
#identityForm h2 {
  margin: 0 0 5px;
  font: 800 clamp(30px, 3.4vw, 46px) / 1.14 var(--serif);
}
.identity-choices {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.identity-choices legend,
.identity-name label {
  display: block;
  padding: 0;
  margin: 0 0 9px;
  font-size: 14px;
  font-weight: 700;
}
.role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.role-option {
  position: relative;
  cursor: pointer;
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 91px;
  padding: 13px 15px;
  border: 1px solid #abab98;
  border-radius: 7px;
  background: #f7f4e8;
}
.role-option:hover,
.role-option:has(input:focus-visible) {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}
.role-option:has(input:checked) {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
  background: #e9eee0;
}
.role-option input {
  position: absolute;
  top: 12px;
  right: 12px;
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}
.role-icon {
  font:
    26px/1 Georgia,
    serif;
  color: var(--green);
}
.role-option strong {
  font-size: 16px;
  line-height: 1.3;
}
.identity-name input,
.quick-select input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #9ea58e;
  padding: 8px 12px;
  border-radius: 5px;
  background: #fffdf7;
}
.enter-gate {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 5px;
}
.enter-gate span {
  margin: 0;
}
.enter-gate:disabled {
  opacity: 1;
  background: #d9dfd1;
  border-color: #c4cbbd;
  color: #545f53;
}
#identityError {
  margin: 0;
}
.lobby-heading {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0 22px;
}
.lobby-heading h1 {
  margin: 0;
  font: 800 clamp(30px, 4vw, 46px) / 1.1 var(--serif);
}
.lobby-heading div {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.table-cabinet {
  border: 1px solid #382c1e;
  background: #211e15;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 5px 12px #221a1529;
  color: #fcf4d7;
}
.table-strip,
.turn-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 19px;
}
.table-strip {
  color: #e1d8bb;
  border-bottom: 1px solid #5f4a30;
  background: #29291f;
  font-size: 12px;
}
.table-strip strong {
  font-weight: 550;
}
.table-strip i {
  font-style: normal;
  padding: 0 5px;
  opacity: 0.6;
}
#connection {
  white-space: nowrap;
  color: #dce6c9;
}
#connection::before {
  content: '●';
  padding-right: 5px;
  color: #95b984;
  font-size: 9px;
}
.table-stage {
  position: relative;
  isolation: isolate;
  height: clamp(308px, 39vh, 460px);
  background: #153d2a url('/felt-table.jpg') center / 100% 100% no-repeat;
}
.pos-north {
  --sx: 50%;
  --sy: 11%;
  --px: 50%;
  --py: 30%;
}
.pos-west {
  --sx: 12%;
  --sy: 50%;
  --px: 30.5%;
  --py: 50%;
}
.pos-east {
  --sx: 88%;
  --sy: 50%;
  --px: 69.5%;
  --py: 50%;
}
.pos-upper-west {
  --sx: 18%;
  --sy: 25%;
  --px: 27%;
  --py: 46%;
}
.pos-upper-east {
  --sx: 82%;
  --sy: 25%;
  --px: 73%;
  --py: 46%;
}
.pos-south {
  --sx: 50%;
  --sy: 89%;
  --px: 50%;
  --py: 70%;
}
.seat-pin,
.played,
.table-centre {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
}
.seat-pin {
  left: var(--sx);
  top: var(--sy);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  width: clamp(100px, 15vw, 170px);
  max-width: 24%;
  min-height: 48px;
  border: 1px solid #899773;
  border-radius: 8px;
  background: linear-gradient(125deg, #223529f5, #15291ff5);
  color: #f5eed8;
  box-shadow: 0 3px 7px #0008;
  text-align: left;
}
.seat-pin.on-turn {
  border-color: #ffd676;
  box-shadow:
    0 0 0 2px #deb261,
    0 4px 14px #141006b3;
}
.seat-pin.self {
  background: linear-gradient(125deg, #354331f5, #29372cf5);
}
.seat-pin.vacant {
  opacity: 0.85;
  border-style: dashed;
}
.seat-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 29px;
  height: 33px;
  border: 1px solid #98956c;
  border-radius: 45% 45% 40% 40%;
  background: #47563b;
  color: #f5e3af;
  font:
    23px/1 Georgia,
    serif;
}
.seat-avatar.agent {
  background: #334c4c;
}
.seat-info {
  min-width: 0;
}
.seat-pin small,
.seat-pin strong,
.seat-info > span {
  display: block;
  overflow-wrap: anywhere;
}
.seat-pin strong {
  font-size: clamp(12px, 1.2vw, 16px);
  line-height: 1.28;
  max-height: 2.6em;
  overflow: hidden;
}
.seat-pin small {
  color: #dfd4ac;
  font-size: 10px;
  line-height: 1.35;
}
.seat-info > span {
  font-size: 11px;
  line-height: 1.3;
  color: #e2e5cc;
}
.played {
  z-index: 1;
  left: var(--px);
  top: var(--py);
  width: 22%;
}
.play-label {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  background: #0a291bd9;
  border: 1px solid #b2bb8759;
  border-radius: 4px;
  color: #ffedbe;
  font-size: 11px;
  line-height: 1.3;
  padding: 2px 6px;
}
.table-centre {
  left: 50%;
  top: 50%;
  width: max-content;
  max-width: 22%;
}
.table-centre > small {
  display: block;
  margin-top: 4px;
  color: #f1deb0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 3px #102215;
}
.deck-backs {
  height: 39px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 5px;
}
.deck-backs i {
  display: block;
  width: 25px;
  height: 35px;
  margin-right: -6px;
  border-radius: 3px;
  border-width: 2px;
}
.deck-backs i:first-child {
  transform: rotate(-12deg) translateY(2px);
}
.deck-backs i:last-child {
  transform: rotate(13deg) translateY(2px);
}
.trick-cards {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  row-gap: 2px;
  padding-left: 4px;
}
.trick-card {
  display: grid;
  justify-items: center;
  align-content: center;
  background: linear-gradient(120deg, #fffdf1, #e9dfc7);
  color: #172d25;
  border: 1px solid #c4bea5;
  border-radius: 4px;
  width: 31px;
  height: 41px;
  margin-left: -4px;
  box-shadow: 1px 2px 2px #101b1466;
  line-height: 1;
}
.trick-card b {
  white-space: nowrap;
  font:
    bold 15px/1 Georgia,
    var(--serif);
}
.trick-card.joker b {
  font-size: 10px;
}
.trick-card i {
  font:
    13px/1 Georgia,
    serif;
}
.trick-card.named {
  width: 43px;
  height: auto;
  min-height: 39px;
  padding: 2px;
}
.trick-card em {
  font: 700 10px/1.15 var(--serif);
}
.trick-cards.long .trick-card {
  width: 23px;
  height: 29px;
  margin-left: -5px;
}
.trick-cards.long .trick-card b,
.trick-cards.long .trick-card i {
  font-size: 11px;
}
.warm {
  color: #a93628;
}
.turn-line {
  min-height: 44px;
  background: #28372b;
  border-top: 1px solid #9d7542;
  font-size: 14px;
}
.turn-line > div {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
.turn-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9fa890;
}
.turn-dot.mine {
  background: #f2c565;
  box-shadow: 0 0 0 3px #ead18130;
}
.turn-extra {
  color: #e3d8b6;
  font-size: 12px;
}
.deal {
  background: #eaca84;
  color: #282618;
  padding: 7px 13px;
  font-weight: 750;
  white-space: nowrap;
}
.hand-tray {
  margin: 8px 0;
  border-radius: 8px;
}
.card-spread {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 10px;
  padding: 20px 28px 9px 0;
}
.playing-card {
  position: relative;
  display: block;
  flex: 0 0 clamp(32px, 3.7vw, 49px);
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
  color: #192b27;
}
.playing-card.warm {
  color: #ac3527;
}
.paper-face {
  display: block;
  pointer-events: auto;
  position: absolute;
  top: 0;
  left: 0;
  width: 59px;
  height: 100%;
  border: 1px solid #a8a493;
  border-radius: 5px;
  padding: 5px;
  background: linear-gradient(130deg, #fffef9 30%, #eee9d9);
  box-shadow: 1px 3px 4px #302b1f40;
  transition: transform 110ms ease;
}
.playing-card[aria-pressed='true'] .paper-face {
  transform: translateY(-10px);
  background: #eaf2df;
  border-color: #246341;
  box-shadow:
    0 -3px 0 #418647,
    1px 3px 5px #26351b44;
}
.playing-card:focus-visible {
  outline: none;
  z-index: 2;
}
.playing-card:focus-visible .paper-face {
  outline: 3px solid #c47b28;
}
.playing-card[aria-disabled='true'] .paper-face {
  background: #e8e6dd;
  color: #6f726b;
}
.playing-card.wild .paper-face {
  border-color: #ba8a32;
}
.card-index {
  display: grid;
  text-align: center;
  width: max-content;
  min-width: 15px;
  font:
    700 22px/0.92 Georgia,
    var(--serif);
}
.card-index small {
  font:
    15px/1 Georgia,
    var(--serif);
}
.joker .card-index {
  font: 750 12px/1.3 var(--serif);
}
.card-pip {
  position: absolute;
  right: 6px;
  bottom: 6px;
  opacity: 0.9;
  font:
    30px/0.95 Georgia,
    var(--serif);
}
.wild-mark {
  position: absolute;
  bottom: 4px;
  left: 3px;
  color: #84621c;
  font: 700 10px var(--sans);
}
.hero-hand {
  gap: 8px;
  padding-right: 0;
}
.hero-hand .playing-card {
  flex-basis: 63px;
  height: 84px;
}
.hero-hand .paper-face {
  width: 100%;
}
.hero-hand .card-pip {
  font: 750 12px/1.2 var(--serif);
  left: 4px;
  right: 4px;
  text-align: center;
}
.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.table-controls .actions {
  margin: 0;
}
.quick-select {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 12px;
}
.quick-select input {
  width: 125px;
  min-height: 34px;
  padding: 5px 8px;
}
.quick-select button {
  min-height: 34px;
  padding: 4px 9px;
}
@media (max-width: 760px) {
  #identity {
    grid-template-columns: 0.85fr 1fr;
  }
  .welcome-table {
    min-height: 385px;
    padding: 22px;
  }
  .welcome-cards {
    transform: scale(0.76) rotate(-5deg);
  }
  #identityForm {
    padding: 24px 18px;
    gap: 17px;
  }
  .seat-pin {
    gap: 4px;
    padding: 5px 6px;
  }
  .seat-avatar {
    width: 23px;
    height: 27px;
    font-size: 17px;
  }
  .table-stage {
    height: 330px;
  }
}
@media (max-width: 590px) {
  #identity {
    grid-template-columns: 1fr;
    margin: 15px auto 25px;
  }
  .welcome-table {
    min-height: 137px;
    padding: 19px;
    background-size: 120% auto;
    background-position: center 34%;
  }
  .welcome-cards {
    left: 77%;
    top: 52%;
    transform: scale(0.53) rotate(-5deg);
  }
  .welcome-title {
    max-width: 60%;
  }
  .welcome-title h1 {
    font-size: 30px;
  }
  .welcome-title p {
    font-size: 10px;
    letter-spacing: 0;
    margin: 8px 0 0;
  }
  #identityForm {
    padding: 22px;
  }
  #identityForm h2 {
    font-size: 29px;
  }
  .role-option {
    min-height: 70px;
  }
  .table-strip,
  .turn-line {
    padding: 8px 10px;
  }
  .table-stage {
    height: 332px;
  }
  .seat-avatar {
    display: none;
  }
  .seat-pin {
    max-width: 25%;
    min-height: 39px;
  }
  .seat-pin strong {
    font-size: 12px;
  }
  .seat-pin small,
  .seat-info > span {
    font-size: 9px;
  }
  .pos-west {
    --sx: 14%;
    --sy: 38%;
    --px: 19%;
    --py: 58%;
  }
  .pos-east {
    --sx: 86%;
    --sy: 38%;
    --px: 81%;
    --py: 58%;
  }
  .pos-upper-west {
    --sx: 20%;
    --sy: 24%;
    --px: 22%;
    --py: 46%;
  }
  .pos-upper-east {
    --sx: 80%;
    --sy: 24%;
    --px: 78%;
    --py: 46%;
  }
  .pos-south {
    --sy: 89%;
    --py: 68%;
  }
  .pos-north {
    --py: 28%;
  }
  .played {
    width: 29%;
  }
  .table-centre {
    top: 49%;
    max-width: 26%;
  }
  .trick-card {
    width: 23px;
    height: 34px;
  }
  .trick-cards.long .trick-card {
    width: 17px;
    height: 23px;
  }
  .play-label {
    font-size: 10px;
  }
  .table-controls {
    align-items: flex-start;
  }
  .card-spread {
    padding: 16px 16px 8px 0;
    row-gap: 8px;
  }
  .playing-card {
    flex-basis: 32px;
    height: 64px;
  }
  .paper-face {
    width: 45px;
    padding: 4px;
  }
  .card-index {
    font-size: 18px;
  }
  .card-pip {
    font-size: 23px;
    right: 3px;
  }
  .hand-head {
    align-items: flex-start;
  }
  .hand-head #selection {
    font-size: 11px;
    text-align: right;
    max-width: 57%;
  }
  .hand-tray {
    padding: 12px 10px;
  }
  .room-head {
    align-items: center;
    flex-direction: row;
  }
  .room-tools {
    gap: 5px;
    justify-content: flex-end;
  }
  .room-tools .secondary {
    padding: 5px 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .paper-face {
    transition: none;
  }
}
